diff --git a/src/main/java/run/halo/app/controller/admin/api/AdminController.java b/src/main/java/run/halo/app/controller/admin/api/AdminController.java index 871aae89d..36b89bec0 100644 --- a/src/main/java/run/halo/app/controller/admin/api/AdminController.java +++ b/src/main/java/run/halo/app/controller/admin/api/AdminController.java @@ -24,7 +24,7 @@ import javax.validation.Valid; * * @author johnniang * @author ryanwang - * @date 3/19/19 + * @date 2019-03-19 */ @Slf4j @RestController @@ -41,7 +41,7 @@ public class AdminController { } @GetMapping(value = "/is_installed") - @ApiOperation("Check install status") + @ApiOperation("Checks Installation status") public boolean isInstall() { return optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false); } @@ -61,13 +61,13 @@ public class AdminController { } @PostMapping("password/code") - @ApiOperation("Send reset password verify code.") + @ApiOperation("Sends reset password verify code") public void sendResetCode(@RequestBody @Valid ResetPasswordParam param) { adminService.sendResetPasswordCode(param); } @PutMapping("password/reset") - @ApiOperation("Reset password by verify code.") + @ApiOperation("Resets password by verify code") public void resetPassword(@RequestBody @Valid ResetPasswordParam param) { adminService.resetPasswordByCode(param); } @@ -79,11 +79,6 @@ public class AdminController { return adminService.refreshToken(refreshToken); } - /** - * Get some statistics about the count of posts, the count of comments, etc. - * - * @return counts - */ @GetMapping("counts") @ApiOperation("Gets count info") @Deprecated @@ -104,31 +99,31 @@ public class AdminController { } @GetMapping("spring/application.yaml") - @ApiOperation("Get application config content") + @ApiOperation("Gets application config content") public BaseResponse getSpringApplicationConfig() { return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), adminService.getApplicationConfig()); } - @PutMapping("spring/application.yaml/update") - @ApiOperation("Update application config content") + @PutMapping("spring/application.yaml") + @ApiOperation("Updates application config content") public void updateSpringApplicationConfig(@RequestParam(name = "content") String content) { adminService.updateApplicationConfig(content); } @PostMapping(value = {"halo/restart", "spring/restart"}) - @ApiOperation("Restart halo server") + @ApiOperation("Restarts halo server") public void restartApplication() { Application.restart(); } @GetMapping(value = "halo/logfile") - @ApiOperation("Get halo log file content.") + @ApiOperation("Gets halo log file content") public BaseResponse getLogFiles(@RequestParam("lines") Long lines) { return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), adminService.getLogFiles(lines)); } @GetMapping(value = "halo/logfile/download") - @ApiOperation("Download halo log file.") + @ApiOperation("Downloads halo log file") public void downloadLogFiles(@RequestParam("lines") Long lines, HttpServletResponse response) { adminService.downloadLogFiles(lines, response); } diff --git a/src/main/java/run/halo/app/controller/admin/api/AttachmentController.java b/src/main/java/run/halo/app/controller/admin/api/AttachmentController.java index 60a851006..d1065e68c 100644 --- a/src/main/java/run/halo/app/controller/admin/api/AttachmentController.java +++ b/src/main/java/run/halo/app/controller/admin/api/AttachmentController.java @@ -36,26 +36,14 @@ public class AttachmentController { this.attachmentService = attachmentService; } - /** - * List of attachment. - * - * @param pageable pageable - * @return Page - */ @GetMapping public Page pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable, AttachmentQuery attachmentQuery) { return attachmentService.pageDtosBy(pageable, attachmentQuery); } - /** - * Get attachment by id. - * - * @param id attachment id - * @return AttachmentDTO - */ @GetMapping("{id:\\d+}") - @ApiOperation("Get attachment detail by id") + @ApiOperation("Gets attachment detail by id") public AttachmentDTO getBy(@PathVariable("id") Integer id) { Attachment attachment = attachmentService.getById(id); return attachmentService.convertToDto(attachment); @@ -70,19 +58,14 @@ public class AttachmentController { return new AttachmentDTO().convertFrom(attachmentService.update(attachment)); } - /** - * Delete attachment by id - * - * @param id id - */ @DeleteMapping("{id:\\d+}") - @ApiOperation("Delete attachment permanently by id") + @ApiOperation("Deletes attachment permanently by id") public AttachmentDTO deletePermanently(@PathVariable("id") Integer id) { return attachmentService.convertToDto(attachmentService.removePermanently(id)); } @DeleteMapping - @ApiOperation("Delete attachments permanently in batch by id array") + @ApiOperation("Deletes attachments permanently in batch by id array") public List deletePermanentlyInBatch(@RequestBody List ids) { return attachmentService.removePermanently(ids); } diff --git a/src/main/java/run/halo/app/controller/admin/api/BackupController.java b/src/main/java/run/halo/app/controller/admin/api/BackupController.java index 84496c383..e75d7f4b0 100644 --- a/src/main/java/run/halo/app/controller/admin/api/BackupController.java +++ b/src/main/java/run/halo/app/controller/admin/api/BackupController.java @@ -43,19 +43,19 @@ public class BackupController { } @PostMapping("halo") - @ApiOperation("Backup halo") + @ApiOperation("Backups halo") public BackupDTO backupHalo() { return backupService.zipWorkDirectory(); } @GetMapping("halo") - @ApiOperation("Get all backups") + @ApiOperation("Gets all backups") public List listBackups() { return backupService.listHaloBackups(); } @GetMapping("halo/{fileName:.+}") - @ApiOperation("Download backup file") + @ApiOperation("Downloads backup file") public ResponseEntity downloadBackup(@PathVariable("fileName") String fileName, HttpServletRequest request) { log.info("Try to download backup file: [{}]", fileName); @@ -77,7 +77,7 @@ public class BackupController { } @DeleteMapping("halo") - @ApiOperation("Delete a backup") + @ApiOperation("Deletes a backup") public void deleteBackup(@RequestParam("filename") String filename) { backupService.deleteHaloBackup(filename); } diff --git a/src/main/java/run/halo/app/controller/admin/api/CategoryController.java b/src/main/java/run/halo/app/controller/admin/api/CategoryController.java index d8ffdb92e..219835ac7 100644 --- a/src/main/java/run/halo/app/controller/admin/api/CategoryController.java +++ b/src/main/java/run/halo/app/controller/admin/api/CategoryController.java @@ -21,7 +21,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC; * Category controller. * * @author johnniang - * @date 3/21/19 + * @date 2019-03-21 */ @RestController @RequestMapping("/api/admin/categories") diff --git a/src/main/java/run/halo/app/controller/admin/api/InstallController.java b/src/main/java/run/halo/app/controller/admin/api/InstallController.java index 54aebc66e..bfb0fb32d 100644 --- a/src/main/java/run/halo/app/controller/admin/api/InstallController.java +++ b/src/main/java/run/halo/app/controller/admin/api/InstallController.java @@ -2,6 +2,7 @@ package run.halo.app.controller.admin.api; import cn.hutool.core.text.StrBuilder; import cn.hutool.crypto.SecureUtil; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.context.ApplicationEventPublisher; @@ -78,6 +79,7 @@ public class InstallController { @PostMapping @ResponseBody @CacheLock + @ApiOperation("Initializes the blog") public BaseResponse installBlog(@RequestBody InstallParam installParam) { // Validate manually ValidationUtils.validate(installParam, CreateCheck.class); diff --git a/src/main/java/run/halo/app/controller/admin/api/JournalCommentController.java b/src/main/java/run/halo/app/controller/admin/api/JournalCommentController.java index 7025d80ba..96708a5f1 100644 --- a/src/main/java/run/halo/app/controller/admin/api/JournalCommentController.java +++ b/src/main/java/run/halo/app/controller/admin/api/JournalCommentController.java @@ -27,7 +27,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC; * Journal comment controller. * * @author johnniang - * @date 19-4-25 + * @date 2019-04-25 */ @RestController @RequestMapping("/api/admin/journals/comments") @@ -53,6 +53,7 @@ public class JournalCommentController { } @GetMapping("latest") + @ApiOperation("Lists latest journal comments") public List listLatest(@RequestParam(name = "top", defaultValue = "10") int top, @RequestParam(name = "status", required = false) CommentStatus status) { List latestComments = journalCommentService.pageLatest(top, status).getContent(); diff --git a/src/main/java/run/halo/app/controller/admin/api/LinkController.java b/src/main/java/run/halo/app/controller/admin/api/LinkController.java index 4636b4b1d..9934dddb4 100644 --- a/src/main/java/run/halo/app/controller/admin/api/LinkController.java +++ b/src/main/java/run/halo/app/controller/admin/api/LinkController.java @@ -12,11 +12,14 @@ import run.halo.app.service.LinkService; import javax.validation.Valid; import java.util.List; +import static org.springframework.data.domain.Sort.Direction.ASC; +import static org.springframework.data.domain.Sort.Direction.DESC; + /** * Link Controller * * @author ryanwang - * @date 2019/3/21 + * @date 2019-03-21 */ @RestController @RequestMapping("/api/admin/links") @@ -28,36 +31,26 @@ public class LinkController { this.linkService = linkService; } - /** - * List all links - * - * @param sort sort - * @return List - */ @GetMapping - public List listLinks(@SortDefault(sort = "priority", direction = Sort.Direction.ASC) Sort sort) { - return linkService.listDtos(sort); + @ApiOperation("Lists links") + public List listLinks(@SortDefault(sort = "team", direction = DESC) Sort sort) { + return linkService.listDtos(sort.and(Sort.by(ASC, "priority"))); } - /** - * Get link by id. - * - * @param id id - * @return LinkDTO - */ @GetMapping("{id:\\d+}") - @ApiOperation("Get link detail by id") + @ApiOperation("Gets link detail by id") public LinkDTO getBy(@PathVariable("id") Integer id) { return new LinkDTO().convertFrom(linkService.getById(id)); } @GetMapping("parse") - @ApiOperation("Get link by parse url") + @ApiOperation("Gets link by parse url") public LinkDTO getByParse(@RequestParam("url") String url) { return linkService.getByParse(url); } @PostMapping + @ApiOperation("Creates a link") public LinkDTO createBy(@RequestBody @Valid LinkParam linkParam) { Link link = linkService.createBy(linkParam); return new LinkDTO().convertFrom(link); @@ -72,11 +65,6 @@ public class LinkController { return new LinkDTO().convertFrom(linkService.update(link)); } - /** - * Delete link by id. - * - * @param id id - */ @DeleteMapping("{id:\\d+}") @ApiOperation("Delete link by id") public void deletePermanently(@PathVariable("id") Integer id) { @@ -84,7 +72,7 @@ public class LinkController { } @GetMapping("teams") - @ApiOperation(("List all link teams")) + @ApiOperation(("Lists all link teams")) public List teams() { return linkService.listAllTeams(); } diff --git a/src/main/java/run/halo/app/controller/admin/api/LogController.java b/src/main/java/run/halo/app/controller/admin/api/LogController.java index 34f02d9ce..d186a99c9 100644 --- a/src/main/java/run/halo/app/controller/admin/api/LogController.java +++ b/src/main/java/run/halo/app/controller/admin/api/LogController.java @@ -20,7 +20,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC; * Log controller. * * @author johnniang - * @date 3/19/19 + * @date 2019-03-19 */ @RestController @RequestMapping("/api/admin/logs") @@ -32,12 +32,6 @@ public class LogController { this.logService = logService; } - /** - * List latest logs. - * - * @param top top - * @return List of logs - */ @GetMapping("latest") @ApiOperation("Pages latest logs") public List pageLatest(@RequestParam(name = "top", defaultValue = "10") int top) { @@ -45,16 +39,14 @@ public class LogController { } @GetMapping + @ApiOperation("Lists logs") public Page pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) { Page logPage = logService.listAll(pageable); return logPage.map(log -> new LogDTO().convertFrom(log)); } - /** - * Clear all logs. - */ @GetMapping("clear") - @ApiOperation("Clear all logs") + @ApiOperation("Clears all logs") public void clear() { logService.removeAll(); } diff --git a/src/main/java/run/halo/app/controller/admin/api/MailController.java b/src/main/java/run/halo/app/controller/admin/api/MailController.java index 4fd753b30..292f52952 100644 --- a/src/main/java/run/halo/app/controller/admin/api/MailController.java +++ b/src/main/java/run/halo/app/controller/admin/api/MailController.java @@ -1,5 +1,6 @@ package run.halo.app.controller.admin.api; +import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,7 +15,7 @@ import javax.validation.Valid; * Mail controller. * * @author johnniang - * @date 19-5-7 + * @date 2019-05-07 */ @RestController @RequestMapping("/api/admin/mails") @@ -27,6 +28,7 @@ public class MailController { } @PostMapping("test") + @ApiOperation("Tests the SMTP service") public BaseResponse testMail(@Valid @RequestBody MailParam mailParam) { mailService.sendMail(mailParam.getTo(), mailParam.getSubject(), mailParam.getContent()); return BaseResponse.ok("发送成功"); diff --git a/src/main/java/run/halo/app/controller/admin/api/MenuController.java b/src/main/java/run/halo/app/controller/admin/api/MenuController.java index ce7992a82..8aeb534df 100644 --- a/src/main/java/run/halo/app/controller/admin/api/MenuController.java +++ b/src/main/java/run/halo/app/controller/admin/api/MenuController.java @@ -35,24 +35,18 @@ public class MenuController { @GetMapping @ApiOperation("Lists all menus") - public List listAll(@SortDefault(sort = "priority", direction = DESC) Sort sort) { - return menuService.listDtos(sort); + public List listAll(@SortDefault(sort = "team", direction = DESC) Sort sort) { + return menuService.listDtos(sort.and(Sort.by(ASC, "priority"))); } @GetMapping("tree_view") - @ApiOperation("List as category tree") - public List listAsTree(@SortDefault(sort = "priority", direction = ASC) Sort sort) { - return menuService.listAsTree(sort); + @ApiOperation("Lists categories as tree") + public List listAsTree(@SortDefault(sort = "team", direction = DESC) Sort sort) { + return menuService.listAsTree(sort.and(Sort.by(ASC, "priority"))); } - /** - * Get menu by menuId. - * - * @param menuId menuId - * @return MenuDTO - */ @GetMapping("{menuId:\\d+}") - @ApiOperation("Get menu detail by id") + @ApiOperation("Gets menu detail by id") public MenuDTO getBy(@PathVariable("menuId") Integer menuId) { return new MenuDTO().convertFrom(menuService.getById(menuId)); } @@ -91,7 +85,7 @@ public class MenuController { } @GetMapping("teams") - @ApiOperation(("List all menu teams")) + @ApiOperation(("Lists all menu teams")) public List teams() { return menuService.listAllTeams(); } diff --git a/src/main/java/run/halo/app/controller/admin/api/OptionController.java b/src/main/java/run/halo/app/controller/admin/api/OptionController.java index 3ca03900e..da09bb9cd 100644 --- a/src/main/java/run/halo/app/controller/admin/api/OptionController.java +++ b/src/main/java/run/halo/app/controller/admin/api/OptionController.java @@ -37,11 +37,13 @@ public class OptionController { } @GetMapping + @ApiOperation("Lists options") public List listAll() { return optionService.listDtos(); } @PostMapping("saving") + @ApiOperation("Saves options") public void saveOptions(@Valid @RequestBody List optionParams) { optionService.save(optionParams); } @@ -64,7 +66,7 @@ public class OptionController { } @GetMapping("{id:\\d+}") - @ApiOperation("Get option detail by id") + @ApiOperation("Gets option detail by id") public OptionSimpleDTO getBy(@PathVariable("id") Integer id) { Option option = optionService.getById(id); return optionService.convertToDto(option); diff --git a/src/main/java/run/halo/app/controller/admin/api/PhotoController.java b/src/main/java/run/halo/app/controller/admin/api/PhotoController.java index 371a8effb..e87a3cc5b 100644 --- a/src/main/java/run/halo/app/controller/admin/api/PhotoController.java +++ b/src/main/java/run/halo/app/controller/admin/api/PhotoController.java @@ -22,7 +22,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC; * Photo controller * * @author ryanwang - * @date 2019-3-21 + * @date 2019-03-21 */ @RestController @RequestMapping("/api/admin/photos") @@ -34,47 +34,33 @@ public class PhotoController { this.photoService = photoService; } - /** - * List all photos - * - * @param sort sort - * @return all of photos - */ @GetMapping(value = "latest") + @ApiOperation("Lists latest photos") public List listPhotos(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) { return photoService.listDtos(sort); } @GetMapping + @ApiOperation("Lists photos") public Page pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable, PhotoQuery photoQuery) { return photoService.pageDtosBy(pageable, photoQuery); } - /** - * Get photo by id. - * - * @param photoId photo id - * @return PhotoDTO - */ @GetMapping("{photoId:\\d+}") - @ApiOperation("Get photo detail by id") + @ApiOperation("Gets photo detail by id") public PhotoDTO getBy(@PathVariable("photoId") Integer photoId) { return new PhotoDTO().convertFrom(photoService.getById(photoId)); } - /** - * Delete photo by id. - * - * @param photoId photo id - */ @DeleteMapping("{photoId:\\d+}") - @ApiOperation("Delete photo by id") + @ApiOperation("Deletes photo by id") public void deletePermanently(@PathVariable("photoId") Integer photoId) { photoService.removeById(photoId); } @PostMapping + @ApiOperation("Creates a photo") public PhotoDTO createBy(@Valid @RequestBody PhotoParam photoParam) { return new PhotoDTO().convertFrom(photoService.createBy(photoParam)); } diff --git a/src/main/java/run/halo/app/controller/admin/api/PostCommentController.java b/src/main/java/run/halo/app/controller/admin/api/PostCommentController.java index 9e40e2397..3424a59c7 100644 --- a/src/main/java/run/halo/app/controller/admin/api/PostCommentController.java +++ b/src/main/java/run/halo/app/controller/admin/api/PostCommentController.java @@ -125,6 +125,7 @@ public class PostCommentController { } @PutMapping("{commentId:\\d+}") + @ApiOperation("Updates a post comment") public BaseCommentDTO updateBy(@Valid @RequestBody PostCommentParam commentParam, @PathVariable("commentId") Long commentId) { PostComment commentToUpdate = postCommentService.getById(commentId); diff --git a/src/main/java/run/halo/app/controller/admin/api/PostController.java b/src/main/java/run/halo/app/controller/admin/api/PostController.java index f269a3def..b8027d9a7 100644 --- a/src/main/java/run/halo/app/controller/admin/api/PostController.java +++ b/src/main/java/run/halo/app/controller/admin/api/PostController.java @@ -34,7 +34,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC; * @author johnniang * @author ryanwang * @author guqing - * @date 3/19/19 + * @date 2019-03-19 */ @RestController @RequestMapping("/api/admin/posts") @@ -88,6 +88,7 @@ public class PostController { } @GetMapping("{postId:\\d+}") + @ApiOperation("Gets a post") public PostDetailVO getBy(@PathVariable("postId") Integer postId) { Post post = postService.getById(postId); return postService.convertToDetailVo(post); @@ -100,6 +101,7 @@ public class PostController { } @PostMapping + @ApiOperation("Creates a post") public PostDetailVO createBy(@Valid @RequestBody PostParam postParam, @RequestParam(value = "autoSave", required = false, defaultValue = "false") Boolean autoSave) { // Convert to @@ -108,6 +110,7 @@ public class PostController { } @PutMapping("{postId:\\d+}") + @ApiOperation("Updates a post") public PostDetailVO updateBy(@Valid @RequestBody PostParam postParam, @PathVariable("postId") Integer postId, @RequestParam(value = "autoSave", required = false, defaultValue = "false") Boolean autoSave) { @@ -119,7 +122,7 @@ public class PostController { } @PutMapping("{postId:\\d+}/status/{status}") - @ApiOperation("Update post status") + @ApiOperation("Updates post status") public BasePostMinimalDTO updateStatusBy( @PathVariable("postId") Integer postId, @PathVariable("status") PostStatus status) { @@ -129,14 +132,14 @@ public class PostController { } @PutMapping("status/{status}") - @ApiOperation("Update post status in batch") + @ApiOperation("Updates post status in batch") public List updateStatusInBatch(@PathVariable(name = "status") PostStatus status, @RequestBody List ids) { return postService.updateStatusByIds(ids, status); } @PutMapping("{postId:\\d+}/status/draft/content") - @ApiOperation("Update draft") + @ApiOperation("Updates draft") public BasePostDetailDTO updateDraftBy( @PathVariable("postId") Integer postId, @RequestBody PostContentParam contentParam) { @@ -147,18 +150,19 @@ public class PostController { } @DeleteMapping("{postId:\\d+}") + @ApiOperation("Deletes a photo permanently") public void deletePermanently(@PathVariable("postId") Integer postId) { postService.removeById(postId); } @DeleteMapping - @ApiOperation("Delete posts permanently in batch by id array") + @ApiOperation("Deletes posts permanently in batch by id array") public List deletePermanentlyInBatch(@RequestBody List ids) { return postService.removeByIds(ids); } @GetMapping(value = {"preview/{postId:\\d+}", "{postId:\\d+}/preview"}) - @ApiOperation("Get preview link") + @ApiOperation("Gets a post preview link") public String preview(@PathVariable("postId") Integer postId) throws UnsupportedEncodingException { Post post = postService.getById(postId); diff --git a/src/main/java/run/halo/app/controller/admin/api/SheetCommentController.java b/src/main/java/run/halo/app/controller/admin/api/SheetCommentController.java index f814a9c1b..533f21f67 100644 --- a/src/main/java/run/halo/app/controller/admin/api/SheetCommentController.java +++ b/src/main/java/run/halo/app/controller/admin/api/SheetCommentController.java @@ -46,6 +46,7 @@ public class SheetCommentController { } @GetMapping + @ApiOperation("Lists sheet comments") public Page pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable, CommentQuery commentQuery) { Page sheetCommentPage = sheetCommentService.pageBy(commentQuery, pageable); @@ -53,6 +54,7 @@ public class SheetCommentController { } @GetMapping("latest") + @ApiOperation("Lists latest sheet comments") public List listLatest(@RequestParam(name = "top", defaultValue = "10") int top, @RequestParam(name = "status", required = false) CommentStatus status) { Page sheetCommentPage = sheetCommentService.pageLatest(top, status); @@ -108,7 +110,7 @@ public class SheetCommentController { } @DeleteMapping - @ApiOperation("Delete sheet comments permanently in batch by id array") + @ApiOperation("Deletes sheet comments permanently in batch by id array") public List deletePermanentlyInBatch(@RequestBody List ids) { return sheetCommentService.removeByIds(ids); } @@ -121,6 +123,7 @@ public class SheetCommentController { } @PutMapping("{commentId:\\d+}") + @ApiOperation("Updates a sheet comment") public BaseCommentDTO updateBy(@Valid @RequestBody SheetCommentParam commentParam, @PathVariable("commentId") Long commentId) { SheetComment commentToUpdate = sheetCommentService.getById(commentId); diff --git a/src/main/java/run/halo/app/controller/admin/api/SheetController.java b/src/main/java/run/halo/app/controller/admin/api/SheetController.java index f7301151e..1a8733a84 100644 --- a/src/main/java/run/halo/app/controller/admin/api/SheetController.java +++ b/src/main/java/run/halo/app/controller/admin/api/SheetController.java @@ -94,6 +94,7 @@ public class SheetController { } @PutMapping("{sheetId:\\d+}/{status}") + @ApiOperation("Updates a sheet") public void updateStatusBy( @PathVariable("sheetId") Integer sheetId, @PathVariable("status") PostStatus status) { @@ -114,6 +115,7 @@ public class SheetController { } @GetMapping("preview/{sheetId:\\d+}") + @ApiOperation("Gets a sheet preview link") public String preview(@PathVariable("sheetId") Integer sheetId) throws UnsupportedEncodingException { Sheet sheet = sheetService.getById(sheetId); diff --git a/src/main/java/run/halo/app/controller/admin/api/StaticStorageController.java b/src/main/java/run/halo/app/controller/admin/api/StaticStorageController.java index 79ed4ac11..f932e0b12 100644 --- a/src/main/java/run/halo/app/controller/admin/api/StaticStorageController.java +++ b/src/main/java/run/halo/app/controller/admin/api/StaticStorageController.java @@ -25,26 +25,26 @@ public class StaticStorageController { } @GetMapping - @ApiOperation("List static files.") + @ApiOperation("Lists static files") public List list() { return staticStorageService.listStaticFolder(); } @DeleteMapping - @ApiOperation("Delete file by relative path") + @ApiOperation("Deletes file by relative path") public void deletePermanently(@RequestParam("path") String path) { staticStorageService.delete(path); } @PostMapping - @ApiOperation("Create folder") + @ApiOperation("Creates a folder") public void createFolder(String basePath, @RequestParam("folderName") String folderName) { staticStorageService.createFolder(basePath, folderName); } @PostMapping("upload") - @ApiOperation("Upload static file") + @ApiOperation("Uploads static file") public void upload(String basePath, @RequestPart("file") MultipartFile file) { staticStorageService.update(basePath, file); diff --git a/src/main/java/run/halo/app/controller/admin/api/TagController.java b/src/main/java/run/halo/app/controller/admin/api/TagController.java index 18571483d..81885dd86 100644 --- a/src/main/java/run/halo/app/controller/admin/api/TagController.java +++ b/src/main/java/run/halo/app/controller/admin/api/TagController.java @@ -37,7 +37,7 @@ public class TagController { } @GetMapping - @ApiOperation("Lists tag") + @ApiOperation("Lists tags") public List listTags(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort, @ApiParam("Return more information(post count) if it is set") @RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) { @@ -48,7 +48,7 @@ public class TagController { } @PostMapping - @ApiOperation("Creates tag") + @ApiOperation("Creates a tag") public TagDTO createTag(@Valid @RequestBody TagParam tagParam) { // Convert to tag Tag tag = tagParam.convertTo(); @@ -59,20 +59,14 @@ public class TagController { return tagService.convertTo(tagService.create(tag)); } - /** - * Get tag by id - * - * @param tagId tag id - * @return TagDTO - */ @GetMapping("{tagId:\\d+}") - @ApiOperation("Get tag detail by id") + @ApiOperation("Gets tag detail by id") public TagDTO getBy(@PathVariable("tagId") Integer tagId) { return tagService.convertTo(tagService.getById(tagId)); } @PutMapping("{tagId:\\d+}") - @ApiOperation("Updates tag") + @ApiOperation("Updates a tag") public TagDTO updateBy(@PathVariable("tagId") Integer tagId, @Valid @RequestBody TagParam tagParam) { // Get old tag @@ -86,7 +80,7 @@ public class TagController { } @DeleteMapping("{tagId:\\d+}") - @ApiOperation("Deletes tag") + @ApiOperation("Deletes a tag") public TagDTO deletePermanently(@PathVariable("tagId") Integer tagId) { // Remove the tag Tag deletedTag = tagService.removeById(tagId); diff --git a/src/main/java/run/halo/app/controller/admin/api/ThemeController.java b/src/main/java/run/halo/app/controller/admin/api/ThemeController.java index b1b0caed1..b3d79927f 100644 --- a/src/main/java/run/halo/app/controller/admin/api/ThemeController.java +++ b/src/main/java/run/halo/app/controller/admin/api/ThemeController.java @@ -43,49 +43,57 @@ public class ThemeController { } @GetMapping - @ApiOperation("List all themes") + @ApiOperation("Lists all themes") public Set listAll() { return themeService.getThemes(); } @GetMapping("activation/files") + @ApiOperation("Lists all activate theme files") public List listFiles() { return themeService.listThemeFolderBy(themeService.getActivatedThemeId()); } @GetMapping("{themeId}/files") + @ApiOperation("Lists theme files by theme id") public List listFiles(@PathVariable("themeId") String themeId) { return themeService.listThemeFolderBy(themeId); } @GetMapping("files/content") + @ApiOperation("Gets template content") public BaseResponse getContentBy(@RequestParam(name = "path") String path) { return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), themeService.getTemplateContent(path)); } @GetMapping("{themeId}/files/content") + @ApiOperation("Gets template content by theme id") public BaseResponse getContentBy(@PathVariable("themeId") String themeId, @RequestParam(name = "path") String path) { return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), themeService.getTemplateContent(themeId, path)); } @PutMapping("files/content") + @ApiOperation("Updates template content") public void updateContentBy(@RequestBody ThemeContentParam param) { themeService.saveTemplateContent(param.getPath(), param.getContent()); } @PutMapping("{themeId}/files/content") + @ApiOperation("Updates template content by theme id") public void updateContentBy(@PathVariable("themeId") String themeId, @RequestBody ThemeContentParam param) { themeService.saveTemplateContent(themeId, param.getPath(), param.getContent()); } @GetMapping("activation/template/custom/sheet") + @ApiOperation("Gets custom sheet templates") public Set customSheetTemplate() { return themeService.listCustomTemplates(themeService.getActivatedThemeId(), ThemeService.CUSTOM_SHEET_PREFIX); } @GetMapping("activation/template/custom/post") + @ApiOperation("Gets custom post templates") public Set customPostTemplate() { return themeService.listCustomTemplates(themeService.getActivatedThemeId(), ThemeService.CUSTOM_POST_PREFIX); } @@ -146,12 +154,13 @@ public class ThemeController { } @PostMapping("upload") - @ApiOperation("Upload theme") + @ApiOperation("Uploads a theme") public ThemeProperty uploadTheme(@RequestPart("file") MultipartFile file) { return themeService.upload(file); } @PutMapping("upload/{themeId}") + @ApiOperation("Upgrades theme by file") public ThemeProperty updateThemeByUpload(@PathVariable("themeId") String themeId, @RequestPart("file") MultipartFile file) { return themeService.update(themeId, file); @@ -164,8 +173,8 @@ public class ThemeController { } @PutMapping("fetching/{themeId}") - public ThemeProperty updateThemeByFetching(@PathVariable("themeId") String themeId, - @RequestPart(name = "file", required = false) MultipartFile file) { + @ApiOperation("Upgrades theme by remote") + public ThemeProperty updateThemeByFetching(@PathVariable("themeId") String themeId) { return themeService.update(themeId); } @@ -177,8 +186,8 @@ public class ThemeController { } @GetMapping(value = "activation/template/exists") + @ApiOperation("Determines if template exists") public BaseResponse exists(@RequestParam(value = "template") String template) { return BaseResponse.ok(themeService.templateExists(template)); } - } diff --git a/src/main/java/run/halo/app/controller/admin/api/UserController.java b/src/main/java/run/halo/app/controller/admin/api/UserController.java index df98f8490..5ff4031ef 100644 --- a/src/main/java/run/halo/app/controller/admin/api/UserController.java +++ b/src/main/java/run/halo/app/controller/admin/api/UserController.java @@ -1,5 +1,6 @@ package run.halo.app.controller.admin.api; +import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import run.halo.app.model.dto.UserDTO; import run.halo.app.model.entity.User; @@ -16,7 +17,7 @@ import javax.validation.Valid; * User controller. * * @author johnniang - * @date 3/19/19 + * @date 2019-03-19 */ @RestController @RequestMapping("/api/admin/users") @@ -29,11 +30,13 @@ public class UserController { } @GetMapping("profiles") + @ApiOperation("Gets user profile") public UserDTO getProfile(User user) { return new UserDTO().convertFrom(user); } @PutMapping("profiles") + @ApiOperation("Updates user profile") public UserDTO updateProfile(@RequestBody UserParam userParam, User user) { // Validate the user param ValidationUtils.validate(userParam, UpdateCheck.class); @@ -46,6 +49,7 @@ public class UserController { } @PutMapping("profiles/password") + @ApiOperation("Updates user's password") public BaseResponse updatePassword(@RequestBody @Valid PasswordParam passwordParam, User user) { userService.updatePassword(passwordParam.getOldPassword(), passwordParam.getNewPassword(), user.getId()); return BaseResponse.ok("密码修改成功"); diff --git a/src/main/java/run/halo/app/controller/content/ContentArchiveController.java b/src/main/java/run/halo/app/controller/content/ContentArchiveController.java index d7ae1bc41..754d3d975 100644 --- a/src/main/java/run/halo/app/controller/content/ContentArchiveController.java +++ b/src/main/java/run/halo/app/controller/content/ContentArchiveController.java @@ -52,8 +52,6 @@ public class ContentArchiveController { private final PostTagService postTagService; - private final PostCommentService postCommentService; - private final OptionService optionService; private final StringCacheStore cacheStore; @@ -63,7 +61,6 @@ public class ContentArchiveController { PostCategoryService postCategoryService, PostMetaService postMetaService, PostTagService postTagService, - PostCommentService postCommentService, OptionService optionService, StringCacheStore cacheStore) { this.postService = postService; @@ -71,7 +68,6 @@ public class ContentArchiveController { this.postCategoryService = postCategoryService; this.postMetaService = postMetaService; this.postTagService = postTagService; - this.postCommentService = postCommentService; this.optionService = optionService; this.cacheStore = cacheStore; } @@ -152,6 +148,8 @@ public class ContentArchiveController { model.addAttribute("categories", categories); model.addAttribute("tags", tags); model.addAttribute("metas", postMetaService.convertToMap(metas)); + + // TODO,Will be deprecated model.addAttribute("comments", Page.empty()); if (themeService.templateExists(ThemeService.CUSTOM_POST_PREFIX + post.getTemplate() + HaloConst.SUFFIX_FTL)) { diff --git a/src/main/java/run/halo/app/controller/content/ContentJournalController.java b/src/main/java/run/halo/app/controller/content/ContentJournalController.java index 955d36608..da8d428f3 100644 --- a/src/main/java/run/halo/app/controller/content/ContentJournalController.java +++ b/src/main/java/run/halo/app/controller/content/ContentJournalController.java @@ -78,7 +78,7 @@ public class ContentJournalController { int[] rainbow = PageUtil.rainbow(page, journals.getTotalPages(), 3); - model.addAttribute("is_journal", true); + model.addAttribute("is_journals", true); model.addAttribute("journals", journalService.convertToCmtCountDto(journals)); model.addAttribute("rainbow", rainbow); return themeService.render("journals"); diff --git a/src/main/java/run/halo/app/controller/content/ContentSheetController.java b/src/main/java/run/halo/app/controller/content/ContentSheetController.java index 7de2a93dc..8194323b9 100644 --- a/src/main/java/run/halo/app/controller/content/ContentSheetController.java +++ b/src/main/java/run/halo/app/controller/content/ContentSheetController.java @@ -17,7 +17,9 @@ import run.halo.app.model.entity.Sheet; import run.halo.app.model.enums.PostStatus; import run.halo.app.model.support.HaloConst; import run.halo.app.model.vo.SheetDetailVO; -import run.halo.app.service.*; +import run.halo.app.service.PhotoService; +import run.halo.app.service.SheetService; +import run.halo.app.service.ThemeService; import run.halo.app.utils.MarkdownUtils; import static org.springframework.data.domain.Sort.Direction.DESC; @@ -36,25 +38,17 @@ public class ContentSheetController { private final ThemeService themeService; - private final SheetCommentService sheetCommentService; - private final PhotoService photoService; - private final OptionService optionService; - private final StringCacheStore cacheStore; public ContentSheetController(SheetService sheetService, ThemeService themeService, - SheetCommentService sheetCommentService, PhotoService photoService, - OptionService optionService, StringCacheStore cacheStore) { this.sheetService = sheetService; this.themeService = themeService; - this.sheetCommentService = sheetCommentService; this.photoService = photoService; - this.optionService = optionService; this.cacheStore = cacheStore; } @@ -132,6 +126,8 @@ public class ContentSheetController { model.addAttribute("sheet", sheetDetailVO); model.addAttribute("post", sheetDetailVO); model.addAttribute("is_sheet", true); + + // TODO,Will be deprecated model.addAttribute("comments", Page.empty()); if (themeService.templateExists(ThemeService.CUSTOM_SHEET_PREFIX + sheet.getTemplate() + HaloConst.SUFFIX_FTL)) { diff --git a/src/main/java/run/halo/app/core/freemarker/tag/PostTagDirective.java b/src/main/java/run/halo/app/core/freemarker/tag/PostTagDirective.java index aea98d26e..69b2c448e 100644 --- a/src/main/java/run/halo/app/core/freemarker/tag/PostTagDirective.java +++ b/src/main/java/run/halo/app/core/freemarker/tag/PostTagDirective.java @@ -56,6 +56,10 @@ public class PostTagDirective implements TemplateDirectiveModel { case "archiveMonth": env.setVariable("archives", builder.build().wrap(postService.listMonthArchives())); break; + case "archive": + String type = params.get("type").toString(); + env.setVariable("archives", builder.build().wrap("year".equals(type) ? postService.listYearArchives() : postService.listMonthArchives())); + break; case "listByCategoryId": Integer categoryId = Integer.parseInt(params.get("categoryId").toString()); env.setVariable("posts", builder.build().wrap(postCategoryService.listPostBy(categoryId, PostStatus.PUBLISHED)));