diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java index 245a5c895..54a448c51 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java @@ -7,6 +7,7 @@ import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.sign.AesUtils; import com.stdiet.custom.domain.SysOrderPause; +import com.stdiet.custom.domain.SysVideoComment; import com.stdiet.custom.domain.SysWxAdLog; import com.stdiet.custom.service.*; import com.stdiet.custom.utils.CookieUtils; @@ -45,6 +46,9 @@ public class SysWapController extends BaseController { @Autowired ISysSmsConfirmServie iSysSmsConfirmServie; + @Autowired + ISysNutritionalVideoService iSysNutritionalVideoService; + /** * 客户食谱详情 @@ -159,6 +163,12 @@ public class SysWapController extends BaseController { return AjaxResult.success(); } + /** + * 获取验证码 + * + * @param request + * @return + */ @GetMapping(value = "/checkCookie") public AjaxResult checkCookie(HttpServletRequest request) { JSONObject resultObj = CookieUtils.checkCookieValida(request, "token"); @@ -169,6 +179,12 @@ public class SysWapController extends BaseController { } } + /** + * 验证码校验 + * + * @param phone + * @return + */ @GetMapping(value = "/getCode") public AjaxResult getCode(@RequestParam String phone) { @@ -200,8 +216,6 @@ public class SysWapController extends BaseController { String tokenStr = phone + "_" + new Date().getTime() + "_" + RandomStringUtils.randomAlphanumeric(8); Cookie cookie = new Cookie("token", AesUtils.encrypt(tokenStr)); cookie.setMaxAge(24 * 60 * 60); -// cookie.setSecure(true); -// cookie.setHttpOnly(true); cookie.setPath("/"); response.addCookie(cookie); return new AjaxResult(20000, "登录成功"); @@ -214,4 +228,63 @@ public class SysWapController extends BaseController { } } + @GetMapping(value = "/video/comment") + public AjaxResult getVideoComment(SysVideoComment videoComment, HttpServletRequest request) { + JSONObject result = CookieUtils.checkCookieValida(request, "token"); + + String phone = result.getString("phone"); + List<SysVideoComment> comments = iSysNutritionalVideoService.selectVideoCommentByTopicId(videoComment, phone == null ? "" : phone); + + return AjaxResult.success(comments); + } + + @PostMapping(value = "/video/post/comment") + public AjaxResult insertVideoComment(@RequestBody SysVideoComment videoComment, HttpServletRequest request) { + JSONObject result = CookieUtils.checkCookieValida(request, "token"); + if (result.getInteger("code") != 200) { + return AjaxResult.error(result.getInteger("code"), result.getString("msg")); + } + + videoComment.setFromUid(result.getString("phone")); + videoComment.setFromRole("phone"); + + SysVideoComment comment = iSysNutritionalVideoService.insertVideoComment(videoComment); + + if (StringUtils.isNull(comment)) { + return AjaxResult.error(); + } + + return AjaxResult.success(comment); + } + + @PostMapping(value = "/video/post/reply") + public AjaxResult insertVideoCommentReply(@RequestBody SysVideoComment videoComment, HttpServletRequest request) { + JSONObject result = CookieUtils.checkCookieValida(request, "token"); + if (result.getInteger("code") != 200) { + return AjaxResult.error(result.getInteger("code"), result.getString("msg")); + } + + videoComment.setFromUid(result.getString("phone")); + videoComment.setFromRole("phone"); + + SysVideoComment reply = iSysNutritionalVideoService.insertVideoCommentReply(videoComment); + + if (StringUtils.isNull(reply)) { + return AjaxResult.error(); + } + + return AjaxResult.success(reply); + } + + @DeleteMapping("/video/delete/comment/{id}") + public AjaxResult deleteVideoComment(@PathVariable String id) { + return toAjax(iSysNutritionalVideoService.deleteVideoCommentById(id)); + } + + @DeleteMapping("/video/delete/reply/{id}") + public AjaxResult deleteVideoReply(@PathVariable String id) { + return toAjax(iSysNutritionalVideoService.deleteVideoCommentReplyById(id)); + } + + } 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 321a436a8..0684885f0 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 @@ -47,11 +47,6 @@ public class VideoWebInterfaceController extends BaseController { JSONObject result = CookieUtils.checkCookieValida(request, "token"); if (result.getInteger("code") != 200) { -// TableDataInfo errInfo = new TableDataInfo(); -// errInfo.setCode(result.getInteger("code")); -// errInfo.setMsg(result.getString("msg")); -// return errInfo; - Cookie cookie = new Cookie("token", ""); cookie.setMaxAge(24 * 60 * 60); cookie.setPath("/"); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java index e333258da..bfcffbe02 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java @@ -31,4 +31,6 @@ public class SysRecipesPlanListInfo { private Integer status; + private String remark; + } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysVideoComment.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysVideoComment.java new file mode 100644 index 000000000..8921ebae5 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysVideoComment.java @@ -0,0 +1,101 @@ +package com.stdiet.custom.domain; + +import com.alibaba.fastjson.JSONArray; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SysVideoComment { + /** + * + */ + String id; + + /** + * 问题id + */ + String topicId; + + /** + * 问题类型 + */ + Integer topicType; + + String commentId; + + String replyId; + + Integer replyType; + + /** + * 角色 + */ + String uid; + + String fromUid; + + String toUid; + + /** + * 问题内容 + */ + String content; + + /** + * 图片地址 + */ + JSONArray img; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + Date createTime; + + /** + * 0-未读 1-已读 + */ + Integer read; + + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + Date updateTime; + + /** + * 角色 + */ + String role; + + String fromRole; + + String toRole; + + // 非持久化字段 + /** + * 角色名字 + */ + String fromName; + String toName; + String name; + + String avatar; + String fromAvatar; + String toAvatar; + + + List<SysVideoComment> comments; + + List<SysVideoComment> replys; + + Integer count; + + Boolean owner; + +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysVideoCommentMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysVideoCommentMapper.java new file mode 100644 index 000000000..241e26cf7 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysVideoCommentMapper.java @@ -0,0 +1,17 @@ +package com.stdiet.custom.mapper; + +import com.stdiet.custom.domain.SysVideoComment; + +import java.util.List; + +public interface SysVideoCommentMapper { + List<SysVideoComment> selectVideoCommentByTopicId(SysVideoComment videoComment); + + int insertVideoComment(SysVideoComment videoComment); + + int insertVideoCommentReply(SysVideoComment videoComment); + + int deleteVideoCommentById(String id); + + int deleteVideoCommentReplyById(String id); +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysNutritionalVideoService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysNutritionalVideoService.java index 09b96e8e3..1131879ba 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysNutritionalVideoService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysNutritionalVideoService.java @@ -1,20 +1,18 @@ package com.stdiet.custom.service; +import com.stdiet.custom.domain.SysNutritionalVideo; +import com.stdiet.custom.domain.SysVideoComment; + import java.util.List; import java.util.Map; -import com.stdiet.custom.domain.SysNutritionalVideo; -import com.stdiet.custom.domain.SysVideoClassify; -import org.apache.ibatis.annotations.Param; - /** * 营养视频Service接口 * * @author xzj * @date 2021-04-29 */ -public interface ISysNutritionalVideoService -{ +public interface ISysNutritionalVideoService { /** * 查询营养视频 * @@ -65,6 +63,7 @@ public interface ISysNutritionalVideoService /** * 获取视频 + * * @param videoId * @return */ @@ -72,12 +71,14 @@ public interface ISysNutritionalVideoService /** * 阿里云视频查询检索 + * * @return */ - public Map<String,Object> searchVideo(String key, Integer status, Integer pageNo, Integer pageSize, String scrollToken); + public Map<String, Object> searchVideo(String key, Integer status, Integer pageNo, Integer pageSize, String scrollToken); /** * 更新微信展示状态 + * * @param wxShow * @param ids * @return @@ -86,7 +87,38 @@ public interface ISysNutritionalVideoService /** * 更新视频播放量 + * * @return */ public int updateVideoPlayNum(String videoId); + + /** + * 获取评论 + * + * @param videoComment + * @return + */ + public List<SysVideoComment> selectVideoCommentByTopicId(SysVideoComment videoComment, String phone); + + /** + * 添加评论 + * + * @param videoComment + * @return + */ + public SysVideoComment insertVideoComment(SysVideoComment videoComment); + + /** + * 添加回复 + * + * @param videoComment + * @return + */ + public SysVideoComment insertVideoCommentReply(SysVideoComment videoComment); + + public int deleteVideoCommentById(String id); + + public int deleteVideoCommentReplyById(String id); + + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java index 31d881c9d..447cb6d86 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java @@ -154,6 +154,10 @@ public class SysCustomerServiceImpl implements ISysCustomerService { @Override public Map<String, Object> getPhysicalSignsById(Long id) { Map<String, Object> result = new HashMap<>(); + + SysCustomer customer = sysCustomerMapper.selectSysCustomerById(id); + result.put("customerInfo", customer); + String key = "customerHealthy"; result.put("type", 0); //查询健康评估信息 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 237f05cde..a1b571a04 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 @@ -1,22 +1,24 @@ package com.stdiet.custom.service.impl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.aliyun.vod20170321.models.SearchMediaResponse; import com.aliyun.vod20170321.models.SearchMediaResponseBody; import com.stdiet.common.utils.AliyunVideoUtils; import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils; +import com.stdiet.custom.domain.SysNutritionalVideo; +import com.stdiet.custom.domain.SysVideoComment; +import com.stdiet.custom.mapper.SysNutritionalVideoMapper; +import com.stdiet.custom.mapper.SysVideoCommentMapper; +import com.stdiet.custom.service.ISysNutritionalVideoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import com.stdiet.custom.mapper.SysNutritionalVideoMapper; -import com.stdiet.custom.domain.SysNutritionalVideo; -import com.stdiet.custom.service.ISysNutritionalVideoService; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 营养视频Service业务层处理 @@ -25,11 +27,13 @@ import com.stdiet.custom.service.ISysNutritionalVideoService; * @date 2021-04-29 */ @Service -public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoService -{ +public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoService { @Autowired private SysNutritionalVideoMapper sysNutritionalVideoMapper; + @Autowired + private SysVideoCommentMapper sysVideoCommentMapper; + /** * 查询营养视频 * @@ -37,8 +41,7 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi * @return 营养视频 */ @Override - public SysNutritionalVideo selectSysNutritionalVideoById(Long id) - { + public SysNutritionalVideo selectSysNutritionalVideoById(Long id) { return sysNutritionalVideoMapper.selectSysNutritionalVideoById(id); } @@ -49,35 +52,34 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi * @return 营养视频 */ @Override - public List<SysNutritionalVideo> selectSysNutritionalVideoList(SysNutritionalVideo sysNutritionalVideo, boolean flag) - { + public List<SysNutritionalVideo> selectSysNutritionalVideoList(SysNutritionalVideo sysNutritionalVideo, boolean flag) { List<SysNutritionalVideo> list = sysNutritionalVideoMapper.selectSysNutritionalVideoList(sysNutritionalVideo); - if(flag && list != null && list.size() > 0){ + if (flag && list != null && list.size() > 0) { List<String> fileUrl = new ArrayList<>(); List<String> videoIdList = new ArrayList<>(); for (SysNutritionalVideo video : list) { - if(StringUtils.isNotEmpty(video.getCoverUrl())){ + if (StringUtils.isNotEmpty(video.getCoverUrl())) { fileUrl.add(video.getCoverUrl()); - }else{ + } else { videoIdList.add(video.getVideoId()); } } - if(fileUrl.size() > 0){ + if (fileUrl.size() > 0) { List<String> downUrlList = AliyunOSSUtils.generatePresignedUrl(fileUrl); - if(downUrlList != null && downUrlList.size() > 0){ + if (downUrlList != null && downUrlList.size() > 0) { int index = 0; for (SysNutritionalVideo video : list) { if (StringUtils.isNotEmpty(video.getCoverUrl())) { video.setCoverUrl(downUrlList.get(index)); index++; - if(index == downUrlList.size()){ + if (index == downUrlList.size()) { break; } } } } } - if(videoIdList.size() > 0) { + if (videoIdList.size() > 0) { List<String> coverUrlList = AliyunVideoUtils.getVideoCoverUrl(videoIdList); if (coverUrlList != null && coverUrlList.size() > 0) { int index = 0; @@ -85,7 +87,7 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi if (StringUtils.isEmpty(video.getCoverUrl())) { video.setCoverUrl(coverUrlList.get(index)); index++; - if(index == coverUrlList.size()){ + if (index == coverUrlList.size()) { break; } } @@ -103,15 +105,14 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi * @return 结果 */ @Override - public int insertSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) - { + public int insertSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) { sysNutritionalVideo.setCreateTime(DateUtils.getNowDate()); //判断封面是上传的还是阿里云视频截图封面 - if(isSnapshot(sysNutritionalVideo.getCoverUrl())){ + if (isSnapshot(sysNutritionalVideo.getCoverUrl())) { //更新阿里云视频封面 - try{ + try { AliyunVideoUtils.updateVideoCoverUrl(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getCoverUrl()); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return 0; } @@ -127,15 +128,14 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi * @return 结果 */ @Override - public int updateSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) - { + public int updateSysNutritionalVideo(SysNutritionalVideo sysNutritionalVideo) { sysNutritionalVideo.setUpdateTime(DateUtils.getNowDate()); sysNutritionalVideo.setCoverUrl(sysNutritionalVideo.getCoverUrl() == null ? "" : sysNutritionalVideo.getCoverUrl()); String coverUrl = sysNutritionalVideo.getCoverUrl(); //判断封面是上传的还是阿里云视频截图封面 sysNutritionalVideo.setCoverUrl(isSnapshot(coverUrl) ? "" : coverUrl); int row = sysNutritionalVideoMapper.updateSysNutritionalVideo(sysNutritionalVideo); - if(row > 0){ + if (row > 0) { sysNutritionalVideo.setCoverUrl(isSnapshot(coverUrl) ? coverUrl : null); updateAliyunVideo(sysNutritionalVideo); } @@ -143,12 +143,12 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi } @Async - public void updateAliyunVideo(SysNutritionalVideo sysNutritionalVideo){ - try{ - if(sysNutritionalVideo != null && sysNutritionalVideo.getVideoId() != null){ + public void updateAliyunVideo(SysNutritionalVideo sysNutritionalVideo) { + try { + if (sysNutritionalVideo != null && sysNutritionalVideo.getVideoId() != null) { AliyunVideoUtils.updateVideo(sysNutritionalVideo.getVideoId(), sysNutritionalVideo.getTitle(), sysNutritionalVideo.getTags(), sysNutritionalVideo.getDescription(), null, sysNutritionalVideo.getCoverUrl()); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } @@ -160,10 +160,9 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi * @return 结果 */ @Override - public int deleteSysNutritionalVideoByIds(Long[] ids) - { + public int deleteSysNutritionalVideoByIds(Long[] ids) { int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoByIds(ids); - if(row > 0){ + if (row > 0) { updateAliyunVideoCateId(ids); } return row; @@ -176,10 +175,9 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi * @return 结果 */ @Override - public int deleteSysNutritionalVideoById(Long id) - { + public int deleteSysNutritionalVideoById(Long id) { int row = sysNutritionalVideoMapper.deleteSysNutritionalVideoById(id); - if(row > 0){ + if (row > 0) { Long[] ids = {id}; updateAliyunVideoCateId(ids); } @@ -188,30 +186,32 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi /** * 获取视频 + * * @param videoId * @return */ - public SysNutritionalVideo selectSysNutritionalVideByVideoId(String videoId){ + public SysNutritionalVideo selectSysNutritionalVideByVideoId(String videoId) { return sysNutritionalVideoMapper.selectSysNutritionalVideByVideoId(videoId); } /** * 阿里云视频查询检索 + * * @return */ - public Map<String,Object> searchVideo(String key, Integer showFlag, Integer pageNo, Integer pageSize, String scrollToken){ + public Map<String, Object> searchVideo(String key, Integer showFlag, Integer pageNo, Integer pageSize, String scrollToken) { pageSize = pageSize.intValue() > 100 ? 10 : pageSize; long total = 0; String newScrollToken = null; List<SysNutritionalVideo> nutritionalVideoList = new ArrayList<>(); try { SearchMediaResponse response = AliyunVideoUtils.searchVideo(key, getStatusString(showFlag), pageNo, pageSize, scrollToken); - if(response != null){ - SearchMediaResponseBody body = response.body; + if (response != null) { + SearchMediaResponseBody body = response.body; total = body.total; newScrollToken = body.scrollToken; List<SearchMediaResponseBody.SearchMediaResponseBodyMediaList> mediaList = body.mediaList; - if(mediaList != null && mediaList.size() > 0){ + if (mediaList != null && mediaList.size() > 0) { for (SearchMediaResponseBody.SearchMediaResponseBodyMediaList media : mediaList) { SysNutritionalVideo sysNutritionalVideo = new SysNutritionalVideo(); sysNutritionalVideo.setTitle(media.video.title); @@ -225,7 +225,7 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi } } } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } Map<String, Object> result = new HashMap<>(); @@ -235,65 +235,135 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi return result; } - private String getStatusString(Integer status){ - if(status == null){ + private String getStatusString(Integer status) { + if (status == null) { return "Normal,Blocked"; } return status.intValue() == 1 ? "Normal" : "Blocked"; } - private Integer getStatus(String status){ - if(status == null){ + private Integer getStatus(String status) { + if (status == null) { return 1; } - return "Normal".equals(status) ? 1 : 0; + return "Normal".equals(status) ? 1 : 0; } /** * 更新微信展示状态 + * * @param wxShow * @param ids * @return */ - public int updateWxshowByIds(Integer wxShow, Long[] ids){ + public int updateWxshowByIds(Integer wxShow, Long[] ids) { return sysNutritionalVideoMapper.updateWxshowByIds(wxShow, ids); } /** * 将删除的阿里云视频放入回收站 + * * @param ids */ @Async - public void updateAliyunVideoCateId(Long[] ids){ + public void updateAliyunVideoCateId(Long[] ids) { try { List<String> videoIdList = sysNutritionalVideoMapper.getVideoIdByIds(ids); - if(videoIdList != null && videoIdList.size() > 0){ + if (videoIdList != null && videoIdList.size() > 0) { for (String videoId : videoIdList) { AliyunVideoUtils.delVideo(videoId); } } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } /** * 更新视频播放量 + * * @return */ - public int updateVideoPlayNum(String videoId){ + public int updateVideoPlayNum(String videoId) { return sysNutritionalVideoMapper.updateVideoPlayNum(videoId); } + @Override + public List<SysVideoComment> selectVideoCommentByTopicId(SysVideoComment videoComment, String uid) { + List<SysVideoComment> comments = sysVideoCommentMapper.selectVideoCommentByTopicId(videoComment); + for (SysVideoComment comment : comments) { + if(comment.getFromUid().equals(uid)){ + comment.setOwner(true); + } else { + comment.setOwner(false); + } + if (comment.getFromRole().equals("phone")) { + comment.setFromUid(StringUtils.hiddenPhoneNumber(comment.getFromUid())); + } + if (comment.getToRole().equals("phone")) { + comment.setToUid(StringUtils.hiddenPhoneNumber(comment.getToUid())); + } + List<SysVideoComment> replys = comment.getReplys(); + for (SysVideoComment reply : replys) { + if(reply.getFromUid().equals(uid)){ + reply.setOwner(true); + } else { + reply.setOwner(false); + } + if (reply.getFromRole().equals("phone")) { + reply.setFromUid(StringUtils.hiddenPhoneNumber(reply.getFromUid())); + } + if (reply.getToRole().equals("phone")) { + reply.setToUid(StringUtils.hiddenPhoneNumber(reply.getToUid())); + } + } + } + return comments; + } + + @Override + public SysVideoComment insertVideoComment(SysVideoComment videoComment) { + String uuid = java.util.UUID.randomUUID().toString().replace("-", ""); + videoComment.setId(uuid); + int rows = sysVideoCommentMapper.insertVideoComment(videoComment); + if (rows > 0) { + return videoComment; + } + return null; + } + + @Override + public SysVideoComment insertVideoCommentReply(SysVideoComment videoComment) { + String id = java.util.UUID.randomUUID().toString().replace("-", ""); + videoComment.setId(id); + String uuid = java.util.UUID.randomUUID().toString().replace("-", ""); + videoComment.setReplyId(uuid); + int rows = sysVideoCommentMapper.insertVideoCommentReply(videoComment); + if (rows > 0) { + return videoComment; + } + return null; + } + + @Override + public int deleteVideoCommentById(String id) { + return sysVideoCommentMapper.deleteVideoCommentById(id); + } + + @Override + public int deleteVideoCommentReplyById(String id) { + return sysVideoCommentMapper.deleteVideoCommentReplyById(id); + } + /** * 判断是否为阿里点播的截图 + * * @param url * @return */ - private boolean isSnapshot(String url){ - return StringUtils.isNotEmpty(url) && url.startsWith("http://outin"); + private boolean isSnapshot(String url) { + return StringUtils.isNotEmpty(url) && url.startsWith("http://outin"); } - } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml index 1bde54407..68dedc763 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml @@ -36,11 +36,13 @@ <result property="nutritionist" column="nutritionist"/> <result property="nutritionistAssisId" column="nutritionist_assis_id"/> <result property="nutritionistAssis" column="nutritionist_assis"/> + <result property="remark" column="remark"/> </resultMap> <sql id="selectSysRecipesPlanVo"> - select id, order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, pause_date, create_time, create_by, update_time, update_by, del_flag, review_status, sub_send, sms_send, subscribed from sys_recipes_plan + select id, order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, pause_date, create_time, create_by, update_time, update_by, del_flag, review_status, sub_send, sms_send, subscribed, remark + from sys_recipes_plan </sql> <select id="selectSysRecipesPlanList" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult"> @@ -141,6 +143,7 @@ <if test="subscribed != null">subscribed = #{subscribed},</if> <if test="subSend != null">sub_send = #{subSend},</if> <if test="smsSend != null">sms_send = #{smsSend},</if> + <if test="remark != null">remark = #{remark},</if> </trim> where id = #{id} and del_flag = 0 </update> @@ -185,10 +188,11 @@ srp.subscribed FROM sys_recipes_plan srp LEFT JOIN sys_customer sc ON sc.id = srp.cus_id - LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sc.main_dietitian AND su_nutritionist.del_flag = 0 + LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sc.main_dietitian AND su_nutritionist.del_flag = + 0 LEFT JOIN sys_user su_nutritionist_assis ON su_nutritionist_assis.user_id = sc.assistant_dietitian AND su_nutritionist_assis.del_flag = 0 - WHERE srp.del_flag = 0 AND sc.del_flag = 0 AND srp.type = 0 + WHERE srp.del_flag = 0 AND sc.del_flag = 0 AND srp.type = 0 <if test="orderId != null">AND srp.order_id = #{orderId}</if> <if test="sendFlag != null">AND srp.send_flag = #{sendFlag}</if> <if test="customer != null and customer != ''">AND (sc.name like concat('%',#{customer},'%') OR sc.phone like @@ -249,6 +253,7 @@ <result property="recipesId" column="recipes_id"/> <result property="sendFlag" column="send_flag"/> <result property="subscribed" column="subscribed"/> + <result property="remark" column="remark"/> <association property="menus" column="recipes_id" select="selectMenuIds"/> </resultMap> @@ -256,12 +261,12 @@ and review_status = 2 and send_flag = 1 --> <select id="selectRecipesPlanListInfo" resultMap="SysRecipesPlanListInfoResult"> - select id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, subscribed from sys_recipes_plan where out_id=#{outId} and del_flag = 0 + select id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, subscribed, remark from sys_recipes_plan where out_id=#{outId} and del_flag = 0 </select> <!-- and review_status = 2 and send_flag = 1--> <select id="selectRecipesPlanListInfoByCusId" resultMap="SysRecipesPlanListInfoResult"> - select id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, subscribed from sys_recipes_plan where cus_id=#{cusId} and del_flag = 0 + select id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, subscribed, remark from sys_recipes_plan where cus_id=#{cusId} and del_flag = 0 </select> <resultMap type="SysRecipesDaily" id="SysRecipesResult"> diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml new file mode 100644 index 000000000..c837bf606 --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysVideoCommentMapper.xml @@ -0,0 +1,148 @@ +<?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.stdiet.custom.mapper.SysVideoCommentMapper"> + + <resultMap id="SysVideoCommentResult" type="SysVideoComment"> + <result column="id" property="id"/> + <result column="topic_id" property="topicId"/> + <result column="content" property="content"/> + <result column="from_uid" property="fromUid"/> + <result column="from_role" property="fromRole"/> + <result column="to_uid" property="toUid"/> + <result column="to_role" property="toRole"/> + <!-- <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/>--> + <result column="create_time" property="createTime"/> + <!-- <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/>--> + <!-- <association property="fromAvatar" column="{uid=from_uid,role=from_role}" select="selectUserAvatar"/>--> + <!-- <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/>--> + <association property="replys" column="id" + select="selectVideoCommentReplyByCommentId"/> + </resultMap> + + <resultMap id="SysVideoCommentReplyResult" type="SysVideoComment"> + <result column="id" property="id"/> + <result column="topic_id" property="topicId"/> + <result column="comment_id" property="commentId"/> + <result column="content" property="content"/> + <result column="from_uid" property="fromUid"/> + <result column="from_role" property="fromRole"/> + <result column="to_uid" property="toUid"/> + <result column="to_role" property="toRole"/> + <result column="reply_id" property="replyId"/> + <!-- <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/>--> + <result column="create_time" property="createTime"/> + <!-- <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/>--> + <!-- <association property="fromAvatar" column="{uid=from_uid,role=from_role}" select="selectUserAvatar"/>--> + <!-- <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/>--> + <!-- <association property="toAvatar" column="{uid=to_uid,role=to_role}" select="selectUserAvatar"/>--> + </resultMap> + + <select id="selectVideoCommentByTopicId" resultMap="SysVideoCommentResult"> + select * from sys_nutritional_video_comment where topic_id = #{topicId} and del_flag = 0 + order by create_time asc + </select> + + <select id="selectVideoCommentReplyByCommentId" resultMap="SysVideoCommentReplyResult"> + select * from sys_nutritional_video_reply where comment_id = #{id} and del_flag = 0 + order by create_time asc + </select> + + <!-- 查询人名--> + <select id="selectUserInfo" parameterType="java.util.Map" resultType="String"> + <choose> + <when test="_parameter.get('role') == 'customer'"> + select name from sys_customer where id = #{uid} + </when> + <otherwise> + select nick_name from sys_user where user_id = #{uid} + </otherwise> + </choose> + </select> + + <!-- 查询头像--> + <select id="selectUserAvatar" parameterType="java.util.Map" resultType="String"> + <choose> + <when test="_parameter.get('role') == 'customer'"> + select avatar_url from sys_wx_user_info where cus_id = #{uid} + </when> + <otherwise> + select IF(avatar != '', CONCAT("https://api.stdiet.top/prod-api", avatar), '') as avatar from sys_user + where user_id = #{uid} + </otherwise> + </choose> + </select> + + + <!-- 插入问题回复--> + <insert id="insertVideoComment" parameterType="SysVideoComment"> + insert into sys_nutritional_video_comment + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">id,</if> + <if test="topicId != null">topic_id,</if> + <if test="fromUid != null">from_uid,</if> + <if test="fromRole != null">from_role,</if> + <if test="toUid != null">to_uid,</if> + <if test="toRole != null">to_role,</if> + <if test="content != null">content,</if> + <if test="img != null">img,</if> + <if test="topicId != null">create_time,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null">#{id},</if> + <if test="topicId != null">#{topicId},</if> + <if test="fromUid != null">#{fromUid},</if> + <if test="fromRole != null">#{fromRole},</if> + <if test="toUid != null">#{toUid},</if> + <if test="toRole != null">#{toRole},</if> + <if test="content != null">#{content},</if> + <if test="img != null"> + #{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler}, + </if> + <if test="topicId != null">now(),</if> + </trim> + </insert> + + <!-- 插入问题回复--> + <insert id="insertVideoCommentReply" parameterType="SysVideoComment" useGeneratedKeys="true" keyColumn="id" + keyProperty="id"> + insert into sys_nutritional_video_reply + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null">id,</if> + <if test="commentId != null">comment_id,</if> + <if test="replyId != null">reply_id,</if> + <if test="content != null">content,</if> + <if test="fromUid != null">from_uid,</if> + <if test="toUid != null">to_uid,</if> + <if test="img != null">img,</if> + <if test="fromRole != null">from_role,</if> + <if test="toRole != null">to_role,</if> + <if test="content != null">create_time,</if> + + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null">#{id},</if> + <if test="commentId != null">#{commentId},</if> + <if test="replyId != null">#{replyId},</if> + <if test="content != null">#{content},</if> + <if test="fromUid != null">#{fromUid},</if> + <if test="toUid != null">#{toUid},</if> + <if test="img != null"> + #{img, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler}, + </if> + <if test="fromRole != null">#{fromRole},</if> + <if test="toRole != null">#{toRole},</if> + <if test="content != null">now(),</if> + </trim> + </insert> + + <update id="deleteVideoCommentById" parameterType="String"> + update sys_nutritional_video_comment set del_flag = 1 where id = #{id} + </update> + + <update id="deleteVideoCommentReplyById" parameterType="String"> + update sys_nutritional_video_reply set del_flag = 1 where id = #{id} + </update> + +</mapper> \ No newline at end of file diff --git a/stdiet-ui/src/components/BodySignView/index.vue b/stdiet-ui/src/components/BodySignView/index.vue index baa172dea..1f379cf07 100644 --- a/stdiet-ui/src/components/BodySignView/index.vue +++ b/stdiet-ui/src/components/BodySignView/index.vue @@ -20,6 +20,12 @@ :value.sync="data.avoidFood" @onConfirm="handleOnConfirm" /> + <RemarkCom + v-if="dev && showRemark" + title="营养师点评" + :value.sync="data.recipesPlanRemark" + @onConfirm="handleOnRemarkConfirm" + /> </div> </template> <script> @@ -39,6 +45,10 @@ export default { type: Boolean, default: false, }, + showRemark: { + type: Boolean, + default: false, + }, }, components: { "text-info": TextInfo, @@ -115,6 +125,21 @@ export default { }); }, }, + watch: { + data(val, oldVal) { + if ( + val && + val.dietitianName && + !this.basicInfo[3].some((obj) => obj.value === "dietitianName") + ) { + this.basicInfo.splice(3, 0, [ + { title: "主营养师", value: "dietitianName" }, + { title: "营养师助理", value: "assDietitianName" }, + { title: "售后营养师", value: "afterDietitianName" }, + ]); + } + }, + }, }; </script> <style lang="scss" scoped> diff --git a/stdiet-ui/src/components/HealthyView/RemarkCom/index.vue b/stdiet-ui/src/components/HealthyView/RemarkCom/index.vue index 119b84075..27b746ee7 100644 --- a/stdiet-ui/src/components/HealthyView/RemarkCom/index.vue +++ b/stdiet-ui/src/components/HealthyView/RemarkCom/index.vue @@ -4,7 +4,7 @@ placement="right" trigger="click" width="400" - title="备注" + :title="title" @hide="handleOnHide" > <el-input @@ -12,10 +12,10 @@ v-model="nData" rows="6" placeholder="请输入备注信息" - maxlength="300" + maxlength="600" show-word-limit /> - <span slot="reference" class="trigger">备注: </span> + <span slot="reference" class="trigger">{{ title }}:</span> </el-popover> <div class="content"> <span v-if="newLine"> @@ -35,6 +35,10 @@ export default { type: String, default: "", }, + title: { + type: String, + default: "备注", + }, }, components: {}, data() { diff --git a/stdiet-ui/src/components/HealthyView/index.vue b/stdiet-ui/src/components/HealthyView/index.vue index c61af37f0..b1db4cc37 100644 --- a/stdiet-ui/src/components/HealthyView/index.vue +++ b/stdiet-ui/src/components/HealthyView/index.vue @@ -21,6 +21,12 @@ :value.sync="data.avoidFood" @onConfirm="handleOnConfirm" /> + <RemarkCom + v-if="dev && showRemark" + title="营养师点评" + :value.sync="data.recipesPlanRemark" + @onConfirm="handleOnRemarkConfirm" + /> </div> <el-collapse> <el-collapse-item @@ -57,6 +63,7 @@ import TextInfo from "@/components/TextInfo"; import ACFCom from "./ACFCom"; import RemarkCom from "./RemarkCom"; import { updateHealthy } from "@/api/custom/healthy"; +import { updateRecipesPlan } from "@/api/custom/recipesPlan"; export default { name: "HealthyView", @@ -69,6 +76,10 @@ export default { type: Boolean, default: false, }, + showRemark: { + type: Boolean, + default: false, + }, }, components: { "text-info": TextInfo, @@ -121,7 +132,7 @@ export default { { title: "过敏源", value: "allergen" }, ], }, - { + { title: "运动习惯评估", content: [ { title: "每周运动次数", value: "motionNum" }, @@ -238,6 +249,33 @@ export default { } }); }, + handleOnRemarkConfirm(data) { + const { pathname } = window.location; + const recipesId = pathname.substring(pathname.lastIndexOf("/") + 1); + updateRecipesPlan({ + id: recipesId, + ...data, + }).then((res) => { + if (res.code === 200) { + this.$message.success("修改成功"); + } + }); + }, + }, + watch: { + data(val, oldVal) { + if ( + val && + val.dietitianName && + !this.basicInfo[3].some((obj) => obj.value === "dietitianName") + ) { + this.basicInfo.splice(3, 0, [ + { title: "主营养师", value: "dietitianName" }, + { title: "营养师助理", value: "assDietitianName" }, + { title: "售后营养师", value: "afterDietitianName" }, + ]); + } + }, }, }; </script> diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index 5f61f0544..a15ff2c4e 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -1,6 +1,6 @@ import { - getCustomerPhysicalSignsByCusId, - getCustomer + getCustomerPhysicalSignsByCusId + // getCustomer } from "@/api/custom/customer"; import { dealHealthy } from "@/utils/healthyData"; import { @@ -34,8 +34,6 @@ const oriState = { healthyDataType: 0, avoidFoodIds: [], // - customerData: {}, - // planList: [], planListLoading: false }; @@ -130,7 +128,8 @@ const actions = { dispatch("fetchTopicDetailActions", { topicId: defTopic.topicId, id: defTopic.id, - uid: defTopic.uid + uid: defTopic.uid, + callback: payload.callback }); }, 100); mTopicList = result.rows; @@ -145,7 +144,6 @@ const actions = { const { healthyData, planList, - customerData, topicList, customerList } = state; @@ -158,11 +156,6 @@ const actions = { if (!planList.length || planList[0].cusId !== parseInt(uid)) { dispatch("getRecipesPlanActions", { cusId: uid }); } - // 客户档案 - if (customerData.id !== parseInt(uid)) { - dispatch("getCustomerFileActions", { cusId: uid }); - } - // const result = await fetchTopicDetail({ topicId, id }); if (result.code === 200) { // 设置已读 @@ -184,12 +177,6 @@ const actions = { }); } }, - async getCustomerFileActions({ commit }, payload) { - const result = await getCustomer(payload.cusId); - if (result.code === 200) { - commit("save", { customerData: result.data }); - } - }, async postTopicReplyActions( { commit, rootGetters, dispatch, state }, payload @@ -223,7 +210,7 @@ const actions = { const healthyDataResult = await getCustomerPhysicalSignsByCusId( payload.cusId ); - const newState = {}; + const newState = { healthyData: {}, avoidFoodIds: [] }; if (healthyDataResult.code === 200) { if (!healthyDataResult.data.customerHealthy) { // throw new Error("客户还没填写健康评估表"); @@ -236,6 +223,12 @@ const actions = { newState.avoidFoodIds = (newState.healthyData.avoidFood || []).map( obj => obj.id ); + newState.healthyData.dietitianName = + healthyDataResult.data.customerInfo.dietitianName; + newState.healthyData.assDietitianName = + healthyDataResult.data.customerInfo.assDietitianName; + newState.healthyData.afterDietitianName = + healthyDataResult.data.customerInfo.afterDietitianName; } } commit("save", { diff --git a/stdiet-ui/src/store/modules/recipes.js b/stdiet-ui/src/store/modules/recipes.js index 23e4e2a08..f01aaecf2 100644 --- a/stdiet-ui/src/store/modules/recipes.js +++ b/stdiet-ui/src/store/modules/recipes.js @@ -49,7 +49,8 @@ const oriState = { igdTypeOptions: [], physicalSignsOptions: [], // - curShortCutObj: {} + curShortCutObj: {}, + recipesPlanRemark: "" }; const mutations = { @@ -147,7 +148,8 @@ const actions = { endNumDay, recipesId, cusId, - reviewStatus + reviewStatus, + remark } = planResponse.data; commit("updateStateData", { cusId, @@ -157,7 +159,8 @@ const actions = { name: payload.name, planId: payload.planId, startNum: startNumDay, - endNum: endNumDay + endNum: endNumDay, + recipesPlanRemark: remark }); getDicts("cus_cus_unit").then(response => { commit("updateStateData", { cusUnitOptions: response.data }); @@ -237,7 +240,8 @@ const actions = { commit("updateStateData", payload); } }, - async getHealthyData({ commit }, payload) { + async getHealthyData({ commit, state }, payload) { + const { recipesPlanRemark } = state; commit("updateStateData", { healthDataLoading: true }); const healthyDataResult = await getCustomerPhysicalSignsByCusId( payload.cusId @@ -256,7 +260,10 @@ const actions = { commit("updateStateData", { healthDataLoading: false, healthyDataType, - healthyData, + healthyData: { + ...healthyData, + recipesPlanRemark + }, avoidFoodIds: (healthyData.avoidFood || []).map(obj => obj.id) }); }, @@ -555,7 +562,7 @@ const actions = { id: new Date().getTime(), name: tarDishes.name, type: response.data.type.split(",").sort(), - className: response.data.className, //大类小类名称 + className: response.data.className, //大类小类名称 data: tarDishes }).then(() => { window.postMessage( diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue index 306e58c52..b4fa504ec 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue @@ -237,7 +237,12 @@ export default { this.replyTarget = ""; this.replyContent = ""; this.replyObj = {}; - this.fetchTopicListApi({ fromUid: data.uid }); + this.fetchTopicListApi({ + fromUid: data.uid, + callback: (msg) => { + this.$message.error(msg); + }, + }); } }, handleOnTopicClick(data) { diff --git a/stdiet-ui/src/views/custom/message/userInfo/index.vue b/stdiet-ui/src/views/custom/message/userInfo/index.vue index e7d69b176..f53cbf9cd 100644 --- a/stdiet-ui/src/views/custom/message/userInfo/index.vue +++ b/stdiet-ui/src/views/custom/message/userInfo/index.vue @@ -15,22 +15,6 @@ :data="healthyDataType === 1 ? healthyData : {}" v-show="healthyDataType === 1" /> - <div v-if="customerData.id" class="customer_service_info"> - <div class="info_item"> - <span>主任营养师:</span> - <span> - {{ customerData.dietitianName || "无" }} - </span> - </div> - <div class="info_item"> - <span>营养师助理:</span> - <span>{{ customerData.assDietitianName || "无" }}</span> - </div> - <div class="info_item"> - <span>售后营养师:</span> - <span>{{ customerData.afterDietitianName || "无" }}</span> - </div> - </div> </div> </el-tab-pane> <el-tab-pane label="食谱计划" name="plan"> @@ -69,12 +53,7 @@ export default { }, }, computed: { - ...mapState([ - "healthyData", - "healthyDataType", - "healthDataLoading", - "customerData", - ]), + ...mapState(["healthyData", "healthyDataType", "healthDataLoading"]), }, }; </script> diff --git a/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue index 27bbb1bd3..a61fab174 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue @@ -10,11 +10,13 @@ <div class="content"> <HealthyView dev + showRemark :data="healthyDataType === 0 ? healthyData : {}" v-show="healthyDataType === 0" /> <BodySignView dev + showRemark :data="healthyDataType === 1 ? healthyData : {}" v-show="healthyDataType === 1" />