提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.bpm.controller.admin.definition; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.enums.CommonStatusEnum; |
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
|
5 |
import com.iailab.framework.common.pojo.PageResult; |
|
6 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
7 |
import com.iailab.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
|
8 |
import com.iailab.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; |
|
9 |
import com.iailab.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; |
|
10 |
import com.iailab.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
|
11 |
import com.iailab.module.bpm.service.definition.BpmUserGroupService; |
|
12 |
import io.swagger.v3.oas.annotations.Operation; |
|
13 |
import io.swagger.v3.oas.annotations.Parameter; |
|
14 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
15 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
16 |
import org.springframework.validation.annotation.Validated; |
|
17 |
import org.springframework.web.bind.annotation.*; |
|
18 |
|
|
19 |
import javax.annotation.Resource; |
|
20 |
import javax.validation.Valid; |
|
21 |
import java.util.List; |
|
22 |
|
|
23 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
24 |
import static com.iailab.framework.common.util.collection.CollectionUtils.convertList; |
|
25 |
|
|
26 |
@Tag(name = "管理后台 - 用户组") |
|
27 |
@RestController |
|
28 |
@RequestMapping("/bpm/user-group") |
|
29 |
@Validated |
|
30 |
public class BpmUserGroupController { |
|
31 |
|
|
32 |
@Resource |
|
33 |
private BpmUserGroupService userGroupService; |
|
34 |
|
|
35 |
@PostMapping("/create") |
|
36 |
@Operation(summary = "创建用户组") |
|
37 |
@PreAuthorize("@ss.hasPermission('bpm:user-group:create')") |
|
38 |
public CommonResult<Long> createUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO createReqVO) { |
|
39 |
return success(userGroupService.createUserGroup(createReqVO)); |
|
40 |
} |
|
41 |
|
|
42 |
@PutMapping("/update") |
|
43 |
@Operation(summary = "更新用户组") |
|
44 |
@PreAuthorize("@ss.hasPermission('bpm:user-group:update')") |
|
45 |
public CommonResult<Boolean> updateUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO updateReqVO) { |
|
46 |
userGroupService.updateUserGroup(updateReqVO); |
|
47 |
return success(true); |
|
48 |
} |
|
49 |
|
|
50 |
@DeleteMapping("/delete") |
|
51 |
@Operation(summary = "删除用户组") |
|
52 |
@Parameter(name = "id", description = "编号", required = true) |
|
53 |
@PreAuthorize("@ss.hasPermission('bpm:user-group:delete')") |
|
54 |
public CommonResult<Boolean> deleteUserGroup(@RequestParam("id") Long id) { |
|
55 |
userGroupService.deleteUserGroup(id); |
|
56 |
return success(true); |
|
57 |
} |
|
58 |
|
|
59 |
@GetMapping("/get") |
|
60 |
@Operation(summary = "获得用户组") |
|
61 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
62 |
@PreAuthorize("@ss.hasPermission('bpm:user-group:query')") |
|
63 |
public CommonResult<BpmUserGroupRespVO> getUserGroup(@RequestParam("id") Long id) { |
|
64 |
BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); |
|
65 |
return success(BeanUtils.toBean(userGroup, BpmUserGroupRespVO.class)); |
|
66 |
} |
|
67 |
|
|
68 |
@GetMapping("/page") |
|
69 |
@Operation(summary = "获得用户组分页") |
|
70 |
@PreAuthorize("@ss.hasPermission('bpm:user-group:query')") |
|
71 |
public CommonResult<PageResult<BpmUserGroupRespVO>> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { |
|
72 |
PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(pageVO); |
|
73 |
return success(BeanUtils.toBean(pageResult, BpmUserGroupRespVO.class)); |
|
74 |
} |
|
75 |
|
|
76 |
@GetMapping("/simple-list") |
|
77 |
@Operation(summary = "获取用户组精简信息列表", description = "只包含被开启的用户组,主要用于前端的下拉选项") |
|
78 |
public CommonResult<List<BpmUserGroupRespVO>> getUserGroupSimpleList() { |
|
79 |
List<BpmUserGroupDO> list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
|
80 |
return success(convertList(list, group -> new BpmUserGroupRespVO().setId(group.getId()).setName(group.getName()))); |
|
81 |
} |
|
82 |
|
|
83 |
} |