package com.sf.mapperTest;


import com.sf.entity.SysUser;
import com.sf.mapper.SysUserMapper;
import com.sf.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title SysUserMapperTest
 * @description
 * @create 2025/11/16
 */
public class SysUserMapperTest {

    /**
     * SysUserMapper接口findById方法-单元测试
     * @throws Exception
     */
    @Test
    public void testFindById() throws Exception {
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        SysUserMapper sysUserMapper = sqlSession.getMapper(SysUserMapper.class);
        SysUser sysUser = sysUserMapper.findById(1);
        System.out.println(sysUser);
    }

    /**
     * SysUserMapper接口findAll方法-单元测试
     * @throws Exception
     */
    @Test
    public void testFindAll() throws Exception {
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        SysUserMapper sysUserMapper = sqlSession.getMapper(SysUserMapper.class);
        List<SysUser> sysUsers = sysUserMapper.findAll();
        sysUsers.forEach(System.out::println);
    }
    @Test
    public void findUserWithInfoAndRole(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        SysUserMapper sysUserMapper = sqlSession.getMapper(SysUserMapper.class);
        SysUser sysUser = sysUserMapper.findUserWithInfoAndRole(1);
        System.out.println(sysUser);
    }
}
