|
@@ -0,0 +1,174 @@
|
|
|
+/*
|
|
|
+ * Copyright [2022] [https://www.xiaonuo.vip]
|
|
|
+ *
|
|
|
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
|
|
+ *
|
|
|
+ * 1.请不要删除和修改根目录下的LICENSE文件。
|
|
|
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
|
|
|
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
|
|
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
|
|
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
|
|
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
|
|
+ */
|
|
|
+package vip.xiaonuo.biz.modular.qychecklist.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.util.URLUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import vip.xiaonuo.common.annotation.CommonLog;
|
|
|
+import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
+import vip.xiaonuo.biz.modular.qychecklist.entity.QyCheckList;
|
|
|
+import vip.xiaonuo.biz.modular.qychecklist.param.QyCheckListAddParam;
|
|
|
+import vip.xiaonuo.biz.modular.qychecklist.param.QyCheckListEditParam;
|
|
|
+import vip.xiaonuo.biz.modular.qychecklist.param.QyCheckListIdParam;
|
|
|
+import vip.xiaonuo.biz.modular.qychecklist.param.QyCheckListPageParam;
|
|
|
+import vip.xiaonuo.biz.modular.qychecklist.service.QyCheckListService;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import jakarta.validation.Valid;
|
|
|
+import jakarta.validation.constraints.NotEmpty;
|
|
|
+import java.util.List;
|
|
|
+import java.io.IOException;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 回执单列表控制器
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+@Tag(name = "回执单列表控制器")
|
|
|
+@RestController
|
|
|
+@Validated
|
|
|
+public class QyCheckListController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private QyCheckListService qyCheckListService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取回执单列表分页
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+ @Operation(summary = "获取回执单列表分页")
|
|
|
+ @SaCheckPermission("/biz/qychecklist/page")
|
|
|
+ @GetMapping("/biz/qychecklist/page")
|
|
|
+ public CommonResult<Page<QyCheckList>> page(QyCheckListPageParam qyCheckListPageParam) {
|
|
|
+ return CommonResult.data(qyCheckListService.page(qyCheckListPageParam));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加回执单列表
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+ @Operation(summary = "添加回执单列表")
|
|
|
+ @CommonLog("添加回执单列表")
|
|
|
+ @SaCheckPermission("/biz/qychecklist/add")
|
|
|
+ @PostMapping("/biz/qychecklist/add")
|
|
|
+ public CommonResult<String> add(@RequestBody @Valid QyCheckListAddParam qyCheckListAddParam) {
|
|
|
+ qyCheckListService.add(qyCheckListAddParam);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑回执单列表
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+ @Operation(summary = "编辑回执单列表")
|
|
|
+ @CommonLog("编辑回执单列表")
|
|
|
+ @SaCheckPermission("/biz/qychecklist/edit")
|
|
|
+ @PostMapping("/biz/qychecklist/edit")
|
|
|
+ public CommonResult<String> edit(@RequestBody @Valid QyCheckListEditParam qyCheckListEditParam) {
|
|
|
+ qyCheckListService.edit(qyCheckListEditParam);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出回执单列表
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+ @Operation(summary = "导出回执单列表")
|
|
|
+ @CommonLog("导出回执单列表")
|
|
|
+ @SaCheckPermission("/biz/qychecklist/export")
|
|
|
+ @PostMapping("/biz/qychecklist/export")
|
|
|
+ public void export(@RequestBody @Valid QyCheckListPageParam qyCheckListPageParam, HttpServletResponse response) {
|
|
|
+ Page<QyCheckList> page = qyCheckListService.page(qyCheckListPageParam);
|
|
|
+ List<QyCheckList> records = page.getRecords();
|
|
|
+ exportExcel(response,QyCheckList.class,records,"回执单列表");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出表格数据
|
|
|
+ * @param cl 表格字段实体类
|
|
|
+ * @param data 查询数据
|
|
|
+ * @param sheetName 表格名称
|
|
|
+ */
|
|
|
+ public void exportExcel(HttpServletResponse response, Class cl, List data, String sheetName){
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ try {
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + URLUtil.encode(sheetName) + ".xlsx");
|
|
|
+ response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
+ response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
+ EasyExcel.write(response.getOutputStream(), cl).autoCloseStream(Boolean.FALSE).sheet(sheetName).doWrite(data);
|
|
|
+ } catch (IOException e) {
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("application/json");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ map.put("status", "failure");
|
|
|
+ map.put("message", "下载文件失败" + e.getMessage());
|
|
|
+ try {
|
|
|
+ response.getWriter().println(JSON.toJSONString(map));
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除回执单列表
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+ @Operation(summary = "删除回执单列表")
|
|
|
+ @CommonLog("删除回执单列表")
|
|
|
+ @SaCheckPermission("/biz/qychecklist/delete")
|
|
|
+ @PostMapping("/biz/qychecklist/delete")
|
|
|
+ public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
|
|
|
+ List<QyCheckListIdParam> qyCheckListIdParamList) {
|
|
|
+ qyCheckListService.delete(qyCheckListIdParamList);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取回执单列表详情
|
|
|
+ *
|
|
|
+ * @author hgx
|
|
|
+ * @date 2024/07/05 10:49
|
|
|
+ */
|
|
|
+ @Operation(summary = "获取回执单列表详情")
|
|
|
+ @SaCheckPermission("/biz/qychecklist/detail")
|
|
|
+ @GetMapping("/biz/qychecklist/detail")
|
|
|
+ public CommonResult<QyCheckList> detail(@Valid QyCheckListIdParam qyCheckListIdParam) {
|
|
|
+ return CommonResult.data(qyCheckListService.detail(qyCheckListIdParam));
|
|
|
+ }
|
|
|
+}
|