|
|
|
@ -1,9 +1,14 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.jlw.dao.CourseInfoDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.CourseLabelDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.CourseInfo;
|
|
|
|
|
import com.ibeetl.jlw.entity.CourseLabel;
|
|
|
|
|
import com.ibeetl.jlw.web.query.CourseLabelQuery;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
@ -13,8 +18,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.ibeetl.jlw.enums.AddTypeEnum.ADMIN_ADD;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CourseLabel Service
|
|
|
|
@ -27,6 +35,10 @@ public class CourseLabelService extends CoreBaseService<CourseLabel> {
|
|
|
|
|
@Autowired
|
|
|
|
|
private CourseLabelDao courseLabelDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CourseInfoDao courseInfoDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PageQuery<CourseLabel> queryByCondition(PageQuery query) {
|
|
|
|
|
PageQuery ret = courseLabelDao.queryByCondition(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
@ -66,4 +78,32 @@ public class CourseLabelService extends CoreBaseService<CourseLabel> {
|
|
|
|
|
List<CourseLabel> list = courseLabelDao.template(courseLabel);
|
|
|
|
|
return CollectionUtils.isEmpty(list) ? null : list.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult<String> delCourseLabelHandler(CourseLabel courseLabel, CoreUser coreUser) {
|
|
|
|
|
Assert.isTrue(coreUser.isUniAdmin() || coreUser.isAdmin(), "只允许学校管理员和超管访问该接口!");
|
|
|
|
|
CourseLabel cl = queryById(courseLabel.getCourseLabelId());
|
|
|
|
|
// 只有超管才能修改系统分配的数据
|
|
|
|
|
Assert.isFalse(ADMIN_ADD.equals(cl.getAddType()) && coreUser.isUniAdmin(), "用户无法修改系统分配的数据!");
|
|
|
|
|
|
|
|
|
|
CourseInfo courseInfo = new CourseInfo();
|
|
|
|
|
courseInfo.setCourseLabelId(courseLabel.getCourseLabelId());
|
|
|
|
|
courseInfo.setCourseInfoType(1);
|
|
|
|
|
|
|
|
|
|
long count = courseInfoDao.createLambdaQuery()
|
|
|
|
|
.andEq(CourseInfo::getCourseLabelId, courseLabel.getCourseLabelId())
|
|
|
|
|
.andEq(CourseInfo::getCourseInfoType, 1)
|
|
|
|
|
.andIn(CourseInfo::getCourseInfoStatus, Arrays.asList(1, 2))
|
|
|
|
|
.count();
|
|
|
|
|
|
|
|
|
|
if (count>0){
|
|
|
|
|
return JsonResult.failMessage("该标签下有课程,无法删除!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean success = updateTemplate(courseLabel);
|
|
|
|
|
if (success) {
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
} else {
|
|
|
|
|
return JsonResult.failMessage("更新失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|