| | |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.init.LocalCache; |
| | | import com.matrix.system.common.init.UserCacheManager; |
| | | import com.matrix.system.common.interceptor.HostInterceptor; |
| | | import com.matrix.system.common.service.SysCompanyService; |
| | | import com.matrix.system.common.service.SysUsersService; |
| | |
| | | @Autowired |
| | | WeChatApiTools weChatApiTools; |
| | | |
| | | @Autowired |
| | | private UserCacheManager userCacheManager; |
| | | |
| | | @Value("${file_storage_path}") |
| | | private String fileStoragePath; |
| | |
| | | } |
| | | |
| | | String openId = json.getString("openid"); |
| | | return null; |
| | | res.setStatus(AjaxResult.STATUS_SUCCESS); |
| | | res.putInMap("openId", openId); |
| | | SysUsers hasBind = sysUsersService.findByOpenId(openId, HostInterceptor.getCompanyId()); |
| | | if (hasBind == null) { |
| | | res.setInfo("未绑定用户"); |
| | | return res; |
| | | } |
| | | |
| | | String token = userCacheManager.saveUserInfo(hasBind); |
| | | LogUtil.info("用户token={}", token); |
| | | res.putInMap("token", token); |
| | | res.putInMap("userInfo", hasBind); |
| | | return res; |
| | | } |
| | | |
| | | @ApiOperation(value = "绑定用户") |
| | | @PostMapping(value = "/bindUser") |
| | | public AjaxResult bindUser(@RequestBody @Validated LoginDto loginDto) { |
| | | SysUsers user = new SysUsers(); |
| | | user.setSuAccount(loginDto.getUsername()); |
| | | user.setSuPassword(loginDto.getPassword()); |
| | | LoginStrategy apLogin = new AccountPasswordLogin(user, sysUsersService); |
| | | user = authorityManager.login(apLogin); |
| | | user.setSuPassword(null); |
| | | user.setOpenIds(null); |
| | | String token = userCacheManager.saveUserInfo(user); |
| | | |
| | | AjaxResult result = AjaxResult.buildSuccessInstance("登陆成功"); |
| | | authorityManager.initUserPower(result, user); |
| | | result.putInMap("token", token); |
| | | result.putInMap("userInfo", user); |
| | | |
| | | synchronized (this) { |
| | | SysUsers hasBind = sysUsersService.findByOpenId(loginDto.getOpenId(), HostInterceptor.getCompanyId()); |
| | | if (hasBind != null) { |
| | | if(StrUtil.isNotBlank(hasBind.getOpenIds())) { |
| | | List<String> openIds = StrUtil.split(hasBind.getOpenIds(), ','); |
| | | openIds.remove(loginDto.getOpenId()); |
| | | |
| | | hasBind.setOpenIds(CollUtil.join(openIds, ",")); |
| | | sysUsersService.modifyByModel(hasBind); |
| | | } |
| | | } |
| | | |
| | | List<String> openIds = StrUtil.split(user.getOpenIds(), ','); |
| | | openIds.add(loginDto.getOpenId()); |
| | | user.setOpenIds(CollUtil.join(openIds, ",")); |
| | | sysUsersService.modifyByModel(user); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | } |