123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package com.caimei.controller.admin.data;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.vo.ImageFormVo;
- import com.caimei.model.vo.ImageListVo;
- import com.caimei.service.data.ImageService;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- /**
- * 资料库图片API
- *
- * @author : Aslee
- * @date : 2021/7/9
- */
- @Api(tags = "资料库图片API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/data/image")
- public class ImageApi {
- private final ImageService imageService;
- @ApiOperation("图片列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1图片列表,2图片审核列表"),
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
- @ApiImplicitParam(name = "imageTitle", required = false, value = "图片标题"),
- @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
- @ApiImplicitParam(name = "status", required = false, value = "图片状态:0已下线,1已上线,2待上线"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<ImageListVo>> getImageList(Integer listType, Integer authUserId, String imageTitle, Integer auditStatus, Integer status,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return imageService.getImageList(listType, authUserId, imageTitle, auditStatus, status, pageNum, pageSize);
- }
- @ApiOperation("添加/编辑图片")
- @ApiImplicitParam(name = "params", value = "imageId:图片id;authUserId:供应商用户id;imageTitle:图片标题;imageArr:图片数组", required = true)
- @PostMapping("/save")
- public ResponseJson saveImage(@RequestBody String params) throws Exception {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer imageId = paramsMap.getInteger("imageId");
- Integer authUserId = paramsMap.getInteger("authUserId");
- String imageTitle = paramsMap.getString("imageTitle");
- JSONArray imageArr = paramsMap.getJSONArray("imageArr");
- return imageService.saveImage(imageId, authUserId, imageTitle, imageArr);
- }
- @ApiOperation("图片回显数据")
- @ApiImplicitParam(name = "imageId", value = "图片id", required = true)
- @GetMapping("/form/data")
- public ResponseJson<ImageFormVo> getImageFormData(Integer imageId) {
- return imageService.getImageFormData(imageId);
- }
- @ApiOperation("更新图片状态")
- @ApiImplicitParam(name = "params", value = "imageId:图片id;status:图片状态:0停用 1启用;", required = true)
- @PostMapping("/update/status")
- public ResponseJson updateImageStatus(@RequestBody Map<String,Integer> params) {
- Integer imageId = params.get("imageId");
- Integer status = params.get("status");
- return imageService.updateImageStatus(imageId, status);
- }
- @ApiOperation("删除图片")
- @ApiImplicitParam(name = "params", value = "imageId:图片id", required = true)
- @PostMapping("/delete")
- public ResponseJson deleteImage(@RequestBody Map<String,Integer> params) {
- Integer imageId = params.get("imageId");
- return imageService.deleteImage(imageId);
- }
- @ApiOperation("审核图片")
- @ApiImplicitParam(name = "params", value = "imageId:图片id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
- @PostMapping("/audit")
- public ResponseJson auditImage(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer imageId = paramsMap.getInteger("imageId");
- Integer auditStatus = paramsMap.getInteger("auditStatus");
- String invalidReason = paramsMap.getString("invalidReason");
- Integer auditBy = paramsMap.getInteger("auditBy");
- return imageService.auditImage(imageId, auditStatus, invalidReason, auditBy);
- }
- }
|