1
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.jarvis.domain.GiftCoupon;
|
||||
import com.ruoyi.jarvis.service.IGiftCouponService;
|
||||
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.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 礼金管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/giftcoupon")
|
||||
public class GiftCouponController extends BaseController {
|
||||
|
||||
private final IGiftCouponService giftCouponService;
|
||||
|
||||
public GiftCouponController(IGiftCouponService giftCouponService) {
|
||||
this.giftCouponService = giftCouponService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询礼金列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(GiftCoupon query, HttpServletRequest request) {
|
||||
startPage();
|
||||
|
||||
// 处理时间筛选参数
|
||||
String beginTimeStr = request.getParameter("beginTime");
|
||||
String endTimeStr = request.getParameter("endTime");
|
||||
|
||||
if (beginTimeStr != null && !beginTimeStr.isEmpty()) {
|
||||
query.getParams().put("beginTime", beginTimeStr);
|
||||
}
|
||||
if (endTimeStr != null && !endTimeStr.isEmpty()) {
|
||||
query.getParams().put("endTime", endTimeStr);
|
||||
}
|
||||
|
||||
List<GiftCoupon> list = giftCouponService.selectGiftCouponList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出礼金列表
|
||||
*/
|
||||
@Log(title = "礼金管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, GiftCoupon giftCoupon) throws IOException {
|
||||
String fileName = "礼金数据";
|
||||
|
||||
List<GiftCoupon> list = giftCouponService.selectGiftCouponList(giftCoupon);
|
||||
|
||||
// 设置响应头,指定文件名
|
||||
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<GiftCoupon> util = new ExcelUtil<GiftCoupon>(GiftCoupon.class);
|
||||
util.exportExcel(response, list, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取礼金详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{giftCouponKey}")
|
||||
public AjaxResult getInfo(@PathVariable("giftCouponKey") String giftCouponKey) {
|
||||
return success(giftCouponService.selectGiftCouponByKey(giftCouponKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询礼金统计信息
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public AjaxResult statistics(GiftCoupon giftCoupon, HttpServletRequest request) {
|
||||
// 处理时间筛选参数
|
||||
String beginTimeStr = request.getParameter("beginTime");
|
||||
String endTimeStr = request.getParameter("endTime");
|
||||
|
||||
if (beginTimeStr != null && !beginTimeStr.isEmpty()) {
|
||||
giftCoupon.getParams().put("beginTime", beginTimeStr);
|
||||
}
|
||||
if (endTimeStr != null && !endTimeStr.isEmpty()) {
|
||||
giftCoupon.getParams().put("endTime", endTimeStr);
|
||||
}
|
||||
|
||||
GiftCoupon statistics = giftCouponService.selectGiftCouponStatistics(giftCoupon);
|
||||
return success(statistics);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user