feat: add archive freemarker custom tag.

pull/462/head^2
ruibaby 2020-01-02 20:33:14 +08:00
parent d3ef9c4a7a
commit 6c7968cc2b
24 changed files with 112 additions and 152 deletions

View File

@ -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<String> 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<String> 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);
}

View File

@ -36,26 +36,14 @@ public class AttachmentController {
this.attachmentService = attachmentService;
}
/**
* List of attachment.
*
* @param pageable pageable
* @return Page<AttachmentDTO>
*/
@GetMapping
public Page<AttachmentDTO> 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<Attachment> deletePermanentlyInBatch(@RequestBody List<Integer> ids) {
return attachmentService.removePermanently(ids);
}

View File

@ -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<BackupDTO> listBackups() {
return backupService.listHaloBackups();
}
@GetMapping("halo/{fileName:.+}")
@ApiOperation("Download backup file")
@ApiOperation("Downloads backup file")
public ResponseEntity<Resource> 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);
}

View File

@ -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")

View File

@ -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<String> installBlog(@RequestBody InstallParam installParam) {
// Validate manually
ValidationUtils.validate(installParam, CreateCheck.class);

View File

@ -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<JournalCommentWithJournalVO> listLatest(@RequestParam(name = "top", defaultValue = "10") int top,
@RequestParam(name = "status", required = false) CommentStatus status) {
List<JournalComment> latestComments = journalCommentService.pageLatest(top, status).getContent();

View File

@ -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<LinkDTO> listLinks(@SortDefault(sort = "priority", direction = Sort.Direction.ASC) Sort sort) {
return linkService.listDtos(sort);
@ApiOperation("Lists links")
public List<LinkDTO> 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<String> teams() {
return linkService.listAllTeams();
}

View File

@ -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<LogDTO> pageLatest(@RequestParam(name = "top", defaultValue = "10") int top) {
@ -45,16 +39,14 @@ public class LogController {
}
@GetMapping
@ApiOperation("Lists logs")
public Page<LogDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
Page<Log> 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();
}

View File

@ -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("发送成功");

View File

@ -35,24 +35,18 @@ public class MenuController {
@GetMapping
@ApiOperation("Lists all menus")
public List<MenuDTO> listAll(@SortDefault(sort = "priority", direction = DESC) Sort sort) {
return menuService.listDtos(sort);
public List<MenuDTO> 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<MenuVO> listAsTree(@SortDefault(sort = "priority", direction = ASC) Sort sort) {
return menuService.listAsTree(sort);
@ApiOperation("Lists categories as tree")
public List<MenuVO> 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<String> teams() {
return menuService.listAllTeams();
}

View File

@ -37,11 +37,13 @@ public class OptionController {
}
@GetMapping
@ApiOperation("Lists options")
public List<OptionDTO> listAll() {
return optionService.listDtos();
}
@PostMapping("saving")
@ApiOperation("Saves options")
public void saveOptions(@Valid @RequestBody List<OptionParam> 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);

View File

@ -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<PhotoDTO> listPhotos(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
return photoService.listDtos(sort);
}
@GetMapping
@ApiOperation("Lists photos")
public Page<PhotoDTO> 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));
}

View File

@ -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);

View File

@ -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<Post> updateStatusInBatch(@PathVariable(name = "status") PostStatus status,
@RequestBody List<Integer> 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<Post> deletePermanentlyInBatch(@RequestBody List<Integer> 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);

View File

@ -46,6 +46,7 @@ public class SheetCommentController {
}
@GetMapping
@ApiOperation("Lists sheet comments")
public Page<SheetCommentWithSheetVO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
CommentQuery commentQuery) {
Page<SheetComment> sheetCommentPage = sheetCommentService.pageBy(commentQuery, pageable);
@ -53,6 +54,7 @@ public class SheetCommentController {
}
@GetMapping("latest")
@ApiOperation("Lists latest sheet comments")
public List<SheetCommentWithSheetVO> listLatest(@RequestParam(name = "top", defaultValue = "10") int top,
@RequestParam(name = "status", required = false) CommentStatus status) {
Page<SheetComment> 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<SheetComment> deletePermanentlyInBatch(@RequestBody List<Long> 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);

View File

@ -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);

View File

@ -25,26 +25,26 @@ public class StaticStorageController {
}
@GetMapping
@ApiOperation("List static files.")
@ApiOperation("Lists static files")
public List<StaticFile> 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);

View File

@ -37,7 +37,7 @@ public class TagController {
}
@GetMapping
@ApiOperation("Lists tag")
@ApiOperation("Lists tags")
public List<? extends TagDTO> 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);

View File

@ -43,49 +43,57 @@ public class ThemeController {
}
@GetMapping
@ApiOperation("List all themes")
@ApiOperation("Lists all themes")
public Set<ThemeProperty> listAll() {
return themeService.getThemes();
}
@GetMapping("activation/files")
@ApiOperation("Lists all activate theme files")
public List<ThemeFile> listFiles() {
return themeService.listThemeFolderBy(themeService.getActivatedThemeId());
}
@GetMapping("{themeId}/files")
@ApiOperation("Lists theme files by theme id")
public List<ThemeFile> listFiles(@PathVariable("themeId") String themeId) {
return themeService.listThemeFolderBy(themeId);
}
@GetMapping("files/content")
@ApiOperation("Gets template content")
public BaseResponse<String> 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<String> 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<String> customSheetTemplate() {
return themeService.listCustomTemplates(themeService.getActivatedThemeId(), ThemeService.CUSTOM_SHEET_PREFIX);
}
@GetMapping("activation/template/custom/post")
@ApiOperation("Gets custom post templates")
public Set<String> 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));
}
}

View File

@ -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("密码修改成功");

View File

@ -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)) {

View File

@ -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");

View File

@ -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)) {

View File

@ -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)));