|
@@ -0,0 +1,91 @@
|
|
|
+package com.yc.ship.module.product.controller.admin.distributorDiscount;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
+import com.sun.xml.internal.fastinfoset.util.StringArray;
|
|
|
+import com.yc.ship.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import com.yc.ship.framework.common.pojo.CommonResult;
|
|
|
+import com.yc.ship.framework.common.pojo.PageParam;
|
|
|
+import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
+import com.yc.ship.framework.common.util.collection.ArrayUtils;
|
|
|
+import com.yc.ship.framework.common.util.collection.CollectionUtils;
|
|
|
+import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
+import com.yc.ship.framework.excel.core.util.ExcelUtils;
|
|
|
+import com.yc.ship.module.product.controller.admin.distributorDiscount.vo.DistributorDiscountPageReqVO;
|
|
|
+import com.yc.ship.module.product.controller.admin.distributorDiscount.vo.DistributorDiscountRespVO;
|
|
|
+import com.yc.ship.module.product.controller.admin.distributorDiscount.vo.DistributorDiscountSaveReqVO;
|
|
|
+import com.yc.ship.module.product.dal.dataobject.distributorDiscount.DistributorDiscountDO;
|
|
|
+import com.yc.ship.module.product.service.distributorDiscount.DistributorDiscountService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.yc.ship.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static com.yc.ship.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 分销商专属折扣")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/distributor-discount")
|
|
|
+@Validated
|
|
|
+public class DistributorDiscountController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DistributorDiscountService distributorDiscountService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建分销商专属折扣")
|
|
|
+ public CommonResult<Long> createDistributorDiscount(@Valid @RequestBody DistributorDiscountSaveReqVO createReqVO) {
|
|
|
+ return success(distributorDiscountService.createDistributorDiscount(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新分销商专属折扣")
|
|
|
+ public CommonResult<Boolean> updateDistributorDiscount(@Valid @RequestBody DistributorDiscountSaveReqVO updateReqVO) {
|
|
|
+ distributorDiscountService.updateDistributorDiscount(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除分销商专属折扣")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ public CommonResult<Boolean> deleteDistributorDiscount(@RequestParam("id") Long id) {
|
|
|
+ distributorDiscountService.deleteDistributorDiscount(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得分销商专属折扣")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ public CommonResult<DistributorDiscountRespVO> getDistributorDiscount(@RequestParam("id") Long id) {
|
|
|
+ DistributorDiscountDO distributorDiscount = distributorDiscountService.getDistributorDiscount(id);
|
|
|
+ DistributorDiscountRespVO bean = BeanUtils.toBean(distributorDiscount, DistributorDiscountRespVO.class);
|
|
|
+ return success(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得分销商专属折扣分页")
|
|
|
+ public CommonResult<PageResult<DistributorDiscountRespVO>> getDistributorDiscountPage(@Valid DistributorDiscountPageReqVO pageReqVO) {
|
|
|
+ PageResult<DistributorDiscountDO> pageResult = distributorDiscountService.getDistributorDiscountPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, DistributorDiscountRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出分销商专属折扣 Excel")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportDistributorDiscountExcel(@Valid DistributorDiscountPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<DistributorDiscountDO> list = distributorDiscountService.getDistributorDiscountPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "分销商专属折扣.xls", "数据", DistributorDiscountRespVO.class,
|
|
|
+ BeanUtils.toBean(list, DistributorDiscountRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|