石墨消解仪后端服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

2 months ago
  1. package com.iflytop.gd.app.controller;
  2. import com.iflytop.gd.app.model.dto.PhotoSaveDTO;
  3. import com.iflytop.gd.app.model.dto.PhotoTakeDTO;
  4. import com.iflytop.gd.app.model.vo.PhotoListVO;
  5. import com.iflytop.gd.app.model.vo.PhotoVO;
  6. import com.iflytop.gd.app.service.api.PhotosService;
  7. import com.iflytop.gd.common.base.BasePageQuery;
  8. import com.iflytop.gd.common.result.Result;
  9. import io.swagger.v3.oas.annotations.Operation;
  10. import io.swagger.v3.oas.annotations.Parameter;
  11. import io.swagger.v3.oas.annotations.tags.Tag;
  12. import lombok.RequiredArgsConstructor;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.web.bind.annotation.*;
  15. import java.util.List;
  16. /**
  17. * 照片接口
  18. */
  19. @Tag(name = "照片")
  20. @RestController
  21. @RequestMapping("/api/photo")
  22. @RequiredArgsConstructor
  23. @Slf4j
  24. public class PhotoController {
  25. private final PhotosService photosService;
  26. @Operation(summary = "照片列表")
  27. @GetMapping("/list")
  28. public Result<List<PhotoListVO>> getList(BasePageQuery pageQuery) {
  29. return Result.success(photosService.getList(pageQuery));
  30. }
  31. @Operation(summary = "根据id获取照片")
  32. @GetMapping("/{id}")
  33. public Result<PhotoVO> get(@PathVariable Long id) {
  34. return Result.success(photosService.get(id));
  35. }
  36. @Operation(summary = "拍摄一张照片")
  37. @PostMapping("/take")
  38. public Result<String> take(@RequestBody PhotoTakeDTO photoTakeDTO) throws Exception {
  39. return Result.success(photosService.take(photoTakeDTO));
  40. }
  41. @Operation(summary = "保存照片")
  42. @PostMapping("/save")
  43. public Result<?> save(@RequestBody PhotoSaveDTO photoSaveDTO) {
  44. photosService.save(photoSaveDTO);
  45. return Result.success();
  46. }
  47. @Operation(summary = "删除照片")
  48. @DeleteMapping("/{ids}")
  49. public Result<String> delete(@Parameter(description = "ID,多个以英文逗号(,)分割") @PathVariable String ids) {
  50. boolean isSuccess = photosService.deletePhoto(ids);
  51. if (isSuccess) {
  52. return Result.success();
  53. }
  54. return Result.failed();
  55. }
  56. }