Selaa lähdekoodia

管乐迷课件新增老师和学员的课件权限配置

zouxuan 1 vuosi sitten
vanhempi
commit
f9fa9a0997

+ 8 - 0
mec-application/src/main/java/com/ym/mec/web/controller/LessonCoursewareController.java

@@ -8,6 +8,7 @@ import com.microsvc.toolkit.common.webportal.exception.BizException;
 import com.ym.mec.biz.dal.entity.LessonCourseware;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
 import com.ym.mec.biz.service.LessonCoursewareService;
+import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
@@ -31,6 +32,8 @@ public class LessonCoursewareController extends BaseController {
 	private CoursewareFeignService coursewareFeignService;
 	@Resource
 	private LessonCoursewareService lessonCoursewareService;
+	@Resource
+	private SysUserService sysUserService;
 
 	@ApiOperation(value = "获取内容平台课件教材")
 	@PostMapping("/queryPage")
@@ -77,10 +80,13 @@ public class LessonCoursewareController extends BaseController {
 		if (CollectionUtils.isEmpty(lessonCoursewareIds)) {
 			throw new BizException("课件id不能为空");
 		}
+		Integer userId = sysUserService.getUserId();
 		List<LessonCourseware> list = new ArrayList<>();
 		lessonCoursewareIds.forEach(id -> {
 			LessonCourseware lessonCourseware = new LessonCourseware();
 			lessonCourseware.setLessonCourseId(id);
+			lessonCourseware.setCreateBy(userId);
+			lessonCourseware.setUpdateBy(userId);
 			list.add(lessonCourseware);
 		});
 		Integer count = lessonCoursewareService.lambdaQuery().in(LessonCourseware::getLessonCourseId, lessonCoursewareIds).count();
@@ -95,6 +101,7 @@ public class LessonCoursewareController extends BaseController {
 	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/updateEnableFlag')")
 	public HttpResponseResult updateEnableFlag(Integer id,Boolean enableFlag){
 		lessonCoursewareService.lambdaUpdate().set(LessonCourseware::getEnable, enableFlag)
+				.set(LessonCourseware::getUpdateBy, sysUserService.getUserId())
 				.eq(LessonCourseware::getId, id)
 				.update();
 		return succeed();
@@ -105,6 +112,7 @@ public class LessonCoursewareController extends BaseController {
 	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/updateSubject')")
 	public HttpResponseResult updateSubject(Integer id,Integer subjectId){
 		lessonCoursewareService.lambdaUpdate().set(LessonCourseware::getSubjectId, subjectId)
+				.set(LessonCourseware::getUpdateBy, sysUserService.getUserId())
 				.eq(LessonCourseware::getId, id)
 				.update();
 		return succeed();

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LessonCourseware.java

@@ -36,6 +36,14 @@ public class LessonCourseware{
 	@TableField(value = "enable_")
 	private Boolean enable = false;
 
+	@ApiModelProperty(value = "创建人")
+	@TableField(value = "create_by_")
+	private Integer createBy;
+
+	@ApiModelProperty(value = "修改人")
+	@TableField(value = "update_by_")
+	private Integer updateBy;
+
 	@ApiModelProperty(value = "更新时间")
 	@TableField(value = "update_time_")
 	private Date updateTime;

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/LessonCoursewareWrapper.java

@@ -87,6 +87,21 @@ public class LessonCoursewareWrapper {
 
         @ApiModelProperty(value = "老师适用范围ALL,RANGE,DISABLE")
         private String teacherRangeType;
+
+        @ApiModelProperty(value = "创建人")
+        private Integer createBy;
+
+        @ApiModelProperty(value = "修改人")
+        private Integer updateBy;
+
+        @ApiModelProperty(value = "创建人")
+        private String createName;
+
+        @ApiModelProperty(value = "修改人")
+        private String updateName;
+
+        @ApiModelProperty(value = "创建时间")
+        private String createTime;
     }
 
     @Data

+ 20 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -1,6 +1,5 @@
 package com.ym.mec.biz.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
@@ -15,6 +14,7 @@ import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
 import com.ym.mec.biz.service.LessonCoursewareService;
 import com.ym.mec.biz.service.LessonCoursewareUserMapperService;
+import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.util.collection.MapUtil;
 import org.apache.commons.collections.CollectionUtils;
@@ -25,9 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -45,6 +43,8 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
     @Resource
     private LessonCoursewareUserMapperService lessonCoursewareUserMapperService;
     @Resource
+    private SysUserService sysUserService;
+    @Resource
     private SubjectDao subjectDao;
     @Resource
     private TeacherDao teacherDao;
@@ -76,25 +76,31 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
             if(CollectionUtils.isNotEmpty(entityList)){
                 Map<Long, CbsLessonCoursewareWrapper.Entity> entityMap = entityList.stream().collect(Collectors.groupingBy(CbsLessonCoursewareWrapper.Entity::getId,
                         Collectors.collectingAndThen(Collectors.toList(), e -> e.get(0))));
+                List<Integer> collect = dtos.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
+                String subjectIds = collect.stream().map(e -> String.valueOf(e)).collect(Collectors.joining(","));
+                List<Map<Integer, String>> subjectNames = subjectDao.queryNameByIds(subjectIds);
+                Map<Integer, String> subjectNameMap = MapUtil.convertMybatisMap(subjectNames);
+
+                List<Integer> userIds = dtos.stream().map(e -> e.getCreateBy()).filter(Objects::nonNull).distinct().collect(Collectors.toList());
+                userIds.addAll(dtos.stream().map(e -> e.getUpdateBy()).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
+                userIds.removeAll(Collections.singleton(null));
+                Map<Integer, String> userNameMap = new HashMap<>();
+                if(CollectionUtils.isNotEmpty(userIds)){
+                    userNameMap = MapUtil.convertMybatisMap(teacherDao.queryNameByIdList(userIds));
+                }
                 for (LessonCoursewareWrapper.LessonCoursewareDto e : dtos) {
                     CbsLessonCoursewareWrapper.Entity entity = entityMap.get(e.getLessonCoursewareId());
                     if (Objects.isNull(entity)) {
                         continue;
                     }
+                    e.setCreateName(userNameMap.get(e.getCreateBy()));
+                    e.setUpdateName(userNameMap.get(e.getUpdateBy()));
+                    e.setSubjectName(subjectNameMap.get(e.getSubjectId()));
                     e.setName(entity.getName());
                     e.setCover(entity.getCoverImg());
                     e.setCourseNum(entity.getCourseNum());
                 }
             }
-            List<Integer> collect = dtos.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
-            if(CollectionUtils.isNotEmpty(collect)){
-                String subjectIds = collect.stream().map(e -> String.valueOf(e)).collect(Collectors.joining(","));
-                List<Map<Integer, String>> subjectNames = subjectDao.queryNameByIds(subjectIds);
-                Map<Integer, String> subjectNameMap = MapUtil.convertMybatisMap(subjectNames);
-                for (LessonCoursewareWrapper.LessonCoursewareDto e : dtos) {
-                    e.setSubjectName(subjectNameMap.get(e.getSubjectId()));
-                }
-            }
         }
         return page.setRecords(dtos);
     }
@@ -108,6 +114,7 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
         }
         lessonCourseware.setStudentRangeType(updateRange.getStudentRangeType());
         lessonCourseware.setTeacherRangeType(updateRange.getTeacherRangeType());
+        lessonCourseware.setUpdateBy(sysUserService.getUserId());
         this.updateById(lessonCourseware);
         lessonCoursewareUserMapperService.lambdaUpdate()
                 .eq(LessonCoursewareUserMapper::getLessonCoursewareId, updateRange.getLessonCoursewareId()).remove();

+ 5 - 4
mec-biz/src/main/resources/config/mybatis/LessonCoursewareMapper.xml

@@ -5,10 +5,10 @@
     <sql id="selectPageSql">
         <where>
             <if test="param.studentId != null">
-                AND (lc.student_range_type_ == 'ALL' OR (lcum.user_id_ = #{param.studentId} AND lcum.user_type_ = 'STUDENT'))
+                AND (lc.student_range_type_ = 'ALL' OR (lcum.user_id_ = #{param.studentId} AND lcum.user_type_ = 'STUDENT'))
             </if>
             <if test="param.teacherId != null">
-                AND (lc.teacher_range_type_ == 'ALL' OR (lcum.user_id_ = #{param.teacherId} AND lcum.user_type_ = 'TEACHER'))
+                AND (lc.teacher_range_type_ = 'ALL' OR (lcum.user_id_ = #{param.teacherId} AND lcum.user_type_ = 'TEACHER'))
             </if>
             <if test="param.lessonCoursewareIds != null">
                 and lc.lesson_course_id_ IN
@@ -17,7 +17,7 @@
                 </foreach>
             </if>
             <if test="param.subjectId != null">
-                and lc.id_subject_id_ = #{param.subjectId}
+                and lc.subject_id_ = #{param.subjectId}
             </if>
             <if test="param.studentRangeType != null and param.studentRangeType != ''">
                 and lc.student_range_type_ = #{param.studentRangeType}
@@ -32,7 +32,8 @@
     </sql>
     <select id="selectPage" resultType="com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper$LessonCoursewareDto">
         select lc.id_ id, lc.subject_id_ subjectId, lc.lesson_course_id_ lessonCoursewareId, lc.enable_ enable,
-               lc.student_range_type_ studentRangeType, lc.teacher_range_type_ teacherRangeType
+               lc.student_range_type_ studentRangeType, lc.teacher_range_type_ teacherRangeType,
+               lc.create_by_ createBy,lc.update_by_ updateBy,lc.create_time_ createTime
         from lesson_courseware lc
         left join lesson_courseware_user_mapper lcum ON lcum.lesson_courseware_id_ = lc.id_
         <include refid="selectPageSql"/>