| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.im.comm.Result; |
| | | import com.ruoyi.im.config.IpUtils; |
| | | import com.ruoyi.im.dto.UpdateUserBusinessDto; |
| | | import com.ruoyi.im.service.ImApiServcie; |
| | | import com.ruoyi.im.dto.RegisterDto; |
| | | import com.ruoyi.im.service.InsuranceProductService; |
| | | import com.ruoyi.im.service.MedicalInsuranceAccountService; |
| | | import com.ruoyi.im.util.SymmetricCryptoUtil; |
| | | import com.ruoyi.system.domain.GroupWelcomeConfig; |
| | | import com.ruoyi.system.domain.IpBlacklist; |
| | | import com.ruoyi.system.domain.UserAccount; |
| | | import com.ruoyi.im.util.ValidatorUtil; |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.domain.out.UserOut; |
| | | import com.ruoyi.system.domain.vo.UserAccountUpdateVo; |
| | | import com.ruoyi.system.service.GroupWelcomeConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | |
| | | import java.nio.file.Paths; |
| | | import java.nio.file.attribute.PosixFilePermission; |
| | | import java.nio.file.attribute.PosixFilePermissions; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/im/api") |
| | |
| | | |
| | | @Autowired |
| | | UserAccountService userAccountService; |
| | | @Autowired |
| | | GroupWelcomeConfigService groupWelcomeConfigService; |
| | | |
| | | @Autowired |
| | | InsuranceProductService insuranceProductService; |
| | | |
| | | @Autowired |
| | | MedicalInsuranceAccountService medicalInsuranceAccountService; |
| | | |
| | | |
| | | @Value("${file.upload-dir}") |
| | |
| | | @PostMapping("/register") |
| | | public Result register(@Validated RegisterDto dto){ |
| | | try { |
| | | // 验证手机号 |
| | | boolean isPhoneValid = ValidatorUtil.isValidPhone(dto.getAccount()); |
| | | if(!isPhoneValid){ |
| | | return Result.error("手机号格式不正确"); |
| | | } |
| | | return imApiServcie.register(dto); |
| | | } catch (RuntimeException e) { |
| | | // 从异常消息中解析Result对象 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取二维码链接和邀请码 |
| | | */ |
| | | @GetMapping("/getUserCodeAndUrl") |
| | | public Result getUserCodeAndUrl(@RequestParam("account") String account){ |
| | | try { |
| | | GroupWelcomeConfig groupWelcomeConfig = groupWelcomeConfigService.getOne(new LambdaQueryWrapper<>(GroupWelcomeConfig.class) |
| | | .eq(GroupWelcomeConfig::getConfigurationName, "IM-BASICS").last(" limit 1")); |
| | | UserAccount userAccount = userAccountService.getOne(new LambdaQueryWrapper<UserAccount>().eq(UserAccount::getAccount, account)); |
| | | Map<String,String> map = new HashMap<>(); |
| | | map.put("url",ObjectUtil.isNotEmpty(groupWelcomeConfig.getCodeUrl()) ? groupWelcomeConfig.getCodeUrl() : ""); |
| | | map.put("code",userAccount.getInvitationCode()); |
| | | return Result.success(map); |
| | | } catch (RuntimeException e) { |
| | | // 从异常消息中解析Result对象 |
| | | return JSON.parseObject(e.getMessage(), Result.class); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改用户信息只有数据库 |
| | |
| | | return Result.error("账号不存在!"); |
| | | } |
| | | userAccount.setLoginIp(clientIp); |
| | | userAccount.setLoginTime(new Date()); |
| | | userAccountService.updateById(userAccount); |
| | | return Result.success(); |
| | | }catch (Exception e){ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 产品信息列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public Result list() { |
| | | LambdaQueryWrapper<InsuranceProduct> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(InsuranceProduct::getStatus, "ACTIVE"); |
| | | // 按创建时间倒序排列 |
| | | wrapper.orderByDesc(InsuranceProduct::getCreatedAt); |
| | | |
| | | |
| | | List<InsuranceProduct> list = insuranceProductService.list(wrapper); |
| | | return Result.success(list); |
| | | } |
| | | /** |
| | | * 获取用户详情 |
| | | */ |
| | | @GetMapping("/getUserByAccount") |
| | | public Result getUserByAccount(HttpServletRequest request,@RequestParam("account") String account){ |
| | | try { |
| | | String clientIp = IpUtils.getClientIp(request); |
| | | if(StringUtils.isEmpty(clientIp)){ |
| | | return Result.success(); |
| | | } |
| | | UserAccount userAccount = userAccountService.getOne(new LambdaQueryWrapper<>(UserAccount.class).eq(UserAccount::getCloudMessageAccount, account)); |
| | | if(ObjectUtil.isEmpty(userAccount)){ |
| | | return Result.error("账号不存在!"); |
| | | } |
| | | UserOut user = new UserOut(); |
| | | MedicalInsuranceAccount insuranceAccount = medicalInsuranceAccountService.getOne(new LambdaQueryWrapper<>(MedicalInsuranceAccount.class) |
| | | .eq(MedicalInsuranceAccount::getUserId, userAccount.getId()) |
| | | .eq(MedicalInsuranceAccount::getAccountStatus, MedicalInsuranceAccount.AccountStatus.ACTIVE) |
| | | ); |
| | | user.setKycStatus(userAccount.getKycStatus()); |
| | | if(ObjectUtil.isEmpty(insuranceAccount)){ |
| | | return Result.success(user); |
| | | } |
| | | user.setAmountClaimed(insuranceAccount.getAmountClaimed()); |
| | | user.setAlreadyReceived(insuranceAccount.getAlreadyReceived()); |
| | | return Result.success(user); |
| | | }catch (Exception e){ |
| | | log.error("获取失败:",e); |
| | | return Result.error("获取失败,请稍后再试!"); |
| | | } |
| | | } |
| | | } |