package com.usky.system.controller.api;

import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.util.BeanMapperUtils;
import com.usky.system.RemoteUserService;
import com.usky.system.domain.SysUser;
import com.usky.system.domain.SysUserVO;
import com.usky.system.model.LoginUser;
import com.usky.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SysUserControllerApi implements RemoteUserService {


    @Autowired
    private ISysUserService iSysUserService;

    @Override
    public ApiResult<LoginUser> getUserInfo(String username) {
        return ApiResult.success(iSysUserService.getUserInfo(username));
    }

    @Override
    public ApiResult<Boolean> registerUserInfo(SysUserVO sysUser) {
        return ApiResult.success(iSysUserService.register(BeanMapperUtils.map(sysUser, SysUser.class)));
    }

    public ApiResult<List<SysUser>>userList(){
        return ApiResult.success(iSysUserService.userList());
    }

    public ApiResult<List<SysUser>>userByIdList(List<Integer> userIds){
        return ApiResult.success(iSysUserService.userByIdList(userIds));
    }

    public ApiResult<List<SysUser>>userAllList(){
        return ApiResult.success(iSysUserService.userAllList());
    }
}
