he2802 2 سال پیش
والد
کامیت
1e1f28c74b

+ 16 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -182,6 +182,14 @@ public class GoodsController extends BaseController {
         return toAjax(iGoodsService.insertBankByAddBo(bo)>0 ? 1 : 0);
     }
 
+    @ApiOperation("新增讲义商品")
+    @PreAuthorize("@ss.hasPermi('system:goods:add')")
+    @Log(title = "商品", businessType = BusinessType.INSERT)
+    @PostMapping("/handouts")
+    public AjaxResult<Void> addHandouts(@RequestBody GoodsAddBo bo) {
+        return toAjax(iGoodsService.insertHandoutsByAddBo(bo)>0 ? 1 : 0);
+    }
+
     /**
      * 修改商品
      */
@@ -193,6 +201,14 @@ public class GoodsController extends BaseController {
         return toAjax(iGoodsService.updateBankByEditBo(bo) ? 1 : 0);
     }
 
+    @ApiOperation("修改讲义商品")
+    @PreAuthorize("@ss.hasPermi('system:goods:edit')")
+    @Log(title = "讲义商品", businessType = BusinessType.UPDATE)
+    @PostMapping("/handouts/edit")
+    public AjaxResult<Void> editHandouts(@RequestBody GoodsEditBo bo) {
+        return toAjax(iGoodsService.updateHandoutsByEditBo(bo) ? 1 : 0);
+    }
+
     /**
      * 查询题目业务层次关系列表
      */

+ 13 - 5
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/CommonCourseController.java

@@ -16,12 +16,10 @@ import com.zhongzheng.modules.bank.service.IQuestionModuleChapterService;
 import com.zhongzheng.modules.bank.vo.ExamQuestionVo;
 import com.zhongzheng.modules.bank.vo.ExamVo;
 import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+import com.zhongzheng.modules.course.bo.CourseHandoutsFileQueryBo;
 import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
 import com.zhongzheng.modules.course.bo.CourseSubjectQueryBo;
-import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
-import com.zhongzheng.modules.course.service.ICourseMenuService;
-import com.zhongzheng.modules.course.service.ICourseModuleChapterService;
-import com.zhongzheng.modules.course.service.ICourseSubjectService;
+import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.*;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherQueryBo;
@@ -66,7 +64,7 @@ public class CommonCourseController extends BaseController {
 
     private final ICourseSubjectService iCourseSubjectService;
 
-
+    private final ICourseHandoutsService iCourseHandoutsService;
 
     /**
      * 查询课程目录结构列表
@@ -120,4 +118,14 @@ public class CommonCourseController extends BaseController {
         List<CourseSubjectVo> list = iCourseSubjectService.queryList(bo);
         return AjaxResult.success(list);
     }
+
+    /**
+     * 获取讲义列详细信息
+     */
+    @ApiOperation("获取讲义列详细信息去地址")
+    @GetMapping("/handouts/file/detail")
+    public AjaxResult<CourseHandoutsVo> getInfo(CourseHandoutsFileQueryBo queryBo) {
+        CourseHandoutsVo detail = iCourseHandoutsService.queryByIdNoUrl(queryBo);
+        return AjaxResult.success(detail);
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseHandoutsService.java

@@ -24,6 +24,8 @@ public interface ICourseHandoutsService extends IService<CourseHandouts> {
 	 */
 	CourseHandoutsVo queryById(CourseHandoutsFileQueryBo queryBo);
 
+	CourseHandoutsVo queryByIdNoUrl(CourseHandoutsFileQueryBo queryBo);
+
 	/**
 	 * 查询列表
 	 */

+ 53 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseHandoutsServiceImpl.java

@@ -79,7 +79,7 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
                 String path = file.getUrlName();
                 file.setFilePath(getFilePath(file, path));
                 if (file.getType() == 2) {
-                    handleCourseFile(file);
+                    handleCourseFile(file,true);
                 }
             });
             courseHandoutsVo.setFileList(courseFileVos);
@@ -87,7 +87,48 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
             List<CourseFileVo> fileVos = courseFileVos.stream().filter(item -> item.getParentId() == 0L).collect(Collectors.toList());
             if (!CollectionUtils.isEmpty(fileVos)) {
                 fileVos.forEach(file -> {
-                    assembleFile(file, courseFileVos);
+                    assembleFile(file, courseFileVos,true);
+                });
+                courseHandoutsVo.setFileList(fileVos);
+            }
+        }
+        return courseHandoutsVo;
+    }
+
+    @Override
+    public CourseHandoutsVo queryByIdNoUrl(CourseHandoutsFileQueryBo queryBo) {
+        CourseHandouts db = this.baseMapper.selectById(queryBo.getHandoutsId());
+        if (Validator.isEmpty(db)) {
+            throw new CustomException("查无数据");
+        }
+        //获得讲义业务层
+        CourseHandoutsVo courseHandoutsVo = BeanUtil.toBean(db, CourseHandoutsVo.class);
+        List<CourseHandoutsBusinessVo> courseHandoutsBusinessVos = baseMapper.selectEntity(courseHandoutsVo.getHandoutsId());
+        courseHandoutsVo.setCourseHandoutsBusinessVo(courseHandoutsBusinessVos);
+
+        CourseFileQueryBo bo = new CourseFileQueryBo();
+        bo.setHandoutsId(courseHandoutsVo.getHandoutsId());
+        bo.setUrlName(queryBo.getFileName());
+        List<CourseFileVo> courseFileVos = iCourseFileService.queryList(bo);
+        if (CollectionUtils.isEmpty(courseFileVos)) {
+            courseHandoutsVo.setFileList(new ArrayList<>());
+            return courseHandoutsVo;
+        }
+        if (StringUtils.isNotBlank(queryBo.getFileName())) {
+            courseFileVos.forEach(file -> {
+                //获取路径
+                String path = file.getUrlName();
+                file.setFilePath(getFilePath(file, path));
+                if (file.getType() == 2) {
+                    handleCourseFile(file,false);
+                }
+            });
+            courseHandoutsVo.setFileList(courseFileVos);
+        } else {
+            List<CourseFileVo> fileVos = courseFileVos.stream().filter(item -> item.getParentId() == 0L).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(fileVos)) {
+                fileVos.forEach(file -> {
+                    assembleFile(file, courseFileVos,false);
                 });
                 courseHandoutsVo.setFileList(fileVos);
             }
@@ -104,7 +145,10 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
         return getFilePath(BeanUtil.toBean(courseFile, CourseFileVo.class), urlName);
     }
 
-    private void handleCourseFile(CourseFileVo file) {
+    private void handleCourseFile(CourseFileVo file,Boolean withUrl) {
+        if(!withUrl){
+            file.setUrl(null);
+        }
         List<CourseFile> list = iCourseFileService
                 .list(new LambdaQueryWrapper<CourseFile>()
                         .eq(CourseFile::getParentId, file.getFileId())
@@ -113,12 +157,15 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
             return;
         }
         list.forEach(item -> {
-            handleCourseFile(BeanUtil.toBean(item, CourseFileVo.class));
+            handleCourseFile(BeanUtil.toBean(item, CourseFileVo.class),withUrl);
         });
         file.setChildren(list.stream().map(x -> BeanUtil.toBean(x, CourseFileVo.class)).collect(Collectors.toList()));
     }
 
-    private void assembleFile(CourseFileVo parent, List<CourseFileVo> childs) {
+    private void assembleFile(CourseFileVo parent, List<CourseFileVo> childs,Boolean withUrl) {
+        if(!withUrl){
+            parent.setUrl(null);
+        }
         if (CollectionUtils.isEmpty(childs)) {
             return;
         }
@@ -128,7 +175,7 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
         }
         parent.setChildren(collect);
         collect.forEach(item -> {
-            assembleFile(item, childs);
+            assembleFile(item, childs,withUrl);
         });
     }
 

+ 16 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -321,8 +321,8 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
             bo.setImportNo(importNo);
             bo.setSectionType(sectionType);
         //    bo.setDurationTime(sectionImport.getDurationTime());
-            bo.setRecordingUrl(sectionImport.getRecordingUrl());
-            bo.setLiveUrl(sectionImport.getLiveUrl());
+            bo.setRecordingUrl(dealTxt(sectionImport.getRecordingUrl()));
+            bo.setLiveUrl(dealTxt(sectionImport.getLiveUrl()));
             bo.setPublishStatus(sectionImport.getPublishStatus().equals("发布")?1:0);
             bo.setStatus(1);
             bo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
@@ -377,6 +377,20 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
         return rs;
     }
 
+    private String dealTxt(String txt) {
+        if(Validator.isEmpty(txt)){
+            return "";
+        }
+        txt = txt.trim();
+        if (txt.startsWith("\\t")) {
+            txt = txt.replace("\\t", "");
+        }
+        if (txt.startsWith("\t")) {
+            txt = txt.replace("\t", "");
+        }
+        return txt;
+    }
+
     @Override
     public Map<String, Object> importChapterSection(List<CourseChapterSectionImport> sectionList,List<CourseSectionBusinessAddBo> businessList, String operName) throws ParseException {
         if (Validator.isNull(sectionList) || sectionList.size() == 0) {

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -55,6 +55,8 @@ public interface IGoodsService extends IService<Goods> {
 
 	Long insertBankByAddBo(GoodsBankAddBo bo);
 
+	Long insertHandoutsByAddBo(GoodsAddBo bo);
+
 	/**
 	 * 根据编辑业务对象修改商品
 	 * @param bo 商品编辑业务对象
@@ -64,6 +66,8 @@ public interface IGoodsService extends IService<Goods> {
 
 	Boolean updateBankByEditBo(GoodsBankEditBo bo);
 
+	Boolean updateHandoutsByEditBo(GoodsEditBo bo);
+
 	/**
 	 * 校验并删除数据
 	 * @param ids 主键集合

+ 41 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -632,6 +632,24 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return add.getGoodsId();
     }
 
+    @Override
+    public Long insertHandoutsByAddBo(GoodsAddBo bo) {
+        if (StringUtils.isNotBlank(bo.getExternalLink())){
+            Pattern pattern = Pattern.compile("^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+$");
+            if (!pattern.matcher(bo.getExternalLink()).matches()){
+                throw new CustomException("请输入正确的商品外链");
+            }
+        }
+        Goods add = BeanUtil.toBean(bo, Goods.class);
+        add.setCode(ServletUtils.getEncoded("SP"));
+        validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        boolean result = this.save(add);
+        Long goodsId = add.getGoodsId();
+        return goodsId;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(GoodsEditBo bo) {
@@ -769,6 +787,29 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return this.updateById(update);
     }
 
+    @Override
+    public Boolean updateHandoutsByEditBo(GoodsEditBo bo) {
+        if (StringUtils.isNotBlank(bo.getExternalLink())){
+            Pattern pattern = Pattern.compile("^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+$");
+            if (!pattern.matcher(bo.getExternalLink()).matches()){
+                throw new CustomException("请输入正确的商品外链");
+            }
+        }
+        Goods update = BeanUtil.toBean(bo, Goods.class);
+        validEntityBeforeSave(update);
+        update.setUpdateTime(DateUtils.getNowTime());
+
+        //购买须知
+        if (Validator.isEmpty(bo.getBuyNote())) {
+            LambdaUpdateWrapper<Goods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+            objectLambdaUpdateWrapper.eq(Goods::getGoodsId, bo.getGoodsId());
+            objectLambdaUpdateWrapper.set(Goods::getBuyNote, null);
+            update(null, objectLambdaUpdateWrapper);
+        }
+
+        return this.updateById(update);
+    }
+
     /**
      * 保存前的数据校验
      *

+ 8 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -339,13 +339,14 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
         if(Validator.isEmpty(courseSectionVo)){
             throw new CustomException("节数据错误");
         }
+        GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
+        String fullName;
+        CourseBusinessQueryBo queryBusinessBo = new CourseBusinessQueryBo();
+        queryBusinessBo.setId(goodsVo.getBusinessId());
+        fullName = iCourseBusinessService.queryFullName(queryBusinessBo);
         //判断录播拍照是否达标
         if(courseSectionVo.getSectionType()==1&&Validator.isNotEmpty(bo.getStatus())&&bo.getStatus()==1){
-            GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
             if(Validator.isNotEmpty(goodsVo)){
-                CourseBusinessQueryBo queryBo = new CourseBusinessQueryBo();
-                queryBo.setId(goodsVo.getBusinessId());
-                String fullName = iCourseBusinessService.queryFullName(queryBo);
                 if(Validator.isNotEmpty(fullName)){
                     if(fullName.equals("继续教育二级建造师")||fullName.equals("继续教育二级造价师")||fullName.equals("考前培训七大员施工现场专业人员")){
                         if(Validator.isNotEmpty(courseSectionVo.getDurationTime())||Validator.isNotEmpty(bo.getVideoCurrentTime())){
@@ -477,6 +478,9 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
             UserStudyRecordVo lastVo = queryLast(queryBo);
             if(Validator.isEmpty(lastVo)||Validator.isNotEmpty(bo.getPhoto())||Validator.isEmpty(lastVo.getVideoCurrentTime())||lastVo.getVideoCurrentTime().longValue()>add.getVideoCurrentTime().longValue()){
                 //如果没有历史数据或者之前播放时长比现在晚,或者携带照片则新增观看记录
+                if(Validator.isNotEmpty(fullName)&&(fullName.equals("考前培训七大员施工现场专业人员")||fullName.equals("考前培训一级建造师"))){
+                    bo.setErJianErZao(true);
+                }
                 if(Validator.isNotEmpty(lastVo)&&Validator.isNotEmpty(lastVo.getSectionId())
                         &&Validator.isNotEmpty(bo.getErJianErZao())&&bo.getErJianErZao()
                         &&Validator.isEmpty(bo.getPhoto())&&(lastVo.getVideoCurrentTime().longValue()>add.getVideoCurrentTime().longValue())){