package com.test;

import com.test.bean.Admin;
import com.test.bean.User;
import com.test.mapper.AdminMapper;
import com.test.mapper.UserMapper;
import com.test.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDateTime;
import java.util.ArrayList;

@SpringBootTest
@Slf4j
class MyBatisDemoApplicationTests {


    @Autowired
    AdminMapper adminMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    UserServiceImpl userService;

    @Test
    public void geiAllAdmin(){
        ArrayList<Admin> allAdmin = adminMapper.getAllAdmin();
        System.out.println(allAdmin.toString());

        Admin admin = adminMapper.getAdminById(0);
        System.out.println(admin.toString());
    }

    @Test
    public void testLogin(){
        Admin admin = adminMapper.doLogin("Tom","123456");
        System.out.println(admin.toString());
    }

    @Test
    public void testAddUser(){
        User user = new User(null, "张三", "男", "150101200001013012", "15812341234", LocalDateTime.now(),LocalDateTime.now());
        boolean b = userMapper.addUser(user);
        System.out.println(b);
    }

    @Test
    public void testUpdateUser(){
        User user = new User(1, "张三", "男同", "150101200001013012", "15812341234", null, null);

        User user1 = userService.updateUser(user);
        System.out.println(user1);
    }

}
