package com.sf.mapperTest;


import com.sf.entity.Card;
import com.sf.entity.Classes;
import com.sf.entity.Student;
import com.sf.mapper.ManyToManyMapper;
import com.sf.mapper.OneToManyMapper;
import com.sf.mapper.OneToOneMapper;
import com.sf.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.Iterator;
import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title ManyTableTest
 * @description
 * @create 2025/11/2
 */
public class ManyTableTest {

    @Test
    public void oneToOneTest() {
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        OneToOneMapper mapper = sqlSession.getMapper(OneToOneMapper.class);
        List<Card> cards = mapper.selectAll();
        cards.forEach(System.out::println);
    }

    @Test
    public void oneToOneMany() {
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        OneToManyMapper oneToManyMapper = sqlSession.getMapper(OneToManyMapper.class);
        List<Classes> classes = oneToManyMapper.selectAll();
        classes.forEach(System.out::println);
    }
    @Test
    public void manyToMany(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        ManyToManyMapper mapper = sqlSession.getMapper(ManyToManyMapper.class);
        List<Student> students = mapper.selectAll();
        students.forEach(System.out::println);
    }
}
