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