Commit 0be22efd authored by luzhuang's avatar luzhuang

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

parent d36a13b5
......@@ -330,7 +330,7 @@ public class BLessonController extends PaginationController<BLesson> {
if (StringUtils.isNotEmpty(param.getCourse())) {
allCourse = bCourseService.findAllCourse(curUser.getCorpId());
}
bLessonService.queryListAllLessonByPagination(getPaginationUtility(), param, allCourse);
bLessonService.queryListAllLessonByPagination(getPaginationUtility(), param, allCourse,curUser);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......
......@@ -58,6 +58,19 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" </foreach> </script> ")
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删除课程-标签表
......@@ -351,15 +364,28 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"</script>")
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
* @return
*/
@Select("<script>" +
"select business_id businessId,l_name lName from b_label " +
"where business_id in " +
@Select("<script> select business_id businessId,l_name lName ,'1' type " +
" from b_label " +
" where business_id in " +
" <foreach item='item' index='index' collection='list' open='(' separator=',' close=')'> #{item} </foreach> " +
" </script>")
List<QueryLabelResDTO> queryPushLabelByLessonId(List<String> list);
......@@ -379,8 +405,9 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"where 1=1 " +
"and bl.del_flag !=1 " +
"and bl.flag = 1 " +
"and blc.lesson_id = #{lessonId}")
String getCorpLable(String lessonId);
"and blc.lesson_id = #{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> {
@NotBlank
private String sort;
private String corpId;
}
......@@ -204,7 +204,7 @@ public interface BLessonService{
* @param model
* @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
......
......@@ -290,18 +290,7 @@ public class BLessonServiceImpl implements BLessonService {
departs.removeAll(Collections.singleton(""));
}
List<BLesson> result = bLessonRepository.queryPush(curUser, departs);
// result.forEach(lesson->{
// 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);
return addNew(addPushLable(result,curUser));
}
/**
......@@ -309,20 +298,9 @@ public class BLessonServiceImpl implements BLessonService {
* @param model
* @return
*/
public List<BLesson> queryPush(FindListLessonDTO model) {
public List<BLesson> queryPush(FindListLessonDTO model,CurUser curUser) {
List<BLesson> result = bLessonRepository.queryPushMore(model);
// result.forEach(lesson->{
// 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);
return addNew(addPushLable(result,curUser));
}
@Override
......@@ -408,12 +386,6 @@ public class BLessonServiceImpl implements BLessonService {
BLesson model = new BLesson();
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))) {
model.setDefaultUrl(null);
}
......@@ -444,14 +416,6 @@ public class BLessonServiceImpl implements BLessonService {
List<BViewrangeSon> bViewrangeSons = new ArrayList<>();
//model.getViewRangePerson()不为空 新建bViewrangeSon对象放入bViewrangeSons中
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());
bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangePerson, "0", bViewrange.getBusinessId());
}
......@@ -468,8 +432,7 @@ public class BLessonServiceImpl implements BLessonService {
//添加课程标签表
if (StringUtils.isNotEmpty(model.getLabels())) {
//标签集合
List<BLessonLabel> bLessonLabels = addLabel(model);
bLessonRepository.insertLessonLabel(bLessonLabels);
addLabel(model,curUser);
}
} else {
UserUtil.setCurrentMergeOperation(model);
......@@ -561,8 +524,7 @@ public class BLessonServiceImpl implements BLessonService {
//删除原标签添,加课程标签表
if (StringUtils.isNotEmpty(model.getLabels())) {
//标签集合
List<BLessonLabel> bLessonLabels = addLabel(model);
bLessonRepository.insertLessonLabel(bLessonLabels);
addLabel(model,curUser);
}
//删除原有文件
bTrainFileRepository.deleteByLessonId(model.getBusinessId());
......@@ -1177,7 +1139,7 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@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> ids = Arrays.asList(new String[]{model.getUserId()});
......@@ -1244,7 +1206,7 @@ public class BLessonServiceImpl implements BLessonService {
ListAllLesson = bLessonRepository.queryInterestedListByPagination(model);
break;
case "5":
ListAllLesson = this.queryPush(model);
ListAllLesson = this.queryPush(model,curUser);
break;
default:
throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
......@@ -1773,8 +1735,13 @@ public class BLessonServiceImpl implements BLessonService {
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<>();
String[] labels = model.getLabels().split(",");
......@@ -1788,9 +1755,16 @@ public class BLessonServiceImpl implements BLessonService {
bLessonLabel.setLabelId(labels[index]);
bLessonLabel.setLessonId(model.getBusinessId());
bLessonLabel.setSort(String.valueOf(sortNum));
if("###".equals(model.getCorpId()))
bLessonLabel.setCorpId(curUser.getCorpId());
bLessonLabels.add(bLessonLabel);
sortNum++;
}
if("###".equals(model.getCorpId())){
bLessonRepository.insertLessonLabel2(bLessonLabels);
}else{
bLessonRepository.insertLessonLabel(bLessonLabels);
}
return bLessonLabels;
}
......@@ -2077,7 +2051,7 @@ public class BLessonServiceImpl implements BLessonService {
List<BLesson> learn = addNew(bLessonRepository.queryLearnListByPagination(model));
List<BLesson> collect = addNew(bLessonRepository.queryCollectListByPagination(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){
if("1".equals(bLesson.getIsNew())){
recommendCount++;
......@@ -2112,4 +2086,28 @@ public class BLessonServiceImpl implements BLessonService {
dto.setPush(pushCount);
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