| | |
| | | package com.matrix.system.app.action; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.matrix.component.redis.RedisClient; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.*; |
| | | import com.matrix.system.app.authority.AppAuthorityManager; |
| | | import com.matrix.system.app.dto.LoginDto; |
| | | import com.matrix.system.app.dto.PwdResetDto; |
| | | import com.matrix.system.app.dto.SmsCodeDto; |
| | | import com.matrix.system.app.dto.UploadPhotoDto; |
| | | import com.matrix.system.app.dto.*; |
| | | import com.matrix.system.app.utils.Sms106Send; |
| | | import com.matrix.system.app.vo.UserInfoVo; |
| | | import com.matrix.system.common.authority.DefaultAuthorityManager; |
| | | import com.matrix.system.common.authority.strategy.AccountPasswordLogin; |
| | | import com.matrix.system.common.authority.strategy.LoginStrategy; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.init.LocalCache; |
| | | import com.matrix.system.common.service.SysUsersService; |
| | | import com.matrix.system.common.tools.PasswordUtil; |
| | | import com.matrix.system.common.tools.UploadUtil; |
| | |
| | | * @author wzy |
| | | * @date 2020-12-21 |
| | | **/ |
| | | @CrossOrigin(origins = "*") |
| | | @Api(value = "CommonAction", tags = "手机端公共请求类(含登陆)") |
| | | @RestController |
| | | @RequestMapping(value = "/api/common") |
| | |
| | | private AppAuthorityManager authorityManager; |
| | | |
| | | @Autowired |
| | | private RedisClient redisClient; |
| | | private BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | |
| | | @Value("${file_storage_path}") |
| | | private String fileStoragePath; |
| | | @Value("${static_resource_url}") |
| | | private String nginxUrl; |
| | | |
| | | @Value("${login_public_key}") |
| | | private String publicKey; |
| | | |
| | | @ApiOperation(value = "登陆接口", notes = "手机端登陆接口") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "OK", response = UserInfoVo.class) |
| | | }) |
| | | @PostMapping(value = "/login") |
| | | public AjaxResult login(@RequestBody @Validated LoginDto loginDto) { |
| | | public AjaxResult login(@RequestBody @Validated LoginDto loginDto) throws Exception { |
| | | |
| | | SysUsers user = new SysUsers(); |
| | | user.setSuAccount(loginDto.getUsername()); |
| | |
| | | user.setSuPassword(null); |
| | | |
| | | String token = UUIDUtil.getRandomID(); |
| | | redisClient.saveValueForever(token, JSONObject.toJSONString(user)); |
| | | redisClient.saveValueForever(user.getSuId().toString(), token); |
| | | LocalCache.save(token, user); |
| | | |
| | | userInfoVo.setId(user.getSuId()); |
| | | userInfoVo.setName(user.getSuName()); |
| | | userInfoVo.setRoleName(user.getRoleName()); |
| | | userInfoVo.setPhoto(user.getSuPhoto()); |
| | | |
| | | String sb = token + "_1" + "_/api/vip/findVipInfoById/972"; |
| | | AjaxResult result = AjaxResult.buildSuccessInstance("登陆成功"); |
| | | authorityManager.initUserPower(result,user); |
| | | result.putInMap("user", userInfoVo); |
| | | result.putInMap("token", token); |
| | | result.putInMap("rasToken", RSAUtils.encryptByPublicKey(sb, publicKey)); |
| | | return result; |
| | | } |
| | | |
| | |
| | | return AjaxResult.buildFailInstance("该手机号不存在"); |
| | | } |
| | | |
| | | String codeExist = redisClient.getCachedValue(smsCodeDto.getTelphone()); |
| | | String codeExist = LocalCache.get(smsCodeDto.getTelphone()); |
| | | if (StringUtils.isNotBlank(codeExist)) { |
| | | return AjaxResult.buildFailInstance("请勿重复发送验证码"); |
| | | } |
| | | redisClient.saveValue(smsCodeDto.getTelphone(), "123456", 120); |
| | | |
| | | Integer code =(int) ((Math.random() * 9 + 1) * 100000); |
| | | Sms106Send.sendVerifyCode(smsCodeDto.getTelphone(), code.toString(), 2); |
| | | LocalCache.save(smsCodeDto.getTelphone(), code.toString(), 120 * 1000); |
| | | return AjaxResult.buildSuccessInstance("发送成功"); |
| | | } |
| | | |
| | |
| | | return AjaxResult.buildFailInstance("该手机号不存在"); |
| | | } |
| | | |
| | | String code = redisClient.getCachedValue(pwdResetDto.getTelphone()); |
| | | String code = LocalCache.get(pwdResetDto.getTelphone()); |
| | | if (StringUtils.isBlank(code)) { |
| | | return AjaxResult.buildFailInstance("验证码已失效,请重新发送"); |
| | | } |
| | |
| | | |
| | | int i = sysUsersService.updateUserPassword(user.getSuId(), pwd); |
| | | if (i > 0) { |
| | | redisClient.removeObject(pwdResetDto.getTelphone()); |
| | | LocalCache.remove(pwdResetDto.getTelphone()); |
| | | return AjaxResult.buildSuccessInstance("修改成功"); |
| | | } |
| | | return AjaxResult.buildFailInstance("修改失败"); |
| | |
| | | public AjaxResult findAppVersion() { |
| | | return AjaxResult.buildSuccessInstance(sysUsersService.findAppVersion()); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取api接口地址", notes = "获取api接口地址") |
| | | @GetMapping(value = "/findApiUrl") |
| | | public AjaxResult findApiUrl() { |
| | | List<UrlDto> data = new ArrayList<>(); |
| | | UrlDto urlDto = new UrlDto(); |
| | | urlDto.setUrl("http://myapp.jyymatrix.cc"); |
| | | urlDto.setName("正式环境"); |
| | | data.add(urlDto); |
| | | |
| | | urlDto = new UrlDto(); |
| | | urlDto.setUrl("http://test.hive.jyymatrix.cc"); |
| | | urlDto.setName("测试环境"); |
| | | data.add(urlDto); |
| | | |
| | | urlDto = new UrlDto(); |
| | | urlDto.setUrl("http://hive.mydoline.com"); |
| | | urlDto.setName("美度专线"); |
| | | data.add(urlDto); |
| | | |
| | | urlDto = new UrlDto(); |
| | | urlDto.setUrl("http://localhost:8080"); |
| | | urlDto.setName("开发环境"); |
| | | data.add(urlDto); |
| | | |
| | | return AjaxResult.buildSuccessInstance(data); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |