完成基本功能
This commit is contained in:
@@ -14,10 +14,14 @@ import com.dd.admin.business.noteImg.domain.NoteImgDto;
|
||||
import com.dd.admin.business.noteImg.domain.NoteImgVo;
|
||||
import com.dd.admin.business.noteImg.entity.NoteImg;
|
||||
import com.dd.admin.business.noteImg.service.NoteImgService;
|
||||
import com.dd.admin.business.upNotes.domain.UpNotesDto;
|
||||
import com.dd.admin.business.upNotes.domain.UpNotesVo;
|
||||
import com.dd.admin.business.upNotes.service.UpNotesService;
|
||||
import com.dd.admin.common.aop.operationLog.aop.OperLog;
|
||||
import com.dd.admin.common.aop.operationLog.aop.OperType;
|
||||
import com.dd.admin.common.model.result.ResultBean;
|
||||
import com.dd.admin.common.security.SecurityUtil;
|
||||
import com.dd.admin.common.security.jwt.JwtTokenUtil;
|
||||
import com.dd.admin.common.utils.AddressUtils;
|
||||
import com.dd.admin.common.utils.IPUtils;
|
||||
import com.dd.admin.common.utils.RandomXiaohongshuAuthorName;
|
||||
@@ -45,16 +49,85 @@ public class ApiController {
|
||||
HttpServletRequest request;
|
||||
@Autowired
|
||||
NoteImgService noteImgService;
|
||||
|
||||
@Autowired
|
||||
UpNotesService upNotesService;
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
@ApiOperation(value = "获取所有笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/notes")
|
||||
@OperLog(operModule = "获取所有笔记",operType = OperType.QUERY,operDesc = "获取所有笔记")
|
||||
@OperLog(operModule = "获取所有笔记", operType = OperType.QUERY, operDesc = "获取所有笔记")
|
||||
public ResultBean<IPage<NoteVo>> page(NoteDto noteDto) {
|
||||
// 1. 通过noteService根据传入的NoteDto参数查询笔记的分页信息,获取包含笔记数据的分页对象
|
||||
IPage<NoteVo> pageInfo = noteService.selectNotePage(noteDto);
|
||||
|
||||
// 2. 创建一个用于存储当前用户点赞笔记信息的列表,初始化为空
|
||||
List<UpNotesVo> upNotesVos = new ArrayList<>();
|
||||
|
||||
// 3. 从请求头中获取名为"token"的token字符串,用于后续解析获取用户ID
|
||||
String token = request.getHeader("token");
|
||||
String authorId = "";
|
||||
try {
|
||||
// 4. 尝试使用jwtTokenUtil工具类从获取到的token中解析出用户名(这里假设用户名就是用户ID),如果解析成功则赋值给authorId变量
|
||||
authorId = 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);
|
||||
}
|
||||
|
||||
// 10. 通过upNotesService查询所有笔记的点赞数量统计信息,获取一个包含各笔记点赞数量相关信息的列表
|
||||
List<UpNotesVo> selectAllUpCount = upNotesService.selectAllUpCount();
|
||||
|
||||
// 11. 获取前面查询到的笔记分页信息中的具体笔记记录列表,后续要对这些笔记记录进行相关属性的设置操作
|
||||
List<NoteVo> records = pageInfo.getRecords();
|
||||
// 12. 为了能在下面的lambda表达式中使用upNotesVos变量,创建一个final修饰的变量来引用它,因为lambda表达式中访问的外部变量需要是final或者事实上的final(不可重新赋值)
|
||||
List<UpNotesVo> 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());
|
||||
}
|
||||
});
|
||||
|
||||
// 20. 将处理好的包含笔记信息(已设置点赞状态和点赞数量)的分页对象包装在ResultBean中返回,以便前端或其他调用方获取处理后的结果数据
|
||||
return ResultBean.success(pageInfo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取ip地址")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/getIpAddress")
|
||||
@OperLog(operModule = "获取ip地址",operType = OperType.QUERY,operDesc = "获取单个笔记")
|
||||
public ResultBean<String> getIpAddress() {
|
||||
String ipAddr = IPUtils.getIpAddr(request);
|
||||
String realAddress = AddressUtils.getRealAddress(ipAddr);
|
||||
return ResultBean.success(realAddress);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取单个笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/getNote")
|
||||
|
@@ -2,20 +2,35 @@ package com.dd.admin.business.api;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.dd.admin.business.author.entity.Author;
|
||||
import com.dd.admin.business.author.service.AuthorService;
|
||||
import com.dd.admin.business.file.entity.File;
|
||||
import com.dd.admin.business.file.service.FileService;
|
||||
import com.dd.admin.business.follow.entity.Follow;
|
||||
import com.dd.admin.business.follow.service.FollowService;
|
||||
import com.dd.admin.business.note.domain.NoteDto;
|
||||
import com.dd.admin.business.note.domain.NoteVo;
|
||||
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.starNotes.domain.StarNotesDto;
|
||||
import com.dd.admin.business.starNotes.domain.StarNotesVo;
|
||||
import com.dd.admin.business.starNotes.entity.StarNotes;
|
||||
import com.dd.admin.business.starNotes.service.StarNotesService;
|
||||
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 com.dd.admin.business.upNotes.service.UpNotesService;
|
||||
import com.dd.admin.common.aop.operationLog.aop.OperLog;
|
||||
import com.dd.admin.common.aop.operationLog.aop.OperType;
|
||||
import com.dd.admin.common.model.result.ResultBean;
|
||||
import com.dd.admin.common.utils.AddressUtils;
|
||||
import com.dd.admin.common.utils.CommonUtil;
|
||||
import com.dd.admin.common.utils.IPUtils;
|
||||
import com.dd.admin.common.utils.StringUtil;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -43,6 +58,182 @@ public class AuthApi {
|
||||
NoteImgService noteImgService;
|
||||
@Value("${server.port}")
|
||||
String port;
|
||||
@Autowired
|
||||
UpNotesService upNotesService;
|
||||
@Autowired
|
||||
StarNotesService starNotesService;
|
||||
@Autowired
|
||||
FollowService followService;
|
||||
|
||||
@ApiOperation(value = "获取所有笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/auth/notes")
|
||||
@OperLog(operModule = "获取所有笔记",operType = OperType.QUERY,operDesc = "获取所有笔记")
|
||||
public ResultBean<IPage<NoteVo>> page(NoteDto noteDto) {
|
||||
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||
|
||||
IPage<NoteVo> pageInfo = noteService.selectNotePage(noteDto);
|
||||
List<NoteVo> records = pageInfo.getRecords();
|
||||
UpNotesDto upNotesDto = new UpNotesDto();
|
||||
upNotesDto.setFollowId(authorId);
|
||||
List<UpNotesVo> upNotesVos = upNotesService.selectUpNotesList(upNotesDto);
|
||||
|
||||
List<UpNotesVo> 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 = "获取所有笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/auth/getFollowNotes")
|
||||
@OperLog(operModule = "获取所有笔记",operType = OperType.QUERY,operDesc = "获取所有笔记")
|
||||
public ResultBean<IPage<NoteVo>> getFollowNotes(NoteDto noteDto) {
|
||||
String followId = String.valueOf(request.getAttribute("authorId"));
|
||||
|
||||
List<Follow> follows = followService.selectFollowListByFollowId(followId);
|
||||
|
||||
IPage<NoteVo> pageInfo = new IPage<NoteVo>() {
|
||||
@Override
|
||||
public List<OrderItem> orders() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NoteVo> getRecords() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoteVo> setRecords(List<NoteVo> records) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotal() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoteVo> setTotal(long total) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoteVo> setSize(long size) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCurrent() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoteVo> setCurrent(long current) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
if(CollectionUtil.isNotEmpty(follows)){
|
||||
String authorIds = CommonUtil.getIds(follows, "authorId");
|
||||
noteDto.setAuthorIds(authorIds);
|
||||
pageInfo = noteService.selectNotePage(noteDto);
|
||||
List<NoteVo> records = pageInfo.getRecords();
|
||||
UpNotesDto upNotesDto = new UpNotesDto();
|
||||
upNotesDto.setFollowId(followId);
|
||||
List<UpNotesVo> upNotesVos = upNotesService.selectUpNotesList(upNotesDto);
|
||||
|
||||
List<UpNotesVo> 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 = "获取所有点赞笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/auth/getUpNotes")
|
||||
@OperLog(operModule = "获取所有点赞笔记",operType = OperType.QUERY,operDesc = "获取所有点赞笔记")
|
||||
public ResultBean<IPage<NoteVo>> getUpNotes(NoteDto noteDto) {
|
||||
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||
|
||||
IPage<NoteVo> pageInfo = noteService.selectMineUpNotes(authorId);
|
||||
List<NoteVo> records = pageInfo.getRecords();
|
||||
UpNotesDto upNotesDto = new UpNotesDto();
|
||||
upNotesDto.setFollowId(authorId);
|
||||
List<UpNotesVo> upNotesVos = upNotesService.selectUpNotesList(upNotesDto);
|
||||
|
||||
List<UpNotesVo> 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 = "获取所有收藏笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/auth/getStarNotes")
|
||||
@OperLog(operModule = "获取所有收藏笔记",operType = OperType.QUERY,operDesc = "获取所有收藏笔记")
|
||||
public ResultBean<IPage<NoteVo>> getStarNotes(NoteDto noteDto) {
|
||||
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||
|
||||
IPage<NoteVo> pageInfo = noteService.selectMineStarNotes(authorId);
|
||||
List<NoteVo> records = pageInfo.getRecords();
|
||||
|
||||
UpNotesDto upNotesDto = new UpNotesDto();
|
||||
upNotesDto.setFollowId(authorId);
|
||||
List<UpNotesVo> upNotesVos = upNotesService.selectUpNotesList(upNotesDto);
|
||||
|
||||
List<UpNotesVo> 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 = "获取博主信息")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@@ -55,6 +246,49 @@ public class AuthApi {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取博主笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@GetMapping("/api/auth/getMineNotes")
|
||||
@OperLog(operModule = "获取博主笔记",operType = OperType.QUERY,operDesc = "获取博主笔记")
|
||||
public ResultBean<IPage<NoteVo>> getMineNotes(NoteDto noteDto) {
|
||||
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||
noteDto.setAuthorId(authorId);
|
||||
IPage<NoteVo> pageInfo = noteService.selectNotePage(noteDto);
|
||||
return ResultBean.success(pageInfo);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "点赞笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@PostMapping("/api/auth/upNote")
|
||||
@OperLog(operModule = "点赞笔记",operType = OperType.ADD,operDesc = "点赞笔记")
|
||||
public ResultBean upNote(@RequestBody NoteDto noteDto) {
|
||||
String followId = String.valueOf(request.getAttribute("authorId"));
|
||||
Author follow = authorService.getById(followId);
|
||||
Boolean upNote = Boolean.FALSE;
|
||||
//查看在不在点赞列表
|
||||
UpNotes upNotes = upNotesService.selectOneByFollowId(noteDto.getNoteId(),noteDto.getAuthorId(), followId);
|
||||
//不在证明是点赞
|
||||
if(upNotes==null){
|
||||
upNotes = new UpNotes();
|
||||
upNotes.setAuthorId(noteDto.getAuthorId());
|
||||
upNotes.setAuthorName(noteDto.getAuthorName());
|
||||
upNotes.setFollowId(follow.getAuthorId());
|
||||
upNotes.setFollowName(follow.getAuthorName());
|
||||
upNotes.setNoteId(noteDto.getNoteId());
|
||||
upNotes.setNoteTitle(noteDto.getNoteTitle());
|
||||
upNote = Boolean.TRUE;
|
||||
upNotesService.save(upNotes);
|
||||
}else{
|
||||
//在则表示取消赞删除数据
|
||||
upNotesService.removeById(upNotes);
|
||||
}
|
||||
return ResultBean.success(upNote);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "创建笔记")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@PostMapping("/api/auth/addNote")
|
||||
|
@@ -54,6 +54,8 @@ public class NoteDto {
|
||||
@ApiModelProperty(value = "作者ID")
|
||||
private String authorId;
|
||||
|
||||
private String authorIds;
|
||||
|
||||
@ApiModelProperty(value = "作者头像")
|
||||
private String authorAvatar;
|
||||
|
||||
|
@@ -83,7 +83,10 @@ public class NoteVo {
|
||||
private String ipRealAddress;
|
||||
|
||||
@ApiModelProperty(value = "点赞数")
|
||||
private Long upCount;
|
||||
private Integer upCount = 0;
|
||||
|
||||
@ApiModelProperty(value = "被当前达人点赞")
|
||||
private Boolean isUp = Boolean.FALSE;
|
||||
|
||||
@ApiModelProperty(value = "收藏数")
|
||||
private Long starCount;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.dd.admin.business.note.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.dd.admin.business.noteImg.domain.NoteImgVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -25,4 +26,7 @@ public interface NoteMapper extends BaseMapper<Note> {
|
||||
IPage<NoteVo> selectNotePage(Page<NoteVo> page, @Param("noteDto") NoteDto noteDto);
|
||||
|
||||
List<NoteVo> selectNoteList(@Param("noteDto") NoteDto noteDto);
|
||||
|
||||
IPage<NoteVo> selectMineUpNotes(Page<NoteVo> page, @Param("followId")String followId);
|
||||
IPage<NoteVo> selectMineStarNotes(Page<NoteVo> page, @Param("followId")String followId);
|
||||
}
|
||||
|
@@ -32,7 +32,16 @@
|
||||
<select id="selectNotePage" resultType="com.dd.admin.business.note.domain.NoteVo">
|
||||
select
|
||||
*,CREATE_TIME AS createTimeStr
|
||||
from business_note where 1 = 1
|
||||
from business_note where deleted = 0
|
||||
<if test="noteDto.authorId != null and noteDto.authorId != ''">
|
||||
and AUTHOR_ID = #{noteDto.authorId}
|
||||
</if>
|
||||
<if test="noteDto.authorIds != null and noteDto.authorId != ''">
|
||||
and AUTHOR_ID in ${noteDto.authorIds}
|
||||
</if>
|
||||
<if test="noteDto.ipRealAddress != null and noteDto.ipRealAddress != ''">
|
||||
and IP_REAL_ADDRESS = #{noteDto.ipRealAddress}
|
||||
</if>
|
||||
order by CREATE_TIME desc
|
||||
</select>
|
||||
|
||||
@@ -41,4 +50,15 @@
|
||||
*
|
||||
from business_note where 1 = 1
|
||||
</select>
|
||||
|
||||
<select id="selectMineUpNotes" resultType="com.dd.admin.business.note.domain.NoteVo">
|
||||
select * from business_note a left join business_up_notes b on a.note_id = b.note_id
|
||||
where b.follow_id = #{followId}
|
||||
order by b.create_time desc
|
||||
</select>
|
||||
<select id="selectMineStarNotes" resultType="com.dd.admin.business.note.domain.NoteVo">
|
||||
select * from business_note a left join business_star_notes b on a.note_id = b.note_id
|
||||
where b.follow_id = #{followId}
|
||||
order by b.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
@@ -1,10 +1,13 @@
|
||||
package com.dd.admin.business.note.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.dd.admin.business.note.entity.Note;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dd.admin.business.note.domain.NoteVo;
|
||||
import com.dd.admin.business.note.domain.NoteDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,4 +26,9 @@ public interface NoteService extends IService<Note> {
|
||||
//笔记表-列表
|
||||
List<NoteVo> selectNoteList(NoteDto noteDto);
|
||||
|
||||
IPage<NoteVo> selectMineUpNotes( String followId);
|
||||
|
||||
IPage<NoteVo> selectMineStarNotes( String followId);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -33,4 +33,16 @@ public class NoteServiceImpl extends ServiceImpl<NoteMapper, Note> implements No
|
||||
public List<NoteVo> selectNoteList(NoteDto noteDto) {
|
||||
return baseMapper.selectNoteList(noteDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoteVo> selectMineUpNotes(String followId) {
|
||||
Page page = PageFactory.defaultPage();
|
||||
return baseMapper.selectMineUpNotes(page,followId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoteVo> selectMineStarNotes(String followId) {
|
||||
Page page = PageFactory.defaultPage();
|
||||
return baseMapper.selectMineStarNotes(page,followId);
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.dd.admin.business.note.domain.NoteVo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -27,7 +29,7 @@ public class NoteImgVo {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "关联id")
|
||||
private String noteImgId;
|
||||
private NoteVo noteImgId;
|
||||
|
||||
@ApiModelProperty(value = "图片上传的文件id")
|
||||
private String imgId;
|
||||
|
@@ -25,4 +25,5 @@ public interface NoteImgMapper extends BaseMapper<NoteImg> {
|
||||
IPage<NoteImgVo> selectNoteImgPage(Page<NoteImgVo> page, @Param("noteImgDto") NoteImgDto noteImgDto);
|
||||
|
||||
List<NoteImgVo> selectNoteImgList(@Param("noteImgDto") NoteImgDto noteImgDto);
|
||||
|
||||
}
|
||||
|
@@ -34,4 +34,5 @@
|
||||
</if>
|
||||
order by IMG_SORT asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@@ -43,6 +43,8 @@ public class ApiInterceptor implements HandlerInterceptor {
|
||||
if (StrUtil.isBlank(token)) {
|
||||
throw new ApiException("请登录后访问");
|
||||
}
|
||||
|
||||
|
||||
//解析token
|
||||
System.out.println(token);
|
||||
String authorId = jwtTokenUtil.getUsernameFromToken(token);
|
||||
|
@@ -24,10 +24,11 @@ public class AddressUtils {
|
||||
String rspStr = RegionUtil.getRegion(ip);
|
||||
if (StringUtils.isNotEmpty(rspStr)) {
|
||||
String[] obj = rspStr.split("\\|");
|
||||
String region = obj[2];
|
||||
// String region = obj[2];
|
||||
String city = obj[3];
|
||||
|
||||
return String.format("%s%s", region, city);
|
||||
// return String.format("%s%s", region, city);
|
||||
return String.format("%s", city);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取地理位置异常 {}", e.toString());
|
||||
|
Reference in New Issue
Block a user