tuqin
2026-09-24 0891b6708cc09c2672a19661a8555aae0e742df1
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
package com.ruoyi.aftersalesservice.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.aftersalesservice.dto.AfterSalesNearExpiryExportDto;
import com.ruoyi.aftersalesservice.dto.AfterSalesNearExpiryImportDto;
import com.ruoyi.aftersalesservice.pojo.AfterSalesNearExpiry;
import com.ruoyi.aftersalesservice.service.AfterSalesNearExpiryService;
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.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * <br>
 * 临期售后管理控制层
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/02 14:40
 */
@RestController
@Tag(name = "临期售后管理")
@RequestMapping("/afterSalesNearExpiryService")
@AllArgsConstructor
public class AfterSalesNearExpiryController extends BaseController {
 
    private AfterSalesNearExpiryService afterSalesNearExpiryService;
 
    /**
     * 新增临期售后
     */
    @PostMapping("/add")
    @Operation(summary = "新增临期售后")
    @Log(title = "新增临期售后", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody AfterSalesNearExpiry entity) {
        afterSalesNearExpiryService.add(entity);
        return AjaxResult.success("添加成功");
    }
 
    /**
     * 更新临期售后
     */
    @PostMapping("/update")
    @Operation(summary = "更新临期售后")
    @Log(title = "更新临期售后", businessType = BusinessType.UPDATE)
    public AjaxResult update(@RequestBody AfterSalesNearExpiry entity) {
        afterSalesNearExpiryService.update(entity);
        return AjaxResult.success("更新成功");
    }
 
    /**
     * 删除临期售后
     */
    @DeleteMapping("/delete")
    @Operation(summary = "删除临期售后")
    @Log(title = "删除临期售后", businessType = BusinessType.DELETE)
    public AjaxResult delete(Long[] ids) {
        afterSalesNearExpiryService.delete(ids);
        return AjaxResult.success("删除成功");
    }
 
    /**
     * 分页查询临期售后
     */
    @GetMapping("/listPage")
    @Operation(summary = "分页查询临期售后")
    @Log(title = "分页查询临期售后", businessType = BusinessType.OTHER)
    public AjaxResult listPage(Page<AfterSalesNearExpiry> page, AfterSalesNearExpiry entity) {
        IPage<AfterSalesNearExpiry> listPage = afterSalesNearExpiryService.listPage(page, entity);
        return AjaxResult.success(listPage);
    }
 
    /**
     * 导入临期售后
     */
    @PostMapping("/import")
    @Operation(summary = "临期售后管理-导入")
    @Log(title = "临期售后管理-导入", businessType = BusinessType.IMPORT)
    public AjaxResult importData(MultipartFile file) {
        return afterSalesNearExpiryService.importData(file);
    }
 
    /**
     * 下载导入模板
     */
    @PostMapping("/importTemplate")
    @Operation(summary = "临期售后管理-导入模板")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil<AfterSalesNearExpiryImportDto> util = new ExcelUtil<AfterSalesNearExpiryImportDto>(AfterSalesNearExpiryImportDto.class);
        util.importTemplateExcel(response, "临期售后管理导入模板");
    }
 
    /**
     * 导出临期售后
     */
    @PostMapping("/export")
    @Operation(summary = "临期售后管理-导出")
    @Log(title = "临期售后管理-导出", businessType = BusinessType.EXPORT)
    public void export(HttpServletResponse response) {
        Page<AfterSalesNearExpiry> page = new Page<>(-1, -1);
        List<AfterSalesNearExpiry> list = afterSalesNearExpiryService.listPage(page, new AfterSalesNearExpiry()).getRecords();
        List<AfterSalesNearExpiryExportDto> exportList = new ArrayList<>();
        for (AfterSalesNearExpiry item : list) {
            AfterSalesNearExpiryExportDto dto = new AfterSalesNearExpiryExportDto();
            BeanUtils.copyProperties(item, dto);
            if (item.getStatus() != null) {
                dto.setStatusName(String.valueOf(item.getStatus()));
            }
            exportList.add(dto);
        }
        ExcelUtil<AfterSalesNearExpiryExportDto> util = new ExcelUtil<AfterSalesNearExpiryExportDto>(AfterSalesNearExpiryExportDto.class);
        util.exportExcel(response, exportList, "临期售后管理");
    }
 
}