添加 课程绑定新街口

beetlsql3-dev
yaodan 2 years ago
parent 88eade1289
commit c820a655cc

@ -0,0 +1,14 @@
package com.ibeetl.jlw.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum CourseLabelTypeEnum {
APPLICATION("应用课程类"),
CERTIFICATE("考证课程类"),
THEORY("理论课程类");
private final String type;
}

@ -32,7 +32,6 @@ import org.apache.poi.xwpf.usermodel.*;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.core.query.LambdaQuery;
import org.beetl.sql.core.query.interfacer.StrongValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
@ -52,6 +51,7 @@ import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.jlw.util.ConvertM3U8.booleanMap;
import static com.ibeetl.admin.core.util.StreamUtils.listJoin;
import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUserId;
import static com.ibeetl.jlw.enums.CourseLabelTypeEnum.*;
import static java.lang.Math.min;
import static java.math.BigDecimal.ROUND_HALF_UP;
import static java.math.BigDecimal.ZERO;
@ -274,6 +274,48 @@ public class CourseInfoService extends CoreBaseService<CourseInfo>{
return true;
}
public boolean courseBind(CourseInfoQuery courseInfoQuery){
if (CERTIFICATE.getType().equals(courseInfoQuery.getCourseLabelType())|| APPLICATION.getType().equals(courseInfoQuery.getCourseLabelType())){
CourseLabel param = new CourseLabel();
param.setCourseLabelType(courseInfoQuery.getCourseLabelType());
CourseLabel courseLabel = courseLabelService.getOnce(param);
if (courseLabel==null){
throw new PlatformException("课程模块数据异常");
}
courseInfoQuery.setCourseLabelId(courseLabel.getCourseLabelId());
} else if (THEORY.getType().equals(courseInfoQuery.getCourseLabelType())&&courseInfoQuery.getCourseLabelId()==null) {
return true;
}
updateTemplate(courseInfoQuery.pojo());
CourseInfo courseInfo = courseInfoDao.single(courseInfoQuery.getCourseInfoId());
// 不管有没有绑定应用,都先删除
deleteByCourseInfoId(courseInfo.getCourseInfoId());
if(StringUtils.isNotBlank(courseInfoQuery.getResourcesApplicationIds())){
CourseLabel courseLabel = courseLabelService.queryById(courseInfo.getCourseLabelId());
Assert.isTrue(courseLabel != null && "应用课程类".equals(courseLabel.getCourseLabelType()), "只有应用课程类的课程,才能绑定应用!");
List<ResourcesApplicationCourse> resourcesApplicationCourseList = new ArrayList<>();
String[] resourcesApplicationIds = courseInfoQuery.getResourcesApplicationIds().split(",");
for(int i=0;i<resourcesApplicationIds.length;i++){
ResourcesApplicationCourse resourcesApplicationCourse = new ResourcesApplicationCourse();
resourcesApplicationCourse.setResourcesApplicationId(Long.parseLong(resourcesApplicationIds[i]));
resourcesApplicationCourse.setCourseInfoId(courseInfo.getCourseInfoId());
resourcesApplicationCourseList.add(resourcesApplicationCourse);
}
if(resourcesApplicationCourseList.size()>0){
resourcesApplicationCourseService.insertBatch(resourcesApplicationCourseList);
}
}
return true;
}
public void deleteCourseInfo(String ids){
try {
//遍历下级 TODO 有问题

@ -6,8 +6,10 @@ import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.jlw.dao.CourseLabelDao;
import com.ibeetl.jlw.entity.CourseLabel;
import com.ibeetl.jlw.web.query.CourseLabelQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.core.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -15,27 +17,24 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* CourseLabel Service
*/
@Service
@Transactional
public class CourseLabelService extends CoreBaseService<CourseLabel>{
public class CourseLabelService extends CoreBaseService<CourseLabel> {
@Autowired private CourseLabelDao courseLabelDao;
@Autowired
private CourseLabelDao courseLabelDao;
public PageQuery<CourseLabel>queryByCondition(PageQuery query){
PageQuery ret = courseLabelDao.queryByCondition(query);
public PageQuery<CourseLabel> queryByCondition(PageQuery query) {
PageQuery ret = courseLabelDao.queryByCondition(query);
queryListAfter(ret.getList());
return ret;
}
public void deleteCourseLabel(String ids){
public void deleteCourseLabel(String ids) {
try {
courseLabelDao.deleteCourseLabelByIds(ids);
} catch (Exception e) {
@ -43,12 +42,13 @@ public class CourseLabelService extends CoreBaseService<CourseLabel>{
}
}
public List<CourseLabel> getValues (Object paras){
public List<CourseLabel> getValues(Object paras) {
List<CourseLabel> list = sqlManager.select(SqlId.of("jlw.courseLabel.getCourseLabelValues"), CourseLabel.class, paras);
dictParser(list);
return list;
}
public List<CourseLabel> getValuesByQueryNotWithPermission (CourseLabelQuery query){
public List<CourseLabel> getValuesByQueryNotWithPermission(CourseLabelQuery query) {
List<CourseLabel> list = courseLabelDao.getValuesByQueryNotWithPermission(query);
dictParser(list);
return list;
@ -56,10 +56,15 @@ public class CourseLabelService extends CoreBaseService<CourseLabel>{
/**
* course_label_type
*
* @return
*/
public List<String> disLabelType() {
return courseLabelDao.createLambdaQuery().distinct().select(String.class, "course_label_type");
}
public CourseLabel getOnce(CourseLabel courseLabel) {
PageResult<CourseLabel> page = courseLabelDao.createLambdaQuery().addParam(courseLabel).page(1, 1);
return CollectionUtils.isEmpty(page.getList()) ? null : page.getList().get(0);
}
}

@ -271,6 +271,21 @@ public class CourseInfoController{
return JsonResult.failMessage("更新失败");
}
}
@PostMapping(MODEL + "/courseBind.json")
@Function("courseInfo.edit")
@ResponseBody
public JsonResult<String> courseBind(CourseInfoQuery courseInfoQuery, BindingResult result) {
boolean success = courseInfoService.courseBind(courseInfoQuery);
if (success) {
//移除缓存
courseInfoService.flushCache(courseInfoQuery.getCourseInfoId());
corePlatformService.clearDictCache();
return JsonResult.success();
} else {
return JsonResult.failMessage("更新失败");
}
}
@GetMapping(MODEL + "/view.json")
@Function("courseInfo.query")

Loading…
Cancel
Save