1
zj
2025-10-14 8e1c5b13e9dd4a88f17dfe4569d4a51b3495d83a
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java
@@ -78,6 +78,7 @@
     */
    @PostMapping("/purchaseApplication")
    public Result purchaseApplication(UserPolicyDto dto) {
        synchronized (dto.getAccount()) {
        // 生成锁的key:基于用户ID和产品ID,防止同一用户同时购买同一产品
        String lockKey = redisDistributedLock.generateLockKey(dto.getAccount(), dto.getProductId());
@@ -103,12 +104,32 @@
            }
        }
    }
    }
    /**
     * 根据用户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 {