package com.landaiqing.test;

import com.landaiqing.entity.AdminUserEntity;
import com.landaiqing.mapper.adminMapper;
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 java.io.IOException;
import java.io.InputStream;

public class Test01 {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        // 2.获取到获取到
        SqlSession sqlSession = sqlSessionFactory.openSession();
        // 3.根据 mapper id=getByUsers 执行该s  ql 语句 通过  sql语句得到我们的对象 orm
//        List<UserEntity> userEntitys = sqlSession.selectList("getByUsers", UserEntity.class);
        adminMapper mapper = sqlSession.getMapper(adminMapper.class);
//        System.out.println(mapper.login("666","666"));
//        AdminUserEntity adminUserEntity = new AdminUserEntity();
//        adminUserEntity.setAdminId(1);
//        adminUserEntity.setAdminUserName("777");
//        adminUserEntity.setAdminPassword("777");
//        adminUserEntity.setIsValid(1);
        System.out.println(mapper.deleteAdmin(4));
        sqlSession.commit();
//        System.out.println(userEntitys);
        sqlSession.close();
    }
}
