| | |
| | | */ |
| | | @PostMapping("/purchaseApplication") |
| | | public Result purchaseApplication(UserPolicyDto dto) { |
| | | synchronized (dto.getAccount()) { |
| | | // 生成锁的key:基于用户ID和产品ID,防止同一用户同时购买同一产品 |
| | | String lockKey = redisDistributedLock.generateLockKey(dto.getAccount(), dto.getProductId()); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据用户id查询保单 |
| | | */ |
| | | @GetMapping("/updateGender") |
| | | public AjaxResult updateGender(@RequestParam(value = "id") Integer id,@RequestParam(value = "gender") UserPolicy.Gender gender) { |
| | | try { |
| | | UserPolicy userPolicy = userPolicyService.getById(id); |
| | | if(ObjectUtil.isEmpty(userPolicy)){ |
| | | AjaxResult.error("保单不存在!"); |
| | | } |
| | | userPolicy.setGender(gender); |
| | | userPolicyService.updateById(userPolicy); |
| | | return AjaxResult.success("修改成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return AjaxResult.error("修改失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据用户id查询保单 |
| | | */ |
| | | @GetMapping("/getPolicyById") |
| | | public Result getPolicyById(@RequestParam(value = "account") String account) { |
| | | try { |