|
@@ -2,6 +2,8 @@ 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.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
@@ -10,7 +12,9 @@ import com.qmth.exam.reserve.bean.category.CategoryCacheBean;
|
|
|
import com.qmth.exam.reserve.bean.category.CategoryInfo;
|
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
|
import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
|
+import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingReq;
|
|
|
+import com.qmth.exam.reserve.bean.teaching.TeachingSaveReq;
|
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingVO;
|
|
|
import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
|
import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
|
|
@@ -19,8 +23,12 @@ import com.qmth.exam.reserve.entity.CategoryEntity;
|
|
|
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.util.PageUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -179,7 +187,44 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|
|
|
|
|
@Override
|
|
|
public PageResult<TeachingVO> page(TeachingReq req) {
|
|
|
- return null;
|
|
|
+ if(req.getLevel() == null){
|
|
|
+ req.setLevel(CategoryLevel.TEACHING.getValue());
|
|
|
+ }
|
|
|
+ IPage<TeachingVO> iPage = baseMapper.page(new Page<>(req.getPageNumber(), req.getPageSize()),
|
|
|
+ req);
|
|
|
+ return PageUtil.of(iPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void saveTeaching(LoginUser user, TeachingSaveReq req) {
|
|
|
+ checkTeaching(req);
|
|
|
+ CategoryEntity category = new CategoryEntity();
|
|
|
+ BeanUtils.copyProperties(req, category);
|
|
|
+ category.setLevel(CategoryLevel.TEACHING.getValue());
|
|
|
+ category.setOrgId(user.getOrgId());
|
|
|
+ category.setParentId(getById(req.getCityId()).getId());
|
|
|
+ saveOrUpdate(category);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkTeaching(TeachingSaveReq req) {
|
|
|
+ if(StringUtils.isBlank(req.getCode())) {
|
|
|
+ throw new StatusException("教学点代码不能为空");
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(req.getName())) {
|
|
|
+ throw new StatusException("教学点名称不能为空");
|
|
|
+ }
|
|
|
+ if(req.getCityId() == null) {
|
|
|
+ throw new StatusException("请选择教学点所在城市");
|
|
|
+ }
|
|
|
+ if(req.getId() == null) {
|
|
|
+ LambdaQueryWrapper<CategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CategoryEntity::getCode, req.getCode());
|
|
|
+ List<CategoryEntity> list = baseMapper.selectList(wrapper);
|
|
|
+ if(list.size() > 0) {
|
|
|
+ throw new StatusException("教学点代码已经存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|