GiftCardOrderController.java 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.ylx.giftCard.controller;
  2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  3. import com.ylx.common.annotation.Log;
  4. import com.ylx.common.core.domain.R;
  5. import com.ylx.common.enums.BusinessType;
  6. import com.ylx.common.exception.ServiceException;
  7. import com.ylx.common.utils.poi.ExcelUtil;
  8. import com.ylx.giftCard.domain.dto.GiftCardOrderQueryDTO;
  9. import com.ylx.giftCard.domain.vo.GiftCardOrderExportVO;
  10. import com.ylx.giftCard.domain.vo.GiftCardOrderPageVO;
  11. import com.ylx.giftCard.service.IGiftCardOrderService;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import lombok.extern.slf4j.Slf4j;
  15. import org.springframework.web.bind.annotation.GetMapping;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import javax.annotation.Resource;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.util.List;
  22. @RestController
  23. @RequestMapping("/gift/card/order")
  24. @Api(tags = {"购物卡订单"})
  25. @Slf4j
  26. public class GiftCardOrderController {
  27. @Resource
  28. private IGiftCardOrderService giftCardOrderService;
  29. /**
  30. * 分页查询购物卡订单
  31. *
  32. * @param page 分页参数
  33. * @param dto 查询条件
  34. * @return 购物卡订单分页列表
  35. */
  36. @GetMapping("/page")
  37. @ApiOperation("分页查询购物卡订单")
  38. public R<Page<GiftCardOrderPageVO>> page(Page<GiftCardOrderPageVO> page, GiftCardOrderQueryDTO dto) {
  39. try {
  40. return R.ok(giftCardOrderService.getAdminGiftCardOrderPage(page, dto));
  41. } catch (ServiceException e) {
  42. return R.fail(e.getMessage());
  43. } catch (Exception e) {
  44. log.error("分页查询购物卡订单异常", e);
  45. return R.fail("分页查询购物卡订单失败");
  46. }
  47. }
  48. /**
  49. * 导出购物卡订单
  50. *
  51. * @param response 响应对象
  52. * @param dto 查询条件
  53. */
  54. @PostMapping("/export")
  55. @ApiOperation("导出购物卡订单")
  56. @Log(title = "导出购物卡订单", businessType = BusinessType.EXPORT)
  57. public void export(HttpServletResponse response, GiftCardOrderQueryDTO dto) {
  58. try {
  59. List<GiftCardOrderExportVO> list = giftCardOrderService.getAdminGiftCardOrderExportList(dto);
  60. ExcelUtil<GiftCardOrderExportVO> util = new ExcelUtil<>(GiftCardOrderExportVO.class);
  61. util.exportExcel(response, list, "购物卡订单");
  62. } catch (ServiceException e) {
  63. log.error("导出购物卡订单参数异常", e);
  64. throw e;
  65. } catch (Exception e) {
  66. log.error("导出购物卡订单异常", e);
  67. throw new RuntimeException("导出购物卡订单失败", e);
  68. }
  69. }
  70. }