| package com.mzl.flower.web.flower; | 
|   | 
| 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.constant.Constants; | 
| import com.mzl.flower.dto.request.flower.*; | 
| import com.mzl.flower.dto.response.flower.FlowerListDTO; | 
| import com.mzl.flower.dto.response.flower.FlowerZoneDTO; | 
| import com.mzl.flower.service.flower.FlowerService; | 
| import com.mzl.flower.service.flower.FlowerZoneService; | 
| 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.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/flower/zone") | 
| @Api(value = "专区管理", tags = "专区管理") | 
| @Validated | 
| @Slf4j | 
| public class FlowerZoneController extends BaseController { | 
|   | 
|     private final FlowerZoneService flowerZoneService; | 
|   | 
|     private final FlowerService flowerService; | 
|     public FlowerZoneController(FlowerZoneService flowerZoneService, FlowerService flowerService) { | 
|         this.flowerZoneService = flowerZoneService; | 
|         this.flowerService = flowerService; | 
|     } | 
|   | 
|     @PostMapping("/page/new") | 
|     @ApiOperation(value = "新增专区") | 
|     public ResponseEntity<ReturnDataDTO> addTag(@RequestBody FlowerZoneCreateDTO dto) { | 
|         flowerZoneService.addZone(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @PostMapping("/page/edit") | 
|     @ApiOperation(value = "编辑专区") | 
|     public ResponseEntity<ReturnDataDTO> updateZone(@RequestBody FlowerZoneUpdateDTO dto) { | 
|         flowerZoneService.updateZone(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/page/view") | 
|     @ApiOperation(value = "查询专区详情") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "专区id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<FlowerZoneDTO>> getZone(@NotNull(message = "id不能为空") Long id){ | 
|         return returnData(R.SUCCESS.getCode(), flowerZoneService.getZone(id)); | 
|     } | 
|      | 
|     @GetMapping("/page") | 
|     @ApiOperation(value = "专区分页查询") | 
|     public ResponseEntity<ReturnDataDTO<Page<FlowerZoneDTO>>> selectZonePage(Page page,String name){ | 
|         return returnData(R.SUCCESS.getCode(), flowerZoneService.selectZonePage(page, name)); | 
|     } | 
|   | 
|     @GetMapping("/page/delete") | 
|     @ApiOperation(value = "删除专区") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "专区id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> deleteZone(@NotNull(message = "id不能为空") Long id){ | 
|         flowerZoneService.deleteZone(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/list") | 
|     @ApiOperation(value = "用户端-专区列表查询") | 
|     public ResponseEntity<ReturnDataDTO<List<FlowerZoneDTO>>> selectZoneList(){ | 
|         return returnData(R.SUCCESS.getCode(), flowerZoneService.selectZoneList(Constants.COMMON_PUBLISH_STATUS.published.name())); | 
|     } | 
|   | 
|     @GetMapping("/page/changeStatus") | 
|     @ApiOperation(value = "专区上下架") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "专区id", required = true, dataType = "Long", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> changeStatus(@NotNull(message = "id不能为空") Long id){ | 
|         flowerZoneService.changeStatus(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|   | 
|     @PostMapping("/page/set/rank") | 
|     @ApiOperation(value = "设置专区商品排序") | 
|     public ResponseEntity<ReturnDataDTO> setFlowerRank(@RequestBody FlowerZoneRankDTO dto) { | 
|         flowerZoneService.setFlowerZoneRank(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|   | 
|     @GetMapping("/page/flower/list") | 
|     @ApiOperation(value = "商品列表") | 
|     public ResponseEntity<ReturnDataDTO<Page<FlowerListDTO>>> selectZoneFlowerList(Page page, FlowerZoneQueryDTO dto){ | 
|         if(dto.getZoneId()==null || dto.getZoneId()==0){ | 
|             throw new ValidationException("专区id不能为空"); | 
|         } | 
|         return returnData(R.SUCCESS.getCode(), flowerService.selectZoneFlowerList(page, dto)); | 
|     } | 
|   | 
|   | 
| } |