|
|
|
|
package com.youlai.boot.mini.controller;
|
|
|
|
|
|
|
|
|
|
import com.youlai.boot.common.annotation.Log;
|
|
|
|
|
import com.youlai.boot.common.annotation.RepeatSubmit;
|
|
|
|
|
import com.youlai.boot.common.enums.ActionTypeEnum;
|
|
|
|
|
import com.youlai.boot.common.enums.LogModuleEnum;
|
|
|
|
|
import com.youlai.boot.common.result.PageResult;
|
|
|
|
|
import com.youlai.boot.common.result.Result;
|
|
|
|
|
import com.youlai.boot.mini.model.dto.DeleteStrayAnimalDTO;
|
|
|
|
|
import com.youlai.boot.mini.model.dto.DeleteStrayAnimalNoteMediaDTO;
|
|
|
|
|
import com.youlai.boot.mini.model.dto.EditVisibilityDTO;
|
|
|
|
|
import com.youlai.boot.mini.model.form.StrayAnimalForm;
|
|
|
|
|
import com.youlai.boot.mini.model.query.OwnStrayAnimalQuery;
|
|
|
|
|
import com.youlai.boot.mini.model.vo.StrayAnimalShortVO;
|
|
|
|
|
import com.youlai.boot.mini.service.StrayAnimalService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 流浪动物信息
|
|
|
|
|
*/
|
|
|
|
|
@Tag(name = "流浪动物信息的相关接口")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/v1/mini/strayAnimal")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class StrayAnimalController {
|
|
|
|
|
|
|
|
|
|
private final StrayAnimalService strayAnimalService;
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "添加动物信息")
|
|
|
|
|
@PostMapping(value = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.INSERT)
|
|
|
|
|
public Result<?> saveStrayAnimal(
|
|
|
|
|
@Valid StrayAnimalForm formData,
|
|
|
|
|
@RequestPart(name = "images") List<MultipartFile> images,
|
|
|
|
|
@RequestPart(name = "videos", required = false) List<MultipartFile> videos
|
|
|
|
|
) {
|
|
|
|
|
String uuid = strayAnimalService.saveStrayAnimal(formData, images, videos);
|
|
|
|
|
return Result.success(uuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "编辑动物信息(不包含图片/视频媒体资源)")
|
|
|
|
|
@PostMapping(value = "/update/{animalUuid}")
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.UPDATE)
|
|
|
|
|
public Result<?> updateStrayAnimal(
|
|
|
|
|
@PathVariable String animalUuid,
|
|
|
|
|
@Validated @RequestBody StrayAnimalForm formData
|
|
|
|
|
) {
|
|
|
|
|
strayAnimalService.updateStrayAnimal(animalUuid, formData);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "编辑动物信息时,删除流浪动物信息媒体资源")
|
|
|
|
|
@PostMapping(value = "/update/deleteMediaSource")
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.UPDATE)
|
|
|
|
|
public Result<?> deleteMediaSource(
|
|
|
|
|
@RequestBody @Validated DeleteStrayAnimalNoteMediaDTO deleteStrayAnimalNoteMediaDTO
|
|
|
|
|
){
|
|
|
|
|
strayAnimalService.deleteMediaSource(deleteStrayAnimalNoteMediaDTO);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "编辑动物信息时,添加流浪动物信息媒体资源", description = "比如补充图片、补充视频")
|
|
|
|
|
@PostMapping(value = "/update/saveMediaSource/{noteUuid}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.UPDATE)
|
|
|
|
|
public Result<?> saveMediaSource(
|
|
|
|
|
@PathVariable String noteUuid,
|
|
|
|
|
@RequestPart(name = "images", required = false) List<MultipartFile> images,
|
|
|
|
|
@RequestPart(name = "videos", required = false) List<MultipartFile> videos
|
|
|
|
|
) {
|
|
|
|
|
strayAnimalService.saveMediaSource(noteUuid, images, videos);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "编辑动物信息可见范围")
|
|
|
|
|
@PostMapping(value = "/update/visibility/{animalUuid}")
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.UPDATE)
|
|
|
|
|
public Result<?> updateVisibility(
|
|
|
|
|
@PathVariable String animalUuid,
|
|
|
|
|
@RequestBody @Validated EditVisibilityDTO editVisibilityDTO
|
|
|
|
|
) {
|
|
|
|
|
strayAnimalService.updateVisibility(animalUuid, editVisibilityDTO);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除动物信息")
|
|
|
|
|
@PostMapping(value = "/delete")
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.DELETE)
|
|
|
|
|
public Result<?> delete(
|
|
|
|
|
@RequestBody @Validated DeleteStrayAnimalDTO deleteStrayAnimalDTO
|
|
|
|
|
) {
|
|
|
|
|
strayAnimalService.delete(deleteStrayAnimalDTO);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取个人登记创建的动物信息列表")
|
|
|
|
|
@GetMapping(value = "/getOwnPage")
|
|
|
|
|
@Log(module = LogModuleEnum.STRAY_ANIMAL_INFO, value = ActionTypeEnum.LIST)
|
|
|
|
|
public PageResult<StrayAnimalShortVO> getOwnPage(
|
|
|
|
|
OwnStrayAnimalQuery queryParams
|
|
|
|
|
) {
|
|
|
|
|
return PageResult.success(strayAnimalService.getOwnPage(queryParams));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|