陶杰
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
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.dto.request.flower.FlowerTagCreateDTO;
import com.mzl.flower.dto.request.flower.FlowerTagQueryDTO;
import com.mzl.flower.dto.request.flower.FlowerTagUpdateDTO;
import com.mzl.flower.dto.response.flower.FlowerTagDTO;
import com.mzl.flower.service.flower.FlowerTagService;
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 javax.validation.constraints.NotBlank;
import java.util.List;
 
@RestController
@RequestMapping("/api/flower/tag")
@Api(value = "商品标签管理", tags = "商品标签管理")
@Validated
@Slf4j
public class FlowerTagController extends BaseController {
 
    @Autowired
    private FlowerTagService tagService;
 
    @PostMapping("/list/new")
    @ApiOperation(value = "新增商品标签")
    public ResponseEntity<ReturnDataDTO> addTag(@RequestBody FlowerTagCreateDTO dto) {
        return returnData(R.SUCCESS.getCode(), tagService.addTag(dto));
    }
 
    @PostMapping("/list/edit")
    @ApiOperation(value = "编辑商品标签")
    public ResponseEntity<ReturnDataDTO> updateTag(@RequestBody FlowerTagUpdateDTO dto) {
        return returnData(R.SUCCESS.getCode(), tagService.updateTag(dto));
    }
 
    @GetMapping("/list/view")
    @ApiOperation(value = "查询商品标签详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品标签id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<FlowerTagDTO>> getTag(@NotBlank(message = "id不能为空") String id){
        return returnData(R.SUCCESS.getCode(), tagService.getTag(id));
    }
    
    @GetMapping("/list")
    @ApiOperation(value = "获取商品标签列表")
    public ResponseEntity<ReturnDataDTO<Page<FlowerTagDTO>>> selectTagList(Page page, FlowerTagQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), tagService.selectTagList(page, dto));
    }
 
    @GetMapping("/list/delete")
    @ApiOperation(value = "删除商品标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品标签id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> deleteTag(Long id){
        tagService.deleteTag(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
}