瀏覽代碼

基础接口补缺

wangliang 4 年之前
父節點
當前提交
dda3cd3e0c
共有 20 個文件被更改,包括 508 次插入178 次删除
  1. 7 0
      pom.xml
  2. 74 7
      themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java
  3. 8 1
      themis-backend/src/main/java/com/qmth/themis/backend/api/TBExamInvigilateUserController.java
  4. 42 60
      themis-backend/src/main/java/com/qmth/themis/backend/api/TBOrgController.java
  5. 85 15
      themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java
  6. 57 0
      themis-backend/src/main/resources/ehcache.xml
  7. 1 1
      themis-business/src/main/java/com/qmth/themis/business/config/RedisConfig.java
  8. 6 1
      themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java
  9. 10 1
      themis-business/src/main/java/com/qmth/themis/business/dao/TBOrgMapper.java
  10. 3 1
      themis-business/src/main/java/com/qmth/themis/business/dao/TBUserMapper.java
  11. 8 60
      themis-business/src/main/java/com/qmth/themis/business/enums/RoleEnum.java
  12. 13 0
      themis-business/src/main/java/com/qmth/themis/business/service/TBOrgService.java
  13. 3 2
      themis-business/src/main/java/com/qmth/themis/business/service/TBUserService.java
  14. 5 3
      themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java
  15. 20 0
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TBOrgServiceImpl.java
  16. 4 2
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TBUserServiceImpl.java
  17. 3 3
      themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskRoomCodeImportTemplete.java
  18. 72 0
      themis-business/src/main/java/com/qmth/themis/business/util/EhcacheUtil.java
  19. 40 0
      themis-business/src/main/resources/mapper/TBOrgMapper.xml
  20. 47 21
      themis-business/src/main/resources/mapper/TBUserMapper.xml

+ 7 - 0
pom.xml

@@ -43,6 +43,7 @@
         <gson.version>2.8.6</gson.version>
         <commons.version>3.10</commons.version>
         <jackson.version>2.11.0</jackson.version>
+        <ehcache.version>2.10.6</ehcache.version>
     </properties>
 
     <dependencyManagement>
@@ -186,6 +187,12 @@
                 <artifactId>jedis</artifactId>
                 <version>${redis.version}</version>
             </dependency>
+            <!-- ehcache 缓存 -->
+            <dependency>
+                <groupId>net.sf.ehcache</groupId>
+                <artifactId>ehcache</artifactId>
+                <version>${ehcache.version}</version>
+            </dependency>
             <!-- rocketmq -->
             <dependency>
                 <groupId>org.apache.rocketmq</groupId>

+ 74 - 7
themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java

@@ -6,15 +6,11 @@ import com.qmth.themis.backend.config.DictionaryConfig;
 import com.qmth.themis.backend.util.ServletUtil;
 import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.constant.SystemConstant;
-import com.qmth.themis.business.entity.TBAttachment;
-import com.qmth.themis.business.entity.TBPrivilege;
-import com.qmth.themis.business.entity.TBTaskHistory;
-import com.qmth.themis.business.entity.TBUser;
+import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.DownloadFileEnum;
 import com.qmth.themis.business.enums.RoleEnum;
-import com.qmth.themis.business.service.TBAttachmentService;
-import com.qmth.themis.business.service.TBPrivilegeService;
-import com.qmth.themis.business.service.TBTaskHistoryService;
+import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.util.EhcacheUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
@@ -62,6 +58,12 @@ public class SysController {
     @Resource
     SystemConfig systemConfig;
 
+    @Resource
+    TBOrgService tbOrgService;
+
+    @Resource
+    TBRoleService tbRoleService;
+
     @ApiOperation(value = "菜单查询接口")
     @RequestMapping(value = "/getMenu", method = RequestMethod.GET)
     @ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class)})
@@ -162,4 +164,69 @@ public class SysController {
         map.put("url", url);
         return ResultUtil.ok(map);
     }
+
+    @ApiOperation(value = "根据机构代码查询机构信息接口")
+    @RequestMapping(value = "/org/queryByOrgCode", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
+    public Result queryByOrgCode(@ApiParam(value = "机构code", required = true) @RequestParam(required = false) String code) {
+        if (Objects.isNull(code) || Objects.equals(code, "")) {
+            throw new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL);
+        }
+        TBOrg tbOrg = (TBOrg) EhcacheUtil.get(SystemConstant.orgCodeCache, code);
+        if (Objects.isNull(tbOrg)) {
+            QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
+            tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, code);
+            tbOrg = tbOrgService.getOne(tbOrgQueryWrapper);
+            if (Objects.nonNull(tbOrg)) {
+                EhcacheUtil.put(SystemConstant.orgCodeCache, code, tbOrg);
+            }
+        }
+        if (Objects.isNull(tbOrg)) {
+            throw new BusinessException(ExceptionResultEnum.ORG_NO);
+        }
+        Map map = new HashMap<>();
+        map.put("logo", tbOrg.getLogo());
+        return ResultUtil.ok(map);
+    }
+
+    @ApiOperation(value = "机构查询接口")
+    @RequestMapping(value = "/org/query", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
+    public Result query(@ApiParam(value = "机构id", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "机构编码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "机构名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable) {
+        QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
+        if (Objects.nonNull(id)) {
+            tbOrgQueryWrapper.lambda().eq(TBOrg::getId, id);
+        }
+        if (Objects.nonNull(code)) {
+            tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, code);
+        }
+        if (Objects.nonNull(name)) {
+            tbOrgQueryWrapper.lambda().like(TBOrg::getName, name);
+        }
+        if (Objects.nonNull(enable)) {
+            tbOrgQueryWrapper.lambda().eq(TBOrg::getEnable, enable);
+        }
+        List<TBOrg> tbOrgList = tbOrgService.list(tbOrgQueryWrapper);
+        Map map = new HashMap<>();
+        map.put(SystemConstant.RECORDS, tbOrgList);
+        return ResultUtil.ok(map);
+    }
+
+    @ApiOperation(value = "角色查询接口")
+    @RequestMapping(value = "/role/query", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TBRole.class)})
+    public Result roleList() {
+        List<TBRole> tbRoleList = (List<TBRole>) EhcacheUtil.get(SystemConstant.roleCache, SystemConstant.roleCache);
+        if (Objects.isNull(tbRoleList)) {
+            QueryWrapper<TBRole> tbRoleQueryWrapper = new QueryWrapper<>();
+            tbRoleQueryWrapper.lambda().notIn(TBRole::getRoleCode, RoleEnum.SUPER_ADMIN.name(),RoleEnum.STUDENT.name());
+            tbRoleList = tbRoleService.list(tbRoleQueryWrapper);
+            if (Objects.nonNull(tbRoleList)) {
+                EhcacheUtil.put(SystemConstant.roleCache, SystemConstant.roleCache, tbRoleList);
+            }
+        }
+        Map map = new HashMap();
+        map.put(SystemConstant.RECORDS, tbRoleList);
+        return ResultUtil.ok(map);
+    }
 }

+ 8 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/TBExamInvigilateUserController.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.backend.util.ServletUtil;
+import com.qmth.themis.business.annotation.ApiJsonObject;
+import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.*;
@@ -74,7 +76,12 @@ public class TBExamInvigilateUserController {
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    public Result save(@ApiParam(value = "监考员信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+    public Result save(
+            @ApiJsonObject(name = "saveInvigilateUser", value = {
+                    @ApiJsonProperty(key = "roomCode", description = "考场代码"),
+                    @ApiJsonProperty(key = "userId", type = "long", example = "1", description = "用户id")
+            })
+            @ApiParam(value = "监考员信息", required = true) @RequestBody Map<String, Object> mapParameter) {
         String roomCode = null;
         try {
             if (Objects.isNull(mapParameter.get("roomCode")) || Objects.equals(mapParameter.get("roomCode"), "")) {

+ 42 - 60
themis-backend/src/main/java/com/qmth/themis/backend/api/TBOrgController.java

@@ -1,11 +1,16 @@
 package com.qmth.themis.backend.api;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.backend.util.ServletUtil;
+import com.qmth.themis.business.annotation.ApiJsonObject;
+import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.service.TBOrgService;
+import com.qmth.themis.business.util.EhcacheUtil;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.common.contanst.Constants;
@@ -19,7 +24,6 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -46,64 +50,13 @@ public class TBOrgController {
 
     //    @CachePut(value = "org_cache", key = "'orgCacheQuery'")
 //    @Cacheable(value = "org_cache", key = "#p0")
-    @ApiOperation(value = "机构查询接口")
-    @RequestMapping(value = "/query", method = RequestMethod.GET)
-    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
-    public Result query(@ApiParam(value = "机构id", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "机构编码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "机构名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable) {
-        QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
-        if (Objects.nonNull(id)) {
-            tbOrgQueryWrapper.lambda().eq(TBOrg::getId, id);
-        }
-        if (Objects.nonNull(code)) {
-            tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, code);
-        }
-        if (Objects.nonNull(name)) {
-            tbOrgQueryWrapper.lambda().like(TBOrg::getName, name);
-        }
-        if (Objects.nonNull(enable)) {
-            tbOrgQueryWrapper.lambda().eq(TBOrg::getEnable, enable);
-        }
-        List<TBOrg> tbOrgList = tbOrgService.list(tbOrgQueryWrapper);
-        Map map = new HashMap<>();
-        map.put(SystemConstant.RECORDS, tbOrgList);
-        return ResultUtil.ok(map);
-    }
-
     @ApiOperation(value = "机构查询分页接口")
-    @RequestMapping(value = "/queryByPage", method = RequestMethod.GET)
-    @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
-    public Result queryByPage(@ApiParam(value = "机构代码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "机构名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable) {
-        QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
-        if (Objects.nonNull(code)) {
-            tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, code);
-        }
-        if (Objects.nonNull(name)) {
-            tbOrgQueryWrapper.lambda().like(TBOrg::getName, name);
-        }
-        if (Objects.nonNull(enable)) {
-            tbOrgQueryWrapper.lambda().eq(TBOrg::getEnable, enable);
-        }
-        List<TBOrg> tbOrgList = tbOrgService.list(tbOrgQueryWrapper);
-        Map map = new HashMap<>();
-        map.put(SystemConstant.RECORDS, tbOrgList);
-        return ResultUtil.ok(map);
-    }
-
-    @ApiOperation(value = "根据机构代码查询机构信息接口")
-    @RequestMapping(value = "/queryByOrgCode", method = RequestMethod.GET)
+    @RequestMapping(value = "/query", method = RequestMethod.GET)
     @ApiResponses({@ApiResponse(code = 200, message = "机构信息", response = TBOrg.class)})
-    public Result queryByOrgCode(@ApiParam(value = "机构code", required = true) @RequestParam(required = false) String code) {
-        if (Objects.nonNull(code) || Objects.equals(code, "")) {
-            throw new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL);
-        }
-        QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
-        tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, code);
-        TBOrg tbOrg = tbOrgService.getOne(tbOrgQueryWrapper);
-        if (Objects.isNull(tbOrg)) {
-            throw new BusinessException(ExceptionResultEnum.ORG_NO);
-        }
+    public Result queryByPage(@ApiParam(value = "机构代码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "机构名称", required = false) @RequestParam(required = false) String name, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        IPage<Map> tborgIPage = tbOrgService.queryByPage(new Page<>(pageNumber, pageSize), code, name, enable);
         Map map = new HashMap<>();
-        map.put("logo", tbOrg.getLogo());
+        map.put(SystemConstant.RECORDS, tborgIPage);
         return ResultUtil.ok(map);
     }
 
@@ -121,12 +74,41 @@ public class TBOrgController {
             tbOrg.setId(Constants.idGen.next());
             tbOrg.setCreateId(tbUser.getId());
         } else {
-            if (Objects.nonNull(redisUtil.getOrg(tbOrg.getId()))) {
-                redisUtil.setOrg(tbOrg.getId(), tbOrg);
-            }
             tbOrg.setUpdateId(tbUser.getId());
         }
+        redisUtil.setOrg(tbOrg.getId(), tbOrg);
+        EhcacheUtil.put(SystemConstant.orgCodeCache, tbOrg.getCode(), tbOrg);
         tbOrgService.saveOrUpdate(tbOrg);
         return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
     }
+
+    @ApiOperation(value = "机构停用/启用接口")
+    @RequestMapping(value = "/enable", method = RequestMethod.POST)
+    @Transactional
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result enable(@ApiJsonObject(name = "enableOrg", value = {
+            @ApiJsonProperty(key = "id", type = "long", example = "1", description = "机构id"),
+            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "停用/启用")
+    }) @ApiParam(value = "用户信息", required = true) @RequestBody Map<String, Object> user) {
+        if (Objects.isNull(user.get("id")) || Objects.equals(user.get("id"), "")) {
+            throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
+        }
+        Long orgId = Long.parseLong(String.valueOf(user.get("id")));
+        if (Objects.isNull(user.get("enable")) || Objects.equals(user.get("enable"), "")) {
+            throw new BusinessException(ExceptionResultEnum.ENABLE_IS_NULL);
+        }
+        Integer enable = Integer.parseInt(String.valueOf(user.get("enable")));
+        TBOrg tbOrg = (TBOrg) redisUtil.getOrg(orgId);
+        if (Objects.isNull(tbOrg)) {
+            tbOrg = tbOrgService.getById(orgId);
+        }
+        if (Objects.isNull(tbOrg)) {
+            throw new BusinessException(ExceptionResultEnum.USER_NO);
+        }
+        //保存用户
+        tbOrg.setEnable(enable);
+        tbOrgService.updateById(tbOrg);
+        redisUtil.setOrg(orgId, tbOrg);
+        return ResultUtil.ok(JSONObject.parseObject(SystemConstant.SUCCESS));
+    }
 }

+ 85 - 15
themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java

@@ -1,6 +1,9 @@
 package com.qmth.themis.backend.api;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.gson.Gson;
 import com.qmth.themis.backend.util.ServletUtil;
 import com.qmth.themis.business.annotation.ApiJsonObject;
@@ -18,6 +21,7 @@ import com.qmth.themis.business.service.CacheService;
 import com.qmth.themis.business.service.TBOrgService;
 import com.qmth.themis.business.service.TBUserRoleService;
 import com.qmth.themis.business.service.TBUserService;
+import com.qmth.themis.business.util.EhcacheUtil;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.SessionUtil;
@@ -79,32 +83,45 @@ public class TBUserController {
     @ApiOperation(value = "用户登录接口")
     @RequestMapping(value = "/login/account", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = TBUser.class)})
-    public Result login(@ApiParam(value = "用户信息", required = true) @RequestBody Map<String,Object> map) throws NoSuchAlgorithmException {
-        if (Objects.isNull(map)) {
+    public Result login(@ApiJsonObject(name = "loginAccount", value = {
+            @ApiJsonProperty(key = "loginName", description = "登录名"),
+            @ApiJsonProperty(key = "password", description = "密码"),
+            @ApiJsonProperty(key = "code", description = "机构代码")
+    }) @ApiParam(value = "用户信息", required = true) @RequestBody Map<String, Object> mapParameter) throws NoSuchAlgorithmException {
+        if (Objects.isNull(mapParameter)) {
             throw new BusinessException(ExceptionResultEnum.USER_INFO_IS_NULL);
         }
-        if (Objects.isNull(map.get("loginName")) || Objects.equals(map.get("loginName"), "")) {
+        if (Objects.isNull(mapParameter.get("loginName")) || Objects.equals(mapParameter.get("loginName"), "")) {
             throw new BusinessException(ExceptionResultEnum.LOGIN_NAME_IS_NULL);
         }
-        if (Objects.isNull(map.get("password")) || Objects.equals(map.get("password"), "")) {
+        if (Objects.isNull(mapParameter.get("password")) || Objects.equals(mapParameter.get("password"), "")) {
             throw new BusinessException(ExceptionResultEnum.PASSWORD_IS_NULL);
         }
-        if (Objects.isNull(map.get("code")) || Objects.equals(map.get("code"), "")) {
+        if (Objects.isNull(mapParameter.get("code")) || Objects.equals(mapParameter.get("code"), "")) {
             throw new BusinessException(ExceptionResultEnum.ORG_CODE_IS_NULL);
         }
-        String loginName = String.valueOf(map.get("loginName"));
-        String password = String.valueOf(map.get("password"));
-        String orgCode = String.valueOf(map.get("code"));
-        QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
-        tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, orgCode);
-        TBOrg tbOrg = tbOrgService.getOne(tbOrgQueryWrapper);
+        String loginName = String.valueOf(mapParameter.get("loginName"));
+        String password = String.valueOf(mapParameter.get("password"));
+        String orgCode = String.valueOf(mapParameter.get("code"));
+        TBOrg tbOrg = (TBOrg) EhcacheUtil.get(SystemConstant.orgCodeCache, orgCode);
+        if (Objects.isNull(tbOrg)) {
+            QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
+            tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, orgCode);
+            tbOrg = tbOrgService.getOne(tbOrgQueryWrapper);
+            if (Objects.nonNull(tbOrg)) {
+                EhcacheUtil.put(SystemConstant.orgCodeCache, orgCode, tbOrg);
+            }
+        }
         if (Objects.isNull(tbOrg)) {
             throw new BusinessException(ExceptionResultEnum.ORG_NO);
         }
 
         QueryWrapper<TBUser> wrapper = new QueryWrapper<>();
-        wrapper.lambda().eq(TBUser::getLoginName, loginName).eq(TBUser::getOrgId, tbOrg.getId());
+        wrapper.lambda().eq(TBUser::getLoginName, loginName);
         TBUser user = tbUserService.getOne(wrapper);
+        if (Objects.nonNull(user.getOrgId()) && user.getOrgId().longValue() != tbOrg.getId().longValue()) {
+            throw new BusinessException("用户机构不匹配");
+        }
         //用户不存在
         if (Objects.isNull(user)) {
             throw new BusinessException(ExceptionResultEnum.USER_NO);
@@ -533,10 +550,10 @@ public class TBUserController {
     @ApiOperation(value = "用户查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.GET)
     @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = TBUser.class)})
-    public Result query(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "登录名", required = false) @RequestParam(required = false) String loginName, @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name, @ApiParam(value = "角色", required = false) @RequestParam(required = false) String role, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable) {
-        List<TBUser> tbUserList = tbUserService.userQuery(id, loginName, name, role, enable);
+    public Result query(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "登录名", required = false) @RequestParam(required = false) String loginName, @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name, @ApiParam(value = "角色", required = false) @RequestParam(required = false) String role, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        IPage<Map> tbUserIPage = tbUserService.userQuery(new Page<>(pageNumber, pageSize), id, loginName, name, role, enable);
         Map map = new HashMap<>();
-        map.put(SystemConstant.RECORDS, tbUserList);
+        map.put(SystemConstant.RECORDS, tbUserIPage);
         return ResultUtil.ok(map);
     }
 
@@ -621,4 +638,57 @@ public class TBUserController {
     public Result validateGetVerifyCode() {
         return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
     }
+
+    @ApiOperation(value = "用户停用/启用接口")
+    @RequestMapping(value = "/enable", method = RequestMethod.POST)
+    @Transactional
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result enable(@ApiJsonObject(name = "enableUser", value = {
+            @ApiJsonProperty(key = "id", type = "long", example = "1", description = "用户id"),
+            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "停用/启用")
+    }) @ApiParam(value = "用户信息", required = true) @RequestBody Map<String, Object> user) {
+        if (Objects.isNull(user.get("id")) || Objects.equals(user.get("id"), "")) {
+            throw new BusinessException(ExceptionResultEnum.USER_ID_IS_NULL);
+        }
+        Long userId = Long.parseLong(String.valueOf(user.get("id")));
+        if (Objects.isNull(user.get("enable")) || Objects.equals(user.get("enable"), "")) {
+            throw new BusinessException(ExceptionResultEnum.ENABLE_IS_NULL);
+        }
+        Integer enable = Integer.parseInt(String.valueOf(user.get("enable")));
+        TBUser tbUser = tbUserService.getById(userId);
+        if (Objects.isNull(tbUser)) {
+            throw new BusinessException(ExceptionResultEnum.USER_NO);
+        }
+        //保存用户
+        tbUser.setEnable(enable);
+        tbUserService.updateById(tbUser);
+        return ResultUtil.ok(JSONObject.parseObject(SystemConstant.SUCCESS));
+    }
+
+    @ApiOperation(value = "用户修改密码接口")
+    @RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @Transactional
+    public Result updatePwd(@ApiJsonObject(name = "userUpdatePwd", value = {
+            @ApiJsonProperty(key = "id", type = "long", example = "1", description = "用户ID"),
+            @ApiJsonProperty(key = "password", description = "新密码")
+    }) @ApiParam(value = "用户信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+        if (Objects.isNull(mapParameter.get("id")) || Objects.equals(mapParameter.get("id"), "")) {
+            throw new BusinessException(ExceptionResultEnum.USER_ID_IS_NULL);
+        }
+        Long id = Long.parseLong(String.valueOf(mapParameter.get("id")));
+        if (Objects.isNull(mapParameter.get("password")) || Objects.equals(mapParameter.get("password"), "")) {
+            throw new BusinessException(ExceptionResultEnum.PASSWORD_IS_NULL);
+        }
+        String password = String.valueOf(mapParameter.get("password"));
+        TBUser tbUser = tbUserService.getById(id);
+        if (Objects.isNull(tbUser)) {
+            throw new BusinessException(ExceptionResultEnum.USER_NO);
+        }
+        TBUser currentUser = (TBUser) ServletUtil.getRequestAccount();
+        tbUser.setPassword(password);
+        tbUser.setUpdateId(currentUser.getId());
+        tbUserService.updateById(tbUser);
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
+    }
 }

+ 57 - 0
themis-backend/src/main/resources/ehcache.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
+         updateCheck="false">
+    <diskStore path="/Users/king/Downloads/ehcache" />
+
+    <!--overflowToDisk:是否保存到磁盘,当系统宕机时-->
+    <!--diskPersistent:是否在磁盘上持久化。指重启jvm后,数据是否有效。默认为false。-->
+    <defaultCache
+            eternal="false"
+            maxElementsInMemory="10000"
+            overflowToDisk="false"
+            diskPersistent="false"
+            timeToIdleSeconds="0"
+            timeToLiveSeconds="2400"
+            memoryStoreEvictionPolicy="LRU" />
+
+    <cache
+            name="org_code_cache"
+            eternal="false"
+            maxElementsInMemory="1000"
+            overflowToDisk="false"
+            diskPersistent="false"
+            timeToIdleSeconds="0"
+            timeToLiveSeconds="43200"
+            memoryStoreEvictionPolicy="LRU" />
+
+    <cache
+            name="role_cache"
+            eternal="false"
+            maxElementsInMemory="1000"
+            overflowToDisk="false"
+            diskPersistent="false"
+            timeToIdleSeconds="0"
+            timeToLiveSeconds="43200"
+            memoryStoreEvictionPolicy="LRU" />
+
+<!--    <cache-->
+<!--            name="org_cache"-->
+<!--            eternal="false"-->
+<!--            maxElementsInMemory="1000"-->
+<!--            overflowToDisk="false"-->
+<!--            diskPersistent="false"-->
+<!--            timeToIdleSeconds="0"-->
+<!--            timeToLiveSeconds="43200"-->
+<!--            memoryStoreEvictionPolicy="LRU" />-->
+
+<!--    <cache-->
+<!--            name="user_cache"-->
+<!--            eternal="false"-->
+<!--            maxElementsInMemory="1000"-->
+<!--            overflowToDisk="false"-->
+<!--            diskPersistent="false"-->
+<!--            timeToIdleSeconds="0"-->
+<!--            timeToLiveSeconds="43200"-->
+<!--            memoryStoreEvictionPolicy="LRU" />-->
+</ehcache>

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/config/RedisConfig.java

@@ -43,7 +43,7 @@ public class RedisConfig {
         Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
         redisCacheConfigurationMap.put(SystemConstant.userOauth, this.getRedisCacheConfigurationWithTtl(SystemConstant.REDIS_OAUTH_EXPIRE_TIME));
         redisCacheConfigurationMap.put(SystemConstant.studentOauth, this.getRedisCacheConfigurationWithTtl(SystemConstant.REDIS_OAUTH_EXPIRE_TIME));
-        redisCacheConfigurationMap.put(SystemConstant.configOauth, this.getRedisCacheConfigurationWithTtl(SystemConstant.REDIS_EXPIRE_TIME));
+        redisCacheConfigurationMap.put(SystemConstant.configCache, this.getRedisCacheConfigurationWithTtl(SystemConstant.REDIS_EXPIRE_TIME));
         return redisCacheConfigurationMap;
     }
 

+ 6 - 1
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -135,7 +135,12 @@ public class SystemConstant {
      */
     public static final String userOauth = "user:oauth:cache";
     public static final String studentOauth = "student:oauth:cache";
-    public static final String configOauth = "config:cache";
+    public static final String configCache = "config:cache";
+    /**
+     * ehcache配置
+     */
+    public static final String orgCodeCache = "org_code_cache";
+    public static final String roleCache = "role_cache";
 
     static {
         String[] strs = delayLevel.split(",");

+ 10 - 1
themis-business/src/main/java/com/qmth/themis/business/dao/TBOrgMapper.java

@@ -20,5 +20,14 @@ import java.util.Map;
 @Mapper
 public interface TBOrgMapper extends BaseMapper<TBOrg> {
 
-//    public IPage<Map> queryByPage(IPage<Map> iPage, @Param("code") String code, @Param("name") String name, @Param("enable") Integer enable);
+    /**
+     * 查询机构分页信息
+     *
+     * @param iPage
+     * @param code
+     * @param name
+     * @param enable
+     * @return
+     */
+    public IPage<Map> queryByPage(IPage<Map> iPage, @Param("code") String code, @Param("name") String name, @Param("enable") Integer enable);
 }

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/dao/TBUserMapper.java

@@ -1,6 +1,7 @@
 package com.qmth.themis.business.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.entity.TBUser;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -21,6 +22,7 @@ public interface TBUserMapper extends BaseMapper<TBUser> {
     /**
      * 用户查询
      *
+     * @param iPage
      * @param id
      * @param loginName
      * @param name
@@ -28,5 +30,5 @@ public interface TBUserMapper extends BaseMapper<TBUser> {
      * @param enable
      * @return
      */
-    List<TBUser> userQuery(@Param("id") Long id, @Param("loginName") String loginName, @Param("name") String name, @Param("role") String role, @Param("enable") Integer enable);
+    IPage<Map> userQuery(IPage<Map> iPage,@Param("id") Long id, @Param("loginName") String loginName, @Param("name") String name, @Param("role") String role, @Param("enable") Integer enable);
 }

+ 8 - 60
themis-business/src/main/java/com/qmth/themis/business/enums/RoleEnum.java

@@ -1,7 +1,5 @@
 package com.qmth.themis.business.enums;
 
-import java.util.Objects;
-
 /**
  * @Description: 角色enum
  * @Param:
@@ -10,70 +8,20 @@ import java.util.Objects;
  * @Date: 2020/4/18
  */
 public enum RoleEnum {
-    /**
-     * 系统管理员
-     */
-    SUPER_ADMIN(1, "系统管理员"),
-    /**
-     * 管理员
-     */
-    TEACHER(2, "老师"),
-    /**
-     * 考务老师
-     */
-    STUDENT(3, "学生"),
-    /**
-     * 监考员
-     */
-    INVIGILATE(4, "监考员");
+    SUPER_ADMIN("系统管理员"),
 
-    private int id;
+    INVIGILATE("监考员"),
 
-    private String code;
+    ADMIN("管理员"),
 
-    private RoleEnum(int id, String code) {
-        this.id = id;
-        this.code = code;
-    }
+    INSPECTION("巡考员"),
 
-    /**
-     * 状态转换 toId
-     *
-     * @param value
-     * @return
-     */
-    public static int convertToId(String value) {
-        if (Objects.equals(value.trim(), SUPER_ADMIN.name())) {
-            return SUPER_ADMIN.getId();
-        } else if (Objects.equals(value.trim(), TEACHER.name())) {
-            return TEACHER.getId();
-        } else if (Objects.equals(value.trim(), TEACHER.name())) {
-            return INVIGILATE.getId();
-        } else {
-            return STUDENT.getId();
-        }
-    }
+    STUDENT("学生");
 
-    /**
-     * 状态转换 toName
-     *
-     * @param value
-     * @return
-     */
-    public static String convertToName(String value) {
-        if (Objects.equals(value.trim(), SUPER_ADMIN.getCode())) {
-            return SUPER_ADMIN.name();
-        } else if (Objects.equals(value.trim(), TEACHER.getCode())) {
-            return TEACHER.name();
-        } else if (Objects.equals(value.trim(), TEACHER.getCode())) {
-            return INVIGILATE.name();
-        } else {
-            return STUDENT.name();
-        }
-    }
+    private String code;
 
-    public int getId() {
-        return id;
+    private RoleEnum(String code) {
+        this.code = code;
     }
 
     public String getCode() {

+ 13 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TBOrgService.java

@@ -1,8 +1,11 @@
 package com.qmth.themis.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TBOrg;
 
+import java.util.Map;
+
 /**
  * @Description: 机构 服务类
  * @Param:
@@ -12,4 +15,14 @@ import com.qmth.themis.business.entity.TBOrg;
  */
 public interface TBOrgService extends IService<TBOrg> {
 
+    /**
+     * 查询机构分页信息
+     *
+     * @param iPage
+     * @param code
+     * @param name
+     * @param enable
+     * @return
+     */
+    public IPage<Map> queryByPage(IPage<Map> iPage, String code, String name, Integer enable);
 }

+ 3 - 2
themis-business/src/main/java/com/qmth/themis/business/service/TBUserService.java

@@ -1,9 +1,9 @@
 package com.qmth.themis.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TBUser;
 
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -18,6 +18,7 @@ public interface TBUserService extends IService<TBUser> {
     /**
      * 用户查询
      *
+     * @param iPage
      * @param id
      * @param loginName
      * @param name
@@ -25,5 +26,5 @@ public interface TBUserService extends IService<TBUser> {
      * @param enable
      * @return
      */
-    List<TBUser> userQuery(Long id, String loginName, String name, String role, Integer enable);
+    IPage<Map> userQuery(IPage<Map> iPage,Long id, String loginName, String name, String role, Integer enable);
 }

+ 5 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java

@@ -6,14 +6,13 @@ import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
-import org.springframework.core.annotation.AliasFor;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -52,6 +51,9 @@ public class CacheServiceImpl implements CacheService {
     @Resource
     TEStudentService teStudentService;
 
+    @Resource
+    RedisUtil redisUtil;
+
     /**
      * 添加用户缓存
      *
@@ -81,7 +83,7 @@ public class CacheServiceImpl implements CacheService {
                     List<TBPrivilege> tbPrivilegeList = tbPrivilegeService.list(pWrapper);
                     authDto = new AuthDto(tbUserRoleList.stream().map(s -> s.getRoleCode()).collect(Collectors.toSet()), tbPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()));
                 } else {
-                    TBOrg tbOrg = tbOrgService.getById(user.getOrgId());
+                    TBOrg tbOrg = Objects.isNull(redisUtil.getOrg(user.getOrgId())) ? tbOrgService.getById(user.getOrgId()) : (TBOrg) redisUtil.getOrg(user.getOrgId());
                     //根据角色名查权限
                     Set<String> roleCodes = tbUserRoleList.stream().map(s -> s.getRoleCode()).collect(Collectors.toSet());
                     QueryWrapper<TBRolePrivilege> rpWrapper = new QueryWrapper<>();

+ 20 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBOrgServiceImpl.java

@@ -1,11 +1,15 @@
 package com.qmth.themis.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.dao.TBOrgMapper;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.service.TBOrgService;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.Map;
+
 /**
  * @Description: 机构 服务实现类
  * @Param:
@@ -16,4 +20,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class TBOrgServiceImpl extends ServiceImpl<TBOrgMapper, TBOrg> implements TBOrgService {
 
+    @Resource
+    TBOrgMapper tbOrgMapper;
+
+    /**
+     * 查询机构分页信息
+     *
+     * @param iPage
+     * @param code
+     * @param name
+     * @param enable
+     * @return
+     */
+    @Override
+    public IPage<Map> queryByPage(IPage<Map> iPage, String code, String name, Integer enable) {
+        return tbOrgMapper.queryByPage(iPage, code, name, enable);
+    }
 }

+ 4 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBUserServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.dao.TBUserMapper;
 import com.qmth.themis.business.entity.TBUser;
@@ -26,6 +27,7 @@ public class TBUserServiceImpl extends ServiceImpl<TBUserMapper, TBUser> impleme
     /**
      * 用户查询
      *
+     * @param iPage
      * @param id
      * @param loginName
      * @param name
@@ -34,7 +36,7 @@ public class TBUserServiceImpl extends ServiceImpl<TBUserMapper, TBUser> impleme
      * @return
      */
     @Override
-    public List<TBUser> userQuery(Long id, String loginName, String name, String role, Integer enable) {
-        return tbUserMapper.userQuery(id, loginName, name, role, enable);
+    public IPage<Map> userQuery(IPage<Map> iPage, Long id, String loginName, String name, String role, Integer enable) {
+        return tbUserMapper.userQuery(iPage, id, loginName, name, role, enable);
     }
 }

+ 3 - 3
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskRoomCodeImportTemplete.java

@@ -182,9 +182,9 @@ public class TaskRoomCodeImportTemplete implements TaskImportTemplete {
                 tbUserList.add(tbUser);
 
                 //新增用户角色
-                TBUserRole tbUserRole = new TBUserRole(tbUser.getId(), RoleEnum.TEACHER.name());
-                tbUserRoleService.save(tbUserRole);
-                tbUserRole = new TBUserRole(tbUser.getId(), RoleEnum.INVIGILATE.name());
+//                TBUserRole tbUserRole = new TBUserRole(tbUser.getId(), RoleEnum.TEACHER.name());
+//                tbUserRoleService.save(tbUserRole);
+                TBUserRole tbUserRole = new TBUserRole(tbUser.getId(), RoleEnum.INVIGILATE.name());
                 tbUserRoleService.save(tbUserRole);
                 tbUserRoleList.add(tbUserRole);
             }

+ 72 - 0
themis-business/src/main/java/com/qmth/themis/business/util/EhcacheUtil.java

@@ -0,0 +1,72 @@
+package com.qmth.themis.business.util;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.util.Objects;
+
+/**
+ * @Description: ehcache util
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/6/23
+ */
+public class EhcacheUtil {
+    private final static Logger log = LoggerFactory.getLogger(EhcacheUtil.class);
+
+    private static final String path = "/ehcache.xml";
+
+    private URL url;
+    private static CacheManager manager;
+    private volatile static EhcacheUtil ehCache;
+
+    private EhcacheUtil(String path) {
+        url = getClass().getResource(path);
+        manager = CacheManager.create(url);
+    }
+
+    public static EhcacheUtil getInstance() {
+        if (Objects.isNull(ehCache)) {
+            synchronized (EhcacheUtil.class) {
+                if (Objects.isNull(ehCache)) {
+                    ehCache = new EhcacheUtil(path);
+                }
+            }
+        }
+        return ehCache;
+    }
+
+    static {
+        getInstance();
+    }
+
+    public static void put(String cacheName, Object key, Object value) {
+        Cache cache = manager.getCache(cacheName);
+        Element element = new Element(key, value);
+        cache.put(element);
+    }
+
+    public static Object get(String cacheName, Object key) {
+        Cache cache = manager.getCache(cacheName);
+        Element element = cache.get(key);
+        if (Objects.nonNull(element)) {
+            log.info("Element:{}", JacksonUtil.parseJson(element));
+        }
+        return element == null ? null : element.getObjectValue();
+    }
+
+    public static Cache get(String cacheName) {
+        return manager.getCache(cacheName);
+    }
+
+    public static void remove(String cacheName, Object key) {
+        Cache cache = manager.getCache(cacheName);
+        cache.remove(key);
+    }
+}

+ 40 - 0
themis-business/src/main/resources/mapper/TBOrgMapper.xml

@@ -2,4 +2,44 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.themis.business.dao.TBOrgMapper">
 
+    <select id="queryByPage" resultType="java.util.Map">
+        select
+            t.id,
+            t.name,
+            t.code,
+            t.enable,
+            t.contactName,
+            t.contactPhone,
+            if(t.updateName is not null,t.updateName,t.createName) as updateName,
+            if(t.updateTime is not null,t.updateTime,t.createTime) as updateTime
+            from
+            (
+            select
+                tbo.id, tbo.name, tbo.code, tbo.enable, tbo.contact_name as contactName, tbo.contact_phone as contactPhone, (
+                select
+                    tbu.name
+                from
+                    t_b_user tbu
+                where
+                    tbu.id = tbo.create_id) as createName, tbo.create_time as createTime, (
+                select
+                    tbu.name
+                from
+                    t_b_user tbu
+                where
+                    tbu.id = tbo.update_id) as updateName, tbo.update_time as updateTime
+            from
+                t_b_org tbo
+            <where>
+                <if test="code != null and code != ''">
+                    and tbo.code = #{code}
+                </if>
+                <if test="name != null and name != ''">
+                    and tbo.login_name like concat('%', #{name}, '%')
+                </if>
+                <if test="enable != null and enable != '' or enable == 0">
+                    and tbo.enable = #{enable}
+                </if>
+            </where> ) t
+    </select>
 </mapper>

+ 47 - 21
themis-business/src/main/resources/mapper/TBUserMapper.xml

@@ -2,26 +2,52 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.themis.business.dao.TBUserMapper">
 
-    <select id="userQuery" resultType="com.qmth.themis.business.entity.TBUser">
-        select * from t_b_user tbu
-        left join t_b_user_role tbur on tbur.user_id = tbu.id
-        left join t_b_role tbr on tbr.role_code = tbur.role_code
-        <where>
-            <if test="id != null and id != ''">
-                and tbu.id = #{id}
-            </if>
-            <if test="loginName != null and loginName != ''">
-                and tbu.login_name like concat('%', #{loginName}, '%')
-            </if>
-            <if test="name != null and name != ''">
-                and tbu.name like concat('%', #{name}, '%')
-            </if>
-            <if test="enable != null and enable != '' or enable == 0">
-                and tbu.enable = #{enable}
-            </if>
-            <if test="role != null and role != ''">
-                and tbr.role_code = #{role}
-            </if>
-        </where>
+    <select id="userQuery" resultType="java.util.Map">
+        select
+            t.id,
+            t.name,
+            t.roleName,
+            t.enable,
+            if(t.updateName is not null, t.updateName, t.createName) as updateName,
+            if(t.updateTime is not null, t.updateTime, t.createTime) as updateTime
+            from
+            (
+            select
+            tbu.id, tbu.name, tbr.role_name as roleName, tbu.enable, (
+            select
+            tbu.name
+            from
+            t_b_user t
+            where
+            t.id = tbu.create_id) as createName, tbu.create_time as createTime, (
+            select
+            tbu.name
+            from
+            t_b_user t
+            where
+            t.id = tbu.update_id) as updateName, tbu.update_time as updateTime
+            from
+            t_b_user tbu
+            left join t_b_user_role tbur on
+            tbur.user_id = tbu.id
+            left join t_b_role tbr on
+            tbr.role_code = tbur.role_code
+            <where>
+                <if test="id != null and id != ''">
+                    and tbu.id = #{id}
+                </if>
+                <if test="loginName != null and loginName != ''">
+                    and tbu.login_name like concat('%', #{loginName}, '%')
+                </if>
+                <if test="name != null and name != ''">
+                    and tbu.name like concat('%', #{name}, '%')
+                </if>
+                <if test="enable != null and enable != '' or enable == 0">
+                    and tbu.enable = #{enable}
+                </if>
+                <if test="role != null and role != ''">
+                    and tbr.role_code = #{role}
+                </if>
+            </where> ) t
     </select>
 </mapper>