This commit is contained in:
2025-09-06 18:07:18 +08:00
parent 4a03cb18bb
commit 8562eb52bd
2 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
package com.ruoyi.web.controller.system;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jarvis.domain.JDOrder;
import com.ruoyi.jarvis.service.IJDOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* JD订单列表Controller
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/jdorder")
public class JDOrderListController extends BaseController
{
@Autowired
private IJDOrderService jdOrderService;
/**
* 查询JD订单列表
*/
@GetMapping("/list")
public TableDataInfo list(JDOrder jdOrder)
{
startPage();
List<JDOrder> list = jdOrderService.selectJDOrderList(jdOrder);
return getDataTable(list);
}
/**
* 导出JD订单列表
*/
@Log(title = "JD订单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, JDOrder jdOrder) throws IOException
{
String fileName = "JD订单数据";
List<JDOrder> list = jdOrderService.selectJDOrderList(jdOrder);
// 设置响应头,指定文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String encodedFileName = java.net.URLEncoder.encode(fileName + ".xlsx", "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=" + encodedFileName);
// 添加download-filename响应头以支持前端工具类
response.setHeader("download-filename", encodedFileName);
ExcelUtil<JDOrder> util = new ExcelUtil<JDOrder>(JDOrder.class);
util.exportExcel(response, list, fileName);
}
/**
* 获取JD订单详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(jdOrderService.selectJDOrderById(id));
}
/**
* 新增JD订单
*/
@Log(title = "JD订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody JDOrder jdOrder)
{
return toAjax(jdOrderService.insertJDOrder(jdOrder));
}
/**
* 修改JD订单
*/
@Log(title = "JD订单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody JDOrder jdOrder)
{
return toAjax(jdOrderService.updateJDOrder(jdOrder));
}
/**
* 删除JD订单
*/
@Log(title = "JD订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(jdOrderService.deleteJDOrderByIds(ids));
}
}