feat:增加美食朋友圈功能
This commit is contained in:
40
src/main/java/com/cxx/food/controller/MomentController.java
Normal file
40
src/main/java/com/cxx/food/controller/MomentController.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.cxx.food.controller;
|
||||
|
||||
import com.cxx.food.dto.*;
|
||||
import com.cxx.food.service.MomentService;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/moment")
|
||||
@Tag(name = "美食朋友圈")
|
||||
public class MomentController {
|
||||
@Resource
|
||||
private MomentService momentService;
|
||||
|
||||
@Operation(summary = "新增朋友圈")
|
||||
@PostMapping("")
|
||||
public Boolean addMoment(@RequestBody @JsonView(WriteView.class) @Validated MomentDto momentDto) {
|
||||
return momentService.addMoment(momentDto);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询朋友圈")
|
||||
@GetMapping("")
|
||||
public @JsonView(ReadView.class) List<MomentDto> queryMoment() {
|
||||
return momentService.queryMoment();
|
||||
}
|
||||
|
||||
@Operation(summary = "新增评论")
|
||||
@PostMapping("/{id}/comment")
|
||||
public Boolean addMoment(@PathVariable("id") long id,
|
||||
@RequestBody @JsonView(WriteView.class) @Validated CommentDto commentDto) {
|
||||
return momentService.addComment(id, commentDto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user