diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/VideoWebInterfaceController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/VideoWebInterfaceController.java index 0684885f0..c568bd93f 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/VideoWebInterfaceController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/VideoWebInterfaceController.java @@ -13,6 +13,7 @@ import com.stdiet.custom.domain.SysOrder; import com.stdiet.custom.domain.SysVideoClassify; import com.stdiet.custom.dto.response.NutritionalVideoResponse; import com.stdiet.custom.dto.response.VideoClassifyResponse; +import com.stdiet.custom.dto.response.VideoClassifyTwoResponse; import com.stdiet.custom.service.ISysNutritionalVideoService; import com.stdiet.custom.service.ISysOrderService; import com.stdiet.custom.service.ISysVideoClassifyService; @@ -71,6 +72,7 @@ public class VideoWebInterfaceController extends BaseController { //客户类型 0未付费客户-playLevel根据上传的标记 1已付费客户-playLevel全为0 sysVideoClassify.setUserType(payed); List list = sysVideoClassifyService.getAllClassifyAndVideo(sysVideoClassify); + return getDataTable(list); } diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java index 178c563c3..2df724fa0 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java @@ -15,10 +15,7 @@ import com.stdiet.common.utils.file.MimeTypeUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils; import com.stdiet.common.utils.sign.AesUtils; import com.stdiet.custom.domain.*; -import com.stdiet.custom.dto.response.CustomerCaseResponse; -import com.stdiet.custom.dto.response.MessageNoticeResponse; -import com.stdiet.custom.dto.response.NutritionQuestionResponse; -import com.stdiet.custom.dto.response.NutritionalVideoResponse; +import com.stdiet.custom.dto.response.*; import com.stdiet.custom.page.WxLogInfo; import com.stdiet.custom.service.*; import com.stdiet.system.service.ISysDictTypeService; @@ -43,6 +40,8 @@ public class WechatAppletController extends BaseController { @Autowired ISysRecipesService iSysRecipesService; @Autowired + ISysNutritionalVideoService iSysNutritionalVideoService; + @Autowired private ISysCustomerCaseService sysCustomerCaseService; @Autowired private ISysWxUserLogService sysWxUserLogService; @@ -79,9 +78,9 @@ public class WechatAppletController extends BaseController { * 查询微信小程序中展示的客户案例 */ @GetMapping("/caseList") - public TableDataInfo caseList(SysCustomerCase sysCustomerCase, @RequestParam(value = "pageSize",required = false,defaultValue = "10")int pageSize, - @RequestParam(value="randomFlag",required = false,defaultValue = "false") boolean randomFlag) { - if(randomFlag){ + public TableDataInfo caseList(SysCustomerCase sysCustomerCase, @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize, + @RequestParam(value = "randomFlag", required = false, defaultValue = "false") boolean randomFlag) { + if (randomFlag) { List reponseList = sysCustomerCaseService.getWxCustomerCaseByRandom(pageSize); //处理ID加密 dealIdEnc(reponseList); @@ -91,7 +90,7 @@ public class WechatAppletController extends BaseController { rspData.setRows(reponseList); rspData.setTotal(pageSize); return rspData; - }else{ + } else { startPage(); sysCustomerCase.setKeywordArray(StringUtils.isNotEmpty(sysCustomerCase.getKeyword()) ? sysCustomerCase.getKeyword().split(",") : null); List list = sysCustomerCaseService.getWxCustomerCaseList(sysCustomerCase); @@ -307,7 +306,7 @@ public class WechatAppletController extends BaseController { * @return */ private void dealIdEnc(List list) { - if(list != null){ + if (list != null) { for (CustomerCaseResponse cus : list) { cus.setId(AesUtils.encrypt(cus.getId() + "", null)); } @@ -349,22 +348,23 @@ public class WechatAppletController extends BaseController { */ /** * 获取小程序展示的营养小知识列表 + * * @param sysNutritionQuestion 查询参数对象 - * @param pageNum 分页当前页码 - * @param pageSize 分页每页数量 - * @param randomFlag 随机标识 true 随机获取指定pageSize数量的营养小知识,不支持分页、模糊查询 false 则正常查询 + * @param pageNum 分页当前页码 + * @param pageSize 分页每页数量 + * @param randomFlag 随机标识 true 随机获取指定pageSize数量的营养小知识,不支持分页、模糊查询 false 则正常查询 * @return */ @GetMapping(value = "/getNutritionQuestionList") public AjaxResult getNutritionQuestionList(SysNutritionQuestion sysNutritionQuestion, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, - @RequestParam(value="randomFlag",required = false,defaultValue = "false") boolean randomFlag) { + @RequestParam(value = "randomFlag", required = false, defaultValue = "false") boolean randomFlag) { sysNutritionQuestion.setShowFlag(1); - if(randomFlag){ + if (randomFlag) { //随机获取指定条数 sysNutritionQuestion.setKey(null); List list = sysNutritionQuestionService.getNutritionQuestionByRandom(sysNutritionQuestion, pageSize); return AjaxResult.success(list); - }else{ + } else { Map result = sysNutritionQuestionService.getNutritionQuestionListByKey(sysNutritionQuestion, pageNum, pageSize); return AjaxResult.success(result); } @@ -421,7 +421,7 @@ public class WechatAppletController extends BaseController { sysNutritionalVideo.setUserType(1); } } - if(sysNutritionalVideo.getCateId() != null && sysNutritionalVideo.getCateId().longValue() == 0){ + if (sysNutritionalVideo.getCateId() != null && sysNutritionalVideo.getCateId().longValue() == 0) { sysNutritionalVideo.setCateId(null); } startPage(); @@ -435,7 +435,6 @@ public class WechatAppletController extends BaseController { */ @GetMapping(value = "/getVideoDetailById") public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) { - AjaxResult result = AjaxResult.success(); NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); try { SysNutritionalVideo sysNutritionalVideo = sysNutritionalVideoService.selectSysNutritionalVideByVideoId(videoId); @@ -458,8 +457,7 @@ public class WechatAppletController extends BaseController { } catch (Exception e) { e.printStackTrace(); } - result.put("videoDetail", nutritionalVideoResponse); - return result; + return AjaxResult.success(nutritionalVideoResponse); } /** @@ -742,33 +740,34 @@ public class WechatAppletController extends BaseController { /** * 获取视频分类 + * * @param openid * @return */ @GetMapping("/getVideoClassify") - public AjaxResult getVideoClassify(@RequestParam("openid")String openid) { + public AjaxResult getVideoClassify(@RequestParam("openid") String openid) { SysVideoClassify param = new SysVideoClassify(); param.setParentId(0L); List list = sysVideoClassifyService.getAllClassify(param); - List>> result = new ArrayList<>(); + List>> result = new ArrayList<>(); int groupCount = 3; SysVideoClassify all = new SysVideoClassify(); all.setId(0L); all.setCateName("全部内容"); list.add(0, all); - if(list != null && list.size() > 0){ + if (list != null && list.size() > 0) { //分成三组 - int groupNum = list.size()/groupCount + (list.size() % groupCount > 0 ? 1 : 0); + int groupNum = list.size() / groupCount + (list.size() % groupCount > 0 ? 1 : 0); for (int i = 0; i < groupNum; i++) { - List> groupList = new ArrayList<>(); - for (int j = i * groupCount; j < (i+1)*groupCount; j++) { - if(j < list.size()){ - Map videoClassifyMap = new HashMap<>(); + List> groupList = new ArrayList<>(); + for (int j = i * groupCount; j < (i + 1) * groupCount; j++) { + if (j < list.size()) { + Map videoClassifyMap = new HashMap<>(); SysVideoClassify sysVideoClassify = list.get(j); videoClassifyMap.put("cateName", sysVideoClassify.getCateName()); videoClassifyMap.put("cateId", sysVideoClassify.getId()); groupList.add(videoClassifyMap); - }else{ + } else { break; } } @@ -777,6 +776,70 @@ public class WechatAppletController extends BaseController { } return AjaxResult.success(result); } + + @GetMapping("/studyVideoClassify") + public AjaxResult fetchStudyVideoClassify(@RequestParam String openid) { + int payed = 0; + SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(openid); + if (StringUtils.isNotNull(userInfo)) { + List orders = sysOrderService.getAllOrderByCusId(userInfo.getCusId()); + if (StringUtils.isNotEmpty(orders)) { + payed = 1; + } + } + + SysVideoClassify sysVideoClassify = new SysVideoClassify(); + //父级分类ID 0表示主分类 + sysVideoClassify.setParentId(4l); + //客户类型 0未付费客户-playLevel根据上传的标记 1已付费客户-playLevel全为0 + sysVideoClassify.setUserType(payed); + List list = sysVideoClassifyService.getAllClassifyAndVideo(sysVideoClassify); + + String imgUrl = "https://stdiet.oss-cn-shenzhen.aliyuncs.com/videoCover/2021-07-12/"; + if (StringUtils.isNotNull(list)) { + for (VideoClassifyResponse res : list) { + List classifies = res.getChildrenClassify(); + if (StringUtils.isEmpty(classifies)) { + res.setImgUrl(AliyunOSSUtils.generatePresignedUrl(imgUrl + res.getId() + ".png")); + } else { + for (VideoClassifyResponse twoRes : classifies) { + twoRes.setImgUrl(AliyunOSSUtils.generatePresignedUrl(imgUrl + twoRes.getId() + ".png")); + } + } + } + } + + return AjaxResult.success(list); + } + + @GetMapping("/studyVideoComments") + public AjaxResult fetchStudyVideoComments(@RequestParam String openid, @RequestParam String topicId) { + SysVideoComment videoComment = new SysVideoComment(); + videoComment.setTopicId(topicId); + List comments = iSysNutritionalVideoService.selectVideoCommentByTopicId(videoComment, openid); + return AjaxResult.success(comments); + } + + @PostMapping("/video/post/comment") + public AjaxResult videoPostComment(@RequestBody SysVideoComment videoComment, @RequestParam String openid) { + SysVideoComment comment = iSysNutritionalVideoService.insertVideoComment(videoComment); + if (StringUtils.isNull(comment)) { + return AjaxResult.error(); + } + + return AjaxResult.success(comment); + } + + @PostMapping(value = "/video/post/reply") + public AjaxResult videoPostReply(@RequestBody SysVideoComment videoComment, @RequestParam String openid) { + SysVideoComment reply = iSysNutritionalVideoService.insertVideoCommentReply(videoComment); + + if (StringUtils.isNull(reply)) { + return AjaxResult.error(); + } + + return AjaxResult.success(reply); + } } diff --git a/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java b/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java index 87fdda38f..4291edb72 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java +++ b/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java @@ -2,6 +2,9 @@ package com.stdiet.common.core.domain.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.stdiet.common.annotation.Excel; @@ -16,6 +19,7 @@ import java.util.List; * * @author stdiet */ +@JsonInclude(JsonInclude.Include.NON_NULL) public class SysDictData extends BaseEntity { private static final long serialVersionUID = 1L; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/VideoClassifyResponse.java b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/VideoClassifyResponse.java index 8ed1199ad..ff3f99b3d 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/VideoClassifyResponse.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/VideoClassifyResponse.java @@ -1,14 +1,11 @@ package com.stdiet.custom.dto.response; import lombok.Data; -import java.io.Serializable; + import java.util.List; -import java.util.Map; @Data -public class VideoClassifyResponse implements Serializable { - - private static final long serialVersionUID = 1L; +public class VideoClassifyResponse { //目录分类ID private Long id; @@ -19,8 +16,10 @@ public class VideoClassifyResponse implements Serializable { //用户类型 0 普通用户 1付费客户 private Integer userType; + private String imgUrl; + //子分类 - private List childrenClassify; + private List childrenClassify; //子视频 private List childrenVideo; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysNutritionalVideoServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysNutritionalVideoServiceImpl.java index a1b571a04..0979ba70e 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysNutritionalVideoServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysNutritionalVideoServiceImpl.java @@ -299,9 +299,11 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi } if (comment.getFromRole().equals("phone")) { comment.setFromUid(StringUtils.hiddenPhoneNumber(comment.getFromUid())); + comment.setFromName(StringUtils.hiddenPhoneNumber(comment.getFromName())); } if (comment.getToRole().equals("phone")) { comment.setToUid(StringUtils.hiddenPhoneNumber(comment.getToUid())); + comment.setToName(StringUtils.hiddenPhoneNumber(comment.getToName())); } List replys = comment.getReplys(); for (SysVideoComment reply : replys) { @@ -312,9 +314,11 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi } if (reply.getFromRole().equals("phone")) { reply.setFromUid(StringUtils.hiddenPhoneNumber(reply.getFromUid())); + reply.setFromName(StringUtils.hiddenPhoneNumber(reply.getFromName())); } if (reply.getToRole().equals("phone")) { reply.setToUid(StringUtils.hiddenPhoneNumber(reply.getToUid())); + reply.setToName(StringUtils.hiddenPhoneNumber(reply.getToName())); } } } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml index c837bf606..eb0eac022 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml @@ -14,9 +14,10 @@ - - - + + + + @@ -33,30 +34,33 @@ - - - - + + + + @@ -65,11 +69,10 @@