ソースを参照

Merge branch 'zx_saas_courseware' of http://git.dayaedu.com/yonge/mec into test

# Conflicts:
#	pom.xml
zouxuan 1 年間 前
コミット
ec26b84ded
18 ファイル変更457 行追加41 行削除
  1. 4 0
      mec-application/src/main/java/com/ym/mec/student/controller/LessonCoursewareController.java
  2. 5 2
      mec-application/src/main/java/com/ym/mec/teacher/controller/LessonCoursewareController.java
  3. 42 1
      mec-application/src/main/java/com/ym/mec/teacher/controller/TeacherCourseScheduleController.java
  4. 27 6
      mec-application/src/main/java/com/ym/mec/web/controller/LessonCoursewareController.java
  5. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseSchedule.java
  6. 16 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LessonCourseware.java
  7. 36 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LessonCoursewareUserMapper.java
  8. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/LessonCoursewareMapper.java
  9. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/LessonCoursewareUserMapperMapper.java
  10. 89 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/LessonCoursewareWrapper.java
  11. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareService.java
  12. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareUserMapperService.java
  13. 1 9
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  14. 125 16
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java
  15. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareUserMapperServiceImpl.java
  16. 39 6
      mec-biz/src/main/resources/config/mybatis/LessonCoursewareMapper.xml
  17. 5 0
      mec-biz/src/main/resources/config/mybatis/LessonCoursewareUserMapperMapper.xml
  18. 1 1
      pom.xml

+ 4 - 0
mec-application/src/main/java/com/ym/mec/student/controller/LessonCoursewareController.java

@@ -9,6 +9,7 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.biz.dal.entity.Subject;
 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,11 +32,14 @@ public class LessonCoursewareController extends BaseController {
 	private CoursewareFeignService coursewareFeignService;
 	@Resource
 	private LessonCoursewareService lessonCoursewareService;
+	@Resource
+	private SysUserService sysUserService;
 
 	@ApiOperation(value = "分页查询已添加的课件")
 	@PostMapping("/queryLessonCourseware")
 	public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
 		query.setEnable(true);
+		query.setStudentId(sysUserService.getUserId());
 		IPage<LessonCoursewareWrapper.LessonCoursewareDto> pages = lessonCoursewareService.selectPage(QueryInfo.getPage(query), query);
 		return succeed(PageUtil.pageInfo(pages));
 	}

+ 5 - 2
mec-application/src/main/java/com/ym/mec/teacher/controller/LessonCoursewareController.java

@@ -9,6 +9,7 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.ym.mec.biz.dal.entity.Subject;
 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;
@@ -16,7 +17,6 @@ import com.ym.mec.common.page.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -28,15 +28,18 @@ import java.util.List;
 @RestController
 public class LessonCoursewareController extends BaseController {
 
-	@Autowired
+	@Resource
 	private CoursewareFeignService coursewareFeignService;
 	@Resource
+	private SysUserService sysUserService;
+	@Resource
 	private LessonCoursewareService lessonCoursewareService;
 
 	@ApiOperation(value = "分页查询已添加的课件")
 	@PostMapping("/queryLessonCourseware")
 	public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
 		query.setEnable(true);
+		query.setTeacherId(sysUserService.getUserId());
 		IPage<LessonCoursewareWrapper.LessonCoursewareDto> pages = lessonCoursewareService.selectPage(QueryInfo.getPage(query), query);
 		return succeed(PageUtil.pageInfo(pages));
 	}

+ 42 - 1
mec-application/src/main/java/com/ym/mec/teacher/controller/TeacherCourseScheduleController.java

@@ -1,13 +1,19 @@
 package com.ym.mec.teacher.controller;
 
+import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
+import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
+import com.microsvc.toolkit.common.response.template.R;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.LessonCourseware;
+import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
+import com.ym.mec.biz.dal.enums.TeachModeEnum;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.dal.vo.CourseScheduleWrapper;
 import com.ym.mec.biz.dal.wrapper.LiveGroupWrapper;
@@ -22,13 +28,14 @@ import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.yonge.log.model.AuditLogAnnotation;
 import io.swagger.annotations.*;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
-import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -56,6 +63,12 @@ public class TeacherCourseScheduleController extends BaseController {
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
     @Autowired
     private SubjectService subjectService;
+    @Resource
+    private CoursewareFeignService coursewareFeignService;
+    @Resource
+    private LessonCoursewareUserMapperService lessonCoursewareUserMapperService;
+    @Resource
+    private LessonCoursewareService lessonCoursewareService;
 
     @ApiOperation(value = "根据月份获取该月有课的日期")
     @GetMapping("/getCourseScheduleDateByMonth")
@@ -84,6 +97,34 @@ public class TeacherCourseScheduleController extends BaseController {
         String courseAfterBufferTime = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_AFTER_BUFFER_TIME, user.getTenantId());
         List<CourseScheduleDto> teacherCourseSchedulesWithDate = scheduleService.getTeacherCourseSchedulesWithDate(user.getId(),date,type,user.getTenantId());
         Map<String,Object> result = new HashMap<>(7);
+        if (CollectionUtils.isNotEmpty(teacherCourseSchedulesWithDate)){
+            for (CourseScheduleDto courseScheduleDto : teacherCourseSchedulesWithDate) {
+                if(courseScheduleDto.getTeachMode() == TeachModeEnum.OFFLINE
+                        && StringUtils.isNotEmpty(courseScheduleDto.getCoursewareDetailId())){
+                    //获取课件详情列表
+                    R<CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail> voR = coursewareFeignService.lessonCoursewareDetailDetail(Long.parseLong(courseScheduleDto.getCoursewareDetailId()));
+                    if (voR.getCode().equals(200)){
+                        LessonCourseware lessonCourseware = lessonCoursewareService.lambdaQuery()
+                                .eq(LessonCourseware::getLessonCourseId, voR.getData().getLessonCoursewareId()).last("LIMIT 1").one();
+                        if (Objects.isNull(lessonCourseware) || StringUtils.equals(lessonCourseware.getTeacherRangeType(),"DISABLE")){
+                            courseScheduleDto.setCoursewareEnable(false);
+                            continue;
+                        }
+                        if(StringUtils.equals(lessonCourseware.getTeacherRangeType(),"ALL")){
+                            courseScheduleDto.setCoursewareEnable(true);
+                            continue;
+                        }
+                        LessonCoursewareUserMapper lessonCoursewareUserMapper = lessonCoursewareUserMapperService.lambdaQuery()
+                                .eq(LessonCoursewareUserMapper::getLessonCoursewareId, lessonCourseware.getId())
+                                .eq(LessonCoursewareUserMapper::getUserType, "TEACHER")
+                                .eq(LessonCoursewareUserMapper::getUserId, user.getId()).last("LIMIT 1").one();
+                        if(Objects.nonNull(lessonCoursewareUserMapper)){
+                            courseScheduleDto.setCoursewareEnable(true);
+                        }
+                    }
+                }
+            }
+        }
         result.put("rows",teacherCourseSchedulesWithDate);
         result.put("appealHoursRange",4);
         result.put("offlineSignInEarlyForwardTime", StringUtils.isEmpty(offlineSignInEarlyForwardTime)?60:Integer.parseInt(offlineSignInEarlyForwardTime));

+ 27 - 6
mec-application/src/main/java/com/ym/mec/web/controller/LessonCoursewareController.java

@@ -1,6 +1,5 @@
 package com.ym.mec.web.controller;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
 import com.google.common.collect.Lists;
@@ -9,13 +8,13 @@ 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;
 import com.ym.mec.common.page.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
@@ -29,10 +28,12 @@ import java.util.List;
 @RestController
 public class LessonCoursewareController extends BaseController {
 
-	@Autowired
+	@Resource
 	private CoursewareFeignService coursewareFeignService;
 	@Resource
 	private LessonCoursewareService lessonCoursewareService;
+	@Resource
+	private SysUserService sysUserService;
 
 	@ApiOperation(value = "获取内容平台课件教材")
 	@PostMapping("/queryPage")
@@ -67,9 +68,9 @@ public class LessonCoursewareController extends BaseController {
 	@ApiOperation(value = "分页查询已添加的课件")
 	@PostMapping("/queryLessonCourseware")
 	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/queryLessonCourseware')")
-	public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
-		IPage<LessonCoursewareWrapper.LessonCoursewareDto> pages = lessonCoursewareService.selectPage(QueryInfo.getPage(query), query);
-		return succeed(PageUtil.pageInfo(pages));
+	public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>>
+	queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
+		return succeed(PageUtil.pageInfo(lessonCoursewareService.selectPage(QueryInfo.getPage(query), query)));
 	}
 
 	@ApiOperation(value = "添加课件")
@@ -79,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();
@@ -97,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();
@@ -107,8 +112,24 @@ 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();
 	}
+
+	@ApiOperation(value = "修改适用范围")
+	@PostMapping("/updateRangeType")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/updateRangeType')")
+	public HttpResponseResult updateRangeType(@RequestBody LessonCoursewareWrapper.UpdateRange updateRange){
+		lessonCoursewareService.updateRangeType(updateRange);
+		return succeed();
+	}
+
+	@ApiOperation(value = "获取课件适用范围详情")
+	@GetMapping("/getRangeType")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/getRangeType')")
+	public HttpResponseResult<LessonCoursewareWrapper.UpdateRangeDetail> getRangeType(Integer lessonCoursewareId){
+		return succeed(lessonCoursewareService.getRangeType(lessonCoursewareId));
+	}
 }

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

@@ -251,6 +251,14 @@ public class CourseSchedule  extends BaseEntity{
 	@ApiModelProperty("课件编号")
 	private String coursewareDetailId;
 
+	@Getter
+	@ApiModelProperty("课件是否可以使用")
+	private Boolean coursewareEnable = false;
+
+	public void setCoursewareEnable(Boolean coursewareEnable) {
+		this.coursewareEnable = coursewareEnable;
+	}
+
 	public void setCoursewareDetailId(String coursewareDetailId) {
 		this.coursewareDetailId = coursewareDetailId;
 	}

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

@@ -24,10 +24,26 @@ public class LessonCourseware{
 	@TableField(value = "lesson_course_id_")
 	private Long lessonCourseId;
 
+	@ApiModelProperty(value = "学员适用范围ALL,RANGE,DISABLE")
+	@TableField(value = "student_range_type_")
+	private String studentRangeType;
+
+	@ApiModelProperty(value = "老师适用范围ALL,RANGE,DISABLE")
+	@TableField(value = "teacher_range_type_")
+	private String teacherRangeType;
+
 	@ApiModelProperty(value = "是否启用")
 	@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;

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LessonCoursewareUserMapper.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class LessonCoursewareUserMapper {
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id_", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "课件id")
+    @TableField(value = "lesson_courseware_id_")
+    private Integer lessonCoursewareId;
+
+    @ApiModelProperty(value = "用户类型")
+    @TableField(value = "user_type_")
+    private String userType;
+
+    @ApiModelProperty(value = "用户id")
+    @TableField(value = "user_id_")
+    private Integer userId;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(value = "update_time_")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "create_time_")
+    private Date createTime;
+}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/LessonCoursewareMapper.java

@@ -15,6 +15,8 @@ public interface LessonCoursewareMapper extends BaseMapper<LessonCourseware> {
     List<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(@Param("page") IPage<LessonCoursewareWrapper.LessonCoursewareDto> page,
                                                                  @Param("param") LessonCoursewareWrapper.LessonCoursewareQuery param);
 
+    List<LessonCoursewareWrapper.LessonCoursewareDto> selectList(@Param("param") LessonCoursewareWrapper.LessonCoursewareQuery param);
+
 
     //获取课件关联的声部列表
     List<Subject> getLessonCoursewareSubjectList();

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/LessonCoursewareUserMapperMapper.java

@@ -0,0 +1,15 @@
+package com.ym.mec.biz.dal.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ym.mec.biz.dal.entity.LessonCourseware;
+import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface LessonCoursewareUserMapperMapper extends BaseMapper<LessonCoursewareUserMapper> {
+
+}

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

@@ -1,9 +1,13 @@
 package com.ym.mec.biz.dal.wrapper;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.biz.dal.dto.SimpleUserDto;
+import com.ym.mec.biz.dal.dto.im.BasicUserInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -27,11 +31,26 @@ public class LessonCoursewareWrapper {
 
         private Integer rows = 20;
 
+        private String search;
+
         @ApiModelProperty("声部")
         private Integer subjectId;
 
+        @ApiModelProperty("内容平台课件编号")
+        private List<Long> lessonCoursewareIds;
+
         @ApiModelProperty("启用状态")
         private Boolean enable;
+
+        @ApiModelProperty(value = "学员适用范围ALL,RANGE,DISABLE")
+        private String studentRangeType;
+
+        @ApiModelProperty(value = "老师适用范围ALL,RANGE,DISABLE")
+        private String teacherRangeType;
+
+        private Integer teacherId;
+
+        private Integer studentId;
     }
 
     @Data
@@ -62,6 +81,27 @@ public class LessonCoursewareWrapper {
 
         @ApiModelProperty("声部id")
         private Integer subjectId;
+
+        @ApiModelProperty(value = "学员适用范围ALL,RANGE,DISABLE")
+        private String studentRangeType;
+
+        @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
@@ -96,4 +136,53 @@ public class LessonCoursewareWrapper {
 
     }
 
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel("updateRangeTypeDto-修改适用范围")
+    public static class UpdateRange{
+
+        @ApiModelProperty(value = "课件编号")
+        private Integer lessonCoursewareId;
+
+        @ApiModelProperty(value = "学员适用范围ALL,RANGE,DISABLE")
+        private String studentRangeType;
+
+        @ApiModelProperty(value = "学员编号")
+        private List<Integer> studentIds;
+
+        @ApiModelProperty(value = "老师适用范围ALL,RANGE,DISABLE")
+        private String teacherRangeType;
+
+        @ApiModelProperty(value = "老师编号")
+        private List<Integer> teacherIds;
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel("UpdateRangeDetail-获取适用范围")
+    public static class UpdateRangeDetail{
+
+        @ApiModelProperty(value = "课件编号")
+        private Integer lessonCoursewareId;
+
+        @ApiModelProperty(value = "课件名称")
+        private String name;
+
+        @ApiModelProperty(value = "学员适用范围ALL,RANGE,DISABLE")
+        private String studentRangeType;
+
+        @ApiModelProperty(value = "老师适用范围ALL,RANGE,DISABLE")
+        private String teacherRangeType;
+
+        @ApiModelProperty(value = "适用学员列表")
+        private List<SimpleUserDto> studentList;
+
+        @ApiModelProperty(value = "适用老师列表")
+        private List<SimpleUserDto> teacherList;
+    }
+
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareService.java

@@ -12,5 +12,11 @@ public interface LessonCoursewareService extends IService<LessonCourseware> {
 
     //分页查询已添加的课件
     IPage<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(IPage<LessonCoursewareWrapper.LessonCoursewareDto> page, LessonCoursewareWrapper.LessonCoursewareQuery query);
+
+    //修改课件适用范围
+    void updateRangeType(LessonCoursewareWrapper.UpdateRange updateRange);
+
+    //获取课件适用范围
+    LessonCoursewareWrapper.UpdateRangeDetail getRangeType(Integer lessonCoursewareId);
 }
 

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareUserMapperService.java

@@ -0,0 +1,13 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
+import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
+import com.ym.mec.biz.dal.mapper.LessonCoursewareUserMapperMapper;
+
+public interface LessonCoursewareUserMapperService extends IService<LessonCoursewareUserMapper> {
+
+    LessonCoursewareUserMapperMapper getDao();
+
+}
+

+ 1 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1422,21 +1422,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
         Set<Long> homeworkCourseIds = studentServeService.getTeacherHomeworkCourseIdsWithMonday(userId, classDate);
 
-        for (CourseScheduleDto courseScheduleDto : teacherCourseSchedulesWithDate) {
+		for (CourseScheduleDto courseScheduleDto : teacherCourseSchedulesWithDate) {
             Long studentNum = studentNumCourseMap.get(courseScheduleDto.getId());
             if (Objects.nonNull(studentNum)) {
                 courseScheduleDto.setStudentAttendanceIsFirstTime(studentNum > 0 ? 0 : 1);
             } else {
                 courseScheduleDto.setStudentAttendanceIsFirstTime(1);
             }
-
-//            if (now.before(courseScheduleDto.getStartClassTime())) {
-//            courseScheduleDto.setStatus(CourseStatusEnum.NOT_START);
-//            } else if (now.after(courseScheduleDto.getEndClassTime())) {
-//            courseScheduleDto.setStatus(CourseStatusEnum.OVER);
-//            } else {
-//            courseScheduleDto.setStatus(CourseStatusEnum.UNDERWAY);
-//            }
             if (Objects.nonNull(courseScheduleDto.getClassGroupId())) {
                 //                String[] studentNames = classGroupStudentMapperDao.findCourseStudentName(courseScheduleDto.getId().intValue());
                 List<StudentNameAndPhoneDto> courseStudentNameAndPhone = classGroupStudentMapperDao.findCourseStudentNameAndPhone(courseScheduleDto.getId().intValue());

+ 125 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -4,24 +4,28 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
+import com.microsvc.toolkit.common.response.template.R;
 import com.ym.mec.biz.dal.dao.SubjectDao;
-import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.LessonCourseware;
+import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
+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.SubjectService;
+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;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 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
@@ -34,14 +38,35 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
     public LessonCoursewareMapper getDao() {
         return this.baseMapper;
     }
-
-    @Autowired
+    @Resource
     private CoursewareFeignService coursewareFeignService;
     @Resource
+    private LessonCoursewareUserMapperService lessonCoursewareUserMapperService;
+    @Resource
+    private SysUserService sysUserService;
+    @Resource
     private SubjectDao subjectDao;
+    @Resource
+    private TeacherDao teacherDao;
 
     @Override
     public IPage<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(IPage<LessonCoursewareWrapper.LessonCoursewareDto> page, LessonCoursewareWrapper.LessonCoursewareQuery query) {
+        if(StringUtils.isNotEmpty(query.getSearch())){
+            List<LessonCoursewareWrapper.LessonCoursewareDto> dtos = baseMapper.selectList(query);
+            if(CollectionUtils.isNotEmpty(dtos)){
+                List<Long> lessonCoursewareIds = dtos.stream().map(LessonCoursewareWrapper.LessonCoursewareDto::getLessonCoursewareId).collect(Collectors.toList());
+                CbsLessonCoursewareWrapper.LambdaQuery lambdaQuery = new CbsLessonCoursewareWrapper.LambdaQuery();
+                lambdaQuery.setIds(lessonCoursewareIds);
+                lambdaQuery.setKeyword(query.getSearch());
+                List<CbsLessonCoursewareWrapper.Entity> entityList = coursewareFeignService.lessonCoursewareLambdaQuery(lambdaQuery).feignData();
+                if(CollectionUtils.isNotEmpty(entityList)){
+                    List<Long> collect = entityList.stream().map(e -> e.getId()).collect(Collectors.toList());
+                    query.setLessonCoursewareIds(collect);
+                }else {
+                    return page;
+                }
+            }
+        }
         List<LessonCoursewareWrapper.LessonCoursewareDto> dtos = baseMapper.selectPage(page, query);
         if(CollectionUtils.isNotEmpty(dtos)){
             List<Long> lessonCoursewareIds = dtos.stream().map(LessonCoursewareWrapper.LessonCoursewareDto::getLessonCoursewareId).collect(Collectors.toList());
@@ -51,27 +76,111 @@ 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);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateRangeType(LessonCoursewareWrapper.UpdateRange updateRange) {
+        LessonCourseware lessonCourseware = this.getById(updateRange.getLessonCoursewareId());
+        if (Objects.isNull(lessonCourseware)) {
+            throw new RuntimeException("课件不存在");
+        }
+        lessonCourseware.setStudentRangeType(updateRange.getStudentRangeType());
+        lessonCourseware.setTeacherRangeType(updateRange.getTeacherRangeType());
+        lessonCourseware.setUpdateBy(sysUserService.getUserId());
+        this.updateById(lessonCourseware);
+        lessonCoursewareUserMapperService.lambdaUpdate()
+                .eq(LessonCoursewareUserMapper::getLessonCoursewareId, updateRange.getLessonCoursewareId()).remove();
+        if(StringUtils.equals(updateRange.getStudentRangeType(), "RANGE") && CollectionUtils.isNotEmpty(updateRange.getStudentIds())){
+            List<LessonCoursewareUserMapper> list = updateRange.getStudentIds().stream().map(e -> {
+                LessonCoursewareUserMapper mapper = new LessonCoursewareUserMapper();
+                mapper.setLessonCoursewareId(updateRange.getLessonCoursewareId());
+                mapper.setUserId(e);
+                mapper.setUserType("STUDENT");
+                return mapper;
+            }).collect(Collectors.toList());
+            lessonCoursewareUserMapperService.saveBatch(list);
+        }
+        if(StringUtils.equals(updateRange.getTeacherRangeType(), "RANGE") && CollectionUtils.isNotEmpty(updateRange.getTeacherIds())){
+            List<LessonCoursewareUserMapper> list = updateRange.getTeacherIds().stream().map(e -> {
+                LessonCoursewareUserMapper mapper = new LessonCoursewareUserMapper();
+                mapper.setLessonCoursewareId(updateRange.getLessonCoursewareId());
+                mapper.setUserId(e);
+                mapper.setUserType("TEACHER");
+                return mapper;
+            }).collect(Collectors.toList());
+            lessonCoursewareUserMapperService.saveBatch(list);
+        }
+    }
+
+    @Override
+    public LessonCoursewareWrapper.UpdateRangeDetail getRangeType(Integer lessonCoursewareId) {
+        LessonCourseware lessonCourseware = this.getById(lessonCoursewareId);
+        if (Objects.isNull(lessonCourseware)) {
+            throw new RuntimeException("课件不存在");
+        }
+        R<CbsLessonCoursewareWrapper.LessonCourseware> lessonCoursewareR = coursewareFeignService.lessonCoursewareDetail(lessonCourseware.getLessonCourseId());
+        if (!lessonCoursewareR.getCode().equals(200)) {
+            throw new BizException("获取课件详情失败 {}", lessonCoursewareR.getMessage());
+        }
+        LessonCoursewareWrapper.UpdateRangeDetail detail = new LessonCoursewareWrapper.UpdateRangeDetail();
+        detail.setName(lessonCoursewareR.getData().getName());
+        detail.setLessonCoursewareId(lessonCoursewareId);
+        detail.setStudentRangeType(lessonCourseware.getStudentRangeType());
+        detail.setTeacherRangeType(lessonCourseware.getTeacherRangeType());
+        if(lessonCourseware.getStudentRangeType().equals("RANGE")){
+            List<LessonCoursewareUserMapper> studentList = lessonCoursewareUserMapperService.lambdaQuery()
+                    .eq(LessonCoursewareUserMapper::getLessonCoursewareId, lessonCoursewareId)
+                    .eq(LessonCoursewareUserMapper::getUserType, "STUDENT").list();
+            if(CollectionUtils.isNotEmpty(studentList)){
+                List<Integer> studentIds = studentList.stream().map(LessonCoursewareUserMapper::getUserId).collect(Collectors.toList());
+                List<SimpleUserDto> userDtoList = teacherDao.getUsersSimpleInfo(studentIds);
+                if (CollectionUtils.isNotEmpty(userDtoList)) {
+                    for (SimpleUserDto userDto : userDtoList) {
+                        userDto.setUserName(userDto.getNickName());
+                    }
                 }
+                detail.setStudentList(userDtoList);
             }
         }
-        return page.setRecords(dtos);
+        if(lessonCourseware.getTeacherRangeType().equals("RANGE")){
+            List<LessonCoursewareUserMapper> teacherList = lessonCoursewareUserMapperService.lambdaQuery()
+                    .eq(LessonCoursewareUserMapper::getLessonCoursewareId, lessonCoursewareId)
+                    .eq(LessonCoursewareUserMapper::getUserType, "TEACHER").list();
+            if(CollectionUtils.isNotEmpty(teacherList)){
+                List<Integer> teacherIds = teacherList.stream().map(LessonCoursewareUserMapper::getUserId).collect(Collectors.toList());
+                List<SimpleUserDto> userDtoList = teacherDao.getUsersSimpleInfo(teacherIds);
+                detail.setTeacherList(userDtoList);
+            }
+        }
+        return detail;
     }
 
 }

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareUserMapperServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
+import com.ym.mec.biz.dal.mapper.LessonCoursewareUserMapperMapper;
+import com.ym.mec.biz.service.LessonCoursewareUserMapperService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+@Service
+public class LessonCoursewareUserMapperServiceImpl extends ServiceImpl<LessonCoursewareUserMapperMapper, LessonCoursewareUserMapper> implements LessonCoursewareUserMapperService {
+
+    private final static Logger log = LoggerFactory.getLogger(LessonCoursewareUserMapperServiceImpl.class);
+
+
+    @Override
+    public LessonCoursewareUserMapperMapper getDao() {
+        return this.baseMapper;
+    }
+
+}
+

+ 39 - 6
mec-biz/src/main/resources/config/mybatis/LessonCoursewareMapper.xml

@@ -1,18 +1,51 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.ym.mec.biz.dal.mapper.LessonCoursewareMapper">
-    
-    <select id="selectPage" resultType="com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper$LessonCoursewareDto">
-        select id_ id, subject_id_ subjectId, lesson_course_id_ lessonCoursewareId, enable_ enable from lesson_courseware
+
+    <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'))
+            </if>
+            <if test="param.teacherId != null">
+                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
+                <foreach collection="param.lessonCoursewareIds" item="lessonCoursewareId" open="(" close=")" separator=",">
+                    #{lessonCoursewareId}
+                </foreach>
+            </if>
             <if test="param.subjectId != null">
-                and 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}
+            </if>
+            <if test="param.teacherRangeType != null and param.teacherRangeType != ''">
+                and lc.teacher_range_type_ = #{param.teacherRangeType}
             </if>
             <if test="param.enable != null">
-                and enable_ = #{param.enable}
+                and lc.id_enable_ = #{param.enable}
             </if>
         </where>
-        order by create_time_ desc
+    </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.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"/>
+        GROUP BY lc.id_
+        order by lc.create_time_ desc
+	</select>
+    <select id="selectList" 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 from lesson_courseware lc
+        left join lesson_courseware_user_mapper lcum ON lcum.lesson_courseware_id_ = lc.id_
+        <include refid="selectPageSql"/>
+        GROUP BY lc.id_
+        order by lc.create_time_ desc
 	</select>
     <select id="getLessonCoursewareSubjectList" resultMap="com.ym.mec.biz.dal.dao.SubjectDao.Subject">
         select s.* from lesson_courseware lc

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/LessonCoursewareUserMapperMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ym.mec.biz.dal.mapper.LessonCoursewareUserMapperMapper">
+
+</mapper>

+ 1 - 1
pom.xml

@@ -26,7 +26,7 @@
 		<docker.registry.repository>127.0.0.1:5000</docker.registry.repository>
 		<docker.maven.plugin.version>1.2.2</docker.maven.plugin.version>
 		<com.microsvc.toolkit.version>1.0.4</com.microsvc.toolkit.version>
-		<cbs.version>1.0.4</cbs.version>
+		<cbs.version>1.0.10</cbs.version>
 	</properties>
 
 	<dependencyManagement>