package com.hs.admin;

import com.hs.admin.common.base.PageRequest;
import com.hs.admin.common.base.PageResult;
import com.hs.admin.model.SysUser;
import com.hs.admin.model.reqmodel.UpdateUserReq;
import com.hs.admin.model.reqmodel.UserReq;
import com.hs.admin.model.respmodel.SysUserList;
import com.hs.admin.service.LoginService;
import com.hs.admin.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsAdminApplicationTests.class)
public class UserServiceTest {
    @Autowired
    private UserService userService;
    @Autowired
    private LoginService loginService;

    @Test
    public void testInfo() {
        SysUserList info = userService.info(39);
        System.out.println(info);
        /*UserReq.GetUserReq userReq = new UserReq.GetUserReq();
        PageRequest page = new PageRequest();
        page.setPageNum(1);
        page.setPageSize(10);
        userReq.setUserName("hospital");
        userReq.setPage(page);
        PageResult all = userService.getAllByPage(userReq);
        System.out.println(all);*/
    }

    @Test
    public void testLogin() {
        String loginName = "ddd";
        String password = "1231";
        String ip = "8.8.8.8";
        LoginService.LoginInfo loginInfo = loginService.login(loginName, password, ip);
        System.out.println(loginInfo);
    }

    @Test
    public void testUpdate() {
        UpdateUserReq user = new UpdateUserReq();
        user.setUserId(38);
        user.setPassword("123");
        user.setUserCode("ddd");
        user.setUserName("ddd");
        user.setRoleId(2L);
        user.setIsAdmin(true);

        ArrayList orgs = new ArrayList();
        orgs.add(1L);
        orgs.add(60L);
        user.setOrg(orgs);

        userService.updateUser(user);
    }
}
