Bläddra i källkod

教学点,是否开启考生自主预约

deason 8 månader sedan
förälder
incheckning
4b0ebf265f

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

@@ -67,10 +67,15 @@ public class TeachingController extends BaseController {
 
     @ApiOperation(value = "教学点启用/禁用")
     @PostMapping(value = "/enable")
-    public void enable(@ApiParam("教学点ID") @RequestParam Long id, @ApiParam("启用/禁用") @RequestParam Boolean enable) {
+    public void enable(@ApiParam("教学点ID") @RequestParam Long id, @ApiParam("启用禁用") @RequestParam Boolean enable) {
         categoryService.enable(id, enable);
     }
 
+    @ApiOperation(value = "教学点是否开启考生自主预约")
+    @PostMapping(value = "/selfApplyEnable")
+    public void selfApplyEnable(@ApiParam("教学点ID") @RequestParam Long id, @ApiParam("启用、禁用") @RequestParam Boolean enable) {
+        categoryService.selfApplyEnable(id, enable);
+    }
 
     @ApiOperation(value = "教学点模版下载")
     @PostMapping(value = "/import/template")

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

@@ -27,6 +27,8 @@ public interface CategoryService extends IService<CategoryEntity> {
 
     void enable(Long id, Boolean enable);
 
+    void selfApplyEnable(Long id, Boolean enable);
+
     List<CategoryVO> listCity(LoginUser user);
 
     List<Map<String, Object>> importTeaching(LoginUser user, InputStream inputStream);
@@ -34,4 +36,5 @@ public interface CategoryService extends IService<CategoryEntity> {
     void updateTeachingCapacity(Long teachingId);
 
     TeachingSingleVO getTeaching(Long id);
+
 }

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

@@ -2,6 +2,7 @@ package com.qmth.exam.reserve.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -216,16 +217,36 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
             save(category);
         } else {
             updateById(category);
+
             //清空教学点缓存
             categoryCacheService.clearCategoryByIdCache(category.getId());
         }
     }
 
+    @Transactional
     @Override
     public void enable(Long id, Boolean enable) {
-        CategoryEntity category = getById(id);
-        category.setEnable(enable);
-        updateById(category);
+        LambdaUpdateWrapper<CategoryEntity> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(CategoryEntity::getEnable, enable);
+        updateWrapper.set(CategoryEntity::getUpdateTime, System.currentTimeMillis());
+        updateWrapper.eq(CategoryEntity::getId, id);
+        this.update(updateWrapper);
+
+        //清空教学点缓存
+        categoryCacheService.clearCategoryByIdCache(id);
+    }
+
+    @Transactional
+    @Override
+    public void selfApplyEnable(Long id, Boolean enable) {
+        LambdaUpdateWrapper<CategoryEntity> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(CategoryEntity::getSelfApplyEnable, enable);
+        updateWrapper.set(CategoryEntity::getUpdateTime, System.currentTimeMillis());
+        updateWrapper.eq(CategoryEntity::getId, id);
+        this.update(updateWrapper);
+
+        //清空教学点缓存
+        categoryCacheService.clearCategoryByIdCache(id);
     }
 
     private void checkTeaching(Long orgId, TeachingSaveReq req) {
@@ -396,6 +417,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
             existCategory.setName(category.getName());
             existCategory.setEnable(Boolean.TRUE);
             baseMapper.updateById(existCategory);
+
+            //清空教学点缓存
+            categoryCacheService.clearCategoryByIdCache(existCategory.getId());
         } else {
             baseMapper.insert(category);
         }