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
66 lines
2.0 KiB
package com.iflytop.gd.app.controller;
|
|
|
|
import com.iflytop.gd.app.model.dto.PhotoSaveDTO;
|
|
import com.iflytop.gd.app.model.dto.PhotoTakeDTO;
|
|
import com.iflytop.gd.app.model.vo.PhotoListVO;
|
|
import com.iflytop.gd.app.model.vo.PhotoVO;
|
|
import com.iflytop.gd.app.service.api.PhotosService;
|
|
import com.iflytop.gd.common.base.BasePageQuery;
|
|
import com.iflytop.gd.common.result.Result;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 照片接口
|
|
*/
|
|
@Tag(name = "照片")
|
|
@RestController
|
|
@RequestMapping("/api/photo")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class PhotoController {
|
|
private final PhotosService photosService;
|
|
|
|
@Operation(summary = "照片列表")
|
|
@GetMapping("/list")
|
|
public Result<List<PhotoListVO>> getList(BasePageQuery pageQuery) {
|
|
return Result.success(photosService.getList(pageQuery));
|
|
}
|
|
|
|
@Operation(summary = "根据id获取照片")
|
|
@GetMapping("/{id}")
|
|
public Result<PhotoVO> get(@PathVariable Long id) {
|
|
return Result.success(photosService.get(id));
|
|
}
|
|
|
|
|
|
@Operation(summary = "拍摄一张照片")
|
|
@PostMapping("/take")
|
|
public Result<String> take(@RequestBody PhotoTakeDTO photoTakeDTO) throws Exception {
|
|
return Result.success(photosService.take(photoTakeDTO));
|
|
}
|
|
|
|
|
|
@Operation(summary = "保存照片")
|
|
@PostMapping("/save")
|
|
public Result<?> save(@RequestBody PhotoSaveDTO photoSaveDTO) {
|
|
photosService.save(photoSaveDTO);
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "删除照片")
|
|
@DeleteMapping("/{ids}")
|
|
public Result<String> delete(@Parameter(description = "ID,多个以英文逗号(,)分割") @PathVariable String ids) {
|
|
boolean isSuccess = photosService.deletePhoto(ids);
|
|
if (isSuccess) {
|
|
return Result.success();
|
|
}
|
|
return Result.failed();
|
|
}
|
|
}
|