package com.mzl.flower.web.customer; 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.security.SecurityUtils; import com.mzl.flower.dto.request.customer.CreateCollectDTO; import com.mzl.flower.dto.request.flower.FlowerShowQueryDTO; import com.mzl.flower.dto.response.flower.FlowerShowListDTO; import com.mzl.flower.dto.response.flower.FlowerSupplierListDTO; import com.mzl.flower.service.customer.CollectService; import com.mzl.flower.service.flower.FlowerService; import io.swagger.annotations.Api; 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/collect") @Api(value = "收藏管理", tags = "收藏管理") @Validated @Slf4j public class CollectController extends BaseController { private final CollectService collectService; private final FlowerService flowerService; public CollectController(CollectService collectService, FlowerService flowerService) { this.collectService = collectService; this.flowerService = flowerService; } @PostMapping("/add") @ApiOperation(value = "新增收藏", notes = "新增收藏") public ResponseEntity add(@Validated @RequestBody CreateCollectDTO dto) { collectService.add(dto); return returnData(R.SUCCESS.getCode(),null); } @GetMapping("/delete") @ApiOperation(value = "取消收藏", notes = "取消收藏") public ResponseEntity delete(@NotNull(message = "flowerId不能为空") Long flowerId) { collectService.delete(flowerId); return returnData(R.SUCCESS.getCode(),null); } @GetMapping("/list") @ApiOperation(value = "我的收藏列表", notes = "我的收藏列表") public ResponseEntity>> myCollect(Page page, FlowerShowQueryDTO dto) { return returnData(R.SUCCESS.getCode(),flowerService.myCollect(page,dto)); } @PostMapping("/clear") @ApiOperation(value = "清空失效商品", notes = "清空失效商品") public ResponseEntity clear() { flowerService.clearInvalid(SecurityUtils.getUserId()); return returnData(R.SUCCESS.getCode(),null); } }