| package com.mzl.flower.web.supplier; | 
|   | 
| 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.constant.Constants; | 
| import com.mzl.flower.dto.request.flower.*; | 
| import com.mzl.flower.dto.response.flower.FlowerSupplierDTO; | 
| import com.mzl.flower.dto.response.flower.FlowerSupplierListDTO; | 
| import com.mzl.flower.dto.response.flower.ParamItemDTO; | 
| import com.mzl.flower.service.flower.FlowerParamService; | 
| import com.mzl.flower.service.flower.FlowerService; | 
| 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.*; | 
|   | 
| import javax.validation.constraints.NotNull; | 
| import java.util.List; | 
|   | 
| @RestController | 
| @RequestMapping("/api/supplier/flower") | 
| @Api(value = "商品管理-花农(供应商)", tags = "商品管理-花农(供应商)") | 
| @Validated | 
| @Slf4j | 
| public class FlowerSupplierController extends BaseController { | 
|   | 
|     @Autowired | 
|     private FlowerService flowerService; | 
|   | 
|     @Autowired | 
|     private FlowerParamService paramService; | 
|   | 
|     @GetMapping("/params") | 
|     @ApiOperation(value = "获取分类参数列表") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "categoryId", value = "商品分类id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<List<ParamItemDTO>>> getParamItemListByCategoryId(Long categoryId){ | 
|         return returnData(R.SUCCESS.getCode(), paramService.getParamItemListByCategoryId(categoryId)); | 
|     } | 
|   | 
|     @GetMapping("/list") | 
|     @ApiOperation(value = "商品列表") | 
|     public ResponseEntity<ReturnDataDTO<Page<FlowerSupplierListDTO>>> selectFlowerList(Page page, FlowerQueryDTO dto){ | 
|         return returnData(R.SUCCESS.getCode(), flowerService.selectFlowerSupplierList(page, dto, 0)); | 
|     } | 
|   | 
|     @GetMapping("/list/rc") | 
|     @ApiOperation(value = "回收站商品列表") | 
|     public ResponseEntity<ReturnDataDTO<Page<FlowerSupplierListDTO>>> selectFlowerRcList(Page page, FlowerQueryDTO dto){ | 
|         return returnData(R.SUCCESS.getCode(), flowerService.selectFlowerSupplierList(page, dto, 1)); | 
|     } | 
|   | 
|     @PostMapping("/list/new") | 
|     @ApiOperation(value = "添加商品提交审核") | 
|     public ResponseEntity<ReturnDataDTO> commitFlower(@RequestBody FlowerCreateDTO dto) { | 
|         return returnData(R.SUCCESS.getCode(), flowerService.commitFlower(dto)); | 
|     } | 
|   | 
|     @PostMapping("/list/edit") | 
|     @ApiOperation(value = "编辑商品") | 
|     public ResponseEntity<ReturnDataDTO> editFlower(@RequestBody FlowerUpdateDTO dto) { | 
|         return returnData(R.SUCCESS.getCode(), flowerService.editFlower(dto)); | 
|     } | 
|   | 
|     @GetMapping("/list/view") | 
|     @ApiOperation(value = "商品详情") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<FlowerSupplierDTO>> getFlowerSupplierDetail(@NotNull(message = "id不能为空") Long id) { | 
|         return returnData(R.SUCCESS.getCode(), flowerService.getFlowerSupplierDetail(id)); | 
|     } | 
|   | 
|     @GetMapping("/list/copy") | 
|     @ApiOperation(value = "获取复制商品信息") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<FlowerSupplierDTO>> getFlowerCopyDetail(Long id) { | 
|         FlowerSupplierDTO dto = flowerService.getFlowerSupplierDetail(id); | 
|         dto.setId(null); | 
|         dto.setStatus(null); | 
|         dto.setSales(null); | 
|         return returnData(R.SUCCESS.getCode(), dto); | 
|     } | 
|   | 
|     @GetMapping("/list/up") | 
|     @ApiOperation(value = "商品上架") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> setOn(Long id) { | 
|         flowerService.setOffOn(id, Constants.FLOWER_STATUS.UP.name()); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/list/off") | 
|     @ApiOperation(value = "商品下架") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> setOff(Long id) { | 
|         flowerService.setOffOn(id, Constants.FLOWER_STATUS.OFF.name()); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/list/delete") | 
|     @ApiOperation(value = "商品删除") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> deleteFlower(Long id) { | 
|         flowerService.deleteFlower(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/list/restore") | 
|     @ApiOperation(value = "商品恢复") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> restoreFlower(Long id) { | 
|         flowerService.restoreFlower(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/list/price") | 
|     @ApiOperation(value = "修改价格") | 
|     public ResponseEntity<ReturnDataDTO> editFlowerPrice(@RequestBody FlowerPriceDTO dto) { | 
|         flowerService.editFlowerPrice(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/list/stock") | 
|     @ApiOperation(value = "修改库存") | 
|     public ResponseEntity<ReturnDataDTO> editFlowerStock(@RequestBody FlowerStockDTO dto) { | 
|         flowerService.editFlowerStock(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/list/delete/batch") | 
|     @ApiOperation(value = "商品批量删除") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品ids", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> deleteFlowerBatch(@RequestBody FlowerBatchDTO dto) { | 
|         flowerService.deleteFlowerBatch(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/list/restore/batch") | 
|     @ApiOperation(value = "商品批量恢复") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "商品ids", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> restoreFlowerBatch(@RequestBody FlowerBatchDTO dto) { | 
|         flowerService.restoreFlowerBatch(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
| } |