mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
用户业务层添加了新功能:分页查找
--AdminPageUserDTO.java 管理员分页用户参数DTO --AdminPageUserVO.java 管理员分页用户展示VO --SysUserService.java 添加分页方法定义 --SysUserServiceImpl.java 实现了分页方法
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package xiaozhi.modules.sys.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 管理员分页用户的参数DTO
|
||||
* @author zjy
|
||||
* @since 2025-3-21
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "音色分页参数")
|
||||
public class AdminPageUserDTO {
|
||||
|
||||
|
||||
@Schema(description = "手机号码")
|
||||
@NotBlank(message = "")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "页数")
|
||||
@NotBlank(message = "")
|
||||
private String page;
|
||||
|
||||
@Schema(description = "显示列数")
|
||||
@NotBlank(message = "")
|
||||
private String limit;
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package xiaozhi.modules.sys.service;
|
||||
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.service.BaseService;
|
||||
import xiaozhi.modules.sys.dto.AdminPageUserDTO;
|
||||
import xiaozhi.modules.sys.dto.PasswordDTO;
|
||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
import xiaozhi.modules.sys.vo.AdminPageUserVO;
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,4 +23,11 @@ public interface SysUserService extends BaseService<SysUserEntity> {
|
||||
void delete(Long[] ids);
|
||||
|
||||
void changePassword(Long userId, PasswordDTO passwordDTO);
|
||||
|
||||
/**
|
||||
* 管理员分页用户信息
|
||||
* @param dto 分页查找参数
|
||||
* @return 用户列表分页数据
|
||||
*/
|
||||
PageData<AdminPageUserVO> page(AdminPageUserDTO dto);
|
||||
}
|
||||
|
||||
+29
@@ -1,23 +1,31 @@
|
||||
package xiaozhi.modules.sys.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import xiaozhi.common.constant.Constant;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.exception.RenException;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.service.impl.BaseServiceImpl;
|
||||
import xiaozhi.common.utils.ConvertUtils;
|
||||
import xiaozhi.modules.security.password.PasswordUtils;
|
||||
import xiaozhi.modules.sys.dao.SysUserDao;
|
||||
import xiaozhi.modules.sys.dto.AdminPageUserDTO;
|
||||
import xiaozhi.modules.sys.dto.PasswordDTO;
|
||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||
import xiaozhi.modules.sys.enums.SuperAdminEnum;
|
||||
import xiaozhi.modules.sys.service.SysUserService;
|
||||
import xiaozhi.modules.sys.vo.AdminPageUserVO;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -112,6 +120,27 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||
return baseDao.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<AdminPageUserVO> page(AdminPageUserDTO dto) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(Constant.PAGE, dto.getPage());
|
||||
params.put(Constant.LIMIT,dto.getLimit());
|
||||
IPage<SysUserEntity> page = baseDao.selectPage(
|
||||
getPage(params, "sort", true),
|
||||
//定义查询条件
|
||||
new QueryWrapper<SysUserEntity>()
|
||||
//必须按照ttsID查找
|
||||
.eq("username",dto.getMobile()));
|
||||
List<AdminPageUserVO> list = page.getRecords().stream().map(user -> {
|
||||
AdminPageUserVO adminPageUserVO = new AdminPageUserVO();
|
||||
adminPageUserVO.setUserid(user.getId().toString());
|
||||
adminPageUserVO.setMobile(user.getUsername());
|
||||
//TODO 2. 等设备功能写好,获取对应数据
|
||||
adminPageUserVO.setDeviceCount("0");
|
||||
return adminPageUserVO;
|
||||
}).toList();
|
||||
return new PageData<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
private boolean isStrongPassword(String password) {
|
||||
// 弱密码的正则表达式
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package xiaozhi.modules.sys.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 管理员分页展示用户的VO
|
||||
* @ zjy
|
||||
* @since 2025-3-25
|
||||
*/
|
||||
@Data
|
||||
public class AdminPageUserVO {
|
||||
|
||||
@Schema(description = "设备数量")
|
||||
private String deviceCount;
|
||||
|
||||
@Schema(description = "手机号码")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private String userid;
|
||||
}
|
||||
Reference in New Issue
Block a user