陶杰
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
package com.mzl.flower.web.supplier;
 
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.config.security.SecurityUtils;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.supplier.QuerySupplierDTO;
import com.mzl.flower.dto.request.supplier.UpdateSupplierDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.supplier.SupplierType;
import com.mzl.flower.service.supplier.SupplierTypeService;
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.*;
 
@RestController
@RequestMapping("/api/supplier/type")
@Api(value = "运营-供应商类型管理", tags = "运营-供应商类型管理")
@Validated
@Slf4j
public class SupplierTypeController extends BaseController {
 
    private final SupplierTypeService supplierTypeService;
 
    public SupplierTypeController(SupplierTypeService supplierTypeService) {
        this.supplierTypeService = supplierTypeService;
    }
 
 
    @PostMapping("/add")
    @ApiOperation(value = "新增", notes = "新增")
    public ResponseEntity<ReturnDataDTO> add(@Validated @RequestBody SupplierType dto) {
        supplierTypeService.add(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/update")
    @ApiOperation(value = "修改", notes = "修改")
    public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody SupplierType dto) {
        supplierTypeService.update(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/delete/{id}")
    @ApiOperation(value = "删除", notes = "删除")
    public ResponseEntity<ReturnDataDTO> delete(@PathVariable("id") Long id) {
        supplierTypeService.delete(id);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "详情", notes = "详情")
    public ResponseEntity<ReturnDataDTO<SupplierType>> detail(@PathVariable("id") Long id) {
        return returnData(R.SUCCESS.getCode(),supplierTypeService.detail(id));
    }
 
    @GetMapping("/page")
    @ApiOperation(value = "查询-分页", notes = "查询-分页")
    public ResponseEntity<ReturnDataDTO<Page<SupplierType>>> queryPage(String name, Page page) {
        return returnData(R.SUCCESS.getCode(), supplierTypeService.queryPage(name,page));
    }
 
    @GetMapping("/list")
    @ApiOperation(value = "查询-全部", notes = "查询-全部")
    public ResponseEntity<ReturnDataDTO<Page<SupplierType>>> queryList(String name) {
        return returnData(R.SUCCESS.getCode(), supplierTypeService.queryList(name));
    }
 
}