Rename output dto to dto

pull/146/head
johnniang 2019-04-23 17:49:40 +08:00
parent e6e880d20a
commit 36c8a21af4
54 changed files with 193 additions and 250 deletions

View File

@ -1,6 +1,6 @@
#Fri Mar 08 10:50:45 CST 2019
#Tue Apr 23 17:12:17 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

View File

@ -14,7 +14,7 @@ import java.util.Date;
* @date 3/21/19
*/
@Data
public class AttachmentOutputDTO implements OutputConverter<AttachmentOutputDTO, Attachment> {
public class AttachmentDTO implements OutputConverter<AttachmentDTO, Attachment> {
private Integer id;

View File

@ -3,8 +3,6 @@ package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Category;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Category;
/**
* Category output dto.
@ -13,7 +11,7 @@ import run.halo.app.model.entity.Category;
* @date 3/19/19
*/
@Data
public class CategoryOutputDTO implements OutputConverter<CategoryOutputDTO, Category> {
public class CategoryDTO implements OutputConverter<CategoryDTO, Category> {
private Integer id;

View File

@ -6,9 +6,6 @@ import run.halo.app.model.enums.CommentStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Comment;
import run.halo.app.model.enums.CommentStatus;
import java.util.Date;
@ -20,7 +17,7 @@ import java.util.Date;
@Data
@ToString
@EqualsAndHashCode
public class CommentOutputDTO implements OutputConverter<CommentOutputDTO, Comment> {
public class CommentDTO implements OutputConverter<CommentDTO, Comment> {
private Long id;

View File

@ -9,7 +9,7 @@ import lombok.Data;
* @date 3/19/19
*/
@Data
public class CountOutputDTO {
public class CountDTO {
private long postCount;

View File

@ -3,15 +3,13 @@ package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Gallery;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Gallery;
/**
* @author : RYAN0UP
* @date : 2019/3/21
*/
@Data
public class GalleryOutputDTO implements OutputConverter<GalleryOutputDTO, Gallery> {
public class GalleryDTO implements OutputConverter<GalleryDTO, Gallery> {
private Integer id;

View File

@ -3,8 +3,6 @@ package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Link;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Link;
/**
* Link output dto.
@ -13,7 +11,7 @@ import run.halo.app.model.entity.Link;
* @date : 2019/3/21
*/
@Data
public class LinkOutputDTO implements OutputConverter<LinkOutputDTO, Link> {
public class LinkDTO implements OutputConverter<LinkDTO, Link> {
private Integer id;

View File

@ -6,9 +6,6 @@ import run.halo.app.model.enums.LogType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Log;
import run.halo.app.model.enums.LogType;
import java.util.Date;
@ -19,7 +16,7 @@ import java.util.Date;
@Data
@ToString
@EqualsAndHashCode
public class LogOutputDTO implements OutputConverter<LogOutputDTO, Log> {
public class LogDTO implements OutputConverter<LogDTO, Log> {
private Long id;

View File

@ -3,8 +3,6 @@ package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Menu;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Menu;
/**
* Menu output dto.
@ -13,7 +11,7 @@ import run.halo.app.model.entity.Menu;
* @date 4/3/19
*/
@Data
public class MenuOutputDTO implements OutputConverter<MenuOutputDTO, Menu> {
public class MenuDTO implements OutputConverter<MenuDTO, Menu> {
private Integer id;

View File

@ -11,7 +11,7 @@ import run.halo.app.model.entity.Option;
* @date 3/20/19
*/
@Data
public class OptionOutputDTO implements OutputConverter<OptionOutputDTO, Option> {
public class OptionDTO implements OutputConverter<OptionDTO, Option> {
private String key;

View File

@ -3,8 +3,6 @@ package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Tag;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Tag;
/**
* Tag output dto.
@ -13,7 +11,7 @@ import run.halo.app.model.entity.Tag;
* @date 3/19/19
*/
@Data
public class TagOutputDTO implements OutputConverter<TagOutputDTO, Tag> {
public class TagDTO implements OutputConverter<TagDTO, Tag> {
private Integer id;

View File

@ -9,7 +9,7 @@ import lombok.Data;
* @date 3/20/19
*/
@Data
public class TagWithCountOutputDTO extends TagOutputDTO {
public class TagWithPostCountDTO extends TagDTO {
private Long postCount;

View File

@ -5,8 +5,6 @@ import run.halo.app.model.entity.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.User;
import java.util.Date;
@ -19,7 +17,7 @@ import java.util.Date;
@Data
@ToString
@EqualsAndHashCode
public class UserOutputDTO implements OutputConverter<UserOutputDTO, User> {
public class UserDTO implements OutputConverter<UserDTO, User> {
private Integer id;

View File

@ -1,8 +1,7 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.CategoryOutputDTO;
import run.halo.app.model.dto.CategoryDTO;
import lombok.Data;
import run.halo.app.model.dto.CategoryOutputDTO;
import java.util.List;
@ -13,7 +12,7 @@ import java.util.List;
* @date 3/21/19
*/
@Data
public class CategoryVO extends CategoryOutputDTO {
public class CategoryVO extends CategoryDTO {
private List<CategoryVO> children;
}

View File

@ -1,6 +1,6 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.CommentOutputDTO;
import run.halo.app.model.dto.CommentDTO;
import lombok.Data;
import lombok.ToString;
@ -14,7 +14,7 @@ import java.util.List;
*/
@Data
@ToString(callSuper = true)
public class CommentVO extends CommentOutputDTO {
public class CommentVO extends CommentDTO {
private List<CommentVO> children;

View File

@ -1,11 +1,10 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.CommentOutputDTO;
import run.halo.app.model.dto.CommentDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import run.halo.app.model.dto.CommentOutputDTO;
/**
* Comment list with parent comment vo.
@ -17,7 +16,7 @@ import run.halo.app.model.dto.CommentOutputDTO;
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Slf4j
public class CommentWithParentVO extends CommentOutputDTO implements Cloneable {
public class CommentWithParentVO extends CommentDTO implements Cloneable {
/**
* Parent comment.

View File

@ -1,6 +1,6 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.CommentOutputDTO;
import run.halo.app.model.dto.CommentDTO;
import run.halo.app.model.dto.post.PostMinimalOutputDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -14,7 +14,7 @@ import lombok.ToString;
@Data
@ToString
@EqualsAndHashCode(callSuper = true)
public class CommentWithPostVO extends CommentOutputDTO {
public class CommentWithPostVO extends CommentDTO {
private PostMinimalOutputDTO post;
}

View File

@ -2,8 +2,7 @@ package run.halo.app.model.vo;
import lombok.Data;
import lombok.ToString;
import run.halo.app.model.dto.GalleryOutputDTO;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.dto.GalleryDTO;
import java.util.List;
@ -19,5 +18,5 @@ public class GalleryTeamVO {
private String team;
private List<GalleryOutputDTO> galleries;
private List<GalleryDTO> galleries;
}

View File

@ -1,9 +1,8 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.dto.LinkDTO;
import lombok.Data;
import lombok.ToString;
import run.halo.app.model.dto.LinkOutputDTO;
import java.util.List;
@ -19,5 +18,5 @@ public class LinkTeamVO {
private String team;
private List<LinkOutputDTO> links;
private List<LinkDTO> links;
}

View File

@ -1,7 +1,7 @@
package run.halo.app.model.vo;
import lombok.Data;
import run.halo.app.model.dto.MenuOutputDTO;
import run.halo.app.model.dto.MenuDTO;
import java.util.List;
@ -10,7 +10,7 @@ import java.util.List;
* @date : 2019-04-07
*/
@Data
public class MenuVO extends MenuOutputDTO {
public class MenuVO extends MenuDTO {
private List<MenuVO> children;
}

View File

@ -1,7 +1,7 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.CategoryOutputDTO;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.CategoryDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.dto.post.PostSimpleOutputDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -20,8 +20,8 @@ public class PostListVO extends PostSimpleOutputDTO {
private Long commentCount;
private List<TagOutputDTO> tags;
private List<TagDTO> tags;
private List<CategoryOutputDTO> categories;
private List<CategoryDTO> categories;
}

View File

@ -5,7 +5,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.lang.NonNull;
import org.springframework.web.multipart.MultipartFile;
import run.halo.app.exception.FileOperationException;
import run.halo.app.model.dto.AttachmentOutputDTO;
import run.halo.app.model.dto.AttachmentDTO;
import run.halo.app.model.entity.Attachment;
import run.halo.app.model.params.AttachmentQuery;
import run.halo.app.service.base.CrudService;
@ -27,7 +27,7 @@ public interface AttachmentService extends CrudService<Attachment, Integer> {
* @return a page of attachment output dto
*/
@NonNull
Page<AttachmentOutputDTO> pageDtosBy(@NonNull Pageable pageable, AttachmentQuery attachmentQuery);
Page<AttachmentDTO> pageDtosBy(@NonNull Pageable pageable, AttachmentQuery attachmentQuery);
/**
* Uploads file.
@ -55,7 +55,7 @@ public interface AttachmentService extends CrudService<Attachment, Integer> {
* @return an attachment output dto
*/
@NonNull
AttachmentOutputDTO convertToDto(@NonNull Attachment attachment);
AttachmentDTO convertToDto(@NonNull Attachment attachment);
/**
* List all media type.

View File

@ -2,7 +2,7 @@ package run.halo.app.service;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import run.halo.app.model.dto.GalleryOutputDTO;
import run.halo.app.model.dto.GalleryDTO;
import run.halo.app.model.entity.Gallery;
import run.halo.app.model.vo.GalleryTeamVO;
import run.halo.app.service.base.CrudService;
@ -22,7 +22,7 @@ public interface GalleryService extends CrudService<Gallery, Integer> {
* @param sort sort
* @return all galleries
*/
List<GalleryOutputDTO> listDtos(@NonNull Sort sort);
List<GalleryDTO> listDtos(@NonNull Sort sort);
/**
* Lists gallery team vos.
@ -39,5 +39,5 @@ public interface GalleryService extends CrudService<Gallery, Integer> {
* @param sort sort
* @return list of galleries
*/
List<GalleryOutputDTO> listByTeam(@NonNull String team, Sort sort);
List<GalleryDTO> listByTeam(@NonNull String team, Sort sort);
}

View File

@ -1,13 +1,12 @@
package run.halo.app.service;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.dto.LinkDTO;
import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam;
import run.halo.app.model.vo.LinkTeamVO;
import run.halo.app.service.base.CrudService;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import run.halo.app.service.base.CrudService;
import java.util.List;
@ -25,7 +24,7 @@ public interface LinkService extends CrudService<Link, Integer> {
* @return all links
*/
@NonNull
List<LinkOutputDTO> listDtos(@NonNull Sort sort);
List<LinkDTO> listDtos(@NonNull Sort sort);
/**
* Lists link team vos.

View File

@ -1,10 +1,9 @@
package run.halo.app.service;
import run.halo.app.model.dto.LogOutputDTO;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.model.entity.Log;
import run.halo.app.service.base.CrudService;
import org.springframework.data.domain.Page;
import run.halo.app.service.base.CrudService;
/**
* Log service.
@ -19,5 +18,5 @@ public interface LogService extends CrudService<Log, Long> {
* @param top top number must not be less than 0
* @return a page of latest logs
*/
Page<LogOutputDTO> pageLatest(int top);
Page<LogDTO> pageLatest(int top);
}

View File

@ -2,7 +2,7 @@ package run.halo.app.service;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import run.halo.app.model.dto.MenuOutputDTO;
import run.halo.app.model.dto.MenuDTO;
import run.halo.app.model.entity.Menu;
import run.halo.app.model.params.MenuParam;
import run.halo.app.model.vo.MenuVO;
@ -25,7 +25,7 @@ public interface MenuService extends CrudService<Menu, Integer> {
* @return a list of menu output dto
*/
@NonNull
List<MenuOutputDTO> listDtos(@NonNull Sort sort);
List<MenuDTO> listDtos(@NonNull Sort sort);
/**
* Creates a menu.

View File

@ -5,7 +5,7 @@ import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.transaction.annotation.Transactional;
import run.halo.app.exception.MissingPropertyException;
import run.halo.app.model.dto.OptionOutputDTO;
import run.halo.app.model.dto.OptionDTO;
import run.halo.app.model.entity.Option;
import run.halo.app.model.enums.ValueEnum;
import run.halo.app.model.params.OptionParam;
@ -86,7 +86,7 @@ public interface OptionService extends CrudService<Option, Integer> {
* @return a list of option dto
*/
@NonNull
List<OptionOutputDTO> listDtos();
List<OptionDTO> listDtos();
/**
* Get option by key

View File

@ -1,7 +1,7 @@
package run.halo.app.service;
import org.springframework.transaction.annotation.Transactional;
import run.halo.app.model.dto.TagWithCountOutputDTO;
import run.halo.app.model.dto.TagWithPostCountDTO;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostTag;
import run.halo.app.model.entity.Tag;
@ -41,7 +41,7 @@ public interface PostTagService extends CrudService<PostTag, Integer> {
* @return a list of tag with post count output dto
*/
@NonNull
List<TagWithCountOutputDTO> listTagWithCountDtos(@NonNull Sort sort);
List<TagWithPostCountDTO> listTagWithCountDtos(@NonNull Sort sort);
/**
* Lists tags list map by post id.

View File

@ -1,7 +1,7 @@
package run.halo.app.service;
import org.springframework.lang.NonNull;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.entity.Tag;
import run.halo.app.service.base.CrudService;
@ -31,5 +31,5 @@ public interface TagService extends CrudService<Tag, Integer> {
* @return a list of tag output dto
*/
@NonNull
List<TagOutputDTO> convertTo(List<Tag> tags);
List<TagDTO> convertTo(List<Tag> tags);
}

View File

@ -10,10 +10,9 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.multipart.MultipartFile;
import run.halo.app.handler.file.FileHandlers;
import run.halo.app.model.dto.AttachmentOutputDTO;
import run.halo.app.model.dto.AttachmentDTO;
import run.halo.app.model.entity.Attachment;
import run.halo.app.model.enums.AttachmentType;
import run.halo.app.model.enums.converter.AttachmentTypeConverter;
import run.halo.app.model.params.AttachmentQuery;
import run.halo.app.model.properties.AttachmentProperties;
import run.halo.app.model.properties.PropertyEnum;
@ -54,7 +53,7 @@ public class AttachmentServiceImpl extends AbstractCrudService<Attachment, Integ
}
@Override
public Page<AttachmentOutputDTO> pageDtosBy(@NonNull Pageable pageable, AttachmentQuery attachmentQuery) {
public Page<AttachmentDTO> pageDtosBy(@NonNull Pageable pageable, AttachmentQuery attachmentQuery) {
Assert.notNull(pageable, "Page info must not be null");
// List all
@ -139,26 +138,26 @@ public class AttachmentServiceImpl extends AbstractCrudService<Attachment, Integ
}
@Override
public AttachmentOutputDTO convertToDto(Attachment attachment) {
public AttachmentDTO convertToDto(Attachment attachment) {
Assert.notNull(attachment, "Attachment must not be null");
// Get blog base url
String blogBaseUrl = optionService.getBlogBaseUrl();
// Convert to output dto
AttachmentOutputDTO attachmentOutputDTO = new AttachmentOutputDTO().convertFrom(attachment);
AttachmentDTO attachmentDTO = new AttachmentDTO().convertFrom(attachment);
if (Objects.equals(attachmentOutputDTO.getType(), AttachmentType.LOCAL)) {
if (Objects.equals(attachmentDTO.getType(), AttachmentType.LOCAL)) {
// Append blog base url to path and thumbnail
String fullPath = StringUtils.join(blogBaseUrl, "/", attachmentOutputDTO.getPath());
String fullThumbPath = StringUtils.join(blogBaseUrl, "/", attachmentOutputDTO.getThumbPath());
String fullPath = StringUtils.join(blogBaseUrl, "/", attachmentDTO.getPath());
String fullThumbPath = StringUtils.join(blogBaseUrl, "/", attachmentDTO.getThumbPath());
// Set full path and full thumb path
attachmentOutputDTO.setPath(fullPath);
attachmentOutputDTO.setThumbPath(fullThumbPath);
attachmentDTO.setPath(fullPath);
attachmentDTO.setThumbPath(fullThumbPath);
}
return attachmentOutputDTO;
return attachmentDTO;
}
@Override

View File

@ -3,7 +3,7 @@ package run.halo.app.service.impl;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import run.halo.app.model.dto.GalleryOutputDTO;
import run.halo.app.model.dto.GalleryDTO;
import run.halo.app.model.entity.Gallery;
import run.halo.app.model.vo.GalleryTeamVO;
import run.halo.app.repository.GalleryRepository;
@ -40,10 +40,10 @@ public class GalleryServiceImpl extends AbstractCrudService<Gallery, Integer> im
* @return all galleries
*/
@Override
public List<GalleryOutputDTO> listDtos(Sort sort) {
public List<GalleryDTO> listDtos(Sort sort) {
Assert.notNull(sort, "Sort info must not be null");
return listAll(sort).stream().map(gallery -> (GalleryOutputDTO) new GalleryOutputDTO().convertFrom(gallery)).collect(Collectors.toList());
return listAll(sort).stream().map(gallery -> (GalleryDTO) new GalleryDTO().convertFrom(gallery)).collect(Collectors.toList());
}
/**
@ -57,12 +57,12 @@ public class GalleryServiceImpl extends AbstractCrudService<Gallery, Integer> im
Assert.notNull(sort, "Sort info must not be null");
// List all galleries
List<GalleryOutputDTO> galleries = listDtos(sort);
List<GalleryDTO> galleries = listDtos(sort);
// Get teams
Set<String> teams = ServiceUtils.fetchProperty(galleries, GalleryOutputDTO::getTeam);
Set<String> teams = ServiceUtils.fetchProperty(galleries, GalleryDTO::getTeam);
Map<String, List<GalleryOutputDTO>> teamGalleryListMap = ServiceUtils.convertToListMap(teams, galleries, GalleryOutputDTO::getTeam);
Map<String, List<GalleryDTO>> teamGalleryListMap = ServiceUtils.convertToListMap(teams, galleries, GalleryDTO::getTeam);
List<GalleryTeamVO> result = new LinkedList<>();
@ -88,8 +88,8 @@ public class GalleryServiceImpl extends AbstractCrudService<Gallery, Integer> im
* @return list of galleries
*/
@Override
public List<GalleryOutputDTO> listByTeam(String team, Sort sort) {
public List<GalleryDTO> listByTeam(String team, Sort sort) {
List<Gallery> galleries = galleryRepository.findByTeam(team, sort);
return galleries.stream().map(gallery -> (GalleryOutputDTO) new GalleryOutputDTO().convertFrom(gallery)).collect(Collectors.toList());
return galleries.stream().map(gallery -> (GalleryDTO) new GalleryDTO().convertFrom(gallery)).collect(Collectors.toList());
}
}

View File

@ -1,7 +1,7 @@
package run.halo.app.service.impl;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.dto.LinkDTO;
import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam;
import run.halo.app.model.vo.LinkTeamVO;
@ -16,9 +16,6 @@ import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.repository.LinkRepository;
import run.halo.app.service.base.AbstractCrudService;
import java.util.*;
import java.util.stream.Collectors;
@ -46,7 +43,7 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
* @return all links
*/
@Override
public List<LinkOutputDTO> listDtos(Sort sort) {
public List<LinkDTO> listDtos(Sort sort) {
Assert.notNull(sort, "Sort info must not be null");
return convertTo(listAll(sort));
@ -57,13 +54,13 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
Assert.notNull(sort, "Sort info must not be null");
// List all links
List<LinkOutputDTO> links = listDtos(sort);
List<LinkDTO> links = listDtos(sort);
// Get teams
Set<String> teams = ServiceUtils.fetchProperty(links, LinkOutputDTO::getTeam);
Set<String> teams = ServiceUtils.fetchProperty(links, LinkDTO::getTeam);
// Convert to team link list map (Key: team, value: link list)
Map<String, List<LinkOutputDTO>> teamLinkListMap = ServiceUtils.convertToListMap(teams, links, LinkOutputDTO::getTeam);
Map<String, List<LinkDTO>> teamLinkListMap = ServiceUtils.convertToListMap(teams, links, LinkDTO::getTeam);
List<LinkTeamVO> result = new LinkedList<>();
@ -105,12 +102,12 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
}
@NonNull
private List<LinkOutputDTO> convertTo(@Nullable List<Link> links) {
private List<LinkDTO> convertTo(@Nullable List<Link> links) {
if (CollectionUtils.isEmpty(links)) {
return Collections.emptyList();
}
return links.stream().map(link -> new LinkOutputDTO().<LinkOutputDTO>convertFrom(link))
return links.stream().map(link -> new LinkDTO().<LinkDTO>convertFrom(link))
.collect(Collectors.toList());
}
}

View File

@ -1,6 +1,6 @@
package run.halo.app.service.impl;
import run.halo.app.model.dto.LogOutputDTO;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.model.entity.Log;
import run.halo.app.repository.LogRepository;
import run.halo.app.service.LogService;
@ -10,8 +10,6 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import run.halo.app.repository.LogRepository;
import run.halo.app.service.base.AbstractCrudService;
/**
* LogService implementation class
@ -30,13 +28,13 @@ public class LogServiceImpl extends AbstractCrudService<Log, Long> implements Lo
}
@Override
public Page<LogOutputDTO> pageLatest(int top) {
public Page<LogDTO> pageLatest(int top) {
Assert.isTrue(top > 0, "Top number must not be less than 0");
// Build page request
PageRequest latestPageable = PageRequest.of(0, top, Sort.by(Sort.Direction.DESC, "createTime"));
// List all
return listAll(latestPageable).map(log -> new LogOutputDTO().convertFrom(log));
return listAll(latestPageable).map(log -> new LogDTO().convertFrom(log));
}
}

View File

@ -6,7 +6,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.model.dto.MenuOutputDTO;
import run.halo.app.model.dto.MenuDTO;
import run.halo.app.model.entity.Menu;
import run.halo.app.model.params.MenuParam;
import run.halo.app.model.vo.MenuVO;
@ -36,7 +36,7 @@ public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implemen
}
@Override
public List<MenuOutputDTO> listDtos(Sort sort) {
public List<MenuDTO> listDtos(Sort sort) {
Assert.notNull(sort, "Sort info must not be null");
return convertTo(listAll(sort));
@ -139,13 +139,13 @@ public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implemen
return topMenu;
}
private List<MenuOutputDTO> convertTo(List<Menu> menus) {
private List<MenuDTO> convertTo(List<Menu> menus) {
if (CollectionUtils.isEmpty(menus)) {
return Collections.emptyList();
}
return menus.stream()
.map(menu -> new MenuOutputDTO().<MenuOutputDTO>convertFrom(menu))
.map(menu -> new MenuDTO().<MenuDTO>convertFrom(menu))
.collect(Collectors.toList());
}
}

View File

@ -10,7 +10,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.cache.StringCacheStore;
import run.halo.app.exception.MissingPropertyException;
import run.halo.app.model.dto.OptionOutputDTO;
import run.halo.app.model.dto.OptionDTO;
import run.halo.app.model.entity.Option;
import run.halo.app.model.enums.ValueEnum;
import run.halo.app.model.params.OptionParam;
@ -129,8 +129,8 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
}
@Override
public List<OptionOutputDTO> listDtos() {
return listAll().stream().map(option -> new OptionOutputDTO().<OptionOutputDTO>convertFrom(option)).collect(Collectors.toList());
public List<OptionDTO> listDtos() {
return listAll().stream().map(option -> new OptionDTO().<OptionDTO>convertFrom(option)).collect(Collectors.toList());
}
@Override

View File

@ -18,8 +18,8 @@ import run.halo.app.event.post.VisitEvent;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.exception.BadRequestException;
import run.halo.app.exception.NotFoundException;
import run.halo.app.model.dto.CategoryOutputDTO;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.CategoryDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.dto.post.PostMinimalOutputDTO;
import run.halo.app.model.dto.post.PostSimpleOutputDTO;
import run.halo.app.model.entity.*;
@ -499,7 +499,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
.orElseGet(LinkedList::new)
.stream()
.filter(Objects::nonNull)
.map(tag -> new TagOutputDTO().<TagOutputDTO>convertFrom(tag))
.map(tag -> new TagDTO().<TagDTO>convertFrom(tag))
.collect(Collectors.toList()));
// Set categories
@ -507,7 +507,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
.orElseGet(LinkedList::new)
.stream()
.filter(Objects::nonNull)
.map(category -> new CategoryOutputDTO().<CategoryOutputDTO>convertFrom(category))
.map(category -> new CategoryDTO().<CategoryDTO>convertFrom(category))
.collect(Collectors.toList()));
// Set comment count

View File

@ -1,6 +1,6 @@
package run.halo.app.service.impl;
import run.halo.app.model.dto.TagWithCountOutputDTO;
import run.halo.app.model.dto.TagWithPostCountDTO;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostTag;
import run.halo.app.model.entity.Tag;
@ -17,10 +17,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.repository.PostRepository;
import run.halo.app.repository.PostTagRepository;
import run.halo.app.repository.TagRepository;
import run.halo.app.service.base.AbstractCrudService;
import java.util.*;
import java.util.stream.Collectors;
@ -60,7 +56,7 @@ public class PostTagServiceImpl extends AbstractCrudService<PostTag, Integer> im
}
@Override
public List<TagWithCountOutputDTO> listTagWithCountDtos(Sort sort) {
public List<TagWithPostCountDTO> listTagWithCountDtos(Sort sort) {
Assert.notNull(sort, "Sort info must not be null");
// Find all tags
@ -72,7 +68,7 @@ public class PostTagServiceImpl extends AbstractCrudService<PostTag, Integer> im
// Find post count
return tags.stream().map(
tag -> {
TagWithCountOutputDTO tagWithCountOutputDTO = new TagWithCountOutputDTO().convertFrom(tag);
TagWithPostCountDTO tagWithCountOutputDTO = new TagWithPostCountDTO().convertFrom(tag);
tagWithCountOutputDTO.setPostCount(tagPostCountMap.getOrDefault(tag.getId(), 0L));
return tagWithCountOutputDTO;
}

View File

@ -2,7 +2,7 @@ package run.halo.app.service.impl;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.exception.NotFoundException;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.entity.Tag;
import run.halo.app.repository.TagRepository;
import run.halo.app.service.TagService;
@ -10,10 +10,6 @@ import run.halo.app.service.base.AbstractCrudService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.exception.NotFoundException;
import run.halo.app.repository.TagRepository;
import run.halo.app.service.base.AbstractCrudService;
import java.util.Collections;
import java.util.List;
@ -64,11 +60,11 @@ public class TagServiceImpl extends AbstractCrudService<Tag, Integer> implements
}
@Override
public List<TagOutputDTO> convertTo(List<Tag> tags) {
public List<TagDTO> convertTo(List<Tag> tags) {
return CollectionUtils.isEmpty(tags) ?
Collections.emptyList() :
tags.stream()
.map(tag -> (TagOutputDTO) new TagOutputDTO().convertFrom(tag))
.map(tag -> (TagDTO) new TagDTO().convertFrom(tag))
.collect(Collectors.toList());
}
}

View File

@ -5,8 +5,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import run.halo.app.cache.lock.CacheLock;
import run.halo.app.exception.BadRequestException;
import run.halo.app.model.dto.CountOutputDTO;
import run.halo.app.model.dto.UserOutputDTO;
import run.halo.app.model.dto.CountDTO;
import run.halo.app.model.dto.UserDTO;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.params.LoginParam;
import run.halo.app.model.properties.PrimaryProperties;
@ -61,11 +61,11 @@ public class AdminController {
*/
@GetMapping("counts")
@ApiOperation("Gets count info")
public CountOutputDTO getCount() {
CountOutputDTO countOutputDTO = new CountOutputDTO();
countOutputDTO.setPostCount(postService.countByStatus(PostStatus.PUBLISHED));
countOutputDTO.setAttachmentCount(attachmentService.count());
countOutputDTO.setCommentCount(commentService.count());
public CountDTO getCount() {
CountDTO countDTO = new CountDTO();
countDTO.setPostCount(postService.countByStatus(PostStatus.PUBLISHED));
countDTO.setAttachmentCount(attachmentService.count());
countDTO.setCommentCount(commentService.count());
long currentTimeMillis = System.currentTimeMillis();
@ -73,19 +73,19 @@ public class AdminController {
// TODO Initialize the birthday if absent
Long birthday = optionService.getByPropertyOrDefault(PrimaryProperties.BIRTHDAY, Long.class, currentTimeMillis);
long days = (currentTimeMillis - birthday) / (1000 * 24 * 3600);
countOutputDTO.setEstablishDays(days);
countDTO.setEstablishDays(days);
countOutputDTO.setLinkCount(linkService.count());
countOutputDTO.setVisitCount(postService.countVisit());
countOutputDTO.setLikeCount(postService.countLike());
return countOutputDTO;
countDTO.setLinkCount(linkService.count());
countDTO.setVisitCount(postService.countVisit());
countDTO.setLikeCount(postService.countLike());
return countDTO;
}
@PostMapping("login")
@ApiOperation("Login with session")
@CacheLock(autoDelete = false, traceRequest = true)
public UserOutputDTO login(@Valid @RequestBody LoginParam loginParam, HttpServletRequest request) {
return new UserOutputDTO().convertFrom(userService.login(loginParam.getUsername(), loginParam.getPassword(), request.getSession()));
public UserDTO login(@Valid @RequestBody LoginParam loginParam, HttpServletRequest request) {
return new UserDTO().convertFrom(userService.login(loginParam.getUsername(), loginParam.getPassword(), request.getSession()));
}
@PostMapping("logout")

View File

@ -7,7 +7,7 @@ import org.springframework.data.web.PageableDefault;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import run.halo.app.model.dto.AttachmentOutputDTO;
import run.halo.app.model.dto.AttachmentDTO;
import run.halo.app.model.entity.Attachment;
import run.halo.app.model.params.AttachmentParam;
import run.halo.app.model.params.AttachmentQuery;
@ -39,11 +39,11 @@ public class AttachmentController {
* List of attachment.
*
* @param pageable pageable
* @return Page<AttachmentOutputDTO>
* @return Page<AttachmentDTO>
*/
@GetMapping
public Page<AttachmentOutputDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
AttachmentQuery attachmentQuery) {
public Page<AttachmentDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable,
AttachmentQuery attachmentQuery) {
return attachmentService.pageDtosBy(pageable, attachmentQuery);
}
@ -51,22 +51,22 @@ public class AttachmentController {
* Get attachment by id.
*
* @param id attachment id
* @return AttachmentOutputDTO
* @return AttachmentDTO
*/
@GetMapping("{id:\\d+}")
@ApiOperation("Get attachment detail by id")
public AttachmentOutputDTO getBy(@PathVariable("id") Integer id) {
public AttachmentDTO getBy(@PathVariable("id") Integer id) {
Attachment attachment = attachmentService.getById(id);
return attachmentService.convertToDto(attachment);
}
@PutMapping("{attachmentId:\\d+}")
@ApiOperation("Updates a attachment")
public AttachmentOutputDTO updateBy(@PathVariable("attachmentId") Integer attachmentId,
@RequestBody @Valid AttachmentParam attachmentParam) {
public AttachmentDTO updateBy(@PathVariable("attachmentId") Integer attachmentId,
@RequestBody @Valid AttachmentParam attachmentParam) {
Attachment attachment = attachmentService.getById(attachmentId);
attachmentParam.update(attachment);
return new AttachmentOutputDTO().convertFrom(attachmentService.update(attachment));
return new AttachmentDTO().convertFrom(attachmentService.update(attachment));
}
/**
@ -76,20 +76,20 @@ public class AttachmentController {
*/
@DeleteMapping("{id:\\d+}")
@ApiOperation("Delete attachment by id")
public AttachmentOutputDTO deletePermanently(@PathVariable("id") Integer id) {
public AttachmentDTO deletePermanently(@PathVariable("id") Integer id) {
return attachmentService.convertToDto(attachmentService.removePermanently(id));
}
@PostMapping("upload")
@ApiOperation("Uploads single file")
public AttachmentOutputDTO uploadAttachment(@RequestPart("file") MultipartFile file) {
public AttachmentDTO uploadAttachment(@RequestPart("file") MultipartFile file) {
return attachmentService.convertToDto(attachmentService.upload(file));
}
@PostMapping(value = "uploads", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("Uploads multi files (Invalid in Swagger UI)")
public List<AttachmentOutputDTO> uploadAttachments(@RequestPart("files") MultipartFile[] files) {
List<AttachmentOutputDTO> result = new LinkedList<>();
public List<AttachmentDTO> uploadAttachments(@RequestPart("files") MultipartFile[] files) {
List<AttachmentDTO> result = new LinkedList<>();
for (MultipartFile file : files) {
// Upload single file

View File

@ -4,7 +4,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.CategoryOutputDTO;
import run.halo.app.model.dto.CategoryDTO;
import run.halo.app.model.entity.Category;
import run.halo.app.model.params.CategoryParam;
import run.halo.app.model.vo.CategoryVO;
@ -44,24 +44,24 @@ public class CategoryController {
}
@PostMapping
public CategoryOutputDTO createBy(@Valid @RequestBody CategoryParam categoryParam) {
public CategoryDTO createBy(@Valid @RequestBody CategoryParam categoryParam) {
// Convert to category
Category category = categoryParam.convertTo();
// Save it
return new CategoryOutputDTO().convertFrom(categoryService.create(category));
return new CategoryDTO().convertFrom(categoryService.create(category));
}
/**
* Get Category by id
*
* @param id id
* @return CategoryOutputDTO
* @return CategoryDTO
*/
@GetMapping("{id:\\d+}")
@ApiOperation("Get category detail by id")
public CategoryOutputDTO getBy(@PathVariable("id") Integer id) {
return new CategoryOutputDTO().convertFrom(categoryService.getById(id));
public CategoryDTO getBy(@PathVariable("id") Integer id) {
return new CategoryDTO().convertFrom(categoryService.getById(id));
}
/**

View File

@ -6,7 +6,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.CommentOutputDTO;
import run.halo.app.model.dto.CommentDTO;
import run.halo.app.model.entity.Comment;
import run.halo.app.model.entity.User;
import run.halo.app.model.enums.CommentStatus;
@ -68,7 +68,7 @@ public class CommentController {
}
@PostMapping
public CommentOutputDTO createBy(@RequestBody CommentParam commentParam, HttpServletRequest request, User user) {
public CommentDTO createBy(@RequestBody CommentParam commentParam, HttpServletRequest request, User user) {
// Set some default info
commentParam.setAuthor(StringUtils.isEmpty(user.getNickname()) ? user.getUsername() : user.getNickname());
commentParam.setEmail(user.getEmail());
@ -85,28 +85,28 @@ public class CommentController {
commentService.mustExistById(commentParam.getParentId());
}
return new CommentOutputDTO().convertFrom(commentService.createBy(commentParam.convertTo(), request));
return new CommentDTO().convertFrom(commentService.createBy(commentParam.convertTo(), request));
}
@PutMapping("{commentId:\\d+}/status/{status}")
@ApiOperation("Updates comment status")
public CommentOutputDTO updateStatusBy(@PathVariable("commentId") Long commentId,
@PathVariable("status") CommentStatus status) {
public CommentDTO updateStatusBy(@PathVariable("commentId") Long commentId,
@PathVariable("status") CommentStatus status) {
// Update comment status
Comment updatedComment = commentService.updateStatus(commentId, status);
return new CommentOutputDTO().convertFrom(updatedComment);
return new CommentDTO().convertFrom(updatedComment);
}
@DeleteMapping("{commentId:\\d+}")
@ApiOperation("Deletes comment permanently and recursively")
public CommentOutputDTO deleteBy(@PathVariable("commentId") Long commentId) {
public CommentDTO deleteBy(@PathVariable("commentId") Long commentId) {
// Get comment by id
Comment comment = commentService.getById(commentId);
// Remove it
commentService.remove(comment);
return new CommentOutputDTO().convertFrom(comment);
return new CommentDTO().convertFrom(comment);
}
}

View File

@ -1,13 +1,11 @@
package run.halo.app.web.controller.admin.api;
import run.halo.app.model.dto.GalleryOutputDTO;
import run.halo.app.model.dto.GalleryDTO;
import run.halo.app.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.*;
import run.halo.app.model.dto.GalleryOutputDTO;
import run.halo.app.service.GalleryService;
import java.util.List;
@ -34,7 +32,7 @@ public class GalleryController {
* @return all of galleries
*/
@GetMapping
public List<GalleryOutputDTO> listGalleries(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
public List<GalleryDTO> listGalleries(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
return galleryService.listDtos(sort);
}
@ -42,12 +40,12 @@ public class GalleryController {
* Get gallery by id.
*
* @param galleryId gallery id
* @return GalleryOutputDTO
* @return GalleryDTO
*/
@GetMapping("{galleryId:\\d+}")
@ApiOperation("Get gallery detail by id")
public GalleryOutputDTO getBy(@PathVariable("galleryId") Integer galleryId) {
return new GalleryOutputDTO().convertFrom(galleryService.getById(galleryId));
public GalleryDTO getBy(@PathVariable("galleryId") Integer galleryId) {
return new GalleryDTO().convertFrom(galleryService.getById(galleryId));
}
/**

View File

@ -4,7 +4,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.dto.LinkDTO;
import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam;
import run.halo.app.service.LinkService;
@ -35,7 +35,7 @@ public class LinkController {
* @return List
*/
@GetMapping
public List<LinkOutputDTO> listLinks(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
public List<LinkDTO> listLinks(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
return linkService.listDtos(sort);
}
@ -43,27 +43,27 @@ public class LinkController {
* Get link by id.
*
* @param id id
* @return LinkOutputDTO
* @return LinkDTO
*/
@GetMapping("{id:\\d+}")
@ApiOperation("Get link detail by id")
public LinkOutputDTO getBy(@PathVariable("id") Integer id) {
return new LinkOutputDTO().convertFrom(linkService.getById(id));
public LinkDTO getBy(@PathVariable("id") Integer id) {
return new LinkDTO().convertFrom(linkService.getById(id));
}
@PostMapping
public LinkOutputDTO createBy(@RequestBody @Valid LinkParam linkParam) {
public LinkDTO createBy(@RequestBody @Valid LinkParam linkParam) {
Link link = linkService.createBy(linkParam);
return new LinkOutputDTO().convertFrom(link);
return new LinkDTO().convertFrom(link);
}
@PutMapping("{id:\\d+}")
@ApiOperation("Updates a link")
public LinkOutputDTO updateBy(@PathVariable("id") Integer id,
@RequestBody @Valid LinkParam linkParam) {
public LinkDTO updateBy(@PathVariable("id") Integer id,
@RequestBody @Valid LinkParam linkParam) {
Link link = linkService.getById(id);
linkParam.update(link);
return new LinkOutputDTO().convertFrom(linkService.update(link));
return new LinkDTO().convertFrom(linkService.update(link));
}
/**

View File

@ -1,14 +1,12 @@
package run.halo.app.web.controller.admin.api;
import run.halo.app.model.dto.LogOutputDTO;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.service.LogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.model.dto.LogOutputDTO;
import run.halo.app.service.LogService;
import java.util.List;
@ -36,7 +34,7 @@ public class LogController {
*/
@GetMapping("latest")
@ApiOperation("Pages latest logs")
public List<LogOutputDTO> pageLatest(@RequestParam(name = "top", defaultValue = "10") int top) {
public List<LogDTO> pageLatest(@RequestParam(name = "top", defaultValue = "10") int top) {
return logService.pageLatest(top).getContent();
}

View File

@ -4,7 +4,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.MenuOutputDTO;
import run.halo.app.model.dto.MenuDTO;
import run.halo.app.model.entity.Menu;
import run.halo.app.model.params.MenuParam;
import run.halo.app.model.vo.MenuVO;
@ -34,7 +34,7 @@ public class MenuController {
@GetMapping
@ApiOperation("Lists all menus")
public List<MenuOutputDTO> listAll(@SortDefault(sort = "sort", direction = DESC) Sort sort) {
public List<MenuDTO> listAll(@SortDefault(sort = "sort", direction = DESC) Sort sort) {
return menuService.listDtos(sort);
}
@ -46,14 +46,14 @@ public class MenuController {
@PostMapping
@ApiOperation("Creates a menu")
public MenuOutputDTO createBy(@RequestBody @Valid MenuParam menuParam) {
return new MenuOutputDTO().convertFrom(menuService.createBy(menuParam));
public MenuDTO createBy(@RequestBody @Valid MenuParam menuParam) {
return new MenuDTO().convertFrom(menuService.createBy(menuParam));
}
@PutMapping("{menuId:\\d+}")
@ApiOperation("Updates a menu")
public MenuOutputDTO updateBy(@PathVariable("menuId") Integer menuId,
@RequestBody @Valid MenuParam menuParam) {
public MenuDTO updateBy(@PathVariable("menuId") Integer menuId,
@RequestBody @Valid MenuParam menuParam) {
// Get the menu
Menu menu = menuService.getById(menuId);
@ -61,12 +61,12 @@ public class MenuController {
menuParam.update(menu);
// Update menu in database
return new MenuOutputDTO().convertFrom(menuService.update(menu));
return new MenuDTO().convertFrom(menuService.update(menu));
}
@DeleteMapping("{menuId:\\d+}")
@ApiOperation("Deletes a menu")
public MenuOutputDTO deleteBy(@PathVariable("menuId") Integer menuId) {
return new MenuOutputDTO().convertFrom(menuService.removeById(menuId));
public MenuDTO deleteBy(@PathVariable("menuId") Integer menuId) {
return new MenuDTO().convertFrom(menuService.removeById(menuId));
}
}

View File

@ -1,6 +1,6 @@
package run.halo.app.web.controller.admin.api;
import run.halo.app.model.dto.OptionOutputDTO;
import run.halo.app.model.dto.OptionDTO;
import run.halo.app.model.params.OptionParam;
import run.halo.app.service.OptionService;
import io.swagger.annotations.ApiOperation;
@ -27,7 +27,7 @@ public class OptionController {
}
@GetMapping
public List<OptionOutputDTO> listAll() {
public List<OptionDTO> listAll() {
return optionService.listDtos();
}

View File

@ -1,6 +1,6 @@
package run.halo.app.web.controller.admin.api;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.entity.Tag;
import run.halo.app.model.params.TagParam;
import run.halo.app.service.PostTagService;
@ -10,11 +10,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.entity.Tag;
import run.halo.app.model.params.TagParam;
import run.halo.app.service.PostTagService;
import run.halo.app.service.TagService;
import javax.validation.Valid;
import java.util.List;
@ -41,8 +36,8 @@ public class TagController {
}
@GetMapping
public List<? extends TagOutputDTO> listTags(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort,
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
public List<? extends TagDTO> listTags(@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort,
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
if (more) {
return postTagService.listTagWithCountDtos(sort);
}
@ -50,32 +45,32 @@ public class TagController {
}
@PostMapping
public TagOutputDTO createTag(@Valid @RequestBody TagParam tagParam) {
public TagDTO createTag(@Valid @RequestBody TagParam tagParam) {
// Convert to tag
Tag tag = tagParam.convertTo();
log.debug("Tag to be created: [{}]", tag);
// Create and convert
return new TagOutputDTO().convertFrom(tagService.create(tag));
return new TagDTO().convertFrom(tagService.create(tag));
}
/**
* Get tag by id
*
* @param tagId tag id
* @return TagOutputDTO
* @return TagDTO
*/
@GetMapping("{tagId:\\d+}")
@ApiOperation("Get tag detail by id")
public TagOutputDTO getBy(@PathVariable("tagId") Integer tagId) {
return new TagOutputDTO().convertFrom(tagService.getById(tagId));
public TagDTO getBy(@PathVariable("tagId") Integer tagId) {
return new TagDTO().convertFrom(tagService.getById(tagId));
}
@PutMapping("{tagId:\\d+}")
@ApiOperation("Updates tag")
public TagOutputDTO updateBy(@PathVariable("tagId") Integer tagId,
@Valid @RequestBody TagParam tagParam) {
public TagDTO updateBy(@PathVariable("tagId") Integer tagId,
@Valid @RequestBody TagParam tagParam) {
// Get old tag
Tag tag = tagService.getById(tagId);
@ -83,7 +78,7 @@ public class TagController {
tagParam.update(tag);
// Update tag
return new TagOutputDTO().convertFrom(tagService.update(tag));
return new TagDTO().convertFrom(tagService.update(tag));
}
/**

View File

@ -1,15 +1,11 @@
package run.halo.app.web.controller.admin.api;
import run.halo.app.model.dto.UserOutputDTO;
import run.halo.app.model.dto.UserDTO;
import run.halo.app.model.entity.User;
import run.halo.app.model.params.PasswordParam;
import run.halo.app.model.params.UserParam;
import run.halo.app.service.UserService;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.UserOutputDTO;
import run.halo.app.model.entity.User;
import run.halo.app.model.params.PasswordParam;
import run.halo.app.model.params.UserParam;
import javax.validation.Valid;
@ -30,17 +26,17 @@ public class UserController {
}
@GetMapping("profile")
public UserOutputDTO getProfile(User user) {
return new UserOutputDTO().convertFrom(user);
public UserDTO getProfile(User user) {
return new UserDTO().convertFrom(user);
}
@PutMapping("profile")
public UserOutputDTO updateProfile(@Valid @RequestBody UserParam userParam, User user) {
public UserDTO updateProfile(@Valid @RequestBody UserParam userParam, User user) {
// Update properties
userParam.update(user);
// Update user and convert to dto
return new UserOutputDTO().convertFrom(userService.update(user));
return new UserDTO().convertFrom(userService.update(user));
}
@PutMapping("profile/password")

View File

@ -1,7 +1,7 @@
package run.halo.app.web.controller.content.api;
import io.swagger.annotations.ApiOperation;
import run.halo.app.model.dto.CommentOutputDTO;
import run.halo.app.model.dto.CommentDTO;
import run.halo.app.model.entity.User;
import run.halo.app.model.params.CommentParam;
import run.halo.app.model.properties.BlogProperties;
@ -45,7 +45,7 @@ public class CommentController {
@PostMapping
@ApiOperation("Comments a post")
public CommentOutputDTO comment(@RequestBody CommentParam commentParam, HttpServletRequest request) {
public CommentDTO comment(@RequestBody CommentParam commentParam, HttpServletRequest request) {
// Get authentication
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
@ -67,6 +67,6 @@ public class CommentController {
commentService.mustExistById(commentParam.getParentId());
}
return new CommentOutputDTO().convertFrom(commentService.createBy(commentParam.convertTo(), request));
return new CommentDTO().convertFrom(commentService.createBy(commentParam.convertTo(), request));
}
}

View File

@ -1,6 +1,6 @@
package run.halo.app.web.controller.content.api;
import run.halo.app.model.dto.MenuOutputDTO;
import run.halo.app.model.dto.MenuDTO;
import run.halo.app.service.MenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Sort;
@ -8,7 +8,6 @@ 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 run.halo.app.service.MenuService;
import java.util.List;
@ -32,7 +31,7 @@ public class MenuController {
@GetMapping
@ApiOperation("Lists all menus")
public List<MenuOutputDTO> listAll(@SortDefault(sort = "sort", direction = DESC) Sort sort) {
public List<MenuDTO> listAll(@SortDefault(sort = "sort", direction = DESC) Sort sort) {
return menuService.listDtos(sort);
}
}

View File

@ -1,6 +1,6 @@
package run.halo.app.web.controller.content.api;
import run.halo.app.model.dto.OptionOutputDTO;
import run.halo.app.model.dto.OptionDTO;
import run.halo.app.model.support.BaseResponse;
import run.halo.app.service.OptionService;
import io.swagger.annotations.ApiOperation;
@ -31,7 +31,7 @@ public class OptionController {
@GetMapping("list_view")
@ApiOperation("Lists all options with list view")
public List<OptionOutputDTO> listAll() {
public List<OptionDTO> listAll() {
return optionService.listDtos();
}

View File

@ -1,6 +1,6 @@
package run.halo.app.web.controller.content.api;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.dto.post.PostSimpleOutputDTO;
import run.halo.app.model.entity.Tag;
import run.halo.app.service.PostTagService;
@ -13,11 +13,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.TagOutputDTO;
import run.halo.app.model.dto.post.PostSimpleOutputDTO;
import run.halo.app.model.entity.Tag;
import run.halo.app.service.PostTagService;
import run.halo.app.service.TagService;
import java.util.List;
@ -44,8 +39,8 @@ public class TagController {
@GetMapping
@ApiOperation("Lists tags")
public List<? extends TagOutputDTO> listTags(@SortDefault(sort = "updateTime", direction = DESC) Sort sort,
@ApiParam("If the param is true, post count of tag will be returned")
public List<? extends TagDTO> listTags(@SortDefault(sort = "updateTime", direction = DESC) Sort sort,
@ApiParam("If the param is true, post count of tag will be returned")
@RequestParam(name = "more", required = false, defaultValue = "false") Boolean more) {
if (more) {
return postTagService.listTagWithCountDtos(sort);

View File

@ -1,6 +1,6 @@
package run.halo.app.web.controller.content.api;
import run.halo.app.model.dto.UserOutputDTO;
import run.halo.app.model.dto.UserDTO;
import run.halo.app.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
@ -25,7 +25,7 @@ public class UserController {
@GetMapping("profile")
@ApiOperation("Gets blogger profile")
public UserOutputDTO getProfile() {
return userService.getCurrentUser().map(user -> new UserOutputDTO().<UserOutputDTO>convertFrom(user)).get();
public UserDTO getProfile() {
return userService.getCurrentUser().map(user -> new UserDTO().<UserDTO>convertFrom(user)).get();
}
}