diff --git a/src/main/java/com/dd/admin/business/api/ApiController.java b/src/main/java/com/dd/admin/business/api/ApiController.java index 8bd5fa9..8059b1f 100644 --- a/src/main/java/com/dd/admin/business/api/ApiController.java +++ b/src/main/java/com/dd/admin/business/api/ApiController.java @@ -58,62 +58,21 @@ public class ApiController { @GetMapping("/api/notes") @OperLog(operModule = "获取所有笔记", operType = OperType.QUERY, operDesc = "获取所有笔记") public ResultBean> page(NoteDto noteDto) { - // 1. 通过noteService根据传入的NoteDto参数查询笔记的分页信息,获取包含笔记数据的分页对象 - IPage pageInfo = noteService.selectNotePage(noteDto); - - // 2. 创建一个用于存储当前用户点赞笔记信息的列表,初始化为空 - List upNotesVos = new ArrayList<>(); - // 3. 从请求头中获取名为"token"的token字符串,用于后续解析获取用户ID String token = request.getHeader("token"); - String authorId = ""; + String followId = ""; try { // 4. 尝试使用jwtTokenUtil工具类从获取到的token中解析出用户名(这里假设用户名就是用户ID),如果解析成功则赋值给authorId变量 - authorId = jwtTokenUtil.getUsernameFromToken(token); + followId = jwtTokenUtil.getUsernameFromToken(token); } catch (Exception e) { // 5. 如果在解析token过程中出现异常,此处捕获异常但不做任何处理,authorId仍为空字符串,后续可根据此情况决定是否继续相关业务逻辑 } - - // 6. 判断解析出的用户ID是否不为空(即是否成功获取到了用户ID) - if (StringUtil.isNotEmpty(authorId)) { - // 7. 如果获取到了用户ID,创建一个UpNotesDto对象,用于设置查询条件 - UpNotesDto upNotesDto = new UpNotesDto(); - // 8. 将获取到的用户ID设置到UpNotesDto对象中,作为查询当前用户点赞笔记的条件(表示要查询该用户点赞的笔记) - upNotesDto.setFollowId(authorId); - // 9. 通过upNotesService根据设置好的查询条件,查询当前用户点赞的笔记列表,并将结果赋值给upNotesVos列表 - upNotesVos = upNotesService.selectUpNotesList(upNotesDto); + if(StringUtil.isNotEmpty(followId)){ + noteDto.setFollowId(followId); } - // 10. 通过upNotesService查询所有笔记的点赞数量统计信息,获取一个包含各笔记点赞数量相关信息的列表 - List selectAllUpCount = upNotesService.selectAllUpCount(); - - // 11. 获取前面查询到的笔记分页信息中的具体笔记记录列表,后续要对这些笔记记录进行相关属性的设置操作 - List records = pageInfo.getRecords(); - // 12. 为了能在下面的lambda表达式中使用upNotesVos变量,创建一个final修饰的变量来引用它,因为lambda表达式中访问的外部变量需要是final或者事实上的final(不可重新赋值) - List finalUpNotesVos = upNotesVos; - // 13. 同样,为了在lambda表达式中使用authorId变量,创建一个final修饰的变量来引用它 - String finalAuthorId = authorId; - - // 14. 使用Java 8的Stream API对每条笔记记录进行遍历处理 - records.stream().forEach(noteVo -> { - // 15. 判断当前用户ID是否不为空(即是否获取到了用户ID且有效),如果为空则不进行当前用户对该笔记点赞状态的判断设置操作 - if (StringUtil.isNotEmpty(finalAuthorId)) { - // 16. 在当前用户点赞笔记列表(finalUpNotesVos)中,通过Stream的filter操作筛选出与当前遍历的笔记(noteVo)的ID相等的点赞笔记记录,然后获取第一个匹配的记录(如果有的话),否则返回null - UpNotesVo upNote = finalUpNotesVos.stream().filter(upNotesVo -> noteVo.getNoteId().equals(upNotesVo.getNoteId())).findFirst().orElse(null); - // 17. 如果找到了对应的点赞笔记记录(即upNote不为null),说明当前用户点赞了这条笔记,将笔记的IsUp属性设置为true,表示已点赞状态 - if (upNote!= null) { - noteVo.setIsUp(Boolean.TRUE); - } - } - - // 18. 在所有笔记的点赞数量统计信息列表(selectAllUpCount)中,通过Stream的filter操作筛选出与当前遍历的笔记(noteVo)的ID相等的记录,然后获取第一个匹配的记录(如果有的话),否则返回null - UpNotesVo noteCount = selectAllUpCount.stream().filter(upNotesVo -> upNotesVo.getNoteId().equals(noteVo.getNoteId())).findFirst().orElse(null); - // 19. 如果找到了对应的点赞数量统计记录(即noteCount不为null),将笔记的UpCount属性设置为该记录中的点赞数量,从而为每条笔记设置对应的点赞数量信息 - if (noteCount!= null) { - noteVo.setUpCount(noteCount.getUpCount()); - } - }); - + // 1. 通过noteService根据传入的NoteDto参数查询笔记的分页信息,获取包含笔记数据的分页对象 + IPage pageInfo = noteService.selectNotePage(noteDto); // 20. 将处理好的包含笔记信息(已设置点赞状态和点赞数量)的分页对象包装在ResultBean中返回,以便前端或其他调用方获取处理后的结果数据 return ResultBean.success(pageInfo); } @@ -133,12 +92,22 @@ public class ApiController { @GetMapping("/api/getNote") @OperLog(operModule = "获取单个笔记",operType = OperType.QUERY,operDesc = "获取单个笔记") public ResultBean getNoteById(NoteDto noteDto) { - Note note = noteService.getById(noteDto.getNoteId()); - NoteVo noteVo = BeanUtil.copyProperties(note, NoteVo.class); - noteVo.setCreateTimeStr(noteVo.getCreateTime()); + // 3. 从请求头中获取名为"token"的token字符串,用于后续解析获取用户ID + String token = request.getHeader("token"); + String followId = ""; + try { + // 4. 尝试使用jwtTokenUtil工具类从获取到的token中解析出用户名(这里假设用户名就是用户ID),如果解析成功则赋值给authorId变量 + followId = jwtTokenUtil.getUsernameFromToken(token); + } catch (Exception e) { + // 5. 如果在解析token过程中出现异常,此处捕获异常但不做任何处理,authorId仍为空字符串,后续可根据此情况决定是否继续相关业务逻辑 + } + if(StringUtil.isNotEmpty(followId)){ + noteDto.setFollowId(followId); + } + NoteVo noteVo = noteService.selectNoteDetail(noteDto); NoteImgDto noteImgDto = new NoteImgDto(); - noteImgDto.setNoteId(note.getNoteId()); + noteImgDto.setNoteId(noteVo.getNoteId()); List noteImgVos = noteImgService.selectNoteImgList(noteImgDto); List imageList = noteImgVos.stream().map(NoteImgVo::getImgUrl).collect(Collectors.toList()); noteVo.setImgList(imageList); diff --git a/src/main/java/com/dd/admin/business/api/AuthApi.java b/src/main/java/com/dd/admin/business/api/AuthApi.java index 9ba502a..c60cf52 100644 --- a/src/main/java/com/dd/admin/business/api/AuthApi.java +++ b/src/main/java/com/dd/admin/business/api/AuthApi.java @@ -16,6 +16,10 @@ import com.dd.admin.business.note.entity.Note; import com.dd.admin.business.note.service.NoteService; import com.dd.admin.business.noteImg.entity.NoteImg; import com.dd.admin.business.noteImg.service.NoteImgService; +import com.dd.admin.business.reply.domain.ReplyDto; +import com.dd.admin.business.reply.domain.ReplyVo; +import com.dd.admin.business.reply.entity.Reply; +import com.dd.admin.business.reply.service.ReplyService; import com.dd.admin.business.starNotes.domain.StarNotesDto; import com.dd.admin.business.starNotes.domain.StarNotesVo; import com.dd.admin.business.starNotes.entity.StarNotes; @@ -42,7 +46,12 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static com.dd.admin.common.consts.XhsConst.TRUE; @RestController public class AuthApi { @@ -64,43 +73,29 @@ public class AuthApi { StarNotesService starNotesService; @Autowired FollowService followService; + @Autowired + ReplyService replyService; @ApiOperation(value = "获取所有笔记") @ApiOperationSupport(order = 1) @GetMapping("/api/auth/notes") @OperLog(operModule = "获取所有笔记",operType = OperType.QUERY,operDesc = "获取所有笔记") public ResultBean> page(NoteDto noteDto) { - String authorId = String.valueOf(request.getAttribute("authorId")); - + String followId = String.valueOf(request.getAttribute("authorId")); + noteDto.setFollowId(followId); IPage pageInfo = noteService.selectNotePage(noteDto); - List records = pageInfo.getRecords(); - UpNotesDto upNotesDto = new UpNotesDto(); - upNotesDto.setFollowId(authorId); - List upNotesVos = upNotesService.selectUpNotesList(upNotesDto); - - List selectAllUpCount = upNotesService.selectAllUpCount(); - records.stream().forEach(noteVo->{ - UpNotesVo upNote = upNotesVos.stream().filter(upNotesVo -> noteVo.getNoteId().equals(upNotesVo.getNoteId())).findFirst().orElse(null); - if(upNote!=null){ - noteVo.setIsUp(Boolean.TRUE); - } - UpNotesVo noteCount = selectAllUpCount.stream().filter(upNotesVo -> upNotesVo.getNoteId().equals(noteVo.getNoteId())).findFirst().orElse(null); - if(noteCount!=null){ - noteVo.setUpCount(noteCount.getUpCount()); - } - }); - return ResultBean.success(pageInfo); } - @ApiOperation(value = "获取所有笔记") + @ApiOperation(value = "获取所有关注笔记") @ApiOperationSupport(order = 1) @GetMapping("/api/auth/getFollowNotes") - @OperLog(operModule = "获取所有笔记",operType = OperType.QUERY,operDesc = "获取所有笔记") - public ResultBean> getFollowNotes(NoteDto noteDto) { + @OperLog(operModule = "获取所有关注笔记",operType = OperType.QUERY,operDesc = "获取所有关注笔记") + public ResultBean> getFollowNotes() { String followId = String.valueOf(request.getAttribute("authorId")); - + NoteDto noteDto = new NoteDto(); + noteDto.setFollowId(followId); List follows = followService.selectFollowListByFollowId(followId); IPage pageInfo = new IPage() { @@ -153,24 +148,7 @@ public class AuthApi { String authorIds = CommonUtil.getIds(follows, "authorId"); noteDto.setAuthorIds(authorIds); pageInfo = noteService.selectNotePage(noteDto); - List records = pageInfo.getRecords(); - UpNotesDto upNotesDto = new UpNotesDto(); - upNotesDto.setFollowId(followId); - List upNotesVos = upNotesService.selectUpNotesList(upNotesDto); - - List selectAllUpCount = upNotesService.selectAllUpCount(); - records.stream().forEach(noteVo->{ - UpNotesVo upNote = upNotesVos.stream().filter(upNotesVo -> noteVo.getNoteId().equals(upNotesVo.getNoteId())).findFirst().orElse(null); - if(upNote!=null){ - noteVo.setIsUp(Boolean.TRUE); - } - UpNotesVo noteCount = selectAllUpCount.stream().filter(upNotesVo -> upNotesVo.getNoteId().equals(noteVo.getNoteId())).findFirst().orElse(null); - if(noteCount!=null){ - noteVo.setUpCount(noteCount.getUpCount()); - } - }); } - return ResultBean.success(pageInfo); } @@ -180,27 +158,12 @@ public class AuthApi { @ApiOperationSupport(order = 1) @GetMapping("/api/auth/getUpNotes") @OperLog(operModule = "获取所有点赞笔记",operType = OperType.QUERY,operDesc = "获取所有点赞笔记") - public ResultBean> getUpNotes(NoteDto noteDto) { - String authorId = String.valueOf(request.getAttribute("authorId")); - - IPage pageInfo = noteService.selectMineUpNotes(authorId); - List records = pageInfo.getRecords(); - UpNotesDto upNotesDto = new UpNotesDto(); - upNotesDto.setFollowId(authorId); - List upNotesVos = upNotesService.selectUpNotesList(upNotesDto); - - List selectAllUpCount = upNotesService.selectAllUpCount(); - records.stream().forEach(noteVo->{ - UpNotesVo upNote = upNotesVos.stream().filter(upNotesVo -> noteVo.getNoteId().equals(upNotesVo.getNoteId())).findFirst().orElse(null); - if(upNote!=null){ - noteVo.setIsUp(Boolean.TRUE); - } - UpNotesVo noteCount = selectAllUpCount.stream().filter(upNotesVo -> upNotesVo.getNoteId().equals(noteVo.getNoteId())).findFirst().orElse(null); - if(noteCount!=null){ - noteVo.setUpCount(noteCount.getUpCount()); - } - }); - + public ResultBean> getUpNotes() { + String followId = String.valueOf(request.getAttribute("authorId")); + NoteDto noteDto = new NoteDto(); + noteDto.setFollowId(followId); + noteDto.setMyUpById(followId); + IPage pageInfo = noteService.selectNotePage(noteDto); return ResultBean.success(pageInfo); } @@ -209,28 +172,12 @@ public class AuthApi { @ApiOperationSupport(order = 1) @GetMapping("/api/auth/getStarNotes") @OperLog(operModule = "获取所有收藏笔记",operType = OperType.QUERY,operDesc = "获取所有收藏笔记") - public ResultBean> getStarNotes(NoteDto noteDto) { - String authorId = String.valueOf(request.getAttribute("authorId")); - - IPage pageInfo = noteService.selectMineStarNotes(authorId); - List records = pageInfo.getRecords(); - - UpNotesDto upNotesDto = new UpNotesDto(); - upNotesDto.setFollowId(authorId); - List upNotesVos = upNotesService.selectUpNotesList(upNotesDto); - - List selectAllUpCount = upNotesService.selectAllUpCount(); - records.stream().forEach(noteVo->{ - UpNotesVo upNote = upNotesVos.stream().filter(upNotesVo -> noteVo.getNoteId().equals(upNotesVo.getNoteId())).findFirst().orElse(null); - if(upNote!=null){ - noteVo.setIsUp(Boolean.TRUE); - } - UpNotesVo noteCount = selectAllUpCount.stream().filter(upNotesVo -> upNotesVo.getNoteId().equals(noteVo.getNoteId())).findFirst().orElse(null); - if(noteCount!=null){ - noteVo.setUpCount(noteCount.getUpCount()); - } - }); - + public ResultBean> getStarNotes() { + String followId = String.valueOf(request.getAttribute("authorId")); + NoteDto noteDto = new NoteDto(); + noteDto.setFollowId(followId); + noteDto.setMyStarById(followId); + IPage pageInfo = noteService.selectNotePage(noteDto); return ResultBean.success(pageInfo); } @@ -238,7 +185,7 @@ public class AuthApi { @ApiOperation(value = "获取博主信息") @ApiOperationSupport(order = 1) @GetMapping("/api/auth/getMine") - @OperLog(operModule = "获取博主信息",operType = OperType.QUERY,operDesc = "获取博主信息") + @OperLog(operModule = "获取当前博主信息",operType = OperType.QUERY,operDesc = "获取当前博主信息") public ResultBean getMine() { String authorId = String.valueOf(request.getAttribute("authorId")); Author author = authorService.getById(authorId); @@ -246,12 +193,14 @@ public class AuthApi { } - @ApiOperation(value = "获取博主笔记") + @ApiOperation(value = "获取当前博主笔记") @ApiOperationSupport(order = 1) @GetMapping("/api/auth/getMineNotes") - @OperLog(operModule = "获取博主笔记",operType = OperType.QUERY,operDesc = "获取博主笔记") - public ResultBean> getMineNotes(NoteDto noteDto) { + @OperLog(operModule = "获取当前博主笔记",operType = OperType.QUERY,operDesc = "获取当前博主笔记") + public ResultBean> getMineNotes() { String authorId = String.valueOf(request.getAttribute("authorId")); + NoteDto noteDto = new NoteDto(); + noteDto.setFollowId(authorId); noteDto.setAuthorId(authorId); IPage pageInfo = noteService.selectNotePage(noteDto); return ResultBean.success(pageInfo); @@ -265,7 +214,7 @@ public class AuthApi { public ResultBean upNote(@RequestBody NoteDto noteDto) { String followId = String.valueOf(request.getAttribute("authorId")); Author follow = authorService.getById(followId); - Boolean upNote = Boolean.FALSE; + Boolean isUp = Boolean.FALSE; //查看在不在点赞列表 UpNotes upNotes = upNotesService.selectOneByFollowId(noteDto.getNoteId(),noteDto.getAuthorId(), followId); //不在证明是点赞 @@ -277,16 +226,42 @@ public class AuthApi { upNotes.setFollowName(follow.getAuthorName()); upNotes.setNoteId(noteDto.getNoteId()); upNotes.setNoteTitle(noteDto.getNoteTitle()); - upNote = Boolean.TRUE; + isUp = Boolean.TRUE; upNotesService.save(upNotes); }else{ //在则表示取消赞删除数据 upNotesService.removeById(upNotes); } - return ResultBean.success(upNote); + return ResultBean.success(isUp); }; - + @ApiOperation(value = "收藏笔记") + @ApiOperationSupport(order = 1) + @PostMapping("/api/auth/starNote") + @OperLog(operModule = "收藏笔记",operType = OperType.ADD,operDesc = "收藏笔记") + public ResultBean starNote(@RequestBody NoteDto noteDto) { + String followId = String.valueOf(request.getAttribute("authorId")); + Author follow = authorService.getById(followId); + Boolean isStar = Boolean.FALSE; + //查看在不在点赞列表 + StarNotes starNotes = starNotesService.selectOneByFollowId(noteDto.getNoteId(),noteDto.getAuthorId(), followId); + //不在证明是点赞 + if(starNotes==null){ + starNotes = new StarNotes(); + starNotes.setAuthorId(noteDto.getAuthorId()); + starNotes.setAuthorName(noteDto.getAuthorName()); + starNotes.setFollowId(follow.getAuthorId()); + starNotes.setFollowName(follow.getAuthorName()); + starNotes.setNoteId(noteDto.getNoteId()); + starNotes.setNoteTitle(noteDto.getNoteTitle()); + isStar = Boolean.TRUE; + starNotesService.save(starNotes); + }else{ + //在则表示取消赞删除数据 + starNotesService.removeById(starNotes); + } + return ResultBean.success(isStar); + }; @ApiOperation(value = "创建笔记") @@ -325,4 +300,124 @@ public class AuthApi { noteService.updateById(updateNote); return ResultBean.success(); } + + //外层倒叙 回复正序 + @ApiOperation(value = "获取笔记评论") + @ApiOperationSupport(order = 1) + @GetMapping("/api/auth/getNoteReply") + @OperLog(operModule = "获取笔记评论",operType = OperType.QUERY,operDesc = "获取笔记评论") + public ResultBean getNoteReply( ReplyDto replyDto) { + String noteId = replyDto.getNoteId(); + List replyList = replyService.selectReplyList(new ReplyDto().setNoteId(noteId)); + // 先构建一个以回复ID为键,回复对象为值的Map,方便后续快速查找回复对象 + // 构建以replyId为键,ReplyVo对象为值的Map,方便后续快速查找回复对象 + Map replyMap = replyList.stream() + .collect(Collectors.toMap(ReplyVo::getReplyId, reply -> reply)); + + List secondLevelReplies = replyList + .stream() + .filter(reply -> + (StringUtil.isNotEmpty(reply.getParentId())||StringUtil.isNotEmpty(reply.getTopParentId())) + ).sorted(Comparator.comparing(ReplyVo::getCreateTime)).collect(Collectors.toList()); + secondLevelReplies.forEach(replyVo -> { + if(StringUtil.isNotEmpty(replyVo.getParentId())){ + replyVo.setParentAuthorId(replyMap.get(replyVo.getParentId()).getAuthorId()); + replyVo.setParentAuthorName(replyMap.get(replyVo.getParentId()).getAuthorName()); + } + }); + + // 获取第一层回复(topId为空且parentId也为空) + List firstLevelReplies = replyList.stream() + .filter(reply -> reply.getTopParentId() == null && reply.getParentId() == null) + .collect(Collectors.toList()); + + // 将第二层回复添加到对应的第一层回复下(通过topId与replyId关联) + firstLevelReplies.forEach(firstLevelReply -> { + String firstLevelReplyId = firstLevelReply.getReplyId(); + List relatedSecondLevelReplies = secondLevelReplies.stream() + .filter(secondLevelReply -> firstLevelReplyId.equals(secondLevelReply.getTopParentId())) + .collect(Collectors.toList()); + if (firstLevelReply.getReply() == null) { + firstLevelReply.setReply(new ArrayList<>()); + } + firstLevelReply.getReply().addAll(relatedSecondLevelReplies); + }); + + + return ResultBean.success(firstLevelReplies); + } + + +// // 先按照parentId进行分组,用于后续查找子回复 +// Map> groupedByParentId = replyList.stream() +// .filter(reply -> reply.getParentId()!= null &&!reply.getParentId().isEmpty()) +// .collect(Collectors.groupingBy(ReplyVo::getParentId)); +// +// // 处理每一个顶级回复(parentId为null的回复),递归构建树形结构 +// List resultList = replyList.stream() +// .filter(reply -> reply.getParentId() == null || reply.getParentId().isEmpty()) +// .peek(parentReply -> { +// // 递归设置子回复列表 +// setChildrenReplies(parentReply, groupedByParentId); +// }) +// .collect(Collectors.toList()); + +// // 第一步:将回复列表按照parentId进行分组,key是parentId,value是对应的回复列表 +// Map> groupedByParentId = replyList.stream() +// .filter(reply -> reply.getParentId()!= null &&!reply.getParentId().isEmpty()) +// .collect(Collectors.groupingBy(ReplyVo::getParentId)); +// +// // 第二步:创建一个新的列表,用于存放最终处理后的回复列表,先将没有parentId的元素添加进去 +// List resultList = replyList.stream() +// .filter(reply -> reply.getParentId() == null || reply.getParentId().isEmpty()) +// .collect(Collectors.toList()); +// +// // 第三步:遍历没有parentId的元素,将其对应的子回复列表(通过parentId从分组中获取)设置到Reply属性下 +// resultList.forEach(parentReply -> { +// String parentId = parentReply.getReplyId(); +// List childrenReplies = groupedByParentId.getOrDefault(parentId, new ArrayList<>()); +// parentReply.setReply(childrenReplies); +// }); + + //不再无限极调用 因为前端页面我不会写。。。 采用和官方一样的@形式 + + + private static void setChildrenReplies(ReplyVo parentReply, Map> groupedByParentId) { + String parentId = parentReply.getReplyId(); + List childrenReplies = groupedByParentId.getOrDefault(parentId, new ArrayList<>()); + // 遍历当前层级的子回复,递归设置它们的子回复 + childrenReplies.forEach(childReply -> { + setChildrenReplies(childReply, groupedByParentId); + }); + parentReply.setReply(childrenReplies); + } + + @ApiOperation(value = "回复笔记") + @ApiOperationSupport(order = 1) + @PostMapping("/api/auth/replyNote") + @OperLog(operModule = "回复笔记",operType = OperType.ADD,operDesc = "回复笔记") + public ResultBean replyNote(@RequestBody ReplyDto replyDto) { + String authorId = String.valueOf(request.getAttribute("authorId")); + Author author = authorService.getById(authorId); + Note note = noteService.getById(replyDto.getNoteId()); + if (authorId.equals(note.getAuthorId())) { + replyDto.setAuthorReplay(TRUE); + } + + List replyList = replyService.selectReplyList(new ReplyDto().setNoteId(replyDto.getNoteId())); + if (CollectionUtil.isEmpty(replyList)) { + replyDto.setFirstReplay(TRUE); + } + replyDto.setNoteId(note.getNoteId()); + replyDto.setNoteTitile(note.getNoteTitle()); + replyDto.setAuthorId(authorId); + replyDto.setAuthorName(author.getAuthorName()); + replyDto.setAvatarUrl(author.getAvatarUrl()); + replyDto.setIpAddress(IPUtils.getIpAddr(request)); // 请求IP + replyDto.setIpRealAddress(AddressUtils.getRealAddress(replyDto.getIpAddress())); + Reply reply = BeanUtil.copyProperties(replyDto, Reply.class); + replyService.save(reply); + return ResultBean.success(); + } + } diff --git a/src/main/java/com/dd/admin/business/api/LoginApi.java b/src/main/java/com/dd/admin/business/api/LoginApi.java index 80ed91d..0c1b31b 100644 --- a/src/main/java/com/dd/admin/business/api/LoginApi.java +++ b/src/main/java/com/dd/admin/business/api/LoginApi.java @@ -48,15 +48,6 @@ public class LoginApi { return ResultBean.success(code); } - @ApiOperation(value = "获取验证码") - @ApiOperationSupport(order = 1) - @GetMapping("/api/getMine") - @OperLog(operModule = "获取验证码",operType = OperType.QUERY,operDesc = "获取验证码") - public ResultBean getMine() { - String token = request.getHeader("token"); - return ResultBean.success(token); - } - @ApiOperation(value = "验证码登陆") @ApiOperationSupport(order = 1) @PostMapping("/api/checkCode") diff --git a/src/main/java/com/dd/admin/business/note/domain/NoteDto.java b/src/main/java/com/dd/admin/business/note/domain/NoteDto.java index a469857..1242590 100644 --- a/src/main/java/com/dd/admin/business/note/domain/NoteDto.java +++ b/src/main/java/com/dd/admin/business/note/domain/NoteDto.java @@ -30,7 +30,11 @@ import com.dd.admin.common.model.UpdateGroup; @Data @ApiModel(value="笔记表接收对象") public class NoteDto { + @ApiModelProperty(value = "查询我收藏的字段") + private String myStarById; + @ApiModelProperty(value = "查询我点赞的字段") + private String myUpById; @ApiModelProperty(value = "笔记id") @NotBlank(message = "笔记表id不能为空",groups = UpdateGroup.class) @@ -91,4 +95,10 @@ public class NoteDto { @ApiModelProperty(value = "图片列表") private List imgs; + + @ApiModelProperty(value = "作者ID") + //传入此参数 如果你点赞了会显示相应状态 + private String followId; + + } diff --git a/src/main/java/com/dd/admin/business/note/domain/NoteVo.java b/src/main/java/com/dd/admin/business/note/domain/NoteVo.java index e957ef0..b8c737e 100644 --- a/src/main/java/com/dd/admin/business/note/domain/NoteVo.java +++ b/src/main/java/com/dd/admin/business/note/domain/NoteVo.java @@ -51,6 +51,8 @@ public class NoteVo { @ApiModelProperty(value = "作者ID") private String authorId; + + @ApiModelProperty(value = "作者头像") private String authorAvatar; @@ -91,6 +93,9 @@ public class NoteVo { @ApiModelProperty(value = "收藏数") private Long starCount; + @ApiModelProperty(value = "被当前达人点赞") + private Boolean isStar = Boolean.FALSE; + @ApiModelProperty(value = "图片集合") private List imgList; diff --git a/src/main/java/com/dd/admin/business/note/mapper/NoteMapper.java b/src/main/java/com/dd/admin/business/note/mapper/NoteMapper.java index e756aba..f88f45a 100644 --- a/src/main/java/com/dd/admin/business/note/mapper/NoteMapper.java +++ b/src/main/java/com/dd/admin/business/note/mapper/NoteMapper.java @@ -27,6 +27,8 @@ public interface NoteMapper extends BaseMapper { List selectNoteList(@Param("noteDto") NoteDto noteDto); + NoteVo selectNoteDetail( @Param("noteDto") NoteDto noteDto); + IPage selectMineUpNotes(Page page, @Param("followId")String followId); IPage selectMineStarNotes(Page page, @Param("followId")String followId); } diff --git a/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml b/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml index a18f5ab..3b417f0 100644 --- a/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml +++ b/src/main/java/com/dd/admin/business/note/mapper/xml/NoteMapper.xml @@ -30,19 +30,50 @@ + + diff --git a/src/main/java/com/dd/admin/business/note/service/NoteService.java b/src/main/java/com/dd/admin/business/note/service/NoteService.java index abfde2a..e6d9cca 100644 --- a/src/main/java/com/dd/admin/business/note/service/NoteService.java +++ b/src/main/java/com/dd/admin/business/note/service/NoteService.java @@ -22,10 +22,11 @@ public interface NoteService extends IService { //笔记表-分页列表 IPage selectNotePage(NoteDto noteDto); - //笔记表-列表 List selectNoteList(NoteDto noteDto); + NoteVo selectNoteDetail(NoteDto noteDto); + IPage selectMineUpNotes( String followId); IPage selectMineStarNotes( String followId); diff --git a/src/main/java/com/dd/admin/business/note/service/impl/NoteServiceImpl.java b/src/main/java/com/dd/admin/business/note/service/impl/NoteServiceImpl.java index 1566dca..2b183e6 100644 --- a/src/main/java/com/dd/admin/business/note/service/impl/NoteServiceImpl.java +++ b/src/main/java/com/dd/admin/business/note/service/impl/NoteServiceImpl.java @@ -34,6 +34,11 @@ public class NoteServiceImpl extends ServiceImpl implements No return baseMapper.selectNoteList(noteDto); } + @Override + public NoteVo selectNoteDetail(NoteDto noteDto) { + return baseMapper.selectNoteDetail(noteDto); + } + @Override public IPage selectMineUpNotes(String followId) { Page page = PageFactory.defaultPage(); diff --git a/src/main/java/com/dd/admin/business/reply/controller/ReplyController.java b/src/main/java/com/dd/admin/business/reply/controller/ReplyController.java new file mode 100644 index 0000000..d41babe --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/controller/ReplyController.java @@ -0,0 +1,88 @@ +package com.dd.admin.business.reply.controller; + +import cn.hutool.core.bean.BeanUtil; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import com.dd.admin.common.model.UpdateGroup; +import com.dd.admin.common.model.result.ResultBean; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import javax.validation.constraints.NotBlank; +import com.dd.admin.business.reply.entity.Reply; +import com.dd.admin.business.reply.domain.ReplyVo; +import com.dd.admin.business.reply.domain.ReplyDto; +import com.dd.admin.business.reply.service.ReplyService; + +import java.util.List; + +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 回复表 前端控制器 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +@Api(tags = "回复表") +@RestController +public class ReplyController { + + @Autowired + ReplyService replyService; + + @ApiOperation(value = "回复表-分页列表") + @ApiOperationSupport(order = 1) + @GetMapping("/admin/reply/page") + public ResultBean> page(ReplyDto replyDto) { + IPage pageInfo = replyService.selectReplyPage(replyDto); + return ResultBean.success(pageInfo); + } + + @ApiOperation(value = "回复表-列表") + @ApiOperationSupport(order = 2) + @GetMapping("/admin/reply/list") + public ResultBean> list(ReplyDto replyDto) { + List list = replyService.selectReplyList(replyDto); + return ResultBean.success(list); + } + + @ApiOperation(value = "回复表-添加") + @ApiOperationSupport(order = 3) + @PostMapping("/admin/reply/add") + public ResultBean add(@RequestBody @Validated ReplyDto replyDto) { + Reply reply = BeanUtil.copyProperties(replyDto, Reply.class); + replyService.save(reply); + return ResultBean.success(reply); + } + + @ApiOperation(value = "回复表-查询") + @ApiOperationSupport(order = 4) + @GetMapping("/admin/reply/{replyId}") + public ResultBean get(@PathVariable @NotBlank String replyId) { + Reply reply = replyService.getById(replyId); + ReplyVo replyVo = BeanUtil.copyProperties(reply,ReplyVo.class); + return ResultBean.success(replyVo); + } + + @ApiOperation(value = "回复表-修改") + @ApiOperationSupport(order = 5) + @PostMapping("/admin/reply/update") + public ResultBean update(@RequestBody @Validated(UpdateGroup.class) ReplyDto replyDto) { + Reply reply = BeanUtil.copyProperties(replyDto, Reply.class); + replyService.updateById(reply); + return ResultBean.success(reply); + } + + @ApiOperation(value = "回复表-删除") + @ApiOperationSupport(order = 6) + @GetMapping("/admin/reply/delete/{replyId}") + public ResultBean delete(@PathVariable @NotBlank String replyId) { + Boolean b = replyService.removeById(replyId); + return ResultBean.success(b); + } +} diff --git a/src/main/java/com/dd/admin/business/reply/domain/ReplyDto.java b/src/main/java/com/dd/admin/business/reply/domain/ReplyDto.java new file mode 100644 index 0000000..1c61f13 --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/domain/ReplyDto.java @@ -0,0 +1,103 @@ +package com.dd.admin.business.reply.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotBlank; +import com.dd.admin.common.model.UpdateGroup; +import lombok.experimental.Accessors; + + +/** + *

+ * 回复表返回对象 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +@Data +@ApiModel(value="回复表接收对象") +@Accessors(chain = true) +public class ReplyDto { + + + @ApiModelProperty(value = "回复id") + @NotBlank(message = "回复表id不能为空",groups = UpdateGroup.class) + private String replyId; + + @ApiModelProperty(value = "笔记id") + private String noteId; + + @ApiModelProperty(value = "笔记标题") + private String noteTitile; + + @ApiModelProperty(value = "作者id") + private String authorId; + + @ApiModelProperty(value = "作者名") + private String authorName; + + @ApiModelProperty(value = "作者id") + private String parentAuthorId; + + @ApiModelProperty(value = "作者名") + private String parentAuthorName; + + @ApiModelProperty(value = "第一层回复id") + private String topParentId; + + @ApiModelProperty(value = "上级id") + private String parentId; + + @ApiModelProperty(value = "回复内容") + private String replayContent; + + @ApiModelProperty(value = "回复图片id") + private String replayImgId; + + @ApiModelProperty(value = "回复图片Url") + private String replayImgUrl; + + @ApiModelProperty(value = "0正常 1删除") + private Integer deleted; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "ip地址") + private String ipAddress; + + @ApiModelProperty(value = "真实ip地址") + private String ipRealAddress; + + @ApiModelProperty(value = "是首评 0不是 1是") + private Integer firstReplay; + + @ApiModelProperty(value = "是作者 0不是 1是") + private Integer authorReplay; + + @ApiModelProperty(value = "0正常 1折叠") + private Integer replayStatus; + + @ApiModelProperty(value = "0文字 1图片") + private Integer replayType; + + @ApiModelProperty(value = "点赞数") + private Long upCount; + + @ApiModelProperty(value = "头像地址") + private String avatarUrl; + + +} diff --git a/src/main/java/com/dd/admin/business/reply/domain/ReplyVo.java b/src/main/java/com/dd/admin/business/reply/domain/ReplyVo.java new file mode 100644 index 0000000..7241845 --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/domain/ReplyVo.java @@ -0,0 +1,106 @@ +package com.dd.admin.business.reply.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +import java.util.ArrayList; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 回复表返回对象 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +@Data +@ApiModel(value="回复表返回对象") +public class ReplyVo { + + + @ApiModelProperty(value = "回复id") + private String replyId; + + @ApiModelProperty(value = "笔记id") + private String noteId; + + @ApiModelProperty(value = "笔记标题") + private String noteTitile; + + @ApiModelProperty(value = "作者id") + private String authorId; + + @ApiModelProperty(value = "作者名") + private String authorName; + + @ApiModelProperty(value = "作者id") + private String parentAuthorId; + + @ApiModelProperty(value = "作者名") + private String parentAuthorName; + + @ApiModelProperty(value = "第一层回复的id") + private String topParentId; + + @ApiModelProperty(value = "上级id") + private String parentId; + + @ApiModelProperty(value = "回复内容") + private String replayContent; + + @ApiModelProperty(value = "回复图片id") + private String replayImgId; + + @ApiModelProperty(value = "回复图片Url") + private String replayImgUrl; + + @ApiModelProperty(value = "0正常 1删除") + private Integer deleted; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern="MM-dd", timezone = "GMT+8") + private Date createTimeStr; + + @ApiModelProperty(value = "ip地址") + private String ipAddress; + + @ApiModelProperty(value = "真实ip地址") + private String ipRealAddress; + + @ApiModelProperty(value = "是首评 0不是 1是") + private Integer firstReplay; + + @ApiModelProperty(value = "是作者 0不是 1是") + private Integer authorReplay; + + @ApiModelProperty(value = "0正常 1折叠") + private Integer replayStatus; + + @ApiModelProperty(value = "0文字 1图片") + private Integer replayType; + + @ApiModelProperty(value = "点赞数") + private Long upCount; + + @ApiModelProperty(value = "头像地址") + private String avatarUrl; + + private List Reply = new ArrayList<>(); +} diff --git a/src/main/java/com/dd/admin/business/reply/entity/Reply.java b/src/main/java/com/dd/admin/business/reply/entity/Reply.java new file mode 100644 index 0000000..98deb96 --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/entity/Reply.java @@ -0,0 +1,121 @@ +package com.dd.admin.business.reply.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 回复表 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("business_reply") +@ApiModel(value="Reply对象", description="回复表") +public class Reply implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "回复id") + @TableId(value = "REPLY_ID", type = IdType.ASSIGN_UUID) + private String replyId; + + @ApiModelProperty(value = "笔记id") + @TableField("NOTE_ID") + private String noteId; + + @ApiModelProperty(value = "笔记标题") + @TableField("NOTE_TITILE") + private String noteTitile; + + @ApiModelProperty(value = "作者id") + @TableField("AUTHOR_ID") + private String authorId; + + @ApiModelProperty(value = "作者名") + @TableField("AUTHOR_NAME") + private String authorName; + + @ApiModelProperty(value = "上级id") + @TableField("PARENT_ID") + private String parentId; + + @ApiModelProperty(value = "作者id") + private String parentAuthorId; + + @ApiModelProperty(value = "作者名") + private String parentAuthorName; + + @ApiModelProperty(value = "第一层回复的id") + private String topParentId; + + + @ApiModelProperty(value = "回复内容") + @TableField("REPLAY_CONTENT") + private String replayContent; + + @ApiModelProperty(value = "回复图片id") + @TableField("REPLAY_IMG_ID") + private String replayImgId; + + @ApiModelProperty(value = "回复图片Url") + @TableField("REPLAY_IMG_URL") + private String replayImgUrl; + + @ApiModelProperty(value = "0正常 1删除") + @TableField("DELETED") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "创建时间") + @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "ip地址") + @TableField("IP_ADDRESS") + private String ipAddress; + + @ApiModelProperty(value = "真实ip地址") + @TableField("IP_REAL_ADDRESS") + private String ipRealAddress; + + @ApiModelProperty(value = "是首评 0不是 1是") + @TableField("FIRST_REPLAY") + private Integer firstReplay; + + @ApiModelProperty(value = "是作者 0不是 1是") + @TableField("AUTHOR_REPLAY") + private Integer authorReplay; + + @ApiModelProperty(value = "0正常 1折叠") + @TableField("REPLAY_STATUS") + private Integer replayStatus; + + @ApiModelProperty(value = "0文字 1图片") + @TableField("REPLAY_TYPE") + private Integer replayType; + + @ApiModelProperty(value = "点赞数") + @TableField("UP_COUNT") + private Long upCount; + + @ApiModelProperty(value = "头像地址") + @TableField("AVATAR_URL") + private String avatarUrl; + + +} diff --git a/src/main/java/com/dd/admin/business/reply/mapper/ReplyMapper.java b/src/main/java/com/dd/admin/business/reply/mapper/ReplyMapper.java new file mode 100644 index 0000000..49b892c --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/mapper/ReplyMapper.java @@ -0,0 +1,28 @@ +package com.dd.admin.business.reply.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dd.admin.business.reply.entity.Reply; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dd.admin.business.reply.domain.ReplyVo; +import com.dd.admin.business.reply.domain.ReplyDto; + +import java.util.List; + +/** + *

+ * 回复表 Mapper 接口 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +@Mapper +public interface ReplyMapper extends BaseMapper { + + IPage selectReplyPage(Page page, @Param("replyDto") ReplyDto replyDto); + + List selectReplyList(@Param("replyDto") ReplyDto replyDto); +} diff --git a/src/main/java/com/dd/admin/business/reply/mapper/xml/ReplyMapper.xml b/src/main/java/com/dd/admin/business/reply/mapper/xml/ReplyMapper.xml new file mode 100644 index 0000000..df595ab --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/mapper/xml/ReplyMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + REPLY_ID, NOTE_ID, NOTE_TITILE, AUTHOR_ID, AUTHOR_NAME, PARENT_ID, REPLAY_CONTENT, REPLAY_IMG_ID, REPLAY_IMG_URL, DELETED, CREATE_TIME, IP_ADDRESS, IP_REAL_ADDRESS, FIRST_REPLAY, AUTHOR_REPLAY, REPLAY_STATUS, REPLAY_TYPE, UP_COUNT, AVATAR_URL + + + + + + diff --git a/src/main/java/com/dd/admin/business/reply/service/ReplyService.java b/src/main/java/com/dd/admin/business/reply/service/ReplyService.java new file mode 100644 index 0000000..3e3677b --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/service/ReplyService.java @@ -0,0 +1,26 @@ +package com.dd.admin.business.reply.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.dd.admin.business.reply.entity.Reply; +import com.baomidou.mybatisplus.extension.service.IService; +import com.dd.admin.business.reply.domain.ReplyVo; +import com.dd.admin.business.reply.domain.ReplyDto; +import java.util.List; + +/** + *

+ * 回复表 服务类 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +public interface ReplyService extends IService { + + //回复表-分页列表 + IPage selectReplyPage(ReplyDto replyDto); + + //回复表-列表 + List selectReplyList(ReplyDto replyDto); + +} diff --git a/src/main/java/com/dd/admin/business/reply/service/impl/ReplyServiceImpl.java b/src/main/java/com/dd/admin/business/reply/service/impl/ReplyServiceImpl.java new file mode 100644 index 0000000..973a7c9 --- /dev/null +++ b/src/main/java/com/dd/admin/business/reply/service/impl/ReplyServiceImpl.java @@ -0,0 +1,36 @@ +package com.dd.admin.business.reply.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dd.admin.common.model.PageFactory; +import com.dd.admin.business.reply.entity.Reply; +import com.dd.admin.business.reply.mapper.ReplyMapper; +import com.dd.admin.business.reply.service.ReplyService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import com.dd.admin.business.reply.domain.ReplyVo; +import com.dd.admin.business.reply.domain.ReplyDto; +import java.util.List; + +/** + *

+ * 回复表 服务实现类 + *

+ * + * @author 727869402@qq.com + * @since 2024-12-25 + */ +@Service +public class ReplyServiceImpl extends ServiceImpl implements ReplyService { + + @Override + public IPage selectReplyPage(ReplyDto replyDto) { + Page page = PageFactory.defaultPage(); + return baseMapper.selectReplyPage(page,replyDto); + } + + @Override + public List selectReplyList(ReplyDto replyDto) { + return baseMapper.selectReplyList(replyDto); + } +} diff --git a/src/main/java/com/dd/admin/business/starNotes/service/StarNotesService.java b/src/main/java/com/dd/admin/business/starNotes/service/StarNotesService.java index 92a6628..0e20175 100644 --- a/src/main/java/com/dd/admin/business/starNotes/service/StarNotesService.java +++ b/src/main/java/com/dd/admin/business/starNotes/service/StarNotesService.java @@ -7,6 +7,7 @@ import com.dd.admin.business.starNotes.domain.StarNotesVo; import com.dd.admin.business.starNotes.domain.StarNotesDto; import com.dd.admin.business.upNotes.domain.UpNotesDto; import com.dd.admin.business.upNotes.domain.UpNotesVo; +import com.dd.admin.business.upNotes.entity.UpNotes; import java.util.List; @@ -26,4 +27,7 @@ public interface StarNotesService extends IService { //收藏笔记列表-列表 List selectStarNotesList(StarNotesDto starNotesDto); + StarNotes selectOneByFollowId(String noteId, String authorId, String followId); + + } diff --git a/src/main/java/com/dd/admin/business/starNotes/service/impl/StarNotesServiceImpl.java b/src/main/java/com/dd/admin/business/starNotes/service/impl/StarNotesServiceImpl.java index 7b147d9..302d67d 100644 --- a/src/main/java/com/dd/admin/business/starNotes/service/impl/StarNotesServiceImpl.java +++ b/src/main/java/com/dd/admin/business/starNotes/service/impl/StarNotesServiceImpl.java @@ -1,7 +1,9 @@ package com.dd.admin.business.starNotes.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.dd.admin.business.upNotes.entity.UpNotes; import com.dd.admin.common.model.PageFactory; import com.dd.admin.business.starNotes.entity.StarNotes; import com.dd.admin.business.starNotes.mapper.StarNotesMapper; @@ -33,4 +35,14 @@ public class StarNotesServiceImpl extends ServiceImpl selectStarNotesList(StarNotesDto starNotesDto) { return baseMapper.selectStarNotesList(starNotesDto); } + + @Override + public StarNotes selectOneByFollowId(String noteId, String authorId, String followId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(StarNotes::getNoteId,noteId); + queryWrapper.eq(StarNotes::getAuthorId,authorId); + queryWrapper.eq(StarNotes::getFollowId,followId); + return this.getOne(queryWrapper); + } + } diff --git a/src/main/java/com/dd/admin/common/config/GolbalConfig.java b/src/main/java/com/dd/admin/common/config/GolbalConfig.java index 675baa2..9e991dc 100644 --- a/src/main/java/com/dd/admin/common/config/GolbalConfig.java +++ b/src/main/java/com/dd/admin/common/config/GolbalConfig.java @@ -20,6 +20,16 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class GolbalConfig implements WebMvcConfigurer { + @Autowired + private ApiInterceptor apiInterceptor; + + // 注册拦截器的方法 + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(apiInterceptor) + .addPathPatterns("/api/auth/**"); // 拦截/api下所有请求路径 + } + @Value("${dd.uploadPath}") private String uploadPath; @@ -53,15 +63,7 @@ public class GolbalConfig implements WebMvcConfigurer { } - @Autowired - private ApiInterceptor apiInterceptor; - // 注册拦截器的方法 - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(apiInterceptor) - .addPathPatterns("/api/auth/**"); // 拦截/api下所有请求路径 - } // @Bean diff --git a/src/main/java/com/dd/admin/common/consts/XhsConst.java b/src/main/java/com/dd/admin/common/consts/XhsConst.java new file mode 100644 index 0000000..328afd4 --- /dev/null +++ b/src/main/java/com/dd/admin/common/consts/XhsConst.java @@ -0,0 +1,8 @@ +package com.dd.admin.common.consts; + +public class XhsConst { + /** + * 肯定 + */ + public final static Integer TRUE = 1; +} diff --git a/src/main/java/com/dd/admin/common/security/interceptor/ApiInterceptor.java b/src/main/java/com/dd/admin/common/security/interceptor/ApiInterceptor.java index 2a22297..f46dd9b 100644 --- a/src/main/java/com/dd/admin/common/security/interceptor/ApiInterceptor.java +++ b/src/main/java/com/dd/admin/common/security/interceptor/ApiInterceptor.java @@ -43,8 +43,6 @@ public class ApiInterceptor implements HandlerInterceptor { if (StrUtil.isBlank(token)) { throw new ApiException("请登录后访问"); } - - //解析token System.out.println(token); String authorId = jwtTokenUtil.getUsernameFromToken(token);