haogh 1 month ago
parent
commit
1626a19db4

+ 1 - 1
src/main/java/com/qmth/exam/reserve/controller/admin/TeachingController.java

@@ -79,7 +79,7 @@ public class TeachingController extends BaseController {
         if(loginUser.getRole() == Role.ADMIN){
             throw new StatusException("无权限");
         }
-        categoryService.selfApplyEnable(id, enable);
+        categoryService.selfApplyEnable(id, enable, loginUser.getOrgId());
     }
 
     @ApiOperation(value = "教学点模版下载")

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

@@ -27,7 +27,7 @@ public interface CategoryService extends IService<CategoryEntity> {
 
     void enable(Long id, Boolean enable);
 
-    void selfApplyEnable(Long id, Boolean enable);
+    void selfApplyEnable(Long id, Boolean enable, Long orgId);
 
     List<CategoryVO> listCity(LoginUser user);
 

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

@@ -12,6 +12,7 @@ import com.qmth.boot.core.exception.StatusException;
 import com.qmth.boot.tools.excel.ExcelReader;
 import com.qmth.boot.tools.excel.enums.ExcelType;
 import com.qmth.boot.tools.excel.model.DataMap;
+import com.qmth.exam.reserve.bean.Constants;
 import com.qmth.exam.reserve.bean.category.CategoryCacheBean;
 import com.qmth.exam.reserve.bean.category.CategoryInfo;
 import com.qmth.exam.reserve.bean.login.LoginUser;
@@ -24,9 +25,11 @@ import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
 import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
 import com.qmth.exam.reserve.dao.CategoryDao;
 import com.qmth.exam.reserve.entity.CategoryEntity;
+import com.qmth.exam.reserve.entity.SystemPropertyEntity;
 import com.qmth.exam.reserve.enums.CategoryLevel;
 import com.qmth.exam.reserve.enums.Role;
 import com.qmth.exam.reserve.service.CategoryService;
+import com.qmth.exam.reserve.service.SystemPropertyService;
 import com.qmth.exam.reserve.util.PageUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -52,6 +55,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
     @Autowired
     private CategoryCacheService categoryCacheService;
 
+    @Autowired
+    private SystemPropertyService systemPropertyService;
+
     @Override
     public List<CategoryVO> listTeaching(LoginUser user, Boolean flag) {
         flag = flag != null && flag;
@@ -259,7 +265,13 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
 
     @Transactional
     @Override
-    public void selfApplyEnable(Long id, Boolean enable) {
+    public void selfApplyEnable(Long id, Boolean enable, Long orgId) {
+        //学校管理员是否关闭自主预约
+        SystemPropertyEntity systemProperty = systemPropertyService.findByPropKey(orgId, Constants.APPLY_SWITCH);
+        if (systemProperty != null && systemProperty.getPropValue().equals(Constants.APPLY_SWITCH_CLOSE)) {
+            throw new StatusException("学校管理员已关闭自主预约,教学点管理员不能设置");
+        }
+
         LambdaUpdateWrapper<CategoryEntity> updateWrapper = new LambdaUpdateWrapper<>();
         updateWrapper.set(CategoryEntity::getSelfApplyEnable, enable);
         updateWrapper.set(CategoryEntity::getUpdateTime, System.currentTimeMillis());