Commit d5e28d4c57315d1dd885d3713659b1bf5ad55f62
1 parent
8c32eb24
BPM:简化 userGroup 的实现
Showing
14 changed files
with
64 additions
and
145 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java
| 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition; | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; | 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 4 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
| 5 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; | 8 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; |
| 6 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.bpm.convert.definition.BpmUserGroupConvert; | 9 | +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | 10 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
| 9 | import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; | 11 | import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; |
| 10 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 11 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 12 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 13 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 15 | import io.swagger.v3.oas.annotations.Operation; | 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 jakarta.annotation.Resource; | ||
| 16 | +import jakarta.validation.Valid; | ||
| 16 | import org.springframework.security.access.prepost.PreAuthorize; | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 18 | import org.springframework.web.bind.annotation.*; | 19 | import org.springframework.web.bind.annotation.*; |
| 19 | 20 | ||
| 20 | -import jakarta.annotation.Resource; | ||
| 21 | -import jakarta.validation.Valid; | ||
| 22 | import java.util.List; | 21 | import java.util.List; |
| 23 | 22 | ||
| 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 24 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 25 | 25 | ||
| 26 | @Tag(name = "管理后台 - 用户组") | 26 | @Tag(name = "管理后台 - 用户组") |
| 27 | @RestController | 27 | @RestController |
| @@ -35,14 +35,14 @@ public class BpmUserGroupController { | @@ -35,14 +35,14 @@ public class BpmUserGroupController { | ||
| 35 | @PostMapping("/create") | 35 | @PostMapping("/create") |
| 36 | @Operation(summary = "创建用户组") | 36 | @Operation(summary = "创建用户组") |
| 37 | @PreAuthorize("@ss.hasPermission('bpm:user-group:create')") | 37 | @PreAuthorize("@ss.hasPermission('bpm:user-group:create')") |
| 38 | - public CommonResult<Long> createUserGroup(@Valid @RequestBody BpmUserGroupCreateReqVO createReqVO) { | 38 | + public CommonResult<Long> createUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO createReqVO) { |
| 39 | return success(userGroupService.createUserGroup(createReqVO)); | 39 | return success(userGroupService.createUserGroup(createReqVO)); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | @PutMapping("/update") | 42 | @PutMapping("/update") |
| 43 | @Operation(summary = "更新用户组") | 43 | @Operation(summary = "更新用户组") |
| 44 | @PreAuthorize("@ss.hasPermission('bpm:user-group:update')") | 44 | @PreAuthorize("@ss.hasPermission('bpm:user-group:update')") |
| 45 | - public CommonResult<Boolean> updateUserGroup(@Valid @RequestBody BpmUserGroupUpdateReqVO updateReqVO) { | 45 | + public CommonResult<Boolean> updateUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO updateReqVO) { |
| 46 | userGroupService.updateUserGroup(updateReqVO); | 46 | userGroupService.updateUserGroup(updateReqVO); |
| 47 | return success(true); | 47 | return success(true); |
| 48 | } | 48 | } |
| @@ -62,7 +62,7 @@ public class BpmUserGroupController { | @@ -62,7 +62,7 @@ public class BpmUserGroupController { | ||
| 62 | @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") | 62 | @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") |
| 63 | public CommonResult<BpmUserGroupRespVO> getUserGroup(@RequestParam("id") Long id) { | 63 | public CommonResult<BpmUserGroupRespVO> getUserGroup(@RequestParam("id") Long id) { |
| 64 | BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); | 64 | BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); |
| 65 | - return success(BpmUserGroupConvert.INSTANCE.convert(userGroup)); | 65 | + return success(BeanUtils.toBean(userGroup, BpmUserGroupRespVO.class)); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | @GetMapping("/page") | 68 | @GetMapping("/page") |
| @@ -70,16 +70,14 @@ public class BpmUserGroupController { | @@ -70,16 +70,14 @@ public class BpmUserGroupController { | ||
| 70 | @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") | 70 | @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") |
| 71 | public CommonResult<PageResult<BpmUserGroupRespVO>> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { | 71 | public CommonResult<PageResult<BpmUserGroupRespVO>> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { |
| 72 | PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(pageVO); | 72 | PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(pageVO); |
| 73 | - return success(BpmUserGroupConvert.INSTANCE.convertPage(pageResult)); | 73 | + return success(BeanUtils.toBean(pageResult, BpmUserGroupRespVO.class)); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | - @GetMapping("/list-all-simple") | 76 | + @GetMapping("/simple-list") |
| 77 | @Operation(summary = "获取用户组精简信息列表", description = "只包含被开启的用户组,主要用于前端的下拉选项") | 77 | @Operation(summary = "获取用户组精简信息列表", description = "只包含被开启的用户组,主要用于前端的下拉选项") |
| 78 | - public CommonResult<List<BpmUserGroupRespVO>> getSimpleUserGroups() { | ||
| 79 | - // 获用户门列表,只要开启状态的 | 78 | + public CommonResult<List<BpmUserGroupRespVO>> getUserGroupSimpleList() { |
| 80 | List<BpmUserGroupDO> list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); | 79 | List<BpmUserGroupDO> list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 81 | - // 排序后,返回给前端 | ||
| 82 | - return success(BpmUserGroupConvert.INSTANCE.convertList2(list)); | 80 | + return success(convertList(list, group -> new BpmUserGroupRespVO().setId(group.getId()).setName(group.getName()))); |
| 83 | } | 81 | } |
| 84 | 82 | ||
| 85 | } | 83 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; | ||
| 2 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 3 | -import lombok.*; | ||
| 4 | - | ||
| 5 | -@Schema(description = "管理后台 - 用户组创建 Request VO") | ||
| 6 | -@Data | ||
| 7 | -@EqualsAndHashCode(callSuper = true) | ||
| 8 | -@ToString(callSuper = true) | ||
| 9 | -public class BpmUserGroupCreateReqVO extends BpmUserGroupBaseVO { | ||
| 10 | - | ||
| 11 | -} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java
| @@ -16,6 +16,9 @@ import java.time.LocalDateTime; | @@ -16,6 +16,9 @@ import java.time.LocalDateTime; | ||
| 16 | @ToString(callSuper = true) | 16 | @ToString(callSuper = true) |
| 17 | public class BpmUserGroupPageReqVO extends PageParam { | 17 | public class BpmUserGroupPageReqVO extends PageParam { |
| 18 | 18 | ||
| 19 | + @Schema(description = "编号", example = "1024") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 19 | @Schema(description = "组名", example = "芋道") | 22 | @Schema(description = "组名", example = "芋道") |
| 20 | private String name; | 23 | private String name; |
| 21 | 24 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java
| 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.*; | 4 | +import lombok.Data; |
| 5 | 5 | ||
| 6 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
| 7 | +import java.util.Set; | ||
| 7 | 8 | ||
| 8 | @Schema(description = "管理后台 - 用户组 Response VO") | 9 | @Schema(description = "管理后台 - 用户组 Response VO") |
| 9 | @Data | 10 | @Data |
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class BpmUserGroupRespVO extends BpmUserGroupBaseVO { | 11 | +public class BpmUserGroupRespVO { |
| 13 | 12 | ||
| 14 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 13 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 15 | private Long id; | 14 | private Long id; |
| 16 | 15 | ||
| 16 | + @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") | ||
| 17 | + private String name; | ||
| 18 | + | ||
| 19 | + @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") | ||
| 20 | + private String description; | ||
| 21 | + | ||
| 22 | + @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") | ||
| 23 | + private Set<Long> userIds; | ||
| 24 | + | ||
| 25 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 26 | + private Integer status; | ||
| 27 | + | ||
| 17 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 28 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 18 | private LocalDateTime createTime; | 29 | private LocalDateTime createTime; |
| 19 | 30 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java renamed to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java
| 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; |
| 2 | - | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 2 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | import jakarta.validation.constraints.NotNull; | 3 | import jakarta.validation.constraints.NotNull; |
| 4 | +import lombok.*; | ||
| 5 | + | ||
| 7 | import java.util.Set; | 6 | import java.util.Set; |
| 8 | 7 | ||
| 9 | -/** | ||
| 10 | -* 用户组 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 11 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 12 | -*/ | 8 | +@Schema(description = "管理后台 - 用户组创建/修改 Request VO") |
| 13 | @Data | 9 | @Data |
| 14 | -public class BpmUserGroupBaseVO { | 10 | +public class BpmUserGroupSaveReqVO { |
| 11 | + | ||
| 12 | + @Schema(description = "编号", example = "1024") | ||
| 13 | + private Long id; | ||
| 15 | 14 | ||
| 16 | @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") | 15 | @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") |
| 17 | @NotNull(message = "组名不能为空") | 16 | @NotNull(message = "组名不能为空") |
| 18 | private String name; | 17 | private String name; |
| 19 | 18 | ||
| 20 | - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") | ||
| 21 | - @NotNull(message = "描述不能为空") | 19 | + @Schema(description = "描述", example = "芋道源码") |
| 22 | private String description; | 20 | private String description; |
| 23 | 21 | ||
| 24 | @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") | 22 | @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") |
| 25 | @NotNull(message = "成员编号数组不能为空") | 23 | @NotNull(message = "成员编号数组不能为空") |
| 26 | - private Set<Long> memberUserIds; | 24 | + private Set<Long> userIds; |
| 27 | 25 | ||
| 28 | @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 26 | @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 29 | @NotNull(message = "状态不能为空") | 27 | @NotNull(message = "状态不能为空") |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.AllArgsConstructor; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.NoArgsConstructor; | ||
| 7 | - | ||
| 8 | -@Schema(description = "管理后台 - 用户组精简信息 Response VO") | ||
| 9 | -@Data | ||
| 10 | -@NoArgsConstructor | ||
| 11 | -@AllArgsConstructor | ||
| 12 | -public class BpmUserGroupSimpleRespVO { | ||
| 13 | - | ||
| 14 | - @Schema(description = "用户组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | - @Schema(description = "用户组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") | ||
| 18 | - private String name; | ||
| 19 | - | ||
| 20 | -} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.*; | ||
| 5 | -import jakarta.validation.constraints.*; | ||
| 6 | - | ||
| 7 | -@Schema(description = "管理后台 - 用户组更新 Request VO") | ||
| 8 | -@Data | ||
| 9 | -@EqualsAndHashCode(callSuper = true) | ||
| 10 | -@ToString(callSuper = true) | ||
| 11 | -public class BpmUserGroupUpdateReqVO extends BpmUserGroupBaseVO { | ||
| 12 | - | ||
| 13 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 14 | - @NotNull(message = "编号不能为空") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | -} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.bpm.convert.definition; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; | ||
| 7 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | ||
| 9 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 10 | - | ||
| 11 | -import org.mapstruct.Mapper; | ||
| 12 | -import org.mapstruct.Named; | ||
| 13 | -import org.mapstruct.factory.Mappers; | ||
| 14 | - | ||
| 15 | -/** | ||
| 16 | - * 用户组 Convert | ||
| 17 | - * | ||
| 18 | - * @author 芋道源码 | ||
| 19 | - */ | ||
| 20 | -@Mapper | ||
| 21 | -public interface BpmUserGroupConvert { | ||
| 22 | - | ||
| 23 | - BpmUserGroupConvert INSTANCE = Mappers.getMapper(BpmUserGroupConvert.class); | ||
| 24 | - | ||
| 25 | - BpmUserGroupDO convert(BpmUserGroupCreateReqVO bean); | ||
| 26 | - | ||
| 27 | - BpmUserGroupDO convert(BpmUserGroupUpdateReqVO bean); | ||
| 28 | - | ||
| 29 | - BpmUserGroupRespVO convert(BpmUserGroupDO bean); | ||
| 30 | - | ||
| 31 | - List<BpmUserGroupRespVO> convertList(List<BpmUserGroupDO> list); | ||
| 32 | - | ||
| 33 | - PageResult<BpmUserGroupRespVO> convertPage(PageResult<BpmUserGroupDO> page); | ||
| 34 | - | ||
| 35 | - @Named("convertList2") | ||
| 36 | - List<BpmUserGroupRespVO> convertList2(List<BpmUserGroupDO> list); | ||
| 37 | - | ||
| 38 | -} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java
| @@ -47,6 +47,6 @@ public class BpmUserGroupDO extends BaseDO { | @@ -47,6 +47,6 @@ public class BpmUserGroupDO extends BaseDO { | ||
| 47 | * 成员用户编号数组 | 47 | * 成员用户编号数组 |
| 48 | */ | 48 | */ |
| 49 | @TableField(typeHandler = JsonLongSetTypeHandler.class) | 49 | @TableField(typeHandler = JsonLongSetTypeHandler.class) |
| 50 | - private Set<Long> memberUserIds; | 50 | + private Set<Long> userIds; |
| 51 | 51 | ||
| 52 | } | 52 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java
| @@ -41,7 +41,7 @@ public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy { | @@ -41,7 +41,7 @@ public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy { | ||
| 41 | public Set<Long> calculateUsers(DelegateExecution execution, String param) { | 41 | public Set<Long> calculateUsers(DelegateExecution execution, String param) { |
| 42 | Set<Long> groupIds = StrUtils.splitToLongSet(param); | 42 | Set<Long> groupIds = StrUtils.splitToLongSet(param); |
| 43 | List<BpmUserGroupDO> groups = userGroupService.getUserGroupList(groupIds); | 43 | List<BpmUserGroupDO> groups = userGroupService.getUserGroupList(groupIds); |
| 44 | - return convertSetByFlatMap(groups, BpmUserGroupDO::getMemberUserIds, Collection::stream); | 44 | + return convertSetByFlatMap(groups, BpmUserGroupDO::getUserIds, Collection::stream); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | } | 47 | } |
| 48 | \ No newline at end of file | 48 | \ No newline at end of file |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java
| 1 | package cn.iocoder.yudao.module.bpm.service.definition; | 1 | package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; | ||
| 5 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; | 4 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
| 6 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; | 5 | +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | 6 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
| 8 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 9 | 8 | ||
| @@ -23,14 +22,14 @@ public interface BpmUserGroupService { | @@ -23,14 +22,14 @@ public interface BpmUserGroupService { | ||
| 23 | * @param createReqVO 创建信息 | 22 | * @param createReqVO 创建信息 |
| 24 | * @return 编号 | 23 | * @return 编号 |
| 25 | */ | 24 | */ |
| 26 | - Long createUserGroup(@Valid BpmUserGroupCreateReqVO createReqVO); | 25 | + Long createUserGroup(@Valid BpmUserGroupSaveReqVO createReqVO); |
| 27 | 26 | ||
| 28 | /** | 27 | /** |
| 29 | * 更新用户组 | 28 | * 更新用户组 |
| 30 | * | 29 | * |
| 31 | * @param updateReqVO 更新信息 | 30 | * @param updateReqVO 更新信息 |
| 32 | */ | 31 | */ |
| 33 | - void updateUserGroup(@Valid BpmUserGroupUpdateReqVO updateReqVO); | 32 | + void updateUserGroup(@Valid BpmUserGroupSaveReqVO updateReqVO); |
| 34 | 33 | ||
| 35 | /** | 34 | /** |
| 36 | * 删除用户组 | 35 | * 删除用户组 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java
| @@ -2,13 +2,10 @@ package cn.iocoder.yudao.module.bpm.service.definition; | @@ -2,13 +2,10 @@ package cn.iocoder.yudao.module.bpm.service.definition; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | ||
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 8 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; | 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
| 10 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; | ||
| 11 | -import cn.iocoder.yudao.module.bpm.convert.definition.BpmUserGroupConvert; | 8 | +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; |
| 12 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | 9 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
| 13 | import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; | 10 | import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; |
| 14 | import jakarta.annotation.Resource; | 11 | import jakarta.annotation.Resource; |
| @@ -20,6 +17,7 @@ import java.util.List; | @@ -20,6 +17,7 @@ import java.util.List; | ||
| 20 | import java.util.Map; | 17 | import java.util.Map; |
| 21 | 18 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 20 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 23 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_IS_DISABLE; | 21 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_IS_DISABLE; |
| 24 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; | 22 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; |
| 25 | 23 | ||
| @@ -36,20 +34,18 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { | @@ -36,20 +34,18 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { | ||
| 36 | private BpmUserGroupMapper userGroupMapper; | 34 | private BpmUserGroupMapper userGroupMapper; |
| 37 | 35 | ||
| 38 | @Override | 36 | @Override |
| 39 | - public Long createUserGroup(BpmUserGroupCreateReqVO createReqVO) { | ||
| 40 | - // 插入 | ||
| 41 | - BpmUserGroupDO userGroup = BpmUserGroupConvert.INSTANCE.convert(createReqVO); | 37 | + public Long createUserGroup(BpmUserGroupSaveReqVO createReqVO) { |
| 38 | + BpmUserGroupDO userGroup = BeanUtils.toBean(createReqVO, BpmUserGroupDO.class); | ||
| 42 | userGroupMapper.insert(userGroup); | 39 | userGroupMapper.insert(userGroup); |
| 43 | - // 返回 | ||
| 44 | return userGroup.getId(); | 40 | return userGroup.getId(); |
| 45 | } | 41 | } |
| 46 | 42 | ||
| 47 | @Override | 43 | @Override |
| 48 | - public void updateUserGroup(BpmUserGroupUpdateReqVO updateReqVO) { | 44 | + public void updateUserGroup(BpmUserGroupSaveReqVO updateReqVO) { |
| 49 | // 校验存在 | 45 | // 校验存在 |
| 50 | - this.validateUserGroupExists(updateReqVO.getId()); | 46 | + validateUserGroupExists(updateReqVO.getId()); |
| 51 | // 更新 | 47 | // 更新 |
| 52 | - BpmUserGroupDO updateObj = BpmUserGroupConvert.INSTANCE.convert(updateReqVO); | 48 | + BpmUserGroupDO updateObj = BeanUtils.toBean(updateReqVO, BpmUserGroupDO.class); |
| 53 | userGroupMapper.updateById(updateObj); | 49 | userGroupMapper.updateById(updateObj); |
| 54 | } | 50 | } |
| 55 | 51 | ||
| @@ -63,7 +59,7 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { | @@ -63,7 +59,7 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { | ||
| 63 | 59 | ||
| 64 | private void validateUserGroupExists(Long id) { | 60 | private void validateUserGroupExists(Long id) { |
| 65 | if (userGroupMapper.selectById(id) == null) { | 61 | if (userGroupMapper.selectById(id) == null) { |
| 66 | - throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); | 62 | + throw exception(USER_GROUP_NOT_EXISTS); |
| 67 | } | 63 | } |
| 68 | } | 64 | } |
| 69 | 65 | ||
| @@ -95,12 +91,12 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { | @@ -95,12 +91,12 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { | ||
| 95 | } | 91 | } |
| 96 | // 获得用户组信息 | 92 | // 获得用户组信息 |
| 97 | List<BpmUserGroupDO> userGroups = userGroupMapper.selectBatchIds(ids); | 93 | List<BpmUserGroupDO> userGroups = userGroupMapper.selectBatchIds(ids); |
| 98 | - Map<Long, BpmUserGroupDO> userGroupMap = CollectionUtils.convertMap(userGroups, BpmUserGroupDO::getId); | 94 | + Map<Long, BpmUserGroupDO> userGroupMap = convertMap(userGroups, BpmUserGroupDO::getId); |
| 99 | // 校验 | 95 | // 校验 |
| 100 | ids.forEach(id -> { | 96 | ids.forEach(id -> { |
| 101 | BpmUserGroupDO userGroup = userGroupMap.get(id); | 97 | BpmUserGroupDO userGroup = userGroupMap.get(id); |
| 102 | if (userGroup == null) { | 98 | if (userGroup == null) { |
| 103 | - throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); | 99 | + throw exception(USER_GROUP_NOT_EXISTS); |
| 104 | } | 100 | } |
| 105 | if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { | 101 | if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { |
| 106 | throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); | 102 | throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); |
yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java
| @@ -29,8 +29,8 @@ public class BpmTaskCandidateGroupStrategyTest extends BaseMockitoUnitTest { | @@ -29,8 +29,8 @@ public class BpmTaskCandidateGroupStrategyTest extends BaseMockitoUnitTest { | ||
| 29 | // 准备参数 | 29 | // 准备参数 |
| 30 | String param = "1,2"; | 30 | String param = "1,2"; |
| 31 | // mock 方法 | 31 | // mock 方法 |
| 32 | - BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L))); | ||
| 33 | - BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L))); | 32 | + BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(11L, 12L))); |
| 33 | + BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(21L, 22L))); | ||
| 34 | when(userGroupService.getUserGroupList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(userGroup1, userGroup2)); | 34 | when(userGroupService.getUserGroupList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(userGroup1, userGroup2)); |
| 35 | 35 | ||
| 36 | // 调用 | 36 | // 调用 |
yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 6 | import cn.iocoder.yudao.framework.test.core.util.AssertUtils; | 6 | import cn.iocoder.yudao.framework.test.core.util.AssertUtils; |
| 7 | import cn.iocoder.yudao.framework.test.core.util.RandomUtils; | 7 | import cn.iocoder.yudao.framework.test.core.util.RandomUtils; |
| 8 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; | 8 | +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; |
| 9 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; | 9 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
| 10 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; | 10 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; |
| 11 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | 11 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
| @@ -39,7 +39,7 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest { | @@ -39,7 +39,7 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest { | ||
| 39 | @Test | 39 | @Test |
| 40 | public void testCreateUserGroup_success() { | 40 | public void testCreateUserGroup_success() { |
| 41 | // 准备参数 | 41 | // 准备参数 |
| 42 | - BpmUserGroupCreateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupCreateReqVO.class); | 42 | + BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class); |
| 43 | 43 | ||
| 44 | // 调用 | 44 | // 调用 |
| 45 | Long userGroupId = userGroupService.createUserGroup(reqVO); | 45 | Long userGroupId = userGroupService.createUserGroup(reqVO); |