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.constant.Constants; import com.mzl.flower.dto.request.flower.*; import com.mzl.flower.dto.request.flower.FlowerTagMultipleDTO; import com.mzl.flower.dto.response.flower.*; 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 java.util.List; @RestController @RequestMapping("/api/flower") @Api(value = "商品管理-运营端", tags = "商品管理-运营端") @Validated @Slf4j public class FlowerController extends BaseController { @Autowired private FlowerService flowerService; @Autowired private FlowerParamService paramService; @GetMapping("/list") @ApiOperation(value = "商品列表") public ResponseEntity>> selectFlowerList(Page page, FlowerQueryDTO dto){ return returnData(R.SUCCESS.getCode(), flowerService.selectFlowerList(page, dto)); } @GetMapping("/list/view") @ApiOperation(value = "商品详情") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity> getFlowerDetail(Long id) { return returnData(R.SUCCESS.getCode(), flowerService.getFlowerDetail(id)); } @PostMapping("/list/pass") @ApiOperation(value = "审核通过") public ResponseEntity passFlower(@RequestBody FlowerAuditDTO dto) { flowerService.auditFlower(dto.getId(), dto.getAuditRemarks(), Constants.FLOWER_STATUS.UP.name()); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/reject") @ApiOperation(value = "审核驳回") public ResponseEntity rejectFlower(@RequestBody FlowerAuditDTO dto) { flowerService.auditFlower(dto.getId(), dto.getAuditRemarks(), Constants.FLOWER_STATUS.REJECT.name()); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/pass/multi") @ApiOperation(value = "批量审核通过") public ResponseEntity passFlowers(@RequestBody FlowerAuditMultipleDTO dto) { flowerService.auditFlowers(dto, Constants.FLOWER_STATUS.UP.name()); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/reject/multi") @ApiOperation(value = "批量审核驳回") public ResponseEntity rejectFlowers(@RequestBody FlowerAuditMultipleDTO dto) { flowerService.auditFlowers(dto, Constants.FLOWER_STATUS.REJECT.name()); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/tags") @ApiOperation(value = "批量设置标签") public ResponseEntity setFlowersTags(@RequestBody FlowerTagMultipleDTO dto) { flowerService.setFlowersTags(dto); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/zones") @ApiOperation(value = "批量设置专区") public ResponseEntity setFlowerZone(@RequestBody FlowerZoneBatchDTO dto) { flowerService.setFlowerZone(dto); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/off") @ApiOperation(value = "批量强制下架") public ResponseEntity setFlowersForceOff(@RequestBody FlowerOffDTO dto) { flowerService.setFlowersForceOff(dto); 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> deleteFlower(Long id) { flowerService.deleteFlower(id); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/params") @ApiOperation(value = "获取分类参数列表") @ApiImplicitParams({ @ApiImplicitParam(name = "categoryId", value = "商品分类id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity>> getParamItemListByCategoryId(Long categoryId){ return returnData(R.SUCCESS.getCode(), paramService.getParamItemListByCategoryId(categoryId)); } @PostMapping("/list/edit") @ApiOperation(value = "编辑商品") public ResponseEntity editFlowerAdmin(@RequestBody FlowerUpdateAdminDTO dto) { return returnData(R.SUCCESS.getCode(), flowerService.editFlowerAdmin(dto)); } @PostMapping("/list/recommend/set") @ApiOperation(value = "批量设置推荐") public ResponseEntity setFlowerRecommend(@RequestBody FlowerRecommendMultipleDTO dto) { flowerService.setFlowerRecommend(dto); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/recommend/cancel") @ApiOperation(value = "批量取消推荐") public ResponseEntity cancelFlowerRecommend(@RequestBody FlowerRecommendMultipleDTO dto) { flowerService.cancelFlowerRecommend(dto); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/list/recommend/set/rank") @ApiOperation(value = "设置推荐排序") public ResponseEntity setFlowerRecommendRank(@RequestBody FlowerRecommendRankDTO dto) { flowerService.setFlowerRecommendRank(dto); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/list/shown") @ApiOperation(value = "显示商品") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity> showFlower(Long id){ flowerService.setFlowerShown(id, true); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/list/hidden") @ApiOperation(value = "隐藏商品") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity> hideFlower(Long id){ flowerService.setFlowerShown(id, false); return returnData(R.SUCCESS.getCode(), null); } }