| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.im.comm.Result; |
| | | import com.ruoyi.im.dto.RegisterDto; |
| | | import com.ruoyi.im.service.ImApiServcie; |
| | | import com.ruoyi.system.domain.UserAccount; |
| | | import com.ruoyi.system.domain.vo.UserAccountUpdateVo; |
| | | import com.ruoyi.system.domain.vo.UserAccountVo; |
| | | import com.ruoyi.system.service.UserAccountService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | |
| | | @RestController |
| | | @RequestMapping("/im/user") |
| | | @Slf4j |
| | | public class UserController extends BaseController { |
| | | |
| | | @Autowired |
| | | UserAccountService userAccountService; |
| | | |
| | | @Autowired |
| | | private ImApiServcie imApiServcie; |
| | | |
| | | /** |
| | | * 获取会员列表 |
| | |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(UserAccountVo vo) |
| | | { |
| | | startPage(); |
| | | List<UserAccount> list = userAccountService.list(new LambdaQueryWrapper<UserAccount>() |
| | | .eq(UserAccount::getId, vo.getKeyword()) |
| | | .or() |
| | | .eq(UserAccount::getPhoneNumber, vo.getKeyword()) |
| | | .or() |
| | | .eq(UserAccount::getAccount, vo.getKeyword()) |
| | | .or() |
| | | .eq(UserAccount::getNickname, vo.getKeyword()) |
| | | .eq(ObjectUtil.isNotEmpty(vo.getAccountType()),UserAccount::getAccountType,vo.getAccountType()) |
| | | .eq(ObjectUtil.isNotEmpty(vo.getStatus()),UserAccount::getStatus,vo.getStatus()) |
| | | .between(UserAccount::getCreateTime,vo.getStartTime(),vo.getEndTime()) |
| | | ); |
| | | // 创建查询条件包装器 |
| | | LambdaQueryWrapper<UserAccount> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | // 只有当 keyword 不为空时才添加 OR 条件 |
| | | if (ObjectUtil.isNotEmpty(vo.getKeyword())) { |
| | | queryWrapper.and(wrapper -> wrapper |
| | | .eq(UserAccount::getId, vo.getKeyword()) |
| | | .or() |
| | | .eq(UserAccount::getPhoneNumber, vo.getKeyword()) |
| | | .or() |
| | | .eq(UserAccount::getAccount, vo.getKeyword()) |
| | | .or() |
| | | .eq(UserAccount::getNickname, vo.getKeyword()) |
| | | ); |
| | | } |
| | | |
| | | // 添加其他条件 |
| | | queryWrapper |
| | | .eq(ObjectUtil.isNotEmpty(vo.getAccountType()), UserAccount::getAccountType, vo.getAccountType()) |
| | | .eq(ObjectUtil.isNotEmpty(vo.getStatus()), UserAccount::getStatus, vo.getStatus()) |
| | | .between(ObjectUtil.isAllNotEmpty(vo.getStartTime(), vo.getEndTime()), |
| | | UserAccount::getCreateTime, vo.getStartTime(), vo.getEndTime()); |
| | | |
| | | // 默认按创建时间倒序 |
| | | queryWrapper.orderByDesc(UserAccount::getCreateTime); |
| | | List<UserAccount> list = userAccountService.list(queryWrapper); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | |
| | | * 修改会员 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('im:user:updateUserAccount')") |
| | | @GetMapping("/updateUserAccount") |
| | | @PostMapping("/updateUserAccount") |
| | | public AjaxResult updateUserAccount(UserAccountUpdateVo vo) { |
| | | |
| | | try { |
| | | UserAccount userAccount = userAccountService.getById(vo.getId()); |
| | | if(ObjectUtil.isEmpty(userAccount)){ |
| | | return AjaxResult.error("会员不存在!"); |
| | | } |
| | | return imApiServcie.updateUserAccount(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | logger.error("修改会员失败!"); |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 批量注册 |
| | | */ |
| | | @PostMapping("/batchRegister") |
| | | public Result batchRegister(@Validated RegisterDto dto){ |
| | | try { |
| | | return imApiServcie.batchRegister(dto); |
| | | }catch (Exception e){ |
| | | log.error("批量注册报错:",e); |
| | | return Result.error("注册失败,请稍后再试!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |