huminmin
3 天以前 a317d0d886cda2d4c3eca6022456803cf619a45a
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.ruoyi.stock.controller;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.stock.dto.ManufacturerDto;
import com.ruoyi.stock.execl.ManufacturerExcelDto;
import com.ruoyi.stock.pojo.Manufacturer;
import com.ruoyi.stock.service.ManufacturerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
/**
 * <p>
 * 厂家前端控制器
 * </p>
 *
 * @author 芯导软件(江苏)有限公司
 * @since 2026-05-28 09:52:35
 */
@RestController
@RequestMapping("/stock/manufacturer")
@AllArgsConstructor
@Tag(name = "厂家管理")
public class ManufacturerController {
 
    private ManufacturerService manufacturerService;
 
    /**
     * 厂家新增
     * @param manufacturer
     * @return
     */
    @PostMapping("/add")
    @Log(title = "厂家-新增", businessType = BusinessType.INSERT)
    @Operation(summary = "新增厂家")
    public AjaxResult add(@RequestBody Manufacturer manufacturer) {
        manufacturerService.saveManufacturer(manufacturer);
        return AjaxResult.success();
    }
 
    /**
     * 厂家删除
     * @param ids
     * @return
     */
    @DeleteMapping("/del")
    @Log(title = "厂家-删除", businessType = BusinessType.DELETE)
    @Operation(summary = "删除厂家")
    public AjaxResult delManufacturer(@RequestBody List<Long> ids) {
        if(CollectionUtils.isEmpty(ids)){
            return AjaxResult.error("请选择至少一条数据");
        }
        manufacturerService.delManufacturer(ids);
        return AjaxResult.success();
    }
 
    /**
     * 厂家详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @Log(title = "厂家-详情", businessType = BusinessType.OTHER)
    @Operation(summary = "厂家详情")
    public AjaxResult manufacturerDetail(@PathVariable("id") Long id) {
        return AjaxResult.success(manufacturerService.manufacturerDetail(id));
    }
 
    /**
     * 厂家修改
     * @param manufacturer
     * @return
     */
    @PostMapping("/update")
    @Log(title = "厂家-修改", businessType = BusinessType.UPDATE)
    @Operation(summary = "修改厂家")
    public AjaxResult update(@RequestBody Manufacturer manufacturer) {
        manufacturerService.manufacturerUpdate(manufacturer);
        return AjaxResult.success();
    }
 
    /**
     * 厂家管理分页查询
     * @param page
     * @param manufacturerDto
     * @return
     */
    @GetMapping("/listPage")
    @Log(title = "厂家-分页查询", businessType = BusinessType.OTHER)
    @Operation(summary = "厂家分页查询")
    public AjaxResult manufacturerListPage(Page page, ManufacturerDto manufacturerDto) {
        return AjaxResult.success(manufacturerService.manufacturerListPage(page, manufacturerDto));
    }
 
    /**
     * 厂家导出
     * @param response
     * @param manufacturerDto
     */
    @PostMapping("/export")
    @Log(title = "厂家-导出", businessType = BusinessType.EXPORT)
    @Operation(summary = "厂家导出")
    public void manufacturerExport(HttpServletResponse response, ManufacturerDto manufacturerDto) {
        manufacturerService.manufacturerExport(response, manufacturerDto);
    }
 
    /**
     * 下载模板
     * @param response
     */
    @PostMapping("/downloadTemplate")
    @Log(title = "厂家-下载模板", businessType = BusinessType.EXPORT)
    @Operation(summary = "下载厂家模板")
    public void downloadTemplate(HttpServletResponse response) {
        ExcelUtil<ManufacturerExcelDto> util = new ExcelUtil<>(ManufacturerExcelDto.class);
        util.importTemplateExcel(response, "厂家档案模板");
    }
 
    /**
     * 厂家导入
     */
    @PostMapping("/import")
    @Log(title = "厂家-导入", businessType = BusinessType.IMPORT)
    @Operation(summary = "导入厂家")
    public AjaxResult importData(MultipartFile file) {
        Boolean b = manufacturerService.importData(file);
        if (b) {
            return AjaxResult.success("导入成功");
        }
        return AjaxResult.error("导入失败");
    }
 
    /**
     * 厂家选项接口
     * @return
     */
    @GetMapping("/getOptions")
    @Log(title = "厂家-选项接口", businessType = BusinessType.OTHER)
    @Operation(summary = "获取厂家选项")
    public AjaxResult getOptions() {
        return AjaxResult.success(manufacturerService.list());
    }
}