package com.mzl.flower.web.partner; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mzl.flower.base.BaseController; import com.mzl.flower.base.R; import com.mzl.flower.base.ReturnDataDTO; import com.mzl.flower.config.exception.ValidationException; import com.mzl.flower.dto.request.flower.FlowerMarkupSpCgQueryDTO; import com.mzl.flower.dto.request.flower.FlowerMarkupSpCgSaveDTO; import com.mzl.flower.dto.response.flower.FlowerMarkupSpCgDTO; import com.mzl.flower.dto.response.flower.FlowerMarkupSpCgListDTO; import com.mzl.flower.entity.partner.Partner; import com.mzl.flower.service.flower.FlowerMarkupSpCgService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/flower/markup/spcg") @Api(value = "合伙人商品分类加价管理", tags = "合伙人商品分类加价管理") @Validated @Slf4j public class FlowerMarkupSpCgController extends BaseController { @Autowired private FlowerMarkupSpCgService spCgService; @PostMapping("/list/save") @ApiOperation(value = "新增商品分类加价") public ResponseEntity saveMarkupSpCg(@RequestBody FlowerMarkupSpCgSaveDTO dto) { Partner s = spCgService.getCurrentPartner(); if(s == null){ throw new ValidationException("未找到当前合伙人信息"); } dto.setPartnerId(s.getId()); spCgService.saveMarkupSpCg(dto); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/save/platform") @ApiOperation(value = "运营平台新增商品分类加价") public ResponseEntity saveMarkupSpCgPlatform(@RequestBody FlowerMarkupSpCgSaveDTO dto) { if(dto.getPartnerId()== null || dto.getPartnerId() == 0){ throw new ValidationException("合伙人id不能为空"); } spCgService.saveMarkupSpCg(dto); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/list/view") @ApiOperation(value = "查询商品分类加价详情") @ApiImplicitParams({ @ApiImplicitParam(name = "categoryId", value = "商品分类id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity> getMarkupSpCg(Long categoryId){ return returnData(R.SUCCESS.getCode(), spCgService.getMarkupSpCg(categoryId)); } @GetMapping("/list") @ApiOperation(value = "获取商品分类加价列表") public ResponseEntity>> selectMarkupSpCgList(Page page , FlowerMarkupSpCgQueryDTO dto){ Partner s = spCgService.getCurrentPartner(); if(s == null){ throw new ValidationException("未找到当前合伙人信息"); } dto.setPartnerId(s.getId()); return returnData(R.SUCCESS.getCode(), spCgService.selectMarkupSpCgList(page, dto)); } @GetMapping("/list/platform") @ApiOperation(value = "运营平台获取商品分类加价列表") public ResponseEntity>> selectMarkupSpCgListPlatform(Page page , FlowerMarkupSpCgQueryDTO dto){ if(dto.getPartnerId()== null || dto.getPartnerId() == 0){ throw new ValidationException("合伙人id不能为空"); } return returnData(R.SUCCESS.getCode(), spCgService.selectMarkupSpCgList(page, dto)); } @GetMapping("/list/delete") @ApiOperation(value = "删除商品分类加价") @ApiImplicitParams({ @ApiImplicitParam(name = "categoryId", value = "商品分类id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity> deleteMarkupSpCg(Long categoryId){ spCgService.deleteMarkupSpCg(categoryId); return returnData(R.SUCCESS.getCode(), null); } }