Commit 8f9946b1 authored by luzhuang's avatar luzhuang

分类排序

parent e4d09eff
......@@ -73,7 +73,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "isTest", value = "课件类型(单选) 1视频 2音频 3PPT 4pdf 5资料", required = true, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(CurUser curUser, @Valid BChapter bChapter, BindingResult bindingResult) {
PersistModel data = bChapterService.persist(bChapter);
PersistModel data = bChapterService.persist(bChapter,curUser.getCorpId());
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......@@ -95,7 +95,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value = "203 分页查询章节", notes = "根据条件分页查询章节", response = QueryChapterListResDTO.class)
@PostMapping(value = "/queryBChaptersByPagination")
public Result queryBChaptersByPagination(CurUser curUser,@Valid QueryChapterListDTO param,BindingResult br) {
bChapterService.queryBChaptersByPagination(getPaginationUtility(), param);
bChapterService.queryBChaptersByPagination(getPaginationUtility(), param,curUser.getCorpId());
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -107,7 +107,7 @@ public class BChapterController extends PaginationController<BChapter> {
@GetMapping(value = "/queryBChaptersWithoutAuth")
public Result queryBChapters(CurUser curUser,@Valid QueryChapterListDTO param,BindingResult br) {
Map<String, Object> map = new HashedMap();
map.put("chapterList", bChapterService.queryBChapters(param));
map.put("chapterList", bChapterService.queryBChapters(param,curUser.getCorpId()));
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......@@ -120,7 +120,7 @@ public class BChapterController extends PaginationController<BChapter> {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bChapterService.queryBChaptersWithProgress(param));
bChapterService.queryBChaptersWithProgress(param,curUser.getCorpId()));
}
//
// @ApiOperation(value = "更改章节状态", notes = "根据章节ID更改章节状态")
......
......@@ -47,7 +47,10 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
*/
@Select("<script>select * from b_chapter " +
"where del_flag = 0 and flag = 1 and pid = -1 " +
" and lesson_id = #{lessonId}\n" +
" and lesson_id = #{lessonId} " +
"and corp_id = #{corpId} " +
"order by sort asc</script>")
@ResultMap(value = "SupperChildListResultMap")
List<QueryChapterListResDTO> queryBChapters(Map<String, Object> param);
......
......@@ -11,6 +11,6 @@ public class QueryChapterListDTO {
@ApiModelProperty(value = "课程ID")
private String lessonId;
@Length(min = 1,max = 64,message = "长度最小为1,最大为50")
@ApiModelProperty(value = "课程ID")
@ApiModelProperty(value = "userID")
private String studentId;
}
......@@ -57,4 +57,7 @@ public class QueryChapterListResDTO {
@ApiModelProperty(value = "id")
private String businessId;
@ApiModelProperty(value = "id")
private String corpId;
}
......@@ -27,7 +27,7 @@ public interface BChapterService{
* @param model
* @return
*/
List<QueryChapterListResDTO> queryBChaptersByPagination(PageUtil pageUtil, QueryChapterListDTO model);
List<QueryChapterListResDTO> queryBChaptersByPagination(PageUtil pageUtil, QueryChapterListDTO model,String corpId);
/**
* 根据章节id查找学生分数信息
......@@ -41,21 +41,21 @@ public interface BChapterService{
* @param model
* @return
*/
List<QueryChapterListResDTO> queryBChapters(QueryChapterListDTO model);
List<QueryChapterListResDTO> queryBChapters(QueryChapterListDTO model,String corpId);
/**
* 根据条件查找全部
* @param model
* @return
*/
Map queryBChaptersWithProgress(QueryChapterListDTO model);
Map queryBChaptersWithProgress(QueryChapterListDTO model,String corpId);
/**
* 插入
* @param model
* @return
*/
PersistModel persist(BChapter model);
PersistModel persist(BChapter model,String corpId);
/**
* 修改
......
......@@ -70,8 +70,8 @@ public class BChapterServiceImpl implements BChapterService {
}
@Override
public List<QueryChapterListResDTO> queryBChaptersByPagination(PageUtil pageUtil, QueryChapterListDTO model) {
return queryChapterListResDTO(model);
public List<QueryChapterListResDTO> queryBChaptersByPagination(PageUtil pageUtil, QueryChapterListDTO model,String corpId) {
return queryChapterListResDTO(model,corpId);
}
@Override
......@@ -80,12 +80,12 @@ public class BChapterServiceImpl implements BChapterService {
}
@Override
public List<QueryChapterListResDTO> queryBChapters(QueryChapterListDTO model) {
return queryChapterListResDTO(model);
public List<QueryChapterListResDTO> queryBChapters(QueryChapterListDTO model,String corpId) {
return queryChapterListResDTO(model,corpId);
}
@Override
public Map queryBChaptersWithProgress(QueryChapterListDTO model) {
List<QueryChapterListResDTO> queryChapterListResDTOS = queryChapterListResDTO(model);
public Map queryBChaptersWithProgress(QueryChapterListDTO model,String corpId) {
List<QueryChapterListResDTO> queryChapterListResDTOS = queryChapterListResDTO(model,corpId);
queryChapterListResDTOS.stream().forEach(queryChapterListResDTO -> {
queryChapterListResDTO.getChildList().stream().forEach(childList -> {
List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(childList.getBusinessId(),model.getStudentId());
......@@ -106,18 +106,19 @@ public class BChapterServiceImpl implements BChapterService {
* @param model
* @return
*/
public List<QueryChapterListResDTO> queryChapterListResDTO(QueryChapterListDTO model) {
public List<QueryChapterListResDTO> queryChapterListResDTO(QueryChapterListDTO model,String corpId) {
Map param = new HashMap<String, Object>();
if (model.getLessonId() != null && !"".equals(model.getLessonId())) {
param.put("lessonId", model.getLessonId());
}
param.put("corpId",corpId);
return bChapterRepository.queryBChapters(param);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public PersistModel persist(BChapter model) {
public PersistModel persist(BChapter model,String corpId) {
int line = 0;
if (model.getBusinessId() == null) {
UserUtil.setCurrentPersistOperation(model);
......@@ -135,6 +136,7 @@ public class BChapterServiceImpl implements BChapterService {
}
int sort = bChapterRepository.selectMaxSort(model.getPid(), model.getLessonId());
model.setSort(sort);
model.setCorpId(corpId);
line = bChapterRepository.insertSelective(model);
bChapterRepository.updateClassHourInLesson(model.getLessonId());//更新b_lesson表中 class_hour
......
......@@ -41,7 +41,7 @@ public class BCourseController extends PaginationController<BCourse> {
private BCourseRepository bCourseRepository;
@ApiOperation(value = "301 查询课程分类", notes = "查询课程分类", response = QueryCourseResDTO.class)
@ApiImplicitParam(name = "cName", value = "(课程名)模糊查询", required = true, dataType = "varchar")
@ApiImplicitParam(name = "cName", value = "(课程分类名)模糊查询", required = true, dataType = "varchar")
@PostMapping(value = "/queryCourse")
public Result queryBCourse(CurUser curUser, @Valid String cName, BindingResult br) {
BCourse bCourse = new BCourse();
......@@ -56,11 +56,12 @@ public class BCourseController extends PaginationController<BCourse> {
}
@ApiOperation(value = "302 根据条件分页查询", notes = "根据条件分页查询标签", response = QueryCourseResDTO.class)
@ApiImplicitParam(name = "cName", value = "(课程名)模糊查询", required = false, dataType = "varchar")
@ApiImplicitParam(name = "cName", value = "(课程分类名)模糊查询", required = false, dataType = "varchar")
@GetMapping(value = "/queryBCourseByPagination")
public Result queryBCourseByPagination(CurUser curUser, @Valid String cName, BindingResult br) {
BCourse bCourse = new BCourse();
bCourse.setCName(cName);
bCourse.setCorpId(curUser.getCorpId());
bCourseServiceImpl.queryBCourseByPagination(getPaginationUtility(), bCourse);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
......
......@@ -21,10 +21,10 @@ public class QueryCourseResDTO {
@ApiModelProperty(value = "子章节")
private List<BCourse> children;
@ApiModelProperty(value = "序号")
@ApiModelProperty(value = "排序序号")
private int sort;
@ApiModelProperty(value = "序号")
@ApiModelProperty(value = "上一级")
private String pid;
@ApiModelProperty(value = "等级")
......
package org.rcisoft.business.bcourse.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.apache.commons.lang.StringUtils;
import org.rcisoft.business.bcourse.dao.BCourseRepository;
import org.rcisoft.business.bcourse.dto.AllCourseDTO;
......@@ -47,16 +48,17 @@ public class BCourseServiceImpl implements BCourseService {
if (model.getCName() != null && !"".equals(model.getCName())) {
param.put("cName", model.getCName());
}
param.put("corpId", model.getCorpId());
return bCourseRepository.queryCourses(param);
}
@Override
public PersistModel insertCourse(BCourse bCourse) {
if(bCourse.getCName()==null||bCourse.getCName().equals("")){
if (bCourse.getCName() == null || bCourse.getCName().equals("")) {
throw new ServiceException(ResultServiceEnums.NAME_IS_NULL);
}
List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(),bCourse.getCorpId());
List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(), bCourse.getCorpId());
if (list.size() > 0) {
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
}
......@@ -64,19 +66,19 @@ public class BCourseServiceImpl implements BCourseService {
if (bCourse.getPid() == null || "".equals(bCourse.getPid())) {
bCourse.setPid("00000000");
bCourse.setCourseLevel("1");
int sort = bCourseRepository.getSort(bCourse.getPid(),bCourse.getCorpId());
int sort = bCourseRepository.getSort(bCourse.getPid(), bCourse.getCorpId());
bCourse.setSort(sort);
} else if ("00000000".equals(bCourse.getPid())) {
bCourse.setCourseLevel("1");
int sort = bCourseRepository.getSort(bCourse.getPid(),bCourse.getCorpId());
int sort = bCourseRepository.getSort(bCourse.getPid(), bCourse.getCorpId());
bCourse.setSort(sort);
} else if (bCourseRepository.queryParentLevel(bCourse.getPid(),bCourse.getCorpId()) == 1) {//通过getpid 获取上一级的level
} else if (bCourseRepository.queryParentLevel(bCourse.getPid(), bCourse.getCorpId()) == 1) {//通过getpid 获取上一级的level
bCourse.setCourseLevel("2");
int sort = bCourseRepository.getSort(bCourse.getPid(),bCourse.getCorpId());
int sort = bCourseRepository.getSort(bCourse.getPid(), bCourse.getCorpId());
bCourse.setSort(sort);
} else if (bCourseRepository.queryParentLevel(bCourse.getPid(),bCourse.getCorpId()) == 2) {
} else if (bCourseRepository.queryParentLevel(bCourse.getPid(), bCourse.getCorpId()) == 2) {
bCourse.setCourseLevel("3");
int sort = bCourseRepository.getSort(bCourse.getPid(),bCourse.getCorpId());
int sort = bCourseRepository.getSort(bCourse.getPid(), bCourse.getCorpId());
bCourse.setSort(sort);
} else {
throw new ServiceException(ResultServiceEnums.COURSE_ERROR);
......@@ -86,17 +88,17 @@ public class BCourseServiceImpl implements BCourseService {
}
@Override
public PersistModel removeCourse(String corpId,String id) {
public PersistModel removeCourse(String corpId, String id) {
List<AllCourseDTO> allCourse = null;
if (org.apache.commons.lang3.StringUtils.isNotEmpty(id)){
if (org.apache.commons.lang3.StringUtils.isNotEmpty(id)) {
allCourse = this.findAllCourse(corpId);
}
List<String> courseIds = null;
if (allCourse != null){
if (allCourse != null) {
//查询出所有子分类
courseIds = recursion.FindSons(id,allCourse);
courseIds = recursion.FindSons(id, allCourse);
//将一级分类放入分类集合中
courseIds.add(id);
}
......@@ -106,7 +108,7 @@ public class BCourseServiceImpl implements BCourseService {
@Override
public PersistModel updateCourse(BCourse bCourse) {
List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(),bCourse.getCorpId());
List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(), bCourse.getCorpId());
if (list.size() > 0) {
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
}
......@@ -116,16 +118,86 @@ public class BCourseServiceImpl implements BCourseService {
@Override
public PersistModel sortCourse(String json) {
Map<String,Object> maps = (Map) JSON.parse(json);
// Map<String,Object> maps = (Map) JSON.parse(json);
// List<BCourse> bCourses = new ArrayList<>();
// for (String obj : maps.keySet()) {
// BCourse bCourse = new BCourse();
// String value = maps.get(obj).toString();
// bCourse.setBusinessId(obj.toString());
// String[] split = StringUtils.split(value, ",");
// bCourse.setPid(split[0]);
// bCourse.setSort(Integer.parseInt(split[1]));
// bCourse.setCourseLevel(split[2]);
// bCourses.add(bCourse);
// }
// int line = bCourseRepository.sortCourser(bCourses);
List<Map<String, String>> listObjectFir = (List<Map<String, String>>) JSONArray.parse(json);
List<BCourse> bCourses = new ArrayList<>();
for (String obj : maps.keySet()) {
for (Map<String, String> mapList : listObjectFir) {
BCourse bCourse = new BCourse();
String value = maps.get(obj).toString();
bCourse.setBusinessId(obj.toString());
String[] split = StringUtils.split(value, ",");
bCourse.setPid(split[0]);
bCourse.setSort(Integer.parseInt(split[1]));
bCourse.setCourseLevel(split[2]);
for (Map.Entry<String, String> str : mapList.entrySet()) {
if (str.getKey().equals("key")) {
bCourse.setBusinessId(String.valueOf(str.getValue()));
}
if (str.getKey().equals("pid")) {
bCourse.setPid(String.valueOf(str.getValue()));
}
if (str.getKey().equals("sort")) {
bCourse.setSort(Integer.parseInt(String.valueOf(str.getValue())));
}
if (str.getKey().equals("courseLevel")) {
bCourse.setCourseLevel(String.valueOf(str.getValue()));
}
if (str.getKey().equals("children")) {
String child = String.valueOf(str.getValue());
List<Map<String, String>> list1 = (List<Map<String, String>>) JSONArray.parse(child);
for (Map<String, String> mapList1 : list1) {
BCourse bCourse1 = new BCourse();
for (Map.Entry<String, String> str1 : mapList1.entrySet()) {
if (str1.getKey().equals("key")) {
bCourse1.setBusinessId(str1.getValue());
}
if (str1.getKey().equals("pid")) {
bCourse1.setPid(str1.getValue());
}
if (str1.getKey().equals("sort")) {
bCourse1.setSort(Integer.parseInt(String.valueOf(str1.getValue())));
}
if (str1.getKey().equals("courseLevel")) {
bCourse1.setCourseLevel(String.valueOf(str1.getValue()));
}
if (str1.getKey().equals("children")) {
String child2 = String.valueOf(str1.getValue());
List<Map<String, String>> list2 = (List<Map<String, String>>) JSONArray.parse(child2);
for (Map<String, String> mapList2 : list2) {
BCourse bCourse2 = new BCourse();
for (Map.Entry<String, String> str2 : mapList2.entrySet()) {
if (str2.getKey().equals("key")) {
bCourse2.setBusinessId(str2.getValue());
}
if (str2.getKey().equals("pid")) {
bCourse2.setPid(str2.getValue());
}
if (str2.getKey().equals("sort")) {
bCourse2.setSort(Integer.parseInt(String.valueOf(str2.getValue())));
}
if (str2.getKey().equals("courseLevel")) {
bCourse2.setCourseLevel(String.valueOf(str2.getValue()));
}
}
bCourses.add(bCourse2);
}
}
}
bCourses.add(bCourse1);
}
}
}
bCourses.add(bCourse);
}
int line = bCourseRepository.sortCourser(bCourses);
......
......@@ -29,7 +29,7 @@ import java.util.List;
/**
* Created by on 2019-9-25 10:01:43.
*/
@Api("10 章节")
@Api(tags = "12 学生章节")
@RestController
@RequestMapping("brstudentchapter")
public class BRStudentChapterController extends PaginationController<BRStudentChapter> {
......@@ -38,7 +38,7 @@ public class BRStudentChapterController extends PaginationController<BRStudentCh
private BRStudentChapterService bRStudentChapterServiceImpl;
@ApiOperation(value="1001 添加/更新学生端观看章节进度", notes="添加/更新")
@ApiOperation(value="1201 添加/更新学生端观看章节进度", notes="添加/更新")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
public Result addOrUpdate(@Valid BRStudentChapterDto brStudentChapterDto, BindingResult bindingResult) {
......
......@@ -43,7 +43,7 @@ public abstract class DataEntity<T> implements Serializable {
protected String flag ; // 启用标记(0:停用;1:启用)
// @OperateFlagAnno
protected String corpId ; // 企业id(0:停用;1:启用)
protected String corpId ; // 企业id
/**
* 设置删除
......
......@@ -6,6 +6,7 @@ server:
context-path: /
#uri-encoding: UTF-8
type: dev1
maxHttpHeaderSize: 102400
#logging:
# level:
......
......@@ -22,6 +22,7 @@
<result column="sort" jdbcType="INTEGER" property="sort"/>
<result column="experiment_type" jdbcType="VARCHAR" property="experimentType"/>
<result column="course_time" jdbcType="VARCHAR" property="courseTime"/>
<result column="corp_id" jdbcType="VARCHAR" property="corpId"/>
</resultMap>
<resultMap id="BaseResultMapDTO" type="org.rcisoft.business.bchapter.dto.QueryChapterListResDTO">
......@@ -40,6 +41,7 @@
<result column="is_complete" jdbcType="VARCHAR" property="isComplete"/>
<result column="file_name" jdbcType="VARCHAR" property="fileName"/>
<result column="course_time" jdbcType="VARCHAR" property="courseTime"/>
<result column="corp_id" jdbcType="VARCHAR" property="corpId"/>
</resultMap>
<!--教师和管理员使用这个-->
......
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