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 1e7b3ce..a3f6d48 100644 --- a/src/main/java/com/dd/admin/business/api/AuthApi.java +++ b/src/main/java/com/dd/admin/business/api/AuthApi.java @@ -51,6 +51,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -507,6 +508,46 @@ public class AuthApi { return ResultBean.success(); } + + @ApiOperation(value = "创建笔记") + @ApiOperationSupport(order = 1) + @PostMapping("/api/auth/updateNote") + @OperLog(operModule = "创建笔记",operType = OperType.ADD,operDesc = "创建笔记") + @Transactional + public ResultBean updateNote(@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.updateById(note); + + List imgs = noteDto.getImgs(); + List noteImgList = new ArrayList<>(); + for(int i=0;i { //笔记包含的图片-列表 List selectNoteImgList(NoteImgDto noteImgDto); + Integer deleteNoteImgByNoteId(String noteId); } diff --git a/src/main/java/com/dd/admin/business/noteImg/service/impl/NoteImgServiceImpl.java b/src/main/java/com/dd/admin/business/noteImg/service/impl/NoteImgServiceImpl.java index 2e477b2..13f0957 100644 --- a/src/main/java/com/dd/admin/business/noteImg/service/impl/NoteImgServiceImpl.java +++ b/src/main/java/com/dd/admin/business/noteImg/service/impl/NoteImgServiceImpl.java @@ -1,5 +1,7 @@ package com.dd.admin.business.noteImg.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dd.admin.common.model.PageFactory; @@ -33,4 +35,11 @@ public class NoteImgServiceImpl extends ServiceImpl impl public List selectNoteImgList(NoteImgDto noteImgDto) { return baseMapper.selectNoteImgList(noteImgDto); } + + @Override + public Integer deleteNoteImgByNoteId(String noteId) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(NoteImg::getNoteId, noteId); + return baseMapper.delete(updateWrapper); + } }