Create update api for link.

pull/146/head
ruibaby 2019-04-16 23:17:29 +08:00
parent 59ecc132b3
commit c2bcfd59fc
4 changed files with 18 additions and 10 deletions

View File

@ -21,6 +21,8 @@ public class LinkOutputDTO implements OutputConverter<LinkOutputDTO, Link> {
private String url;
private String logo;
private String description;
private String team;

View File

@ -56,7 +56,7 @@ public interface PostService extends CrudService<Post, Integer> {
Page<Post> pageLatest(int top);
/**
* Lists by status and type
* Lists by status.
*
* @param status post status must not be null
* @param pageable page info must not be null
@ -77,7 +77,7 @@ public interface PostService extends CrudService<Post, Integer> {
/**
* Lists simple output dto by status and type
* Lists simple output dto by status.
*
* @param status post status must not be null
* @param pageable page info must not be null
@ -87,7 +87,7 @@ public interface PostService extends CrudService<Post, Integer> {
Page<PostSimpleOutputDTO> pageSimpleDtoByStatus(@NonNull PostStatus status, @NonNull Pageable pageable);
/**
* Lists page list vo by status, type and pageable.
* Lists page list vo by status and pageable.
*
* @param status post status must not be null
* @param pageable page info must not be null
@ -97,7 +97,7 @@ public interface PostService extends CrudService<Post, Integer> {
Page<PostListVO> pageListVoBy(@NonNull PostStatus status, @NonNull Pageable pageable);
/**
* Count posts by status and type
* Count posts by status.
*
* @param status status
* @return posts count

View File

@ -159,7 +159,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
}
/**
* List by status and type
* List by status.
*
* @param status status
* @param pageable pageable
@ -178,7 +178,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
}
/**
* Counts posts by status and type
* Counts posts by status.
*
* @param status status
* @return posts count

View File

@ -1,15 +1,12 @@
package run.halo.app.web.controller.admin.api;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam;
import run.halo.app.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.*;
import run.halo.app.model.dto.LinkOutputDTO;
import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam;
import run.halo.app.service.LinkService;
import javax.validation.Valid;
@ -60,6 +57,15 @@ public class LinkController {
return new LinkOutputDTO().convertFrom(link);
}
@PutMapping("{id:\\d+}")
@ApiOperation("Updates a link")
public LinkOutputDTO updateBy(@PathVariable("id") Integer id,
@RequestBody @Valid LinkParam linkParam) {
Link link = linkService.getById(id);
linkParam.update(link);
return new LinkOutputDTO().convertFrom(linkService.update(link));
}
/**
* Delete link by id.
*