mirror of https://github.com/halo-dev/halo
Create journal update api for journal.
parent
e8ba507717
commit
288925ff12
|
@ -5,14 +5,12 @@ import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.PageableDefault;
|
||||||
import org.springframework.data.web.SortDefault;
|
import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import run.halo.app.model.dto.BaseCommentDTO;
|
|
||||||
import run.halo.app.model.dto.JournalDTO;
|
import run.halo.app.model.dto.JournalDTO;
|
||||||
import run.halo.app.model.dto.JournalWithCmtCountDTO;
|
import run.halo.app.model.dto.JournalWithCmtCountDTO;
|
||||||
import run.halo.app.model.entity.Journal;
|
import run.halo.app.model.entity.Journal;
|
||||||
import run.halo.app.model.entity.JournalComment;
|
|
||||||
import run.halo.app.model.params.JournalCommentParam;
|
|
||||||
import run.halo.app.model.params.JournalParam;
|
import run.halo.app.model.params.JournalParam;
|
||||||
import run.halo.app.model.vo.BaseCommentVO;
|
import run.halo.app.model.vo.BaseCommentVO;
|
||||||
import run.halo.app.model.vo.BaseCommentWithParentVO;
|
import run.halo.app.model.vo.BaseCommentWithParentVO;
|
||||||
|
@ -51,7 +49,7 @@ public class JournalController {
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("Gets latest journals")
|
@ApiOperation("Gets latest journals")
|
||||||
public Page<JournalWithCmtCountDTO> pageBy(Pageable pageable) {
|
public Page<JournalWithCmtCountDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable) {
|
||||||
Page<Journal> journalPage = journalService.listAll(pageable);
|
Page<Journal> journalPage = journalService.listAll(pageable);
|
||||||
return journalService.convertToCmtCountDto(journalPage);
|
return journalService.convertToCmtCountDto(journalPage);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +68,15 @@ public class JournalController {
|
||||||
return journalService.convertTo(createdJournal);
|
return journalService.convertTo(createdJournal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("{id:\\d+}")
|
||||||
|
@ApiOperation("Updates a Journal")
|
||||||
|
public JournalDTO updateBy(@PathVariable("id") Integer id,
|
||||||
|
@RequestBody @Valid JournalParam journalParam) {
|
||||||
|
Journal journal = journalService.getById(id);
|
||||||
|
journalParam.update(journal);
|
||||||
|
return new JournalDTO().convertFrom(journalService.update(journal));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("{journalId:\\d+}/comments/tree_view")
|
@GetMapping("{journalId:\\d+}/comments/tree_view")
|
||||||
@ApiOperation("Lists comments with tree view")
|
@ApiOperation("Lists comments with tree view")
|
||||||
public Page<BaseCommentVO> listCommentTree(@PathVariable("journalId") Integer journalId,
|
public Page<BaseCommentVO> listCommentTree(@PathVariable("journalId") Integer journalId,
|
||||||
|
|
|
@ -4,6 +4,8 @@ import lombok.Data;
|
||||||
import run.halo.app.model.dto.base.OutputConverter;
|
import run.halo.app.model.dto.base.OutputConverter;
|
||||||
import run.halo.app.model.entity.Journal;
|
import run.halo.app.model.entity.Journal;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Journal dto.
|
* Journal dto.
|
||||||
*
|
*
|
||||||
|
@ -18,4 +20,6 @@ public class JournalDTO implements OutputConverter<JournalDTO, Journal> {
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
private Long likes;
|
private Long likes;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue