陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.mzl.flower.web.partner;
 
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.dto.request.flower.FlowerMarkupSpQueryDTO;
import com.mzl.flower.dto.request.flower.FlowerMarkupSpSaveDTO;
import com.mzl.flower.dto.response.flower.FlowerMarkupSpDTO;
import com.mzl.flower.dto.response.flower.FlowerMarkupSpListDTO;
import com.mzl.flower.entity.partner.Partner;
import com.mzl.flower.service.flower.FlowerMarkupSpService;
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.*;
 
@RestController
@RequestMapping("/api/flower/markup/sp")
@Api(value = "合伙人商品加价管理", tags = "合伙人商品加价管理")
@Validated
@Slf4j
public class FlowerMarkupSpController extends BaseController {
 
    @Autowired
    private FlowerMarkupSpService spService;
 
    @PostMapping("/list/save")
    @ApiOperation(value = "新增商品加价")
    public ResponseEntity<ReturnDataDTO> saveMarkupSp(@RequestBody FlowerMarkupSpSaveDTO dto) {
        Partner s = spService.getCurrentPartner();
        if(s == null){
            throw new ValidationException("未找到当前合伙人信息");
        }
        dto.setPartnerId(s.getId());
        spService.saveMarkupSp(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/save/platform")
    @ApiOperation(value = "运营平台新增商品加价")
    public ResponseEntity<ReturnDataDTO> saveMarkupSpPlatform(@RequestBody FlowerMarkupSpSaveDTO dto) {
        if(dto.getPartnerId()== null || dto.getPartnerId() == 0){
            throw new ValidationException("合伙人id不能为空");
        }
        spService.saveMarkupSp(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    
    @GetMapping("/list/view")
    @ApiOperation(value = "查询商品加价详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "flowerId", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<FlowerMarkupSpDTO>> getMarkupSp(Long flowerId){
        return returnData(R.SUCCESS.getCode(), spService.getMarkupSp(flowerId));
    }
    
    @GetMapping("/list")
    @ApiOperation(value = "获取商品加价列表")
    public ResponseEntity<ReturnDataDTO<Page<FlowerMarkupSpListDTO>>> selectMarkupSpList(Page page, FlowerMarkupSpQueryDTO dto){
        Partner s = spService.getCurrentPartner();
        if(s == null){
            throw new ValidationException("未找到当前合伙人信息");
        }
        dto.setPartnerId(s.getId());
        return returnData(R.SUCCESS.getCode(), spService.selectMarkupSpList(page, dto));
    }
 
    @GetMapping("/list/platform")
    @ApiOperation(value = "平台查询商品加价列表")
    public ResponseEntity<ReturnDataDTO<Page<FlowerMarkupSpListDTO>>> selectMarkupSpListPlatform(Page page, FlowerMarkupSpQueryDTO dto){
        if(dto.getPartnerId()== null || dto.getPartnerId() == 0){
            throw new ValidationException("合伙人id不能为空");
        }
        return returnData(R.SUCCESS.getCode(), spService.selectMarkupSpList(page, dto));
    }
 
    @GetMapping("/list/delete")
    @ApiOperation(value = "删除商品加价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "flowerId", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> deleteMarkupSp(Long flowerId){
        spService.deleteMarkupSp(flowerId);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
}