Commit 0be22efd authored by luzhuang's avatar luzhuang

fix: 平台推荐课程(知识广场) 查询、修改时标签的的操作

parent d36a13b5
...@@ -330,7 +330,7 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -330,7 +330,7 @@ public class BLessonController extends PaginationController<BLesson> {
if (StringUtils.isNotEmpty(param.getCourse())) { if (StringUtils.isNotEmpty(param.getCourse())) {
allCourse = bCourseService.findAllCourse(curUser.getCorpId()); allCourse = bCourseService.findAllCourse(curUser.getCorpId());
} }
bLessonService.queryListAllLessonByPagination(getPaginationUtility(), param, allCourse); bLessonService.queryListAllLessonByPagination(getPaginationUtility(), param, allCourse,curUser);
GridModel gridModel = getGridModelResponse(); GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
......
...@@ -58,6 +58,19 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -58,6 +58,19 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" </foreach> </script> ") " </foreach> </script> ")
int insertLessonLabel(List<BLessonLabel> bLessonLabels); int insertLessonLabel(List<BLessonLabel> bLessonLabels);
/**
* 课程新增 添加标签
*
* @param bLessonLabels
* @return
*/
@Insert("<script>INSERT INTO b_lesson_label " +
" (business_id,label_id,lesson_id,sort,corp_id)VALUES " +
" <foreach collection=\"list\" item=\"item\" separator=\",\"> " +
" (#{item.businessId},#{item.labelId},#{item.lessonId},#{item.sort},#{item.corpId}) " +
" </foreach> </script> ")
int insertLessonLabel2(List<BLessonLabel> bLessonLabels);
/** /**
* 根据课程id删除课程-标签表 * 根据课程id删除课程-标签表
...@@ -351,15 +364,28 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -351,15 +364,28 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"</script>") "</script>")
List<QueryLabelResDTO> queryLabelByLessonId(String lessonId); List<QueryLabelResDTO> queryLabelByLessonId(String lessonId);
//查询push课程中的标签
@Select(" <script> select blb.business_id businessId,blb.l_name lName " +
" from b_lesson_label bll " +
" left join b_label blb on bll.label_id = blb.business_id " +
" left join b_lesson bls on bls.business_id = bll.lesson_id " +
" where blb.del_flag != 1 and blb.flag = 1 " +
" and bls.del_flag != 1 and bls.flag = 1 " +
" and bll.business_id = #{lessonId} " +
" and bll.corp_id = #{corpId} " +
" order by CAST( bll.sort AS UNSIGNED) asc " +
"</script>")
List<QueryLabelResDTO> queryLabelByLessonId2(@Param("lessonId") String lessonId,@Param("corpId")String corpId);
/** /**
* 查询平台推荐课程中的标签 * 查询平台推荐课程中的标签
* @param * @param
* @return * @return
*/ */
@Select("<script>" + @Select("<script> select business_id businessId,l_name lName ,'1' type " +
"select business_id businessId,l_name lName from b_label " + " from b_label " +
"where business_id in " + " where business_id in " +
" <foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item} </foreach> " + " <foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item} </foreach> " +
" </script>") " </script>")
List<QueryLabelResDTO> queryPushLabelByLessonId(List<String> list); List<QueryLabelResDTO> queryPushLabelByLessonId(List<String> list);
...@@ -379,8 +405,9 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -379,8 +405,9 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"where 1=1 " + "where 1=1 " +
"and bl.del_flag !=1 " + "and bl.del_flag !=1 " +
"and bl.flag = 1 " + "and bl.flag = 1 " +
"and blc.lesson_id = #{lessonId}") "and blc.lesson_id = #{lessonId}" +
String getCorpLable(String lessonId); "and blc.corp_id = #{corpId}")
String getCorpLable(@Param("lessonId") String lessonId,@Param("corpId") String corpId);
/** /**
* 首页分页查询全部课程 * 首页分页查询全部课程
......
...@@ -29,4 +29,7 @@ public class BLessonLabel extends IdEntity<BLessonLabel> { ...@@ -29,4 +29,7 @@ public class BLessonLabel extends IdEntity<BLessonLabel> {
@NotBlank @NotBlank
private String sort; private String sort;
private String corpId;
} }
...@@ -204,7 +204,7 @@ public interface BLessonService{ ...@@ -204,7 +204,7 @@ public interface BLessonService{
* @param model * @param model
* @return * @return
*/ */
List<BLesson> queryListAllLessonByPagination(PageUtil pageUtil, FindListLessonDTO model, List<AllCourseDTO> allCourse); List<BLesson> queryListAllLessonByPagination(PageUtil pageUtil, FindListLessonDTO model, List<AllCourseDTO> allCourse,CurUser curUser);
/** /**
* @author: jiangpengpeng * @author: jiangpengpeng
......
...@@ -290,18 +290,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -290,18 +290,7 @@ public class BLessonServiceImpl implements BLessonService {
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
} }
List<BLesson> result = bLessonRepository.queryPush(curUser, departs); List<BLesson> result = bLessonRepository.queryPush(curUser, departs);
// result.forEach(lesson->{ return addNew(addPushLable(result,curUser));
// List<String> list = new ArrayList<>();
// String pushLable = bLessonRepository.getPushLable(lesson.getBusinessId());
// String corpLable = bLessonRepository.getCorpLable(lesson.getBusinessId());
// if(StringUtils.isNotEmpty(pushLable))
// list.addAll(asList(pushLable.split(",")));
// if(StringUtils.isNotEmpty(corpLable))
// list.addAll(asList(corpLable.split(",")));
// if( list != null && list.size() > 0)
// lesson.setLabelList(bLessonRepository.queryPushLabelByLessonId(list));
// });
return addNew(result);
} }
/** /**
...@@ -309,20 +298,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -309,20 +298,9 @@ public class BLessonServiceImpl implements BLessonService {
* @param model * @param model
* @return * @return
*/ */
public List<BLesson> queryPush(FindListLessonDTO model) { public List<BLesson> queryPush(FindListLessonDTO model,CurUser curUser) {
List<BLesson> result = bLessonRepository.queryPushMore(model); List<BLesson> result = bLessonRepository.queryPushMore(model);
// result.forEach(lesson->{ return addNew(addPushLable(result,curUser));
// List<String> list = new ArrayList<>();
// String pushLable = bLessonRepository.getPushLable(lesson.getBusinessId());
// String corpLable = bLessonRepository.getCorpLable(lesson.getBusinessId());
// if(StringUtils.isNotEmpty(pushLable))
// list.addAll(asList(pushLable.split(",")));
// if(StringUtils.isNotEmpty(corpLable))
// list.addAll(asList(corpLable.split(",")));
// if( list != null && list.size() > 0)
// lesson.setLabelList(bLessonRepository.queryPushLabelByLessonId(list));
// });
return addNew(result);
} }
@Override @Override
...@@ -408,12 +386,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -408,12 +386,6 @@ public class BLessonServiceImpl implements BLessonService {
BLesson model = new BLesson(); BLesson model = new BLesson();
BeanUtils.copyProperties(addLessonDTO, model); BeanUtils.copyProperties(addLessonDTO, model);
//取出文件集合创建BMaterial集合
// List<BMaterial> bMaterialList = new ArrayList<>();
// if (trainFileList!=null && trainFileList.size()>0){
// BMaterial bMaterial = new BMaterial();
// }
if (StringUtils.isNotEmpty(addLessonDTO.getDefaultUrl()) && !"http".equalsIgnoreCase(addLessonDTO.getDefaultUrl().substring(0, 4))) { if (StringUtils.isNotEmpty(addLessonDTO.getDefaultUrl()) && !"http".equalsIgnoreCase(addLessonDTO.getDefaultUrl().substring(0, 4))) {
model.setDefaultUrl(null); model.setDefaultUrl(null);
} }
...@@ -444,14 +416,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -444,14 +416,6 @@ public class BLessonServiceImpl implements BLessonService {
List<BViewrangeSon> bViewrangeSons = new ArrayList<>(); List<BViewrangeSon> bViewrangeSons = new ArrayList<>();
//model.getViewRangePerson()不为空 新建bViewrangeSon对象放入bViewrangeSons中 //model.getViewRangePerson()不为空 新建bViewrangeSon对象放入bViewrangeSons中
if (StringUtils.isNotEmpty(model.getViewRangePerson())) { if (StringUtils.isNotEmpty(model.getViewRangePerson())) {
// String[] viewRangePerson = null;
// if (!("1".equals(addLessonDTO.getIsAccountId()))){
// viewRangePerson = model.getViewRangePerson().split(",");
// }else {
// //account转为businessId
// List<String> list = bLessonRepository.queryUserIdByAccountId(model.getViewRangePerson(),curUser.getCorpId());
// viewRangePerson = list.toArray(new String[list.size()]) ;
// }
String[] viewRangePerson = getViewRangePerson(addLessonDTO, model.getViewRangePerson(), curUser.getCorpId()); String[] viewRangePerson = getViewRangePerson(addLessonDTO, model.getViewRangePerson(), curUser.getCorpId());
bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangePerson, "0", bViewrange.getBusinessId()); bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangePerson, "0", bViewrange.getBusinessId());
} }
...@@ -468,8 +432,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -468,8 +432,7 @@ public class BLessonServiceImpl implements BLessonService {
//添加课程标签表 //添加课程标签表
if (StringUtils.isNotEmpty(model.getLabels())) { if (StringUtils.isNotEmpty(model.getLabels())) {
//标签集合 //标签集合
List<BLessonLabel> bLessonLabels = addLabel(model); addLabel(model,curUser);
bLessonRepository.insertLessonLabel(bLessonLabels);
} }
} else { } else {
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
...@@ -561,8 +524,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -561,8 +524,7 @@ public class BLessonServiceImpl implements BLessonService {
//删除原标签添,加课程标签表 //删除原标签添,加课程标签表
if (StringUtils.isNotEmpty(model.getLabels())) { if (StringUtils.isNotEmpty(model.getLabels())) {
//标签集合 //标签集合
List<BLessonLabel> bLessonLabels = addLabel(model); addLabel(model,curUser);
bLessonRepository.insertLessonLabel(bLessonLabels);
} }
//删除原有文件 //删除原有文件
bTrainFileRepository.deleteByLessonId(model.getBusinessId()); bTrainFileRepository.deleteByLessonId(model.getBusinessId());
...@@ -1177,7 +1139,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1177,7 +1139,7 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryListAllLessonByPagination(PageUtil pageUtil, FindListLessonDTO model, List<AllCourseDTO> allCourse) { public List<BLesson> queryListAllLessonByPagination(PageUtil pageUtil, FindListLessonDTO model, List<AllCourseDTO> allCourse,CurUser curUser) {
//---------获取部门------------ //---------获取部门------------
// List<String> departs = getDeparts(); // List<String> departs = getDeparts();
List<String> ids = Arrays.asList(new String[]{model.getUserId()}); List<String> ids = Arrays.asList(new String[]{model.getUserId()});
...@@ -1244,7 +1206,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1244,7 +1206,7 @@ public class BLessonServiceImpl implements BLessonService {
ListAllLesson = bLessonRepository.queryInterestedListByPagination(model); ListAllLesson = bLessonRepository.queryInterestedListByPagination(model);
break; break;
case "5": case "5":
ListAllLesson = this.queryPush(model); ListAllLesson = this.queryPush(model,curUser);
break; break;
default: default:
throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE); throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
...@@ -1773,8 +1735,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1773,8 +1735,13 @@ public class BLessonServiceImpl implements BLessonService {
return addNew(re); return addNew(re);
} }
//遍历标签放入List中 /**
List<BLessonLabel> addLabel(BLesson model) { * 新建 修改 课程时 添加标签
* @param model
* @param curUser
* @return
*/
List<BLessonLabel> addLabel(BLesson model,CurUser curUser) {
//标签集合 //标签集合
List<BLessonLabel> bLessonLabels = new ArrayList<>(); List<BLessonLabel> bLessonLabels = new ArrayList<>();
String[] labels = model.getLabels().split(","); String[] labels = model.getLabels().split(",");
...@@ -1788,9 +1755,16 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1788,9 +1755,16 @@ public class BLessonServiceImpl implements BLessonService {
bLessonLabel.setLabelId(labels[index]); bLessonLabel.setLabelId(labels[index]);
bLessonLabel.setLessonId(model.getBusinessId()); bLessonLabel.setLessonId(model.getBusinessId());
bLessonLabel.setSort(String.valueOf(sortNum)); bLessonLabel.setSort(String.valueOf(sortNum));
if("###".equals(model.getCorpId()))
bLessonLabel.setCorpId(curUser.getCorpId());
bLessonLabels.add(bLessonLabel); bLessonLabels.add(bLessonLabel);
sortNum++; sortNum++;
} }
if("###".equals(model.getCorpId())){
bLessonRepository.insertLessonLabel2(bLessonLabels);
}else{
bLessonRepository.insertLessonLabel(bLessonLabels);
}
return bLessonLabels; return bLessonLabels;
} }
...@@ -2077,7 +2051,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -2077,7 +2051,7 @@ public class BLessonServiceImpl implements BLessonService {
List<BLesson> learn = addNew(bLessonRepository.queryLearnListByPagination(model)); List<BLesson> learn = addNew(bLessonRepository.queryLearnListByPagination(model));
List<BLesson> collect = addNew(bLessonRepository.queryCollectListByPagination(model)); List<BLesson> collect = addNew(bLessonRepository.queryCollectListByPagination(model));
List<BLesson> interest = addNew(bLessonRepository.queryInterestedListByPagination(model)); List<BLesson> interest = addNew(bLessonRepository.queryInterestedListByPagination(model));
List<BLesson> push = addNew(this.queryPush(model)); List<BLesson> push = addNew(this.queryPush(model,curUser));
for(BLesson bLesson : recommend){ for(BLesson bLesson : recommend){
if("1".equals(bLesson.getIsNew())){ if("1".equals(bLesson.getIsNew())){
recommendCount++; recommendCount++;
...@@ -2112,4 +2086,28 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -2112,4 +2086,28 @@ public class BLessonServiceImpl implements BLessonService {
dto.setPush(pushCount); dto.setPush(pushCount);
return dto; return dto;
} }
/**
* 查询时 为知识广场的课程 添加 标签
* @param result
* @param curUser
* @return
*/
public List<BLesson> addPushLable(List<BLesson> result ,CurUser curUser){
result.forEach(lesson->{
List<String> list = new ArrayList<>();
String pushLable = bLessonRepository.getPushLable(lesson.getBusinessId());
// 获取 推荐课程的 企业自定义 标签
List<QueryLabelResDTO> lableList = bLessonRepository.queryLabelByLessonId2(lesson.getBusinessId(),curUser.getCorpId());
if(StringUtils.isNotEmpty(pushLable))
list.addAll(asList(pushLable.split(",")));
if( list != null && list.size() > 0){
// 加入平台推荐 标签
lableList.addAll(bLessonRepository.queryPushLabelByLessonId(list));
}
lesson.setLabelList(lableList);
});
return result;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment