deason 1 год назад
Родитель
Сommit
1b3e1d4649

+ 27 - 4
src/main/java/com/qmth/exam/reserve/controller/admin/SystemPropertyController.java

@@ -1,5 +1,6 @@
 package com.qmth.exam.reserve.controller.admin;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.core.fss.store.FileStore;
@@ -7,16 +8,20 @@ import com.qmth.exam.reserve.bean.Constants;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.systemproperty.SystemPropertyBean;
 import com.qmth.exam.reserve.controller.BaseController;
+import com.qmth.exam.reserve.entity.OrgEntity;
 import com.qmth.exam.reserve.entity.SystemPropertyEntity;
 import com.qmth.exam.reserve.service.ApplyTaskService;
+import com.qmth.exam.reserve.service.OrgService;
 import com.qmth.exam.reserve.service.SystemPropertyService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
@@ -33,22 +38,40 @@ public class SystemPropertyController extends BaseController {
     @Autowired
     private ApplyTaskService applyTaskService;
 
+    @Autowired
+    private OrgService orgService;
+
     @Autowired
     private SystemPropertyService systemPropertyService;
 
     @ApiOperation(value = "获取系统常用属性集合")
     @PostMapping(value = "/properties")
-    public SystemPropertyBean properties() {
+    public SystemPropertyBean properties(@ApiParam("学校ID") @RequestParam(required = false) Long orgId) {
         SystemPropertyBean properties = new SystemPropertyBean();
         properties.setFileUrlPrefix(fileStore.getServer());
 
-        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask();
+        OrgEntity org;
+        if (orgId != null) {
+            org = orgService.getById(orgId);
+        } else {
+            // 未明确指定学校,默认取一个学校
+            LambdaQueryWrapper<OrgEntity> wrapper = new LambdaQueryWrapper<>();
+            wrapper.select(OrgEntity::getId, OrgEntity::getName);
+            wrapper.last("LIMIT 1");
+            org = orgService.getOne(wrapper);
+        }
+        if (org != null) {
+            properties.setOrgTitle(org.getName());
+            orgId = org.getId();
+        }
+
+        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(orgId);
         if (curApplyTask != null) {
-            properties.setOrgTitle(curApplyTask.getOrgName());
+            // 当前预约任务
             properties.setTaskTitle(curApplyTask.getTaskName());
         }
 
-        SystemPropertyEntity systemProperty = systemPropertyService.findByPropKey(Constants.CATEGORY_LEVEL);
+        SystemPropertyEntity systemProperty = systemPropertyService.findByPropKey(orgId, Constants.CATEGORY_LEVEL);
         if (systemProperty != null) {
             properties.setCategoryLevels(systemProperty.getPropValue());
         }

+ 2 - 2
src/main/java/com/qmth/exam/reserve/controller/student/StudentApplyController.java

@@ -78,14 +78,14 @@ public class StudentApplyController extends BaseController {
     @ApiOperation(value = "获取可预约的“日期”列表", notes = "日期格式:yyyyMMdd")
     @PostMapping(value = "/apply/date/list")
     public List<String> dateList() {
-        return examReserveService.getApplyDateList();
+        return examReserveService.getApplyDateList(curLoginStudent().getOrgId());
     }
 
     @ApiOperation(value = "获取可预约的“时段”列表")
     @PostMapping(value = "/apply/time/period/list")
     public ApplyTimePeriodResult timePeriodList(@ApiParam("考点ID") @RequestParam Long examSiteId,
                                                 @ApiParam("预约日期:yyyyMMdd") @RequestParam String date) {
-        return examReserveService.getApplyTimePeriodList(curLoginStudent().getId(), examSiteId, date);
+        return examReserveService.getApplyTimePeriodList(curLoginStudent(), examSiteId, date);
     }
 
 }

+ 6 - 7
src/main/java/com/qmth/exam/reserve/dao/ApplyTaskDao.java

@@ -1,22 +1,21 @@
 package com.qmth.exam.reserve.dao;
 
-import java.util.List;
-
-import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
-import org.apache.ibatis.annotations.Param;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
 import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
 import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.bean.task.TimePeriodVO;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface ApplyTaskDao extends BaseMapper<ApplyTaskEntity> {
 
-    CurrentApplyTaskVO currentApplyTask();
+    CurrentApplyTaskVO currentApplyTask(@Param("orgId") Long orgId);
 
     IPage<ApplyTaskVO> page(Page<ApplyTaskVO> page, @Param(value = "req") ApplyTaskReq req);
 
@@ -24,6 +23,6 @@ public interface ApplyTaskDao extends BaseMapper<ApplyTaskEntity> {
 
     List<TimePeriodVO> getTimePeriodList(Long id);
 
-    void updateRule(ApplyTaskReq req);
+    // void updateRule(ApplyTaskReq req);
 
 }

+ 1 - 1
src/main/java/com/qmth/exam/reserve/service/ApplyTaskService.java

@@ -21,7 +21,7 @@ public interface ApplyTaskService extends IService<ApplyTaskEntity> {
 
     List<CategoryVO> listTask();
 
-    CurrentApplyTaskVO currentApplyTask();
+    CurrentApplyTaskVO currentApplyTask(Long orgId);
 
     ApplyTaskEntity findApplyTask();
 

+ 3 - 2
src/main/java/com/qmth/exam/reserve/service/ExamReserveService.java

@@ -4,6 +4,7 @@ import com.qmth.exam.reserve.bean.RichTextBean;
 import com.qmth.exam.reserve.bean.apply.ApplyTimePeriodResult;
 import com.qmth.exam.reserve.bean.apply.ApplyVO;
 import com.qmth.exam.reserve.bean.apply.TicketInfo;
+import com.qmth.exam.reserve.bean.login.LoginUser;
 
 import java.util.List;
 
@@ -19,9 +20,9 @@ public interface ExamReserveService {
 
     TicketInfo getApplyTicket(Long studentId, Long applyId);
 
-    List<String> getApplyDateList();
+    List<String> getApplyDateList(Long orgId);
 
-    ApplyTimePeriodResult getApplyTimePeriodList(Long studentId, Long examSiteId, String date);
+    ApplyTimePeriodResult getApplyTimePeriodList(LoginUser loginUser, Long examSiteId, String date);
 
     RichTextBean getExamNotice(Long applyTaskId);
 

+ 1 - 1
src/main/java/com/qmth/exam/reserve/service/SystemPropertyService.java

@@ -5,6 +5,6 @@ import com.qmth.exam.reserve.entity.SystemPropertyEntity;
 
 public interface SystemPropertyService extends IService<SystemPropertyEntity> {
 
-    SystemPropertyEntity findByPropKey(String propKey);
+    SystemPropertyEntity findByPropKey(Long orgId, String propKey);
 
 }

+ 2 - 2
src/main/java/com/qmth/exam/reserve/service/impl/ApplyTaskServiceImpl.java

@@ -98,8 +98,8 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
      * 获取当前启用的预约任务
      */
     @Override
-    public CurrentApplyTaskVO currentApplyTask() {
-        return baseMapper.currentApplyTask();
+    public CurrentApplyTaskVO currentApplyTask(Long orgId) {
+        return baseMapper.currentApplyTask(orgId);
     }
 
     @Override

+ 1 - 1
src/main/java/com/qmth/exam/reserve/service/impl/CategoryServiceImpl.java

@@ -67,7 +67,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
         List<CategoryInfo> list = new ArrayList<>();
 
         // 获取当前启用的预约任务
-        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask();
+        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
         if (curApplyTask == null) {
             return list;
         }

+ 5 - 4
src/main/java/com/qmth/exam/reserve/service/impl/ExamReserveServiceImpl.java

@@ -9,6 +9,7 @@ import com.qmth.exam.reserve.bean.apply.ApplyVO;
 import com.qmth.exam.reserve.bean.apply.TicketInfo;
 import com.qmth.exam.reserve.bean.apply.TimePeriodInfo;
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
+import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.dao.StudentApplyDao;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.ExamSiteEntity;
@@ -141,12 +142,12 @@ public class ExamReserveServiceImpl implements ExamReserveService {
     }
 
     @Override
-    public List<String> getApplyDateList() {
+    public List<String> getApplyDateList(Long orgId) {
         // 日期格式:yyyyMMdd
         List<String> dateList = new ArrayList<>();
 
         // 获取当前启用的预约任务
-        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask();
+        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(orgId);
         if (curApplyTask == null) {
             return dateList;
         }
@@ -183,7 +184,7 @@ public class ExamReserveServiceImpl implements ExamReserveService {
     }
 
     @Override
-    public ApplyTimePeriodResult getApplyTimePeriodList(Long studentId, Long examSiteId, String date) {
+    public ApplyTimePeriodResult getApplyTimePeriodList(LoginUser student, Long examSiteId, String date) {
         if (examSiteId == null) {
             throw new StatusException("考点ID不能为空");
         }
@@ -202,7 +203,7 @@ public class ExamReserveServiceImpl implements ExamReserveService {
         }
 
         // 获取当前启用的预约任务
-        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask();
+        CurrentApplyTaskVO curApplyTask = applyTaskService.currentApplyTask(student.getOrgId());
         if (curApplyTask == null) {
             throw new StatusException("当前预约任务不存在");
         }

+ 4 - 1
src/main/java/com/qmth/exam/reserve/service/impl/SystemPropertyServiceImpl.java

@@ -15,9 +15,12 @@ public class SystemPropertyServiceImpl extends ServiceImpl<SystemPropertyDao, Sy
     private static final Logger log = LoggerFactory.getLogger(SystemPropertyServiceImpl.class);
 
     @Override
-    public SystemPropertyEntity findByPropKey(String propKey) {
+    public SystemPropertyEntity findByPropKey(Long orgId, String propKey) {
         LambdaQueryWrapper<SystemPropertyEntity> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(SystemPropertyEntity::getPropKey, propKey);
+        if (orgId != null) {
+            wrapper.eq(SystemPropertyEntity::getOrgId, orgId);
+        }
         return baseMapper.selectOne(wrapper);
     }
 

+ 4 - 5
src/main/resources/mapper/ApplyTaskMapper.xml

@@ -2,18 +2,17 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.exam.reserve.dao.ApplyTaskDao">
 
-	<!-- <resultMap id="custMap" type="com.qmth.exam.reserve.bean.task.TimePeriodVO"> 
-		<result column="params" property="params" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"> 
-		</result> </resultMap> -->
-
 	<select id="currentApplyTask" resultType="com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO">
 		select t.id task_id,t.name task_name,t.org_id,org.name org_name,
 			   t.allow_apply_days,t.allow_apply_cancel_days,
 			   t.self_apply_start_time,t.self_apply_end_time,
 			   t.open_apply_start_time,t.open_apply_end_time
 		from t_apply_task t
-		left join t_org org on org.id=t.org_id
+		left join t_org org on org.id = t.org_id
 		where t.`enable` = 1
+		<if test="orgId != null">
+			and t.org_id = #{orgId}
+		</if>
 		order by t.id desc
 		limit 1
 	</select>