提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.bpm.controller.admin.definition; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; |
|
7 |
import com.iailab.module.bpm.controller.admin.definition.vo.form.BpmFormRespVO; |
|
8 |
import com.iailab.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; |
|
9 |
import com.iailab.module.bpm.dal.dataobject.definition.BpmFormDO; |
|
10 |
import com.iailab.module.bpm.service.definition.BpmFormService; |
|
11 |
import io.swagger.v3.oas.annotations.Operation; |
|
12 |
import io.swagger.v3.oas.annotations.Parameter; |
|
13 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
14 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
15 |
import org.springframework.validation.annotation.Validated; |
|
16 |
import org.springframework.web.bind.annotation.*; |
|
17 |
|
|
18 |
import javax.annotation.Resource; |
|
19 |
import javax.validation.Valid; |
|
20 |
import java.util.List; |
|
21 |
|
|
22 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
23 |
import static com.iailab.framework.common.util.collection.CollectionUtils.convertList; |
|
24 |
|
|
25 |
@Tag(name = "管理后台 - 动态表单") |
|
26 |
@RestController |
|
27 |
@RequestMapping("/bpm/form") |
|
28 |
@Validated |
|
29 |
public class BpmFormController { |
|
30 |
|
|
31 |
@Resource |
|
32 |
private BpmFormService formService; |
|
33 |
|
|
34 |
@PostMapping("/create") |
|
35 |
@Operation(summary = "创建动态表单") |
|
36 |
@PreAuthorize("@ss.hasPermission('bpm:form:create')") |
|
37 |
public CommonResult<Long> createForm(@Valid @RequestBody BpmFormSaveReqVO createReqVO) { |
|
38 |
return success(formService.createForm(createReqVO)); |
|
39 |
} |
|
40 |
|
|
41 |
@PutMapping("/update") |
|
42 |
@Operation(summary = "更新动态表单") |
|
43 |
@PreAuthorize("@ss.hasPermission('bpm:form:update')") |
|
44 |
public CommonResult<Boolean> updateForm(@Valid @RequestBody BpmFormSaveReqVO updateReqVO) { |
|
45 |
formService.updateForm(updateReqVO); |
|
46 |
return success(true); |
|
47 |
} |
|
48 |
|
|
49 |
@DeleteMapping("/delete") |
|
50 |
@Operation(summary = "删除动态表单") |
|
51 |
@Parameter(name = "id", description = "编号", required = true) |
|
52 |
@PreAuthorize("@ss.hasPermission('bpm:form:delete')") |
|
53 |
public CommonResult<Boolean> deleteForm(@RequestParam("id") Long id) { |
|
54 |
formService.deleteForm(id); |
|
55 |
return success(true); |
|
56 |
} |
|
57 |
|
|
58 |
@GetMapping("/get") |
|
59 |
@Operation(summary = "获得动态表单") |
|
60 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
61 |
@PreAuthorize("@ss.hasPermission('bpm:form:query')") |
|
62 |
public CommonResult<BpmFormRespVO> getForm(@RequestParam("id") Long id) { |
|
63 |
BpmFormDO form = formService.getForm(id); |
|
64 |
return success(BeanUtils.toBean(form, BpmFormRespVO.class)); |
|
65 |
} |
|
66 |
|
|
67 |
@GetMapping({"/list-all-simple", "/simple-list"}) |
|
68 |
@Operation(summary = "获得动态表单的精简列表", description = "用于表单下拉框") |
|
69 |
public CommonResult<List<BpmFormRespVO>> getFormSimpleList() { |
|
70 |
List<BpmFormDO> list = formService.getFormList(); |
|
71 |
return success(convertList(list, formDO -> // 只返回 id、name 字段 |
|
72 |
new BpmFormRespVO().setId(formDO.getId()).setName(formDO.getName()))); |
|
73 |
} |
|
74 |
|
|
75 |
@GetMapping("/page") |
|
76 |
@Operation(summary = "获得动态表单分页") |
|
77 |
@PreAuthorize("@ss.hasPermission('bpm:form:query')") |
|
78 |
public CommonResult<PageResult<BpmFormRespVO>> getFormPage(@Valid BpmFormPageReqVO pageVO) { |
|
79 |
PageResult<BpmFormDO> pageResult = formService.getFormPage(pageVO); |
|
80 |
return success(BeanUtils.toBean(pageResult, BpmFormRespVO.class)); |
|
81 |
} |
|
82 |
|
|
83 |
} |