| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package space.anyi.petServiceManagementSystem.server.controller;
- import io.swagger.v3.oas.annotations.Operation;
- import jakarta.servlet.http.HttpServletRequest;
- import jakarta.validation.Valid;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import space.anyi.petServiceManagementSystem.server.common.R;
- import space.anyi.petServiceManagementSystem.server.dto.appointment.AppointmentDto;
- import space.anyi.petServiceManagementSystem.server.service.AppointmentService;
- import space.anyi.petServiceManagementSystem.server.vo.appointment.AppointmentVo;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping("/appointments")
- public class AppointmentController {
- @Autowired
- private AppointmentService appointmentService;
- @PostMapping
- @Operation(summary = "提交预约")
- public R<AppointmentVo> create(@Valid @RequestBody AppointmentDto dto, HttpServletRequest request) {
- Long userId = (Long) request.getAttribute("userId");
- return R.ok(appointmentService.create(dto, userId));
- }
- @GetMapping
- @Operation(summary = "获取我的预约列表")
- public R<List<AppointmentVo>> list(HttpServletRequest request) {
- Long userId = (Long) request.getAttribute("userId");
- return R.ok(appointmentService.list(userId));
- }
- @GetMapping("/{id}")
- @Operation(summary = "获取预约详情")
- public R<AppointmentVo> getById(@PathVariable Long id, HttpServletRequest request) {
- Long userId = (Long) request.getAttribute("userId");
- return R.ok(appointmentService.getById(id, userId));
- }
- @PostMapping("/{id}/cancel")
- @Operation(summary = "申请取消")
- public R<Boolean> cancel(@PathVariable Long id, @RequestBody Map<String, String> body,
- HttpServletRequest request) {
- Long userId = (Long) request.getAttribute("userId");
- return R.ok(appointmentService.cancel(id, body.get("reason"), userId));
- }
- @PostMapping("/{id}/pay-deposit")
- @Operation(summary = "模拟支付定金")
- public R<Boolean> payDeposit(@PathVariable Long id, HttpServletRequest request) {
- Long userId = (Long) request.getAttribute("userId");
- return R.ok(appointmentService.payDeposit(id, userId));
- }
- }
|