创建笔记保存笔记对应图片
This commit is contained in:
parent
c8796352a4
commit
5642cd9613
@ -65,22 +65,7 @@ public class ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "创建笔记")
|
|
||||||
@ApiOperationSupport(order = 1)
|
|
||||||
@PostMapping("/api/addNote")
|
|
||||||
@OperLog(operModule = "创建笔记",operType = OperType.ADD,operDesc = "创建笔记")
|
|
||||||
public ResultBean addNote(@RequestBody NoteDto noteDto) {
|
|
||||||
Note note = BeanUtil.copyProperties(noteDto, Note.class);
|
|
||||||
if(CollectionUtil.isNotEmpty(noteDto.getImgs())){
|
|
||||||
note.setFirstPicture(noteDto.getImgs().get(0));
|
|
||||||
}
|
|
||||||
note.setAuthorName(RandomXiaohongshuAuthorName.generateAuthorName());
|
|
||||||
note.setAuthorAvatar("http://8.146.211.120:8080/upload/avatar/avatar ("+ StringUtil.createCode(1) +").jpg");
|
|
||||||
note.setIpAddress(IPUtils.getIpAddr(request)); // 请求IP
|
|
||||||
note.setIpRealAddress(AddressUtils.getRealAddress(note.getIpAddress()));
|
|
||||||
noteService.save(note);
|
|
||||||
return ResultBean.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,88 @@
|
|||||||
package com.dd.admin.business.api;
|
package com.dd.admin.business.api;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.dd.admin.business.author.entity.Author;
|
import com.dd.admin.business.author.entity.Author;
|
||||||
import com.dd.admin.business.author.service.AuthorService;
|
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.note.domain.NoteDto;
|
||||||
|
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.common.aop.operationLog.aop.OperLog;
|
import com.dd.admin.common.aop.operationLog.aop.OperLog;
|
||||||
import com.dd.admin.common.aop.operationLog.aop.OperType;
|
import com.dd.admin.common.aop.operationLog.aop.OperType;
|
||||||
import com.dd.admin.common.model.result.ResultBean;
|
import com.dd.admin.common.model.result.ResultBean;
|
||||||
|
import com.dd.admin.common.utils.AddressUtils;
|
||||||
|
import com.dd.admin.common.utils.IPUtils;
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class AuthApi {
|
public class AuthApi {
|
||||||
@Autowired
|
@Autowired
|
||||||
AuthorService authorService;
|
AuthorService authorService;
|
||||||
|
@Autowired
|
||||||
|
HttpServletRequest request;
|
||||||
|
@Autowired
|
||||||
|
NoteService noteService;
|
||||||
|
@Autowired
|
||||||
|
FileService fileService;
|
||||||
|
@Autowired
|
||||||
|
NoteImgService noteImgService;
|
||||||
|
|
||||||
@ApiOperation(value = "获取博主信息")
|
@ApiOperation(value = "获取博主信息")
|
||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@GetMapping("/api/auth/getMine")
|
@GetMapping("/api/auth/getMine")
|
||||||
@OperLog(operModule = "获取博主信息",operType = OperType.QUERY,operDesc = "获取博主信息")
|
@OperLog(operModule = "获取博主信息",operType = OperType.QUERY,operDesc = "获取博主信息")
|
||||||
public ResultBean<Author> getMine() {
|
public ResultBean<Author> getMine() {
|
||||||
|
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||||
|
Author author = authorService.getById(authorId);
|
||||||
|
return ResultBean.success(author);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "创建笔记")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@PostMapping("/api/auth/addNote")
|
||||||
|
@OperLog(operModule = "创建笔记",operType = OperType.ADD,operDesc = "创建笔记")
|
||||||
|
public ResultBean addNote(@RequestBody NoteDto noteDto) {
|
||||||
|
String authorId = String.valueOf(request.getAttribute("authorId"));
|
||||||
|
Author author = authorService.getById(authorId);
|
||||||
|
|
||||||
|
Note note = BeanUtil.copyProperties(noteDto, Note.class);
|
||||||
|
note.setAuthorId(author.getAuthorId());
|
||||||
|
note.setAuthorName(author.getAuthorName());
|
||||||
|
note.setAuthorAvatar(author.getAvatarUrl());
|
||||||
|
note.setIpAddress(IPUtils.getIpAddr(request)); // 请求IP
|
||||||
|
note.setIpRealAddress(AddressUtils.getRealAddress(note.getIpAddress()));
|
||||||
|
noteService.save(note);
|
||||||
|
|
||||||
|
List<String> imgs = noteDto.getImgs();
|
||||||
|
List<NoteImg> noteImgList = new ArrayList<>();
|
||||||
|
for(int i=0;i<imgs.size();i++){
|
||||||
|
NoteImg noteImg = new NoteImg();
|
||||||
|
noteImg.setAuthorId(authorId);
|
||||||
|
noteImg.setNoteId(note.getNoteId());
|
||||||
|
noteImg.setImgSort(i);
|
||||||
|
File file = fileService.selectFileByFileId(imgs.get(i));
|
||||||
|
noteImg.setImgUrl(file.getFilePath());
|
||||||
|
noteImgList.add(noteImg);
|
||||||
|
}
|
||||||
|
noteImgService.saveBatch(noteImgList);
|
||||||
|
|
||||||
|
note.setFirstPicture(noteImgList.get(0).getImgUrl());
|
||||||
|
noteService.updateById(note);
|
||||||
return ResultBean.success();
|
return ResultBean.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class LoginApi {
|
public class LoginApi {
|
||||||
|
|
||||||
@ -34,6 +36,8 @@ public class LoginApi {
|
|||||||
AuthorService authorService;
|
AuthorService authorService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JwtTokenUtil jwtTokenUtil;
|
private JwtTokenUtil jwtTokenUtil;
|
||||||
|
@Autowired
|
||||||
|
HttpServletRequest request;
|
||||||
|
|
||||||
@ApiOperation(value = "获取验证码")
|
@ApiOperation(value = "获取验证码")
|
||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@ -44,6 +48,15 @@ public class LoginApi {
|
|||||||
return ResultBean.success(code);
|
return ResultBean.success(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取验证码")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@GetMapping("/api/getMine")
|
||||||
|
@OperLog(operModule = "获取验证码",operType = OperType.QUERY,operDesc = "获取验证码")
|
||||||
|
public ResultBean<String> getMine() {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
return ResultBean.success(token);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "验证码登陆")
|
@ApiOperation(value = "验证码登陆")
|
||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@PostMapping("/api/checkCode")
|
@PostMapping("/api/checkCode")
|
||||||
|
@ -59,7 +59,7 @@ public class AuthorServiceImpl extends ServiceImpl<AuthorMapper, Author> impleme
|
|||||||
author.setPhoneNumber(phoneNumber);
|
author.setPhoneNumber(phoneNumber);
|
||||||
//随机生成昵称
|
//随机生成昵称
|
||||||
author.setAuthorName(RandomXiaohongshuAuthorName.generateAuthorName());
|
author.setAuthorName(RandomXiaohongshuAuthorName.generateAuthorName());
|
||||||
author.setAuthorNo(StringUtil.getDateStringNow() + StringUtil.createCode(4));
|
author.setAuthorNo(StringUtil.getNumberForPK() + StringUtil.createCode(2));
|
||||||
author.setDescription("我是" + author.getAuthorName());
|
author.setDescription("我是" + author.getAuthorName());
|
||||||
//生成随机头像因为没有点击上传所有没有头像id
|
//生成随机头像因为没有点击上传所有没有头像id
|
||||||
author.setAvatarUrl("http://8.146.211.120:8080/upload/avatar/avatar ("+ StringUtil.createCode(1) +").jpg");
|
author.setAvatarUrl("http://8.146.211.120:8080/upload/avatar/avatar ("+ StringUtil.createCode(1) +").jpg");
|
||||||
|
@ -25,6 +25,9 @@ public interface FileService extends IService<File> {
|
|||||||
//文件-列表
|
//文件-列表
|
||||||
List<FileVo> selectFileList(FileDto fileDto);
|
List<FileVo> selectFileList(FileDto fileDto);
|
||||||
|
|
||||||
|
//文件-列表
|
||||||
|
File selectFileByFileId(String fileId);
|
||||||
|
|
||||||
//文件-上传
|
//文件-上传
|
||||||
public FileVo uploadFile(MultipartFile file, String fileSavePath);
|
public FileVo uploadFile(MultipartFile file, String fileSavePath);
|
||||||
|
|
||||||
|
@ -46,6 +46,11 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements Fi
|
|||||||
return baseMapper.selectFileList(fileDto);
|
return baseMapper.selectFileList(fileDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File selectFileByFileId(String fileId) {
|
||||||
|
return getById(fileId);
|
||||||
|
}
|
||||||
|
|
||||||
public String getSysUploadPath(){
|
public String getSysUploadPath(){
|
||||||
java.io.File filepath = new java.io.File(uploadPath);
|
java.io.File filepath = new java.io.File(uploadPath);
|
||||||
//该目录不存在 则创建
|
//该目录不存在 则创建
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.dd.admin.business.noteImg.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.noteImg.entity.NoteImg;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgVo;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgDto;
|
||||||
|
import com.dd.admin.business.noteImg.service.NoteImgService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
@Api(tags = "笔记包含的图片")
|
||||||
|
@RestController
|
||||||
|
public class NoteImgController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
NoteImgService noteImgService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "笔记包含的图片-分页列表")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@GetMapping("/admin/noteImg/page")
|
||||||
|
public ResultBean<IPage<NoteImgVo>> page(NoteImgDto noteImgDto) {
|
||||||
|
IPage<NoteImgVo> pageInfo = noteImgService.selectNoteImgPage(noteImgDto);
|
||||||
|
return ResultBean.success(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "笔记包含的图片-列表")
|
||||||
|
@ApiOperationSupport(order = 2)
|
||||||
|
@GetMapping("/admin/noteImg/list")
|
||||||
|
public ResultBean<List<NoteImgVo>> list(NoteImgDto noteImgDto) {
|
||||||
|
List<NoteImgVo> list = noteImgService.selectNoteImgList(noteImgDto);
|
||||||
|
return ResultBean.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "笔记包含的图片-添加")
|
||||||
|
@ApiOperationSupport(order = 3)
|
||||||
|
@PostMapping("/admin/noteImg/add")
|
||||||
|
public ResultBean<NoteImg> add(@RequestBody @Validated NoteImgDto noteImgDto) {
|
||||||
|
NoteImg noteImg = BeanUtil.copyProperties(noteImgDto, NoteImg.class);
|
||||||
|
noteImgService.save(noteImg);
|
||||||
|
return ResultBean.success(noteImg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "笔记包含的图片-查询")
|
||||||
|
@ApiOperationSupport(order = 4)
|
||||||
|
@GetMapping("/admin/noteImg/{noteImgId}")
|
||||||
|
public ResultBean<NoteImgVo> get(@PathVariable @NotBlank String noteImgId) {
|
||||||
|
NoteImg noteImg = noteImgService.getById(noteImgId);
|
||||||
|
NoteImgVo noteImgVo = BeanUtil.copyProperties(noteImg,NoteImgVo.class);
|
||||||
|
return ResultBean.success(noteImgVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "笔记包含的图片-修改")
|
||||||
|
@ApiOperationSupport(order = 5)
|
||||||
|
@PostMapping("/admin/noteImg/update")
|
||||||
|
public ResultBean<NoteImg> update(@RequestBody @Validated(UpdateGroup.class) NoteImgDto noteImgDto) {
|
||||||
|
NoteImg noteImg = BeanUtil.copyProperties(noteImgDto, NoteImg.class);
|
||||||
|
noteImgService.updateById(noteImg);
|
||||||
|
return ResultBean.success(noteImg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "笔记包含的图片-删除")
|
||||||
|
@ApiOperationSupport(order = 6)
|
||||||
|
@GetMapping("/admin/noteImg/delete/{noteImgId}")
|
||||||
|
public ResultBean<NoteImg> delete(@PathVariable @NotBlank String noteImgId) {
|
||||||
|
Boolean b = noteImgService.removeById(noteImgId);
|
||||||
|
return ResultBean.success(b);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.dd.admin.business.noteImg.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.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;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片返回对象
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value="笔记包含的图片接收对象")
|
||||||
|
public class NoteImgDto {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关联id")
|
||||||
|
@NotBlank(message = "笔记包含的图片id不能为空",groups = UpdateGroup.class)
|
||||||
|
private String noteImgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片上传的文件id")
|
||||||
|
private String imgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "相应的笔记id")
|
||||||
|
private String noteId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片排序")
|
||||||
|
private Integer imgSort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "作者ID")
|
||||||
|
private String authorId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片地址")
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.dd.admin.business.noteImg.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.TableField;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片返回对象
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value="笔记包含的图片返回对象")
|
||||||
|
public class NoteImgVo {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关联id")
|
||||||
|
private String noteImgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片上传的文件id")
|
||||||
|
private String imgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "相应的笔记id")
|
||||||
|
private String noteId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片排序")
|
||||||
|
private Integer imgSort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "作者ID")
|
||||||
|
private String authorId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片地址")
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.dd.admin.business.noteImg.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.TableField;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("business_note_img")
|
||||||
|
@ApiModel(value="NoteImg对象", description="笔记包含的图片")
|
||||||
|
public class NoteImg implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关联id")
|
||||||
|
@TableId(value = "NOTE_IMG_ID", type = IdType.ASSIGN_UUID)
|
||||||
|
private String noteImgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片上传的文件id")
|
||||||
|
@TableField("IMG_ID")
|
||||||
|
private String imgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "相应的笔记id")
|
||||||
|
@TableField("NOTE_ID")
|
||||||
|
private String noteId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片排序")
|
||||||
|
@TableField("IMG_SORT")
|
||||||
|
private Integer imgSort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "作者ID")
|
||||||
|
@TableField("AUTHOR_ID")
|
||||||
|
private String authorId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
@TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片地址")
|
||||||
|
@TableField("IMG_URL")
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.dd.admin.business.noteImg.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.noteImg.entity.NoteImg;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgVo;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgDto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface NoteImgMapper extends BaseMapper<NoteImg> {
|
||||||
|
|
||||||
|
IPage<NoteImgVo> selectNoteImgPage(Page<NoteImgVo> page, @Param("noteImgDto") NoteImgDto noteImgDto);
|
||||||
|
|
||||||
|
List<NoteImgVo> selectNoteImgList(@Param("noteImgDto") NoteImgDto noteImgDto);
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?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.dd.admin.business.noteImg.mapper.NoteImgMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="com.dd.admin.business.noteImg.entity.NoteImg">
|
||||||
|
<id column="NOTE_IMG_ID" property="noteImgId" />
|
||||||
|
<result column="IMG_ID" property="imgId" />
|
||||||
|
<result column="NOTE_ID" property="noteId" />
|
||||||
|
<result column="IMG_SORT" property="imgSort" />
|
||||||
|
<result column="AUTHOR_ID" property="authorId" />
|
||||||
|
<result column="CREATE_TIME" property="createTime" />
|
||||||
|
<result column="UPDATE_TIME" property="updateTime" />
|
||||||
|
<result column="IMG_URL" property="imgUrl" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
NOTE_IMG_ID, IMG_ID, NOTE_ID, IMG_SORT, AUTHOR_ID, CREATE_TIME, UPDATE_TIME, IMG_URL
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectNoteImgPage" resultType="com.dd.admin.business.noteImg.domain.NoteImgVo">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from business_note_img where 1 = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectNoteImgList" resultType="com.dd.admin.business.noteImg.domain.NoteImgVo">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from business_note_img where 1 = 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.dd.admin.business.noteImg.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.dd.admin.business.noteImg.entity.NoteImg;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgVo;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgDto;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
public interface NoteImgService extends IService<NoteImg> {
|
||||||
|
|
||||||
|
//笔记包含的图片-分页列表
|
||||||
|
IPage<NoteImgVo> selectNoteImgPage(NoteImgDto noteImgDto);
|
||||||
|
|
||||||
|
//笔记包含的图片-列表
|
||||||
|
List<NoteImgVo> selectNoteImgList(NoteImgDto noteImgDto);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.dd.admin.business.noteImg.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.noteImg.entity.NoteImg;
|
||||||
|
import com.dd.admin.business.noteImg.mapper.NoteImgMapper;
|
||||||
|
import com.dd.admin.business.noteImg.service.NoteImgService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgVo;
|
||||||
|
import com.dd.admin.business.noteImg.domain.NoteImgDto;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 笔记包含的图片 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 727869402@qq.com
|
||||||
|
* @since 2024-12-23
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class NoteImgServiceImpl extends ServiceImpl<NoteImgMapper, NoteImg> implements NoteImgService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<NoteImgVo> selectNoteImgPage(NoteImgDto noteImgDto) {
|
||||||
|
Page page = PageFactory.defaultPage();
|
||||||
|
return baseMapper.selectNoteImgPage(page,noteImgDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NoteImgVo> selectNoteImgList(NoteImgDto noteImgDto) {
|
||||||
|
return baseMapper.selectNoteImgList(noteImgDto);
|
||||||
|
}
|
||||||
|
}
|
@ -2,22 +2,14 @@ package com.dd.admin.common.config;
|
|||||||
|
|
||||||
import com.dd.admin.common.security.interceptor.ApiInterceptor;
|
import com.dd.admin.common.security.interceptor.ApiInterceptor;
|
||||||
import com.dd.admin.common.utils.ToolUtil;
|
import com.dd.admin.common.utils.ToolUtil;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web 配置
|
* web 配置
|
||||||
@ -61,10 +53,13 @@ public class GolbalConfig implements WebMvcConfigurer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApiInterceptor apiInterceptor;
|
||||||
|
|
||||||
// 注册拦截器的方法
|
// 注册拦截器的方法
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(new ApiInterceptor())
|
registry.addInterceptor(apiInterceptor)
|
||||||
.addPathPatterns("/api/auth/**"); // 拦截/api下所有请求路径
|
.addPathPatterns("/api/auth/**"); // 拦截/api下所有请求路径
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,29 +4,52 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.dd.admin.business.author.entity.Author;
|
||||||
|
import com.dd.admin.business.author.service.AuthorService;
|
||||||
import com.dd.admin.common.exception.ApiException;
|
import com.dd.admin.common.exception.ApiException;
|
||||||
|
import com.dd.admin.common.security.jwt.JwtTokenUtil;
|
||||||
import com.dd.admin.common.security.jwt.service.JwtUserDetailsService;
|
import com.dd.admin.common.security.jwt.service.JwtUserDetailsService;
|
||||||
import com.dd.admin.common.utils.RedisUtil;
|
import com.dd.admin.common.utils.RedisUtil;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jws;
|
import io.jsonwebtoken.Jws;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
@Component
|
@Component
|
||||||
public class ApiInterceptor implements HandlerInterceptor {
|
public class ApiInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtTokenUtil jwtTokenUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuthorService authorService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
HttpServletRequest httpServletRequest;
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
String token = request.getHeader("Authorization");
|
// 预请求过滤
|
||||||
|
if(RequestMethod.OPTIONS.name().equals(request.getMethod())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String token = request.getHeader("token");
|
||||||
if (StrUtil.isBlank(token)) {
|
if (StrUtil.isBlank(token)) {
|
||||||
throw new ApiException("请登录后访问");
|
throw new ApiException("请登录后访问");
|
||||||
}
|
}
|
||||||
|
//解析token
|
||||||
|
System.out.println(token);
|
||||||
|
String authorId = jwtTokenUtil.getUsernameFromToken(token);
|
||||||
|
request.setAttribute("authorId",authorId);
|
||||||
|
|
||||||
|
// Author author = authorService.getById(authorId);
|
||||||
|
// request.setAttribute("author",author);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class StringUtil {
|
|||||||
|
|
||||||
public static String getNumberForPK(){
|
public static String getNumberForPK(){
|
||||||
String id="";
|
String id="";
|
||||||
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmm");
|
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
|
||||||
String temp = sf.format(new Date());
|
String temp = sf.format(new Date());
|
||||||
id=temp;
|
id=temp;
|
||||||
return id;
|
return id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user