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; /** *
* 临期售后管理控制层 *
* * @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 page, AfterSalesNearExpiry entity) { IPage 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 util = new ExcelUtil(AfterSalesNearExpiryImportDto.class); util.importTemplateExcel(response, "临期售后管理导入模板"); } /** * 导出临期售后 */ @PostMapping("/export") @Operation(summary = "临期售后管理-导出") @Log(title = "临期售后管理-导出", businessType = BusinessType.EXPORT) public void export(HttpServletResponse response) { Page page = new Page<>(-1, -1); List list = afterSalesNearExpiryService.listPage(page, new AfterSalesNearExpiry()).getRecords(); List 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 util = new ExcelUtil(AfterSalesNearExpiryExportDto.class); util.exportExcel(response, exportList, "临期售后管理"); } }