package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "PC首页统计-人员数量")
@RestController
@RequestMapping("/pc/system/user/homepage")
@Slf4j
public class SystemHomePageController  extends BaseController {
    @Autowired
    private ISysUserService sysUserService;
//    @Autowired
//    private IAppLoginService appLoginService;
//    @Autowired
//    private IContractorUserService contractorUserService;
//    @Autowired
//    private ITbSysAreaService sysAreaService;
//    @Autowired
//    private IHazardService hazardService;

    @ApiOperation("企业人数")
    @GetMapping("/sysUserStatistics")
    public AjaxResult sysUserStatistics() {
  /*      //用户昵称
        String nickName = null;
        //用户类型：1内部，2承包商
        if ("1".equals(JWTUtil.getAppUserType())) {
            //设置人员姓名
            SysUser sysUser = sysUserService.selectUserById(Long.parseLong(JWTUtil.getPCUserId()));
            if (Objects.nonNull(sysUser)) {
                nickName = sysUser.getNickName();
            }
        } else {
            AppLogin appLogin = appLoginService.selectAppLoginById(JWTUtil.getUserId());
            if (Objects.nonNull(appLogin)) {
                ContractorUserDTO contractorUserDTO = contractorUserService.selectContractorUserById(appLogin.getContractorUserId());
                if (Objects.nonNull(contractorUserDTO)) {
                    nickName = contractorUserDTO.getCompellation();
                }
            }
        }*/

        String companyCode = SecurityUtils.getUserCompanyCode();
//        LoginUser loginUser = getLoginUser();
//        String companyCode = loginUser.getCompanyCode();

        Integer userCount = sysUserService.selectUserCount(companyCode);

        return AjaxResult.success(userCount);
    }

}
