wangliang 4 ani în urmă
părinte
comite
ebf1629cbf

+ 38 - 0
themis-backend/src/main/java/com/qmth/themis/backend/api/TBOrgController.java

@@ -69,6 +69,44 @@ public class TBOrgController {
         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)
+    @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);
+        }
+        Map map = new HashMap<>();
+        map.put("logo", tbOrg.getLogo());
+        return ResultUtil.ok(map);
+    }
+
     //    @CacheEvict(value = "org_cache", key = "'orgCacheQuery'")
     @ApiOperation(value = "机构新增/编辑接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)

+ 21 - 7
themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java

@@ -15,6 +15,7 @@ import com.qmth.themis.business.enums.MqEnum;
 import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.enums.SystemOperationEnum;
 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.JacksonUtil;
@@ -72,24 +73,37 @@ public class TBUserController {
     @Resource
     TBUserRoleService tbUserRoleService;
 
+    @Resource
+    TBOrgService tbOrgService;
+
     @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 TBUser tbUser) throws NoSuchAlgorithmException {
-        if (Objects.isNull(tbUser)) {
+    public Result login(@ApiParam(value = "用户信息", required = true) @RequestBody Map<String,Object> map) throws NoSuchAlgorithmException {
+        if (Objects.isNull(map)) {
             throw new BusinessException(ExceptionResultEnum.USER_INFO_IS_NULL);
         }
-        if (Objects.isNull(tbUser.getLoginName()) || Objects.equals(tbUser.getLoginName(), "")) {
+        if (Objects.isNull(map.get("loginName")) || Objects.equals(map.get("loginName"), "")) {
             throw new BusinessException(ExceptionResultEnum.LOGIN_NAME_IS_NULL);
         }
-        if (Objects.isNull(tbUser.getPassword()) || Objects.equals(tbUser.getPassword(), "")) {
+        if (Objects.isNull(map.get("password")) || Objects.equals(map.get("password"), "")) {
             throw new BusinessException(ExceptionResultEnum.PASSWORD_IS_NULL);
         }
-        String loginName = tbUser.getLoginName();
-        String password = tbUser.getPassword();
+        if (Objects.isNull(map.get("code")) || Objects.equals(map.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);
+        if (Objects.isNull(tbOrg)) {
+            throw new BusinessException(ExceptionResultEnum.ORG_NO);
+        }
 
         QueryWrapper<TBUser> wrapper = new QueryWrapper<>();
-        wrapper.lambda().eq(TBUser::getLoginName, loginName);
+        wrapper.lambda().eq(TBUser::getLoginName, loginName).eq(TBUser::getOrgId, tbOrg.getId());
         TBUser user = tbUserService.getOne(wrapper);
         //用户不存在
         if (Objects.isNull(user)) {

+ 4 - 1
themis-backend/src/main/java/com/qmth/themis/backend/interceptor/AuthInterceptor.java

@@ -73,6 +73,9 @@ public class AuthInterceptor implements HandlerInterceptor {
         if (Objects.isNull(deviceId) || Objects.equals(deviceId, "")) {
             throw new BusinessException(ExceptionResultEnum.DEVICE_ID_INVALID);
         }
+        String authorization = ServletUtil.getRequestAuthorization();
+        String time = ServletUtil.getRequestTime();
+        log.info("platform:{},deviceId:{},authorization:{},method:{},time:{}", platform, deviceId, authorization, method, time);
         Long userId = null;
 //        Long timestamp = Long.parseLong(ServletUtil.getRequestTime(request));
 //        if (!SystemConstant.expire(timestamp.longValue())) {
@@ -80,7 +83,7 @@ public class AuthInterceptor implements HandlerInterceptor {
 //                    .parse(method, url, timestamp, ServletUtil.getRequestAuthorization(request));
         //测试
         final SignatureInfo info = SignatureInfo
-                .parse(ServletUtil.getRequestAuthorization());
+                .parse(authorization);
         if (Objects.nonNull(info) && info.getType() == SignatureType.TOKEN) {
             String sessionId = info.getInvoker();
             TBSession tbSession = (TBSession) redisUtil.getUserSession(sessionId);

+ 1 - 1
themis-backend/src/main/resources/application.properties

@@ -159,5 +159,5 @@ rocketmq.producer.customized-trace-topic=my-trace-topic
 prefix.url.admin=api/admin
 
 #\u65E0\u9700\u9274\u6743\u7684url
-no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/file/**,/upload/**,/client/**,/base_photo/**
+no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**
 common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env

+ 7 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TBOrgMapper.java

@@ -1,8 +1,14 @@
 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.TBOrg;
+import com.qmth.themis.business.enums.TaskStatusEnum;
+import com.qmth.themis.business.enums.TaskTypeEnum;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Map;
 
 /**
  * @Description: 机构 Mapper 接口
@@ -14,4 +20,5 @@ import org.apache.ibatis.annotations.Mapper;
 @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);
 }

+ 12 - 3
themis-business/src/main/resources/db/init.sql

@@ -11,7 +11,7 @@
  Target Server Version : 80020
  File Encoding         : 65001
 
- Date: 29/07/2020 17:32:44
+ Date: 29/07/2020 18:22:29
 */
 
 SET NAMES utf8mb4;
@@ -428,7 +428,7 @@ CREATE TABLE `t_b_session` (
 -- Records of t_b_session
 -- ----------------------------
 BEGIN;
-INSERT INTO `t_b_session` VALUES ('1-1591624781-admin_web', '1', '[SUPER_ADMIN]', 'admin_web', 'web', '1234567891', '0:0:0:0:0:0:0:1', 'ScwzdBr0Z4wcY6MCybYtpLR6hV0qkuhv', '2020-07-29 14:02:27', NULL, '2020-07-29 16:59:03', '2020-07-30 16:59:01');
+INSERT INTO `t_b_session` VALUES ('1-1591624781-admin_web', '1', '[SUPER_ADMIN]', 'admin_web', 'web', '1234567891', '0:0:0:0:0:0:0:1', '3BtiFAEMW0wN3tq4mahtxaDXgfGuCtsS', '2020-07-29 14:02:27', NULL, '2020-07-29 18:20:51', '2020-07-30 18:20:50');
 COMMIT;
 
 -- ----------------------------
@@ -477,7 +477,7 @@ CREATE TABLE `t_b_user` (
 -- Records of t_b_user
 -- ----------------------------
 BEGIN;
-INSERT INTO `t_b_user` VALUES (1, 'sysadmin', '1jdzWuniG6UMtoa3T6uNLA==', NULL, 1, NULL, '2020-07-02 12:08:31', NULL, '系统管理员', 'sysadmin', NULL, NULL);
+INSERT INTO `t_b_user` VALUES (1, 'sysadmin', '1jdzWuniG6UMtoa3T6uNLA==', NULL, 1, 1, '2020-07-02 12:08:31', NULL, '系统管理员', 'sysadmin', NULL, NULL);
 INSERT INTO `t_b_user` VALUES (2, 't1', '1jdzWuniG6UMtoa3T6uNLA==', NULL, 1, 1, '2020-07-02 12:08:31', NULL, NULL, '测试老师1', 1, NULL);
 INSERT INTO `t_b_user` VALUES (3, 'i1', '1jdzWuniG6UMtoa3T6uNLA==', NULL, 1, 1, '2020-07-02 12:08:31', NULL, NULL, '监考老师1', 1, NULL);
 INSERT INTO `t_b_user` VALUES (4, 'i2', '1jdzWuniG6UMtoa3T6uNLA==', NULL, 1, 1, '2020-07-02 12:08:31', NULL, NULL, '监考老师2', 1, NULL);
@@ -882,6 +882,9 @@ CREATE TABLE `t_e_user_log` (
 BEGIN;
 INSERT INTO `t_e_user_log` VALUES (21230512672604160, 1, 5, '登录', '{\"id\":\"34858a0c6dd9407f881987d25e051ae6\",\"topic\":\"themis-topic-userLog\",\"tag\":\"user\",\"timestamp\":1596002547803,\"body\":\"LOGIN\",\"type\":\"USER_LOG\",\"objId\":\"1\",\"objName\":\"sysadmin\",\"ack\":0,\"sequence\":null,\"properties\":null}', '2020-07-29 14:02:29');
 INSERT INTO `t_e_user_log` VALUES (21274945929609216, 1, 5, '登录', '{\"id\":\"6a77351f0cad4c25b02f2a6d9b413725\",\"topic\":\"themis-topic-userLog\",\"tag\":\"user\",\"timestamp\":1596013141766,\"body\":\"LOGIN\",\"type\":\"USER_LOG\",\"objId\":\"1\",\"objName\":\"sysadmin\",\"ack\":0,\"sequence\":null,\"properties\":null}', '2020-07-29 16:59:02');
+INSERT INTO `t_e_user_log` VALUES (21293083840741376, 1, 5, '登录', '{\"id\":\"22a467dbb72248859bb5ea6e8ad18d98\",\"topic\":\"themis-topic-userLog\",\"tag\":\"user\",\"timestamp\":1596017466706,\"body\":\"LOGIN\",\"type\":\"USER_LOG\",\"objId\":\"1\",\"objName\":\"sysadmin\",\"ack\":0,\"sequence\":null,\"properties\":null}', '2020-07-29 18:11:07');
+INSERT INTO `t_e_user_log` VALUES (21295479933370368, 1, 5, '登录', '{\"id\":\"6bcbd31c07304d8cab91b5cc843742af\",\"topic\":\"themis-topic-userLog\",\"tag\":\"user\",\"timestamp\":1596018037317,\"body\":\"LOGIN\",\"type\":\"USER_LOG\",\"objId\":\"1\",\"objName\":\"sysadmin\",\"ack\":0,\"sequence\":null,\"properties\":null}', '2020-07-29 18:20:38');
+INSERT INTO `t_e_user_log` VALUES (21295532060180480, 1, 5, '登录', '{\"id\":\"356c1a8b99134e34b56019abe7c41951\",\"topic\":\"themis-topic-userLog\",\"tag\":\"user\",\"timestamp\":1596018050188,\"body\":\"LOGIN\",\"type\":\"USER_LOG\",\"objId\":\"1\",\"objName\":\"sysadmin\",\"ack\":0,\"sequence\":null,\"properties\":null}', '2020-07-29 18:20:50');
 COMMIT;
 
 -- ----------------------------
@@ -964,9 +967,15 @@ CREATE TABLE `t_m_rocket_message` (
 -- ----------------------------
 BEGIN;
 INSERT INTO `t_m_rocket_message` VALUES ('13b1e84bedea4a0993e44c44a359fe91', 'themis-topic-session', 'web', '{\"id\":\"1-1591624781-admin_web\",\"identity\":\"1\",\"type\":\"[SUPER_ADMIN]\",\"source\":\"admin_web\",\"platform\":\"web\",\"deviceId\":\"1234567891\",\"address\":\"0:0:0:0:0:0:0:1\",\"accessToken\":\"BfVf812accydQeIsoIRsvR4fDISm95iB\",\"lastAccessTime\":1.596002547428E12,\"expireTime\":1.596088947421E12}', 'SESSION', '1-1591624781-admin_web', 'sysadmin', 2, NULL, NULL, '2020-07-29 14:02:30', 1596002547443);
+INSERT INTO `t_m_rocket_message` VALUES ('22a467dbb72248859bb5ea6e8ad18d98', 'themis-topic-userLog', 'user', 'LOGIN', 'USER_LOG', '1', 'sysadmin', 2, NULL, NULL, '2020-07-29 18:11:07', 1596017466706);
 INSERT INTO `t_m_rocket_message` VALUES ('34858a0c6dd9407f881987d25e051ae6', 'themis-topic-userLog', 'user', 'LOGIN', 'USER_LOG', '1', 'sysadmin', 2, NULL, NULL, '2020-07-29 14:02:30', 1596002547803);
+INSERT INTO `t_m_rocket_message` VALUES ('356c1a8b99134e34b56019abe7c41951', 'themis-topic-userLog', 'user', 'LOGIN', 'USER_LOG', '1', 'sysadmin', 2, NULL, NULL, '2020-07-29 18:20:51', 1596018050188);
+INSERT INTO `t_m_rocket_message` VALUES ('406a359f03d448458c34ab7115461558', 'themis-topic-session', 'web', '{\"id\":\"1-1591624781-admin_web\",\"identity\":\"1\",\"type\":\"[SUPER_ADMIN]\",\"source\":\"admin_web\",\"platform\":\"web\",\"deviceId\":\"0.39925292599181117-1596017463776\",\"address\":\"192.168.11.224\",\"accessToken\":\"l4cY69XLsuyVxHA4QwQWJ8qavxm7oe6q\",\"lastAccessTime\":1.596017466657E12,\"expireTime\":1.596103866656E12}', 'SESSION', '1-1591624781-admin_web', 'sysadmin', 2, NULL, NULL, '2020-07-29 18:11:07', 1596017466659);
 INSERT INTO `t_m_rocket_message` VALUES ('6a77351f0cad4c25b02f2a6d9b413725', 'themis-topic-userLog', 'user', 'LOGIN', 'USER_LOG', '1', 'sysadmin', 2, NULL, NULL, '2020-07-29 16:59:03', 1596013141766);
+INSERT INTO `t_m_rocket_message` VALUES ('6bcbd31c07304d8cab91b5cc843742af', 'themis-topic-userLog', 'user', 'LOGIN', 'USER_LOG', '1', 'sysadmin', 2, NULL, NULL, '2020-07-29 18:20:39', 1596018037317);
 INSERT INTO `t_m_rocket_message` VALUES ('76236dbaf5524eda81be384d6a0ce4d4', 'themis-topic-session', 'web', '{\"id\":\"1-1591624781-admin_web\",\"identity\":\"1\",\"type\":\"[SUPER_ADMIN]\",\"source\":\"admin_web\",\"platform\":\"web\",\"deviceId\":\"1234567891\",\"address\":\"0:0:0:0:0:0:0:1\",\"accessToken\":\"ScwzdBr0Z4wcY6MCybYtpLR6hV0qkuhv\",\"lastAccessTime\":1.596013141476E12,\"expireTime\":1.596099541464E12}', 'SESSION', '1-1591624781-admin_web', 'sysadmin', 2, NULL, NULL, '2020-07-29 16:59:03', 1596013141491);
+INSERT INTO `t_m_rocket_message` VALUES ('f37edb6e1c974cdf98ce0dc16cca8fcf', 'themis-topic-session', 'web', '{\"id\":\"1-1591624781-admin_web\",\"identity\":\"1\",\"type\":\"[SUPER_ADMIN]\",\"source\":\"admin_web\",\"platform\":\"web\",\"deviceId\":\"1234567891\",\"address\":\"0:0:0:0:0:0:0:1\",\"accessToken\":\"0frdiFblod0nbwNI9SlAapEQa4JWZ3vV\",\"lastAccessTime\":1.596018036748E12,\"expireTime\":1.59610443674E12}', 'SESSION', '1-1591624781-admin_web', 'sysadmin', 2, NULL, NULL, '2020-07-29 18:20:39', 1596018036767);
+INSERT INTO `t_m_rocket_message` VALUES ('f3c09eb7edc140c19c054600896ae5d5', 'themis-topic-session', 'web', '{\"id\":\"1-1591624781-admin_web\",\"identity\":\"1\",\"type\":\"[SUPER_ADMIN]\",\"source\":\"admin_web\",\"platform\":\"web\",\"deviceId\":\"1234567891\",\"address\":\"0:0:0:0:0:0:0:1\",\"accessToken\":\"3BtiFAEMW0wN3tq4mahtxaDXgfGuCtsS\",\"lastAccessTime\":1.596018050177E12,\"expireTime\":1.596104450177E12}', 'SESSION', '1-1591624781-admin_web', 'sysadmin', 2, NULL, NULL, '2020-07-29 18:20:51', 1596018050178);
 COMMIT;
 
 -- ----------------------------

+ 14 - 10
themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java

@@ -34,7 +34,7 @@ public enum ExceptionResultEnum {
 
     RECORD_ID_IS_NULL("102", "考试记录id不能为空"),
 
-    RECORD_NO("102", "考试记录不存在"),
+    RECORD_NO("500", "考试记录不存在"),
 
     EXAM_INFO_IS_NULL("102", "考试批次信息不能为空"),
 
@@ -64,6 +64,10 @@ public enum ExceptionResultEnum {
 
     ORG_ID_IS_NULL("102", "机构id不能为空"),
 
+    ORG_CODE_IS_NULL("102", "机构代码不能为空"),
+
+    ORG_NO("500","机构信息不存在"),
+
     USER_INFO_IS_NULL("102", "用户信息不能为空"),
 
     MD5_IS_NULL("102", "附件MD5不能为空"),
@@ -76,15 +80,15 @@ public enum ExceptionResultEnum {
 
     DOWNLOAD_FILE_TYPE_ERROR("102", "下载文件类型错误"),
 
-    PASSWORD_NO("102", "密码不正确"),
+    PASSWORD_NO("500", "密码不正确"),
 
-    TASK_NO("102", "任务不存在"),
+    TASK_NO("500", "任务不存在"),
 
-    USER_NO("102", "用户不存在"),
+    USER_NO("500", "用户不存在"),
 
-    EXAM_NO("102", "考试批次信息不存在"),
+    EXAM_NO("500", "考试批次信息不存在"),
 
-    EXAM_ACTIVITY_NO("102", "考试场次信息不存在"),
+    EXAM_ACTIVITY_NO("500", "考试场次信息不存在"),
 
     TOKEN_NO("106", "token已过期"),
 
@@ -106,13 +110,13 @@ public enum ExceptionResultEnum {
 
     ATTACHMENT_ID_IS_NULL("102", "附件id不能为空"),
 
-    ATTACHMENT_NO("102", "附件不存在"),
+    ATTACHMENT_NO("500", "附件不存在"),
 
-    STUDENT_NO("102", "学生不存在"),
+    STUDENT_NO("500", "学生不存在"),
 
-    EXAM_STUDENT_NO("102", "考生不存在"),
+    EXAM_STUDENT_NO("500", "考生不存在"),
 
-    LOGIN_NO("102", "请先登录"),
+    LOGIN_NO("500", "请先登录"),
 
     SCENE_NUMBER_ID_IS_NULL("102", "场次id不能为空"),
 

+ 4 - 1
themis-exam/src/main/java/com/qmth/themis/exam/interceptor/AuthInterceptor.java

@@ -73,6 +73,9 @@ public class AuthInterceptor implements HandlerInterceptor {
         if (Objects.isNull(deviceId) || Objects.equals(deviceId, "")) {
             throw new BusinessException(ExceptionResultEnum.DEVICE_ID_INVALID);
         }
+        String authorization = ServletUtil.getRequestAuthorization();
+        String time = ServletUtil.getRequestTime();
+        log.info("platform:{},deviceId:{},authorization:{},method:{},time:{}", platform, deviceId, authorization, method, time);
         Long userId = null;
 //        Long timestamp = Long.parseLong(ServletUtil.getRequestTime(request));
 //        if (!SystemConstant.expire(timestamp.longValue())) {
@@ -80,7 +83,7 @@ public class AuthInterceptor implements HandlerInterceptor {
 //                    .parse(method, url, timestamp, ServletUtil.getRequestAuthorization(request));
         //测试
         final SignatureInfo info = SignatureInfo
-                .parse(ServletUtil.getRequestAuthorization());
+                .parse(authorization);
         if (Objects.nonNull(info) && info.getType() == SignatureType.TOKEN) {
             String sessionId = info.getInvoker();
             TBSession tbSession = (TBSession) redisUtil.getUserSession(sessionId);