浏览代码

后台管理员模块

bmmx 1 年之前
父节点
当前提交
9c5d83786a

+ 42 - 6
.idea/workspace.xml

@@ -5,8 +5,17 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="46b159bd-08ca-42f0-b80f-41d4944a8a29" name="Changes" comment="初始化运维项目">
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/om/entity/dto/AdminAddDTO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/om/entity/dto/AdminQueryPageDTO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/om/entity/vo/AdminQueryPageVO.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/om/utils/CommonUtil.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/om/controller/admin/AdminController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/om/controller/admin/AdminController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/om/entity/vo/AdminLoginVO.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/om/entity/vo/AdminLoginVO.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/om/handler/GlobalExceptionHandler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/om/handler/GlobalExceptionHandler.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/om/service/IAdminService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/om/service/IAdminService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/om/service/impl/AdminServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/om/service/impl/AdminServiceImpl.java" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -23,6 +32,9 @@
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
+  <component name="MarkdownSettingsMigration">
+    <option name="stateVersion" value="1" />
+  </component>
   <component name="MavenImportPreferences">
     <option name="generalSettings">
       <MavenGeneralSettings>
@@ -60,6 +72,7 @@
     &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
     &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
     &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
+    &quot;npm.dev.executor&quot;: &quot;Run&quot;,
     &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
     &quot;project.structure.proportion&quot;: &quot;0.15&quot;,
     &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
@@ -77,14 +90,14 @@
       <recent name="B:\WorkSpace\PracticalRojects\OperationSystem\src\main\java\com\om" />
     </key>
     <key name="CopyClassDialog.RECENTS_KEY">
+      <recent name="com.om.entity.dto" />
       <recent name="com.om.entity.vo" />
       <recent name="com.om.exception" />
       <recent name="com.om.utils" />
       <recent name="com.om.interceptor" />
-      <recent name="com.om.controller" />
     </key>
   </component>
-  <component name="RunManager">
+  <component name="RunManager" selected="Spring Boot.OperationApplication">
     <configuration name="OperationApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
       <module name="OperationSystem" />
       <option name="SPRING_BOOT_MAIN_CLASS" value="com.om.OperationApplication" />
@@ -98,16 +111,27 @@
         <option name="Make" enabled="true" />
       </method>
     </configuration>
+    <configuration name="dev" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
+      <package-json value="$PROJECT_DIR$/yanxin-admin/package.json" />
+      <command value="run" />
+      <scripts>
+        <script value="dev" />
+      </scripts>
+      <node-interpreter value="project" />
+      <envs />
+      <method v="2" />
+    </configuration>
     <recent_temporary>
       <list>
         <item itemvalue="Spring Boot.OperationApplication" />
+        <item itemvalue="npm.dev" />
       </list>
     </recent_temporary>
   </component>
   <component name="SharedIndexes">
     <attachedChunks>
       <set>
-        <option value="jdk-1.8.0_392-corretto-1.8.0_392-f644763e9732-f719d367" />
+        <option value="jdk-1.8.0_402-corretto-1.8.0_402-4caba194b151-ae57be32" />
       </set>
     </attachedChunks>
   </component>
@@ -132,7 +156,11 @@
       <workItem from="1706664319188" duration="4639000" />
       <workItem from="1706697285028" duration="1227000" />
       <workItem from="1706709514298" duration="695000" />
-      <workItem from="1706750483961" duration="7577000" />
+      <workItem from="1706750483961" duration="9736000" />
+      <workItem from="1706782347495" duration="1275000" />
+      <workItem from="1706785269288" duration="21000" />
+      <workItem from="1706838288496" duration="1975000" />
+      <workItem from="1707095903203" duration="11627000" />
     </task>
     <task id="LOCAL-00001" summary="管理员登录">
       <option name="closed" value="true" />
@@ -158,7 +186,15 @@
       <option name="project" value="LOCAL" />
       <updated>1706772577945</updated>
     </task>
-    <option name="localTasksCounter" value="4" />
+    <task id="LOCAL-00004" summary="初始化运维项目">
+      <option name="closed" value="true" />
+      <created>1706773538956</created>
+      <option name="number" value="00004" />
+      <option name="presentableId" value="LOCAL-00004" />
+      <option name="project" value="LOCAL" />
+      <updated>1706773538956</updated>
+    </task>
+    <option name="localTasksCounter" value="5" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">

+ 11 - 0
pom.xml

@@ -27,6 +27,7 @@
         <commons-lang3.version>3.4</commons-lang3.version>
         <knife4j.version>3.0.3</knife4j.version>
         <hutool.version>5.8.21</hutool.version>
+        <hibernate-validator.version>6.1.5.Final</hibernate-validator.version>
     </properties>
 
 
@@ -125,6 +126,16 @@
             <version>${fastjson.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.validator</groupId>
+            <artifactId>hibernate-validator</artifactId>
+            <version>${hibernate-validator.version}</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 55 - 10
src/main/java/com/om/controller/admin/AdminController.java

@@ -1,15 +1,17 @@
 package com.om.controller.admin;
 
 
+import com.om.entity.dto.AdminAddDTO;
+import com.om.entity.dto.AdminQueryPageDTO;
+import com.om.entity.vo.AdminLoginVO;
+import com.om.entity.vo.AdminQueryPageVO;
 import com.om.service.IAdminService;
 import com.om.utils.AdminContext;
 import com.om.utils.Result;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 
@@ -32,15 +34,58 @@ public class AdminController {
 
     @GetMapping("/login")
     @ApiOperation("管理员登录")
-    public Result login(@RequestParam String username, @RequestParam String password){
+    public Result<AdminLoginVO> login(@RequestParam String username, @RequestParam String password){
         return adminService.login(username,password);
     }
 
-    @GetMapping("/get")
-    @ApiOperation("获取当前登录id")
-    public Result get(){
-        Integer adminId = AdminContext.getAdminId();
-        return Result.ok(adminId);
+
+    @GetMapping("getManagerByToken")
+    @ApiOperation("通过token获取管理员信息")
+    public Result<AdminLoginVO> getManagerByToken(@RequestParam String token){
+        return adminService.getManagerByToken(token);
+    }
+
+    @PostMapping("add")
+    @ApiOperation("添加管理员信息")
+    public Result add(@Validated @RequestBody AdminAddDTO dto){
+        return adminService.add(dto);
+    }
+
+    @GetMapping("delete")
+    @ApiOperation("删除管理员信息")
+    public Result delete(@RequestParam Integer id){
+        return adminService.delete(id);
+    }
+
+    @GetMapping("get")
+    @ApiOperation("根据id查询管理员信息")
+    public Result<AdminLoginVO> get(@RequestParam Integer id){
+        return adminService.get(id);
+    }
+
+    @PostMapping("getPageList")
+    @ApiOperation("分页查询管理员列表")
+    public Result<AdminQueryPageVO> getPageList(@RequestBody AdminQueryPageDTO dto){
+        return adminService.getPageList(dto);
+    }
+
+    @PostMapping("update")
+    @ApiOperation("修改管理员信息")
+    public Result<AdminLoginVO> updateAdmin(@Validated @RequestBody AdminAddDTO dto){
+        return adminService.updateAdmin(dto);
+    }
+
+    @GetMapping("updateState")
+    @ApiOperation("修改管理员状态")
+    public Result updateState(@RequestParam Integer id){
+        return adminService.updateState(id);
+    }
+
+    @GetMapping("logout")
+    @ApiOperation("管理员退出登录")
+    public Result logout(@RequestParam Integer id){
+        return adminService.logout(id);
     }
 
+
 }

+ 60 - 0
src/main/java/com/om/entity/dto/AdminAddDTO.java

@@ -0,0 +1,60 @@
+package com.om.entity.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.bind.DefaultValue;
+
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+@NoArgsConstructor
+public class AdminAddDTO implements Serializable {
+
+    @ApiModelProperty(value = "管理员ID")
+    private Integer id;
+
+    @ApiModelProperty(value = "管理员用户名")
+    private String username;
+
+    @ApiModelProperty(value = "管理员密码")
+    private String password;
+
+    @ApiModelProperty(value = "管理员真实姓名")
+    private String realName;
+
+    @ApiModelProperty(value = "管理员电子邮件")
+    @Email(message = "邮箱格式错误")
+    private String email;
+
+    @ApiModelProperty(value = "管理员电话号码")
+    @NotBlank(message = "手机号码不能为空")
+    @Pattern(regexp = "^1(3|4|5|7|8)\\d{9}$", message = "手机号码格式错误")
+    private String tel;
+
+    @ApiModelProperty(value = "是否启用管理员账户")
+    private Boolean enabled = true;
+
+    @ApiModelProperty(value = "管理员账户创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "管理员账户更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty(value = "管理员权限")
+    private String authority;
+
+    @ApiModelProperty(value = "管理员认证信息")
+    private String auths;
+
+    @ApiModelProperty(value = "token")
+    private String loginToken;
+
+}

+ 18 - 0
src/main/java/com/om/entity/dto/AdminQueryPageDTO.java

@@ -0,0 +1,18 @@
+package com.om.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class AdminQueryPageDTO {
+    @ApiModelProperty(value = "当前页码")
+    private Integer pageIndex;
+
+    @ApiModelProperty(value = "每个页码的大小")
+    private Integer pageSize;
+
+    @ApiModelProperty(value = "搜索字段---搜索用户名")
+    private String search;
+}

+ 3 - 0
src/main/java/com/om/entity/vo/AdminLoginVO.java

@@ -1,5 +1,6 @@
 package com.om.entity.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -32,9 +33,11 @@ public class AdminLoginVO {
     private Boolean enabled;
 
     @ApiModelProperty(value = "管理员账户创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime createTime;
 
     @ApiModelProperty(value = "管理员账户更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime updateTime;
 
     @ApiModelProperty(value = "管理员权限")

+ 31 - 0
src/main/java/com/om/entity/vo/AdminQueryPageVO.java

@@ -0,0 +1,31 @@
+package com.om.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+public class AdminQueryPageVO {
+
+    @ApiModelProperty(value = "当前页码")
+    private Integer current;
+
+    @ApiModelProperty(value = "总页码")
+    private Integer pages;
+
+    @ApiModelProperty(value = "每个页码的大小")
+    private Integer size;
+
+    @ApiModelProperty(value = "总数量")
+    private Integer total;
+
+    @ApiModelProperty(value = "是否是查询")
+    private Boolean searchCount = false;
+
+    @ApiModelProperty(value = "结果集")
+    private List<AdminLoginVO> records;
+
+}

+ 1 - 0
src/main/java/com/om/handler/GlobalExceptionHandler.java

@@ -4,6 +4,7 @@ package com.om.handler;
 import com.om.exception.BadReqException;
 import com.om.exception.BizException;
 import com.om.exception.CustomerAuthenticationException;
+import com.om.utils.CommonUtil;
 import com.om.utils.Result;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.core.Ordered;

+ 21 - 1
src/main/java/com/om/service/IAdminService.java

@@ -1,7 +1,11 @@
 package com.om.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.om.entity.dto.AdminAddDTO;
+import com.om.entity.dto.AdminQueryPageDTO;
 import com.om.entity.po.Admin;
+import com.om.entity.vo.AdminLoginVO;
+import com.om.entity.vo.AdminQueryPageVO;
 import com.om.utils.Result;
 
 /**
@@ -14,5 +18,21 @@ import com.om.utils.Result;
  */
 public interface IAdminService extends IService<Admin> {
 
-    Result login(String username, String password);
+    Result<AdminLoginVO> login(String username, String password);
+
+    Result<AdminLoginVO> getManagerByToken(String token);
+
+    Result add(AdminAddDTO dto);
+
+    Result delete(Integer id);
+
+    Result<AdminLoginVO> get(Integer id);
+
+    Result<AdminLoginVO> updateAdmin(AdminAddDTO dto);
+
+    Result updateState(Integer id);
+
+    Result logout(Integer id);
+
+    Result<AdminQueryPageVO> getPageList(AdminQueryPageDTO dto);
 }

+ 197 - 4
src/main/java/com/om/service/impl/AdminServiceImpl.java

@@ -1,14 +1,20 @@
 package com.om.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.om.constant.RedisConstant;
+import com.om.entity.dto.AdminAddDTO;
+import com.om.entity.dto.AdminQueryPageDTO;
 import com.om.entity.po.Admin;
+import com.om.entity.po.User;
 import com.om.entity.vo.AdminLoginVO;
+import com.om.entity.vo.AdminQueryPageVO;
 import com.om.exception.BadReqException;
 import com.om.exception.BizException;
 import com.om.mapper.AdminMapper;
 import com.om.service.IAdminService;
+import com.om.utils.AdminContext;
 import com.om.utils.JwtUtils;
 import com.om.utils.Result;
 import org.apache.commons.lang3.StringUtils;
@@ -22,9 +28,8 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import java.time.LocalDateTime;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -46,7 +51,7 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
 
 
     @Override
-    public Result login(String username, String password) {
+    public Result<AdminLoginVO> login(String username, String password) {
         if (StringUtils.isBlank(username)){
             throw new BadReqException("用户名不能为空!");
         }
@@ -87,6 +92,194 @@ public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements
         return Result.ok(adminLoginVO);
     }
 
+    @Override
+    public Result<AdminLoginVO> getManagerByToken(String token) {
+        //根据token获取管理员id
+        Integer adminId = jwtUtils.getAdminIdFromToken(token);
+
+        //根据id查询管理员信息
+        Admin admin = this.getById(adminId);
+        //判断是否为空
+        if (BeanUtil.isEmpty(admin)){
+            throw new BadReqException("该管理员不存在,请重试!");
+        }
+
+        AdminLoginVO adminLoginVO = BeanUtil.copyProperties(admin, AdminLoginVO.class);
+        adminLoginVO.setLoginToken(token);
+
+        return Result.ok(adminLoginVO);
+    }
+
+    @Override
+    public Result add(AdminAddDTO dto) {
+        //获取当前登录管理员id
+        Integer adminId = AdminContext.getAdminId();
+        String username = dto.getUsername();
+        String password = dto.getPassword();
+        //判断dto中的数据是否为空
+        if(StringUtils.isEmpty(username)){
+            throw new BadReqException("管理员用户名为空");
+        }
+        if(StringUtils.isEmpty(password)){
+            throw new BadReqException("管理员密码为空");
+        }
+        //判断dto中的用户名是否存在
+        Admin one = this.lambdaQuery()
+                .eq(Admin::getUsername, username)
+                .one();
+        if (!BeanUtil.isEmpty(one)){
+            throw new BadReqException("该用户已经存在,请检查用户名");
+        }
+
+        LocalDateTime now = LocalDateTime.now();
+        //密码加密
+        password = DigestUtils.md5DigestAsHex(password.getBytes());
+        Admin admin = BeanUtil.copyProperties(dto, Admin.class);
+        admin.setPassword(password);
+        admin.setOperatorId(adminId);
+        admin.setCreateTime(now);
+        admin.setUpdateTime(now);
+        //保存到数据库
+        this.save(admin);
+
+        return Result.ok();
+    }
+
+    @Override
+    public Result delete(Integer id) {
+        //根据id查询管理员
+        Admin admin = this.getById(id);
+        //判断该管理员是否存在
+        if (BeanUtil.isEmpty(admin)){
+            throw new BadReqException("该管理员不存在");
+        }
+        //删除该管理员
+        this.removeById(id);
+        return Result.ok();
+    }
+
+    @Override
+    public Result<AdminLoginVO> get(Integer id) {
+        //根据id查询管理员
+        Admin admin = this.getById(id);
+        //判断该管理员是否存在
+        if (BeanUtil.isEmpty(admin)){
+            throw new BadReqException("该管理员不存在");
+        }
+        AdminLoginVO adminLoginVO = BeanUtil.copyProperties(admin, AdminLoginVO.class);
+
+        //从redis中获取token
+        String tokenKey = RedisConstant.ADMIN_TOKEN_PREFIX +id;
+        String redisToken = (String) redisTemplate.opsForValue().get(tokenKey);
+        adminLoginVO.setLoginToken(redisToken);
+
+
+        return Result.ok(adminLoginVO);
+    }
+
+    @Override
+    public Result<AdminLoginVO> updateAdmin(AdminAddDTO dto) {
+        //获取当前登录管理员id
+        Integer adminId = AdminContext.getAdminId();
+        String username = dto.getUsername();
+        String password = dto.getPassword();
+        //判断dto中的数据是否为空
+        if(StringUtils.isEmpty(username)){
+            throw new BadReqException("管理员用户名为空");
+        }
+        //判断dto中的用户名是否存在
+        Admin one = this.lambdaQuery()
+                .eq(Admin::getUsername, username)
+                .one();
+        if (BeanUtil.isEmpty(one)){
+            throw new BadReqException("该用户不存在,请检查用户名");
+        }
+
+        LocalDateTime now = LocalDateTime.now();
+        //密码加密
+        //如果密码密码为空则 不修改密码  使用原密码
+        if (StringUtils.isEmpty(password)){
+            password = one.getPassword();
+        }else {
+            password = DigestUtils.md5DigestAsHex(password.getBytes());
+        }
+        Admin admin = BeanUtil.copyProperties(dto, Admin.class);
+        admin.setPassword(password);
+        admin.setOperatorId(adminId);
+        admin.setUpdateTime(now);
+        //更新到数据库
+        this.updateById(admin);
+
+        //封装vo
+        AdminLoginVO adminLoginVO = BeanUtil.copyProperties(admin, AdminLoginVO.class);
+        //从redis中获取token
+        String tokenKey = RedisConstant.ADMIN_TOKEN_PREFIX +adminId;
+        String redisToken = (String) redisTemplate.opsForValue().get(tokenKey);
+        adminLoginVO.setLoginToken(redisToken);
+
+        return Result.ok(adminLoginVO);
+    }
+
+    @Override
+    public Result updateState(Integer id) {
+        //根据id查询管理员
+        Admin admin = this.getById(id);
+        //判断该管理员是否存在
+        if (BeanUtil.isEmpty(admin)){
+            throw new BadReqException("该管理员不存在");
+        }
+
+        admin.setEnabled(!admin.getEnabled());
+        this.updateById(admin);
+        return Result.ok();
+    }
+
+    @Override
+    public Result logout(Integer id) {
+        //把redis中的token删除
+        //从redis中获取token
+        String tokenKey = RedisConstant.ADMIN_TOKEN_PREFIX +id;
+        if (!redisTemplate.hasKey(tokenKey)) {
+            throw new BadReqException("该管理员的token不存在");
+        }
+        redisTemplate.delete(tokenKey);
+
+        return Result.ok();
+    }
+
+    @Override
+    public Result<AdminQueryPageVO> getPageList(AdminQueryPageDTO dto) {
+        //获取dto中的数据
+        Integer pageIndex = dto.getPageIndex();
+        Integer pageSize = dto.getPageSize();
+        //分页查询
+        Page<Admin> page = this.lambdaQuery()
+                .like(dto.getSearch() != null, Admin::getUsername, dto.getSearch())
+                .orderByDesc(Admin::getCreateTime)
+                .page(new Page<>(pageIndex, pageSize));
+
+
+        AdminQueryPageVO adminQueryPageVO = new AdminQueryPageVO();
+        adminQueryPageVO.setCurrent((int) page.getCurrent());
+        adminQueryPageVO.setSize(pageSize);
+        adminQueryPageVO.setPages((int) page.getPages());
+        if (dto.getSearch() != null){
+            adminQueryPageVO.setSearchCount(true);
+        }
+
+        List<Admin> records = page.getRecords();
+        List<AdminLoginVO> list = new ArrayList<>();
+        for (Admin record : records) {
+            AdminLoginVO adminLoginVO = BeanUtil.copyProperties(record, AdminLoginVO.class);
+
+            list.add(adminLoginVO);
+        }
+
+        adminQueryPageVO.setRecords(list);
+        adminQueryPageVO.setTotal((int) page.getTotal());
+
+        return Result.ok(adminQueryPageVO);
+    }
 
 
 }

+ 9 - 0
src/main/java/com/om/utils/CommonUtil.java

@@ -0,0 +1,9 @@
+package com.om.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class CommonUtil {
+
+
+}