| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.im.comm.Result; |
| | | import com.ruoyi.im.dto.RegisterDto; |
| | | import com.ruoyi.im.out.UserAccountOut; |
| | | import com.ruoyi.im.service.ImApiServcie; |
| | | import com.ruoyi.im.util.ConverterUtil; |
| | | import com.ruoyi.im.util.PhoneNumberValidatorUtil; |
| | | import com.ruoyi.system.domain.UserAccount; |
| | | import com.ruoyi.system.domain.vo.UserAccountUpdateVo; |
| | | import com.ruoyi.system.domain.vo.UserAccountVo; |
| | |
| | | public TableDataInfo list(UserAccountVo vo) |
| | | { |
| | | // 创建查询条件包装器 |
| | | |
| | | LambdaQueryWrapper<UserAccount> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | // 只有当 keyword 不为空时才添加 OR 条件 |
| | |
| | | // 默认按创建时间倒序 |
| | | queryWrapper.orderByDesc(UserAccount::getCreateTime); |
| | | List<UserAccount> list = userAccountService.list(queryWrapper); |
| | | return getDataTable(list); |
| | | List<UserAccountOut> toList = ConverterUtil.convertToList(list, UserAccountOut.class); |
| | | return getDataTable(toList); |
| | | } |
| | | |
| | | /** |
| | | * 修改会员 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('im:user:updateUserAccount')") |
| | | // @PreAuthorize("@ss.hasPermi('im:user:updateUserAccount')") |
| | | @PostMapping("/updateUserAccount") |
| | | public AjaxResult updateUserAccount(UserAccountUpdateVo vo) { |
| | | |
| | |
| | | if(ObjectUtil.isEmpty(userAccount)){ |
| | | return AjaxResult.error("会员不存在!"); |
| | | } |
| | | PhoneNumberValidatorUtil.ValidationResult result = PhoneNumberValidatorUtil.validatePhoneNumber(vo.getPhoneNumber()); |
| | | if(!result.isValid()){ |
| | | return AjaxResult.error("手机号格式不正确!"); |
| | | } |
| | | vo.setAccountId(userAccount.getCloudMessageAccount()); |
| | | return imApiServcie.updateUserAccount(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 批量注册 |
| | | * 创建会员 |
| | | */ |
| | | @PostMapping("/batchRegister") |
| | | public Result batchRegister(@Validated RegisterDto dto){ |
| | | try { |
| | | if(null == dto.getType()){ |
| | | return Result.error("类型不能为空"); |
| | | }else if(dto.getType() == 2){ |
| | | if(StringUtils.isEmpty(dto.getAccount())){ |
| | | return Result.error("账号不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(dto.getPassword())){ |
| | | return Result.error("密码不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(dto.getNickname())){ |
| | | return Result.error("昵称不能为空"); |
| | | } |
| | | }else if (dto.getType() == 1){ |
| | | if(dto.getNumber() <= 0){ |
| | | return Result.error("数量不能为空"); |
| | | }else if(dto.getNumber() > 100){ |
| | | return Result.error("批量注册最多一次100"); |
| | | } |
| | | } |
| | | return imApiServcie.batchRegister(dto); |
| | | }catch (Exception e){ |
| | | log.error("批量注册报错:",e); |
| | | e.printStackTrace(); |
| | | log.error("-----------批量注册报错------------"); |
| | | return Result.error("注册失败,请稍后再试!"); |
| | | } |
| | | } |