添加应用功能优化

pull/44/head
shao1121353141 2023-09-08 23:19:01 +08:00
parent 31b658372a
commit e976af0188
9 changed files with 28 additions and 56 deletions

View File

@ -182,13 +182,6 @@ public class AppEventType {
public static Type DELETE_APP_GROUP = new Type("eiam:event:app_group:delete", public static Type DELETE_APP_GROUP = new Type("eiam:event:app_group:delete",
"删除应用分组", APP_GROUP_RESOURCE, List.of(UserType.ADMIN)); "删除应用分组", APP_GROUP_RESOURCE, List.of(UserType.ADMIN));
/**
*
*/
public static Type ADD_APP_GROUP_ASSOCIATION = new Type(
"eiam:event:add_app_group_association", "添加应用分组关联", APP_GROUP_RESOURCE,
List.of(UserType.ADMIN));
/** /**
* *
*/ */

View File

@ -504,10 +504,6 @@ public enum EventType {
* *
*/ */
DELETE_APP_GROUP(AppEventType.DELETE_APP_GROUP), DELETE_APP_GROUP(AppEventType.DELETE_APP_GROUP),
/**
*
*/
ADD_APP_GROUP_ASSOCIATION(AppEventType.ADD_APP_GROUP_ASSOCIATION),
/** /**
* *
*/ */

View File

@ -176,25 +176,6 @@ public class AppGroupController {
return ApiRestResult.<Boolean> builder().result(result).build(); return ApiRestResult.<Boolean> builder().result(result).build();
} }
/**
*
*
* @param appIds {@link String}
* @return {@link Boolean}
*/
@Lock
@Preview
@Validated
@Operation(summary = "添加应用组关联")
@Audit(type = EventType.ADD_APP_GROUP_ASSOCIATION)
@PostMapping(value = "/add_association/{id}")
@PreAuthorize(value = "authenticated and @sae.hasAuthority(T(cn.topiam.employee.support.security.userdetails.UserType).ADMIN)")
public ApiRestResult<Boolean> addAssociation(@PathVariable(value = "id") String id,
@Parameter(description = "应用ID") String[] appIds) {
return ApiRestResult.<Boolean> builder().result(appGroupService.addAssociation(id, appIds))
.build();
}
/** /**
* *
* *

View File

@ -73,7 +73,7 @@ public interface AppGroupConverter {
* @param appGroupPo {@link AppGroupPO} * @param appGroupPo {@link AppGroupPO}
* @return {@link AppGroupListResult} * @return {@link AppGroupListResult}
*/ */
AppGroupListResult entityConvertToAppGroupListResult(AppGroupPO appGroupPo); AppGroupListResult entityConvertToAppGroupListResult(AppGroupPO appGroupPo);
/** /**
* *
@ -81,7 +81,7 @@ public interface AppGroupConverter {
* @param entity {@link AppGroupEntity} * @param entity {@link AppGroupEntity}
* @return {@link AppGroupGetResult} * @return {@link AppGroupGetResult}
*/ */
AppGroupGetResult entityConvertToAppGroupResult(AppGroupEntity entity); AppGroupGetResult entityConvertToAppGroupResult(AppGroupEntity entity);
/** /**
* entity * entity

View File

@ -51,12 +51,6 @@ public class AppGroupGetResult implements Serializable {
@Parameter(description = "分组编码") @Parameter(description = "分组编码")
private String code; private String code;
/**
*
*/
@Parameter(description = "分组是否启用")
private Boolean enabled;
/** /**
* *
*/ */

View File

@ -39,25 +39,19 @@ public class AppGroupListResult implements Serializable {
* ID * ID
*/ */
@Parameter(description = "ID") @Parameter(description = "ID")
private String id; private String id;
/** /**
* *
*/ */
@Parameter(description = "分组名称") @Parameter(description = "分组名称")
private String name; private String name;
/** /**
* *
*/ */
@Parameter(description = "分组编码") @Parameter(description = "分组编码")
private String code; private String code;
/**
*
*/
@Parameter(description = "是否启用")
private Boolean enabled;
/** /**
* *
@ -69,6 +63,6 @@ public class AppGroupListResult implements Serializable {
* *
*/ */
@Parameter(description = "备注") @Parameter(description = "备注")
private String remark; private String remark;
} }

View File

@ -21,6 +21,7 @@ import java.io.Serializable;
import lombok.Data; import lombok.Data;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
@ -54,4 +55,10 @@ public class AppGroupCreateParam implements Serializable {
@Schema(description = "备注") @Schema(description = "备注")
private String remark; private String remark;
/**
* ID
*/
@Parameter(description = "应用分组ID")
private String[] groupId;
} }

View File

@ -39,23 +39,23 @@ public class AppGroupUpdateParam implements Serializable {
*/ */
@Schema(description = "分组id") @Schema(description = "分组id")
@NotNull(message = "ID不能为空") @NotNull(message = "ID不能为空")
private Long id; private Long id;
/** /**
* *
*/ */
@Schema(description = "分组名称") @Schema(description = "分组名称")
private String name; private String name;
/** /**
* *
*/ */
@Schema(description = "分组编码") @Schema(description = "分组编码")
private String code; private String code;
/** /**
* *
*/ */
@Schema(description = "备注") @Schema(description = "备注")
private String remark; private String remark;
} }

View File

@ -78,8 +78,8 @@ public class AppGroupServiceImpl implements AppGroupService {
@Override @Override
public Page<AppGroupListResult> getAppGroupList(PageModel pageModel, AppGroupQuery query) { public Page<AppGroupListResult> getAppGroupList(PageModel pageModel, AppGroupQuery query) {
//查询映射 //查询映射
org.springframework.data.domain.Page<AppGroupPO> list = appGroupRepository org.springframework.data.domain.Page<AppGroupPO> list = appGroupRepository.getAppGroupList(
.getAppGroupList(query, PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize())); query, PageRequest.of(pageModel.getCurrent(), pageModel.getPageSize()));
return appGroupConverter.entityConvertToAppGroupListResult(list); return appGroupConverter.entityConvertToAppGroupListResult(list);
} }
@ -92,9 +92,16 @@ public class AppGroupServiceImpl implements AppGroupService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean createAppGroup(AppGroupCreateParam param) { public Boolean createAppGroup(AppGroupCreateParam param) {
// TODO 创建后没有数据权限
AppGroupEntity entity = appGroupConverter.appGroupCreateParamConvertToEntity(param); AppGroupEntity entity = appGroupConverter.appGroupCreateParamConvertToEntity(param);
appGroupRepository.save(entity); appGroupRepository.save(entity);
List<AppGroupAssociationEntity> list = new ArrayList<>();
for (String groupId : param.getGroupId()) {
AppGroupAssociationEntity appGroupAssociationEntity = new AppGroupAssociationEntity();
appGroupAssociationEntity.setGroupId(Long.valueOf(groupId));
appGroupAssociationEntity.setAppId(entity.getId());
list.add(appGroupAssociationEntity);
}
appGroupAssociationRepository.saveAll(list);
AuditContext.setTarget( AuditContext.setTarget(
Target.builder().id(String.valueOf(entity.getId())).type(TargetType.APP_GROUP).build()); Target.builder().id(String.valueOf(entity.getId())).type(TargetType.APP_GROUP).build());
return true; return true;
@ -230,7 +237,7 @@ public class AppGroupServiceImpl implements AppGroupService {
* *
* *
* @param appIds {@link String} * @param appIds {@link String}
* @param id {@link String} * @param id {@link String}
* @return {@link Boolean} * @return {@link Boolean}
*/ */
@Override @Override