| | |
| | | import cn.huge.base.common.bo.ReturnBO; |
| | | import cn.huge.base.common.exception.ServiceException; |
| | | import cn.huge.base.common.utils.*; |
| | | import cn.huge.module.client.api.impl.SysClientImpl; |
| | | import cn.huge.module.client.api.impl.UtilsClientImpl; |
| | | import cn.huge.module.ctuser.dao.mapper.CtAccountMapper; |
| | | import cn.huge.module.ctuser.domain.po.CtAccount; |
| | |
| | | import cn.huge.module.ctuser.dto.CtUserAddrDTO; |
| | | import cn.huge.module.ctuser.dto.UserLoginDTO; |
| | | import cn.huge.module.cust.constant.UserBaseConsts; |
| | | import cn.huge.module.sys.dto.GridTokenBaseDTO; |
| | | import cn.huge.module.sys.dto.GridUserBaseDTO; |
| | | import cn.huge.module.utils.JwtUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | private CtUserService ctUserService; |
| | | @Autowired |
| | | private CtUseroleService ctUseroleService; |
| | | @Autowired |
| | | private SysClientImpl sysClient; |
| | | |
| | | /** |
| | | * 更新对象 |
| | |
| | | try{ |
| | | // 判断账号密码是否为空 |
| | | if (StringUtils.isBlank(ctAccountLoginDTO.getAcc()) || StringUtils.isBlank(ctAccountLoginDTO.getCipher())) { |
| | | return ReturnSucUtils.getRepInfo("账号或密码不能为空", null); |
| | | return ReturnFailUtils.getRepInfo("账号或密码不能为空"); |
| | | } |
| | | // 判断账号是否存在 |
| | | CtAccount ctAccount = this.getByAccAndType(ctAccountLoginDTO.getAcc(), UserBaseConsts.ACC_TYPE_1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * web端-网格系统单点登录 |
| | | * @param gridTokenBaseDTO 网格系统token |
| | | * @return UserLoginDTO |
| | | */ |
| | | public ReturnBO webGridLogin(GridTokenBaseDTO gridTokenBaseDTO) { |
| | | try{ |
| | | GridUserBaseDTO gridUserBaseDTO = sysClient.getUserInfo(gridTokenBaseDTO); |
| | | |
| | | // 判断账号密码是否为空 |
| | | if (ObjectUtils.isEmpty(gridUserBaseDTO)) { |
| | | return ReturnFailUtils.getRepInfo("gridToken已失效,请重新登录!"); |
| | | } |
| | | // 判断账号是否存在 |
| | | CtAccount ctAccount = this.getByAccAndType(gridUserBaseDTO.getAccount(), UserBaseConsts.ACC_TYPE_1); |
| | | if (ObjectUtils.isNotEmpty(ctAccount)){ |
| | | //返回结果 |
| | | UserLoginDTO userLoginDTO = new UserLoginDTO(); |
| | | CtUser ctUser = ctUserService.getById(ctAccount.getUserId()); |
| | | if (ObjectUtils.isEmpty(ctUser)){ |
| | | return ReturnFailUtils.getRepInfo("用户不存在!"); |
| | | } |
| | | // 封装用户信息 |
| | | userLoginDTO.setToken(JwtUtils.buildJWT(ctUser.getId())); |
| | | userLoginDTO.setUserId(ctUser.getId()); |
| | | userLoginDTO.setTrueName(ctUser.getTrueName()); |
| | | userLoginDTO.setUnit(ctUser.getUnitName()); |
| | | userLoginDTO.setDept(ctUser.getDeptName()); |
| | | userLoginDTO.setCustId(ctUser.getCustId()); |
| | | // 登录用户角色 |
| | | List<CtUserole> ctUseroleList = ctUseroleService.listByUserId(ctUser.getId()); |
| | | userLoginDTO.setCtUseroleList(ctUseroleList); |
| | | // 登录用户地址信息 |
| | | CtUserAddrDTO ctUserAddrDTO = new CtUserAddrDTO(); |
| | | ctUserAddrDTO.setProv(ctUser.getProv()); |
| | | ctUserAddrDTO.setProvName(ctUser.getProvName()); |
| | | ctUserAddrDTO.setCity(ctUser.getCity()); |
| | | ctUserAddrDTO.setCityName(ctUser.getCityName()); |
| | | ctUserAddrDTO.setArea(ctUser.getArea()); |
| | | ctUserAddrDTO.setAreaName(ctUser.getAreaName()); |
| | | ctUserAddrDTO.setRoad(ctUser.getRoad()); |
| | | ctUserAddrDTO.setRoadName(ctUser.getRoadName()); |
| | | ctUserAddrDTO.setVillage(ctUser.getVillage()); |
| | | ctUserAddrDTO.setVillageName(ctUser.getVillageName()); |
| | | userLoginDTO.setCtUserAddrDTO(ctUserAddrDTO); |
| | | // 最后登录时间 |
| | | Date loginTime = ctAccount.getLoginTime(); |
| | | if (ObjectUtils.isEmpty(ctAccount.getLoginTime())){ |
| | | loginTime = DateUtils.getNowDate(); |
| | | } |
| | | userLoginDTO.setLastLoginTime(loginTime); |
| | | // 更新最新登录时间 |
| | | UpdateWrapper<CtAccount> accountUpdateWrapper = new UpdateWrapper<>(); |
| | | accountUpdateWrapper.set("login_time", loginTime).eq("id", ctAccount.getId()); |
| | | this.update(accountUpdateWrapper); |
| | | return ReturnSucUtils.getRepInfo(userLoginDTO); |
| | | }else{ |
| | | return ReturnFailUtils.getRepInfo("用户不存在!,请确认后重试!"); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("service方法[AccountService.webGridLogin]调用失败,异常信息:"+e, e); |
| | | throw new ServiceException("CtAccountService.webGridLogin", e); |
| | | } |
| | | } |
| | | |
| | | } |