import com.mapper.AccountMapper;
import com.mapper.DepartmentMapper;
import com.mapper.UserMapper;
import com.pojo.dto.AccountVO;
import com.pojo.dto.DepartmentVO;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

public class TestResultMap {
    SqlSession sqlSession;
    AccountMapper accountMapper;
    DepartmentMapper departmentMapper;
    @Before
    public void before() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatisConfig.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsStream);
        sqlSession = build.openSession(true);
        accountMapper = sqlSession.getMapper(AccountMapper.class);
        departmentMapper = sqlSession.getMapper(DepartmentMapper.class);
    }

    @Test
    public void resultMap1() {
        AccountVO vo = accountMapper.findVO(16);
    }

    /**
     * 测试一对多
     */
    @Test
    public void findOneMore() {
        DepartmentVO departmentVO = departmentMapper.oneFindMore(1);
    }
    /**
     * 测试一对多 分步
     *
     */
    @Test
    public void findOneByStep() {
        DepartmentVO byStep = departmentMapper.findByStep(1);
        System.out.println(byStep.getDepName());
    }
}
