|
@@ -19,6 +19,7 @@ import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingReq;
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingReq;
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingSaveReq;
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingSaveReq;
|
|
|
|
+import com.qmth.exam.reserve.bean.teaching.TeachingSingleVO;
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingVO;
|
|
import com.qmth.exam.reserve.bean.teaching.TeachingVO;
|
|
import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
|
|
import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
|
|
@@ -205,13 +206,14 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public void saveTeaching(LoginUser user, TeachingSaveReq req) {
|
|
public void saveTeaching(LoginUser user, TeachingSaveReq req) {
|
|
- checkTeaching(req);
|
|
|
|
|
|
+ checkTeaching(user.getOrgId(), req);
|
|
CategoryEntity category = new CategoryEntity();
|
|
CategoryEntity category = new CategoryEntity();
|
|
BeanUtils.copyProperties(req, category);
|
|
BeanUtils.copyProperties(req, category);
|
|
category.setLevel(CategoryLevel.TEACHING.getValue());
|
|
category.setLevel(CategoryLevel.TEACHING.getValue());
|
|
category.setOrgId(user.getOrgId());
|
|
category.setOrgId(user.getOrgId());
|
|
category.setParentId(getById(req.getCityId()).getId());
|
|
category.setParentId(getById(req.getCityId()).getId());
|
|
- if(req.getId() == null) {
|
|
|
|
|
|
+ if (req.getId() == null) {
|
|
|
|
+ category.setEnable(Boolean.TRUE);
|
|
save(category);
|
|
save(category);
|
|
} else {
|
|
} else {
|
|
updateById(category);
|
|
updateById(category);
|
|
@@ -227,7 +229,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|
updateById(category);
|
|
updateById(category);
|
|
}
|
|
}
|
|
|
|
|
|
- private void checkTeaching(TeachingSaveReq req) {
|
|
|
|
|
|
+ private void checkTeaching(Long orgId, TeachingSaveReq req) {
|
|
if (StringUtils.isBlank(req.getCode())) {
|
|
if (StringUtils.isBlank(req.getCode())) {
|
|
throw new StatusException("教学点代码不能为空");
|
|
throw new StatusException("教学点代码不能为空");
|
|
}
|
|
}
|
|
@@ -240,8 +242,9 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|
if (req.getId() == null) {
|
|
if (req.getId() == null) {
|
|
LambdaQueryWrapper<CategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<CategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(CategoryEntity::getCode, req.getCode());
|
|
wrapper.eq(CategoryEntity::getCode, req.getCode());
|
|
- List<CategoryEntity> list = baseMapper.selectList(wrapper);
|
|
|
|
- if (!list.isEmpty()) {
|
|
|
|
|
|
+ wrapper.eq(CategoryEntity::getOrgId, orgId);
|
|
|
|
+ CategoryEntity categoryEntity = baseMapper.selectOne(wrapper);
|
|
|
|
+ if (categoryEntity != null) {
|
|
throw new StatusException("教学点代码已经存在");
|
|
throw new StatusException("教学点代码已经存在");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -331,7 +334,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
if (CollectionUtils.isNotEmpty(failRecords)) {
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
return failRecords;
|
|
return failRecords;
|
|
}
|
|
}
|
|
return failRecords;
|
|
return failRecords;
|
|
@@ -342,6 +345,19 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|
baseMapper.updateTeachingCapacity(teachingId);
|
|
baseMapper.updateTeachingCapacity(teachingId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public TeachingSingleVO getTeaching(Long id) {
|
|
|
|
+ CategoryEntity category = getById(id);
|
|
|
|
+ TeachingSingleVO vo = new TeachingSingleVO();
|
|
|
|
+ vo.setId(category.getId());
|
|
|
|
+ vo.setCode(category.getCode());
|
|
|
|
+ vo.setName(category.getName());
|
|
|
|
+ vo.setCityId(category.getParentId());
|
|
|
|
+ vo.setEnable(category.getEnable());
|
|
|
|
+ vo.setLevel(category.getLevel());
|
|
|
|
+ return vo;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void saveTeaching(CategoryEntity category) {
|
|
private void saveTeaching(CategoryEntity category) {
|
|
LambdaQueryWrapper<CategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<CategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(CategoryEntity::getCode, category.getCode());
|
|
wrapper.eq(CategoryEntity::getCode, category.getCode());
|