| | |
| | | package cn.iocoder.yudao.module.bpm.controller.admin.definition; |
| | | |
| | | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormImportExcelVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormImportReqVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormImportRespVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormRespVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; |
| | |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得动态表单") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('bpm:form:query')") |
| | | public CommonResult<BpmFormRespVO> getForm(@RequestParam("id") Long id) { |
| | | BpmFormDO form = formService.getForm(id); |
| | | return success(BeanUtils.toBean(form, BpmFormRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得动态表单分页") |
| | | @PreAuthorize("@ss.hasPermission('bpm:form:query')") |
| | | public CommonResult<PageResult<BpmFormRespVO>> getFormPage(@Valid BpmFormPageReqVO pageVO) { |
| | | PageResult<BpmFormDO> pageResult = formService.getFormPage(pageVO); |
| | | return success(BeanUtils.toBean(pageResult, BpmFormRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入动态表单模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<BpmFormImportExcelVO> list = Arrays.asList( |
| | | BpmFormImportExcelVO.builder().name("示例表单").conf("{\"labelWidth\":100}") |
| | | .fieldsJson("[\"{\\\"vModel\\\":\\\"field1\\\"}\"]") |
| | | .status(CommonStatusEnum.ENABLE.getStatus()).remark("示例动态表单").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "动态表单导入模板.xls", "动态表单列表", BpmFormImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入动态表单") |
| | | @PreAuthorize("@ss.hasPermission('bpm:form:import')") |
| | | public CommonResult<BpmFormImportRespVO> importExcel(@Valid BpmFormImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<BpmFormImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), BpmFormImportExcelVO.class); |
| | | return success(formService.importFormList(list, importReqVO)); |
| | | } |
| | | |
| | | } |