Complete sheet comment creation api

pull/146/head
johnniang 2019-04-25 23:40:40 +08:00
parent d7aebebf18
commit 8dc22c20e5
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,33 @@
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.model.dto.BaseCommentDTO;
import run.halo.app.model.entity.SheetComment;
import run.halo.app.model.params.SheetCommentParam;
import run.halo.app.service.SheetCommentService;
/**
* @author johnniang
* @date 19-4-25
*/
@RestController
@RequestMapping("/api/admin/sheets/comments")
public class SheetCommentController {
private final SheetCommentService sheetCommentService;
public SheetCommentController(SheetCommentService sheetCommentService) {
this.sheetCommentService = sheetCommentService;
}
@PostMapping
@ApiOperation("Creates a comment (new or reply)")
public BaseCommentDTO createBy(@RequestBody SheetCommentParam commentParam) {
SheetComment createdComment = sheetCommentService.createBy(commentParam);
return sheetCommentService.convertTo(createdComment);
}
}

View File

@ -0,0 +1,19 @@
package run.halo.app.model.params;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.entity.SheetComment;
/**
* Sheet comment param.
*
* @author johnniang
* @date 19-4-25
*/
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class SheetCommentParam extends BaseCommentParam<SheetComment> {
}