| | |
| | | package com.doumee.service.system.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.doumee.config.jwt.JwtTokenUtil; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | |
| | | import com.doumee.dao.business.dao.SmsEmailMapper; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.doumee.dao.business.model.SmsEmail; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.dto.LoginByOpenidDTO; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.LoginPhoneDTO; |
| | |
| | | |
| | | @Autowired |
| | | private SmsEmailMapper smsEmailMapper; |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | |
| | | |
| | | @Lazy |
| | | @Autowired |
| | |
| | | loginLog.setLoginTime(new Date()); |
| | | loginLog.setSystemVersion(systemVersion); |
| | | loginLog.setIp(Utils.User_Client.getIP(request)); |
| | | loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | // loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | loginLog.setPlatform(Utils.User_Client.getPlatform(request)); |
| | | loginLog.setClientInfo(Utils.User_Client.getBrowser(request)); |
| | | loginLog.setOsInfo(Utils.User_Client.getOS(request)); |
| | |
| | | loginLog.setLoginUsername(dto.getUsername()); |
| | | loginLog.setLoginTime(new Date()); |
| | | loginLog.setSystemVersion(systemVersion); |
| | | loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | // loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | if(request!=null&&request.getHeaders()!=null && request.getHeaders().size()>0){ |
| | | loginLog.setIp(Utils.User_Client.getIP(request)); |
| | | loginLog.setPlatform(Utils.User_Client.getPlatform(request)); |
| | |
| | | if(Objects.nonNull(user.getCompanyId())){ |
| | | company = companyMapper.selectById(user.getCompanyId()); |
| | | } |
| | | dealOpenIdBiz(user,dto.getOpenid()); |
| | | // 获取登录用户信息 |
| | | List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); |
| | | List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId()); |
| | |
| | | } |
| | | |
| | | |
| | | private void dealOpenIdBiz(SystemUser user, String openid) { |
| | | if(StringUtils.isNotBlank(openid)){ |
| | | //如果openId不为空,绑定该用户openid |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .set(SystemUser::getOpenid,null) |
| | | .eq(SystemUser::getType,user.getType()) |
| | | .eq(SystemUser::getOpenid,openid) |
| | | ); |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .set(SystemUser::getOpenid,openid) |
| | | .eq(SystemUser::getId,user.getId())); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | loginLog.setLoginUsername(dto.getPhone()); |
| | | loginLog.setLoginTime(new Date()); |
| | | loginLog.setSystemVersion(systemVersion); |
| | | loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | // loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | if(request!=null&&request.getHeaders()!=null && request.getHeaders().size()>0){ |
| | | loginLog.setIp(Utils.User_Client.getIP(request)); |
| | | loginLog.setPlatform(Utils.User_Client.getPlatform(request)); |
| | |
| | | if(Objects.nonNull(user.getCompanyId())){ |
| | | company = companyMapper.selectById(user.getCompanyId()); |
| | | } |
| | | |
| | | dealOpenIdBiz(user,dto.getOpenid()); |
| | | |
| | | // 获取登录用户信息 |
| | | List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); |
| | | List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId()); |
| | |
| | | loginLog.setLoginUsername(dto.getUsername()); |
| | | loginLog.setLoginTime(new Date()); |
| | | loginLog.setSystemVersion(systemVersion); |
| | | loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | // loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | if(request!=null&&request.getHeaders()!=null && request.getHeaders().size()>0){ |
| | | loginLog.setIp(Utils.User_Client.getIP(request)); |
| | | loginLog.setPlatform(Utils.User_Client.getPlatform(request)); |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void cleanOpenid(Integer userId){ |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .set(SystemUser::getOpenid,null) |
| | | .eq(SystemUser::getId,userId) |
| | | ); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 内部人员 与 司机 根据code查询openId后进行登录接口 |
| | | * @return |
| | |
| | | SystemLoginLog loginLog = new SystemLoginLog(); |
| | | loginLog.setLoginTime(new Date()); |
| | | loginLog.setSystemVersion(systemVersion); |
| | | loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | // loginLog.setLocation(Utils.Location.getLocationString(loginLog.getIp())); |
| | | loginLog.setServerIp(Utils.Server.getIP()); |
| | | |
| | | // 根据用户名查询用户对象 |