zouxuan 1 год назад
Родитель
Сommit
5f40e1104f

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

@@ -0,0 +1,64 @@
+package com.ym.mec.student.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
+import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
+import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
+import com.google.common.collect.Lists;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.response.template.R;
+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.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.security.access.prepost.PreAuthorize;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RequestMapping("${app-config.url.student:}/lessonCourseware")
+@Api(tags = "课件教材")
+@RestController
+public class LessonCoursewareController extends BaseController {
+
+	@Resource
+	private CoursewareFeignService coursewareFeignService;
+	@Resource
+	private LessonCoursewareService lessonCoursewareService;
+
+	@ApiOperation(value = "分页查询已添加的课件")
+	@PostMapping("/queryLessonCourseware")
+	public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
+		query.setEnable(true);
+		IPage<LessonCoursewareWrapper.LessonCoursewareDto> pages = lessonCoursewareService.selectPage(QueryInfo.getPage(query), query);
+		return succeed(PageUtil.pageInfo(pages));
+	}
+
+	@ApiOperation(value = "获取课件详情")
+	@GetMapping("/getLessonCoursewareDetail/{id}")
+	public HttpResponseResult<CbsLessonCoursewareWrapper.LessonCourseware> getLessonCoursewareDetail(@PathVariable("id") Long id){
+		return succeed(coursewareFeignService.lessonCoursewareDetail(id).feignData());
+	}
+
+	@ApiOperation(value = "获取课件关联的课程列表")
+	@GetMapping("/getLessonCoursewareCourseList/{id}")
+	public HttpResponseResult<List<CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail>> getLessonCoursewareCourseList(@PathVariable("id") Long id){
+		CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail cbsQuery =
+				new CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail();
+		cbsQuery.setLessonCoursewareId(id);
+		return succeed(coursewareFeignService.lessonCoursewareDetailList(cbsQuery).feignData());
+	}
+
+	@ApiOperation(value = "获取课程详情")
+	@GetMapping("/getLessonCourseDetail/{id}")
+	public HttpResponseResult<CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail> getLessonCourseDetail(@PathVariable("id") Long id){
+		return succeed(coursewareFeignService.lessonCoursewareDetailDetail(id).feignData());
+	}
+}

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

@@ -0,0 +1,91 @@
+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;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.ym.mec.biz.dal.entity.LessonCourseware;
+import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
+import com.ym.mec.biz.dal.wrapper.SchoolActivityWrapper;
+import com.ym.mec.biz.service.LessonCoursewareService;
+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.security.access.prepost.PreAuthorize;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RequestMapping("${app-config.url.web:}/lessonCourseware")
+@Api(tags = "课件教材")
+@RestController
+public class LessonCoursewareController extends BaseController {
+
+	@Resource
+	private CoursewareFeignService coursewareFeignService;
+	@Resource
+	private LessonCoursewareService lessonCoursewareService;
+
+	@ApiOperation(value = "获取内容平台课件教材")
+	@PostMapping("/queryPage")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/queryPage')")
+	public HttpResponseResult<PageInfo<CbsLessonCoursewareWrapper.LessonCourseware>> queryPage(@RequestBody CbsLessonCoursewareWrapper.LessonCoursewareQuery query) throws Exception {
+		return succeed(PageUtil.pageInfo(coursewareFeignService.lessonCoursewarePage(query).feignData()));
+	}
+
+	@ApiOperation(value = "获取已添加的课件id列表")
+	@PostMapping("/queryLessonCoursewareId")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/queryLessonCoursewareId')")
+	public HttpResponseResult<List<Long>> queryLessonCoursewareId(){
+		List<LessonCourseware> list = lessonCoursewareService.lambdaQuery().list();
+		if (list == null || list.isEmpty()) {
+			return succeed(Lists.newArrayList());
+		}
+		List<Long> ids = list.stream().map(LessonCourseware::getLessonCourseId).collect(java.util.stream.Collectors.toList());
+		return succeed(ids);
+	}
+
+	@ApiOperation(value = "批量删除已添加的课件")
+	@PostMapping("/deleteLessonCourseware")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/deleteLessonCourseware')")
+	public HttpResponseResult<Boolean> deleteLessonCourseware(@RequestBody List<Long> ids){
+		if (CollectionUtils.isEmpty(ids)) {
+			return succeed(false);
+		}
+		return succeed(lessonCoursewareService.removeByIds(ids));
+	}
+
+	@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));
+	}
+
+	@ApiOperation(value = "启用、停用课件")
+	@GetMapping("/updateEnableFlag")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/updateEnableFlag')")
+	public HttpResponseResult updateEnableFlag(Integer id,Boolean enableFlag){
+		lessonCoursewareService.lambdaUpdate().set(LessonCourseware::getEnable, enableFlag)
+				.eq(LessonCourseware::getId, id)
+				.update();
+		return succeed();
+	}
+
+	@ApiOperation(value = "修改课件声部")
+	@GetMapping("/updateSubject")
+	@PreAuthorize("@pcs.hasPermissions('lessonCourseware/updateSubject')")
+	public HttpResponseResult updateSubject(Integer id,Integer subjectId){
+		lessonCoursewareService.lambdaUpdate().set(LessonCourseware::getSubjectId, subjectId)
+				.eq(LessonCourseware::getId, id)
+				.update();
+		return succeed();
+	}
+}

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

@@ -0,0 +1,29 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class LessonCourseware extends BaseEntity {
+	@ApiModelProperty(value = "主键")
+	private Integer id;
+
+	@ApiModelProperty(value = "关联声部")
+	private Integer subjectId;
+
+	@ApiModelProperty(value = "课件编号")
+	private Long lessonCourseId;
+
+	@ApiModelProperty(value = "是否启用")
+	private Boolean enable;
+
+	@ApiModelProperty(value = "更新时间")
+	private Date updateTime;
+
+	@ApiModelProperty(value = "创建时间")
+	private Date createTime;
+}

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

@@ -0,0 +1,18 @@
+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.wrapper.LessonCoursewareWrapper;
+import com.ym.mec.biz.dal.wrapper.SchoolActivityWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface LessonCoursewareMapper extends BaseMapper<LessonCourseware> {
+
+    List<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(@Param("page") IPage<LessonCoursewareWrapper.LessonCoursewareDto> page,
+                                                                 @Param("param") LessonCoursewareWrapper.LessonCoursewareQuery param);
+
+
+}

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

@@ -0,0 +1,61 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Optional;
+
+/**
+ * 课件教材
+ */
+@ApiModel(value = "LessonCoursewareWrapper对象", description = "课件教材")
+public class LessonCoursewareWrapper {
+
+    @Data
+	@Builder
+    @ApiModel("课件教材分页查询")
+    public static class LessonCoursewareQuery implements QueryInfo {
+
+        @ApiModelProperty("声部")
+        private Integer subjectId;
+
+        @ApiModelProperty("启用状态")
+        private Boolean enable;
+    }
+
+    @Data
+	@Builder
+    @ApiModel("课件教材dto")
+    public static class LessonCoursewareDto{
+        private Integer id;
+
+        @ApiModelProperty("课件编号")
+		private Long lessonCoursewareId;
+
+        @ApiModelProperty("课件名称")
+		private String name;
+
+        @ApiModelProperty("封面")
+        private String cover;
+
+        @ApiModelProperty("启用状态")
+        private Boolean enable;
+
+        @ApiModelProperty("课时数")
+        private Integer courseNum;
+
+        @ApiModelProperty("声部")
+        private String subjectName;
+
+        @ApiModelProperty("声部id")
+        private Integer subjectId;
+    }
+
+}

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

@@ -0,0 +1,16 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
+import com.ym.mec.biz.dal.entity.LessonCourseware;
+import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
+
+public interface LessonCoursewareService extends IService<LessonCourseware> {
+
+    LessonCoursewareMapper getDao();
+
+    //分页查询已添加的课件
+    IPage<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(IPage<LessonCoursewareWrapper.LessonCoursewareDto> page, LessonCoursewareWrapper.LessonCoursewareQuery query);
+}
+

+ 76 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -0,0 +1,76 @@
+package com.ym.mec.biz.service.impl;
+
+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.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
+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.SubjectService;
+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.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMapper, LessonCourseware> implements LessonCoursewareService {
+
+    private final static Logger log = LoggerFactory.getLogger(LessonCoursewareServiceImpl.class);
+
+
+    @Override
+    public LessonCoursewareMapper getDao() {
+        return this.baseMapper;
+    }
+
+    @Resource
+    private CoursewareFeignService coursewareFeignService;
+    @Resource
+    private SubjectDao subjectDao;
+
+    @Override
+    public IPage<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(IPage<LessonCoursewareWrapper.LessonCoursewareDto> page, LessonCoursewareWrapper.LessonCoursewareQuery query) {
+        List<LessonCoursewareWrapper.LessonCoursewareDto> dtos = baseMapper.selectPage(page, 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);
+            List<CbsLessonCoursewareWrapper.Entity> entityList = coursewareFeignService.lessonCoursewareLambdaQuery(lambdaQuery).feignData();
+            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))));
+                for (LessonCoursewareWrapper.LessonCoursewareDto e : dtos) {
+                    CbsLessonCoursewareWrapper.Entity entity = entityMap.get(e.getLessonCoursewareId());
+                    if (Objects.isNull(entity)) {
+                        continue;
+                    }
+                    e.setName(entity.getName());
+                    e.setCover(entity.getCoverImg());
+                    e.setCourseNum(entity.getCourseNum());
+                }
+            }
+            String subjectIds = dtos.stream().map(e -> e.getSubjectId().toString()).collect(Collectors.joining(","));
+            if(StringUtils.isNotEmpty(subjectIds)){
+                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);
+    }
+
+}
+

+ 17 - 0
mec-biz/src/main/resources/config/mybatis/LessonCoursewareMapper.xml

@@ -0,0 +1,17 @@
+<?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_ enalbe from lesson_courseware
+        <where>
+            <if test="param.subjectId != null">
+                and subject_id_ = #{param.subjectId}
+            </if>
+            <if test="param.enalbe != null">
+                and enable_ = #{param.enalbe}
+            </if>
+        </where>
+        order by create_time_ desc
+	</select>
+</mapper>

+ 5 - 0
mec-common/common-core/pom.xml

@@ -18,6 +18,11 @@
 
 	<dependencies>
 		<dependency>
+			<groupId>com.dayaedu.cbs.openfeign</groupId>
+			<artifactId>dayaedu-openfeign-client</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
 			<groupId>com.plumelog</groupId>
 			<artifactId>plumelog-logback</artifactId>
 			<version>3.5.3</version>

+ 14 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/page/PageUtil.java

@@ -47,6 +47,20 @@ public class PageUtil {
         return resultPage;
     }
 
+    public static <T> PageInfo<T> pageInfo(com.microsvc.toolkit.common.response.paging.PageInfo<T> source) {
+        if (Objects.isNull(source)) {
+            return new PageInfo<>(1, 20);
+        }
+        int total = Integer.parseInt(String.valueOf(source.getTotal()));
+        int limit = Integer.parseInt(String.valueOf(source.getLimit()));
+        PageInfo<T> resultPage = new PageInfo<>();
+        resultPage.setRows(source.getRows());
+        resultPage.setPageNo(Long.valueOf(source.getCurrent()).intValue());
+        resultPage.setLimit(limit);
+        resultPage.setTotal(total);
+        return resultPage;
+    }
+
     /**
      * 分页有需要拼接时分秒要求的可以使用这个方法
      */