mirror of https://github.com/halo-dev/halo
Improve apis
parent
b6f29c0bac
commit
fadf12a065
|
@ -13,48 +13,21 @@ import lombok.Data;
|
|||
@Data
|
||||
public class AttachmentOutputDTO implements OutputConverter<AttachmentOutputDTO, Attachment> {
|
||||
|
||||
/**
|
||||
* Attachment id.
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 附件名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 附件路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 缩略图路径
|
||||
*/
|
||||
private String thumbPath;
|
||||
|
||||
/**
|
||||
* 附件类型
|
||||
*/
|
||||
private String mediaType;
|
||||
|
||||
/**
|
||||
* 附件后缀
|
||||
*/
|
||||
private String suffix;
|
||||
|
||||
/**
|
||||
* 附件尺寸
|
||||
*/
|
||||
private String dimension;
|
||||
|
||||
/**
|
||||
* 附件大小
|
||||
*/
|
||||
private String size;
|
||||
|
||||
/**
|
||||
* 附件上传类型
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
||||
|
|
|
@ -11,23 +11,11 @@ import lombok.Data;
|
|||
@Data
|
||||
public class CountOutputDTO {
|
||||
|
||||
/**
|
||||
* Post count.
|
||||
*/
|
||||
private Long postCount;
|
||||
|
||||
/**
|
||||
* Comment count.
|
||||
*/
|
||||
private Long commentCount;
|
||||
|
||||
/**
|
||||
* Attachment count.
|
||||
*/
|
||||
private Long attachmentCount;
|
||||
|
||||
/**
|
||||
* Establish days
|
||||
*/
|
||||
private Long establishDays;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package cc.ryanc.halo.model.dto;
|
||||
|
||||
import cc.ryanc.halo.model.dto.base.OutputConverter;
|
||||
import cc.ryanc.halo.model.entity.Link;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2019/3/22
|
||||
*/
|
||||
@Data
|
||||
public class LinkTeamOutputDTO implements OutputConverter<LinkTeamOutputDTO, Link> {
|
||||
|
||||
private String team;
|
||||
|
||||
private List<Link> links;
|
||||
}
|
|
@ -9,38 +9,24 @@ import lombok.ToString;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author johnniang
|
||||
* @date 3/19/19
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class LogOutputDTO implements OutputConverter<LogOutputDTO, Log> {
|
||||
|
||||
/**
|
||||
* Log id.
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 日志标识
|
||||
*/
|
||||
private String logKey;
|
||||
|
||||
/**
|
||||
* 日志事件类型
|
||||
*/
|
||||
private LogType type;
|
||||
|
||||
/**
|
||||
* 日志内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 操作 IP
|
||||
*/
|
||||
private String ipAddress;
|
||||
|
||||
/**
|
||||
* 创建时间戳
|
||||
*/
|
||||
private Date createTime;
|
||||
}
|
||||
|
|
|
@ -19,48 +19,21 @@ import java.util.Date;
|
|||
@EqualsAndHashCode
|
||||
public class UserOutputDTO implements OutputConverter<UserOutputDTO, User> {
|
||||
|
||||
/**
|
||||
* User id.
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Expire time.
|
||||
*/
|
||||
private Date expireTime;
|
||||
|
||||
/**
|
||||
* 创建时间戳
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间戳
|
||||
*/
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
|
@ -6,19 +6,15 @@ import lombok.ToString;
|
|||
|
||||
/**
|
||||
* Post detail output dto.
|
||||
*
|
||||
* @author johnniang
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PostDetailOutputDTO extends PostSimpleOutputDTO {
|
||||
|
||||
/**
|
||||
* 源内容
|
||||
*/
|
||||
private String originalContent;
|
||||
|
||||
/**
|
||||
* 渲染后内容
|
||||
*/
|
||||
private String formatContent;
|
||||
}
|
||||
|
|
|
@ -20,43 +20,19 @@ import java.util.Date;
|
|||
@EqualsAndHashCode
|
||||
public class PostMinimalOutputDTO implements OutputConverter<PostMinimalOutputDTO, Post> {
|
||||
|
||||
/**
|
||||
* Post id.
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* Post title
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Post status.
|
||||
*/
|
||||
private PostStatus status;
|
||||
|
||||
/**
|
||||
* Post url.
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Post type
|
||||
*/
|
||||
private PostType type;
|
||||
|
||||
/**
|
||||
* 更新时间戳
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建时间戳
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* Edit time.
|
||||
*/
|
||||
private Date editTime;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Page simple output dto.
|
||||
*
|
||||
|
@ -18,52 +16,21 @@ import java.util.Date;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PostSimpleOutputDTO extends PostMinimalOutputDTO {
|
||||
|
||||
/**
|
||||
* 文章类型
|
||||
* 0: 普通文章
|
||||
* 1: 自定义页面
|
||||
* 2: 日志
|
||||
*/
|
||||
private PostType type;
|
||||
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* 缩略图
|
||||
*/
|
||||
private String thumbnail;
|
||||
|
||||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
private Long visits;
|
||||
|
||||
/**
|
||||
* 是否允许评论
|
||||
*/
|
||||
private Boolean disallowComment;
|
||||
|
||||
/**
|
||||
* 自定义渲染模板名称
|
||||
*/
|
||||
private String template;
|
||||
|
||||
/**
|
||||
* 是否置顶
|
||||
*/
|
||||
private Integer topPriority;
|
||||
|
||||
/**
|
||||
* 发布来源
|
||||
*/
|
||||
private PostCreateFrom createFrom;
|
||||
|
||||
/**
|
||||
* 点赞量/喜欢量
|
||||
*/
|
||||
private Long likes;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.service;
|
||||
|
||||
import cc.ryanc.halo.model.dto.LinkOutputDTO;
|
||||
import cc.ryanc.halo.model.dto.LinkTeamOutputDTO;
|
||||
import cc.ryanc.halo.model.entity.Link;
|
||||
import cc.ryanc.halo.service.base.CrudService;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
@ -22,4 +23,11 @@ public interface LinkService extends CrudService<Link, Integer> {
|
|||
* @return all links
|
||||
*/
|
||||
List<LinkOutputDTO> listDtos(@NonNull Sort sort);
|
||||
|
||||
/**
|
||||
* List link by group
|
||||
*
|
||||
* @return List<LinkTeamOutputDTO>
|
||||
*/
|
||||
List<LinkTeamOutputDTO> listTeam();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package cc.ryanc.halo.service;
|
|||
import cc.ryanc.halo.model.dto.TagOutputDTO;
|
||||
import cc.ryanc.halo.model.entity.Tag;
|
||||
import cc.ryanc.halo.service.base.CrudService;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cc.ryanc.halo.service.impl;
|
||||
|
||||
import cc.ryanc.halo.model.dto.LinkOutputDTO;
|
||||
import cc.ryanc.halo.model.dto.LinkTeamOutputDTO;
|
||||
import cc.ryanc.halo.model.entity.Link;
|
||||
import cc.ryanc.halo.repository.LinkRepository;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
|
@ -40,4 +41,15 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
|
|||
|
||||
return listAll(sort).stream().map(link -> (LinkOutputDTO) new LinkOutputDTO().convertFrom(link)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* List link by group
|
||||
*
|
||||
* @return List<LinkTeamOutputDTO>
|
||||
*/
|
||||
@Override
|
||||
public List<LinkTeamOutputDTO> listTeam() {
|
||||
// TODO list team
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,11 @@ package cc.ryanc.halo.web.controller.admin.api;
|
|||
|
||||
import cc.ryanc.halo.model.dto.AttachmentOutputDTO;
|
||||
import cc.ryanc.halo.service.AttachmentService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
||||
|
@ -27,8 +26,37 @@ public class AttachmentController {
|
|||
this.attachmentService = attachmentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of attachment.
|
||||
*
|
||||
* @param pageable pageable
|
||||
* @return Page<AttachmentOutputDTO>
|
||||
*/
|
||||
@GetMapping
|
||||
public Page<AttachmentOutputDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
|
||||
return attachmentService.pageDtosBy(pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment by id.
|
||||
*
|
||||
* @param id attachment id
|
||||
* @return AttachmentOutputDTO
|
||||
*/
|
||||
@GetMapping("{id:\\d+}")
|
||||
@ApiOperation("Get attachment detail by id")
|
||||
public AttachmentOutputDTO getBy(@PathVariable("id") Integer id) {
|
||||
return new AttachmentOutputDTO().convertFrom(attachmentService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete attachment by id
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
@DeleteMapping("{id:\\d+}")
|
||||
@ApiOperation("Delete attachment by id")
|
||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||
attachmentService.removeById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,27 @@ public class CategoryController {
|
|||
// Save it
|
||||
return new CategoryOutputDTO().convertFrom(categoryService.create(category));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category by id
|
||||
*
|
||||
* @param id id
|
||||
* @return CategoryOutputDTO
|
||||
*/
|
||||
@GetMapping("{id:\\d+}")
|
||||
@ApiOperation("Get category detail by id")
|
||||
public CategoryOutputDTO getBy(@PathVariable("id") Integer id) {
|
||||
return new CategoryOutputDTO().convertFrom(categoryService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete category by id.
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
@DeleteMapping("{id:\\d+}")
|
||||
@ApiOperation("Delete category by id")
|
||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||
categoryService.removeById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,10 @@ package cc.ryanc.halo.web.controller.admin.api;
|
|||
|
||||
import cc.ryanc.halo.model.dto.GalleryOutputDTO;
|
||||
import cc.ryanc.halo.service.GalleryService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -36,4 +35,27 @@ public class GalleryController {
|
|||
public List<GalleryOutputDTO> listGalleries(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
|
||||
return galleryService.listDtos(sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gallery by id.
|
||||
*
|
||||
* @param id gallery id
|
||||
* @return GalleryOutputDTO
|
||||
*/
|
||||
@GetMapping("{id:\\d+}")
|
||||
@ApiOperation("Get gallery detail by id")
|
||||
public GalleryOutputDTO getBy(@PathVariable("id") Integer id) {
|
||||
return new GalleryOutputDTO().convertFrom(galleryService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete gallery by id.
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
@DeleteMapping("{id:\\d+}")
|
||||
@ApiOperation("Delete gallery by id")
|
||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||
galleryService.removeById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,10 @@ package cc.ryanc.halo.web.controller.admin.api;
|
|||
|
||||
import cc.ryanc.halo.model.dto.LinkOutputDTO;
|
||||
import cc.ryanc.halo.service.LinkService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -36,4 +35,27 @@ public class LinkController {
|
|||
public List<LinkOutputDTO> listLinks(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
|
||||
return linkService.listDtos(sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link by id.
|
||||
*
|
||||
* @param id id
|
||||
* @return LinkOutputDTO
|
||||
*/
|
||||
@GetMapping("{id:\\d+}")
|
||||
@ApiOperation("Get link detail by id")
|
||||
public LinkOutputDTO getBy(@PathVariable("id") Integer id) {
|
||||
return new LinkOutputDTO().convertFrom(linkService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete link by id.
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
@DeleteMapping("{id:\\d+}")
|
||||
@ApiOperation("Delete link by id")
|
||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||
linkService.removeById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,24 @@ public class LogController {
|
|||
this.logService = logService;
|
||||
}
|
||||
|
||||
/**
|
||||
* List latest logs.
|
||||
*
|
||||
* @param top top
|
||||
* @return List of logs
|
||||
*/
|
||||
@GetMapping("latest")
|
||||
@ApiOperation("Pages latest logs")
|
||||
public List<LogOutputDTO> pageLatest(@RequestParam(name = "top", defaultValue = "10") int top) {
|
||||
return logService.pageLatest(top).getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all logs.
|
||||
*/
|
||||
@GetMapping("clear")
|
||||
@ApiOperation("Clear all logs")
|
||||
public void clear() {
|
||||
logService.removeAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import cc.ryanc.halo.model.entity.Tag;
|
|||
import cc.ryanc.halo.model.params.TagParam;
|
||||
import cc.ryanc.halo.service.PostTagService;
|
||||
import cc.ryanc.halo.service.TagService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
|
@ -55,4 +56,27 @@ public class TagController {
|
|||
// Create and convert
|
||||
return new TagOutputDTO().convertFrom(tagService.create(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tag by id
|
||||
*
|
||||
* @param id id
|
||||
* @return TagOutputDTO
|
||||
*/
|
||||
@GetMapping("{id:\\d+}")
|
||||
@ApiOperation("Get tag detail by id")
|
||||
public TagOutputDTO getBy(@PathVariable("id") Integer id) {
|
||||
return new TagOutputDTO().convertFrom(tagService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete tag by id.
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
@DeleteMapping("{id:\\d+}")
|
||||
@ApiOperation("Delete tag by id")
|
||||
public void deletePermanently(@PathVariable("id") Integer id) {
|
||||
tagService.removeById(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue