From e97442208645fb224d39318235a8c0f1a85853ae Mon Sep 17 00:00:00 2001 From: smallbun <2689170096@qq.com> Date: Fri, 8 Sep 2023 18:56:14 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/AppGroupController.java | 2 +- .../converter/app/AppGroupConverter.java | 34 +++---------------- .../pojo/result/app/AppGroupListResult.java | 7 ++++ .../pojo/save/app/AppGroupCreateParam.java | 15 ++++---- .../pojo/update/app/AppGroupUpdateParam.java | 6 ---- .../portal/converter/AppGroupConverter.java | 10 +++--- 6 files changed, 25 insertions(+), 49 deletions(-) diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java b/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java index 0f635ae4..a99ec1fb 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/controller/app/AppGroupController.java @@ -59,7 +59,7 @@ import static cn.topiam.employee.common.constant.AppConstants.APP_PATH; @Tag(name = "应用分组管理") @RestController @AllArgsConstructor -@RequestMapping(value = APP_PATH + "/app_group", produces = MediaType.APPLICATION_JSON_VALUE) +@RequestMapping(value = APP_PATH + "/group", produces = MediaType.APPLICATION_JSON_VALUE) public class AppGroupController { /** diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java index 381b2fcd..3b3f1ee8 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/converter/app/AppGroupConverter.java @@ -96,21 +96,7 @@ public interface AppGroupConverter { * @param entity {@link AppGroupEntity} * @return {@link AppGroupListResult} */ - default AppGroupListResult entityConvertToAppGroupListResult(AppGroupEntity entity) { - if (entity == null) { - return null; - } - - AppGroupListResult appGroupListResult = new AppGroupListResult(); - if (entity.getId() != null) { - appGroupListResult.setId(String.valueOf(entity.getId())); - } - appGroupListResult.setName(entity.getName()); - appGroupListResult.setCode(entity.getCode()); - appGroupListResult.setEnabled(entity.getEnabled()); - appGroupListResult.setRemark(entity.getRemark()); - return appGroupListResult; - } + AppGroupListResult entityConvertToAppGroupListResult(AppGroupEntity entity); /** * 实体转分组返回 @@ -118,20 +104,7 @@ public interface AppGroupConverter { * @param entity {@link AppGroupEntity} * @return {@link AppGroupGetResult} */ - default AppGroupGetResult entityConvertToAppGroupResult(AppGroupEntity entity) { - if (entity == null) { - return null; - } - AppGroupGetResult appGroupGetResult = new AppGroupGetResult(); - - if (entity.getId() != null) { - appGroupGetResult.setId(String.valueOf(entity.getId())); - } - appGroupGetResult.setName(entity.getName()); - appGroupGetResult.setEnabled(entity.getEnabled()); - appGroupGetResult.setCreateTime(entity.getCreateTime()); - return appGroupGetResult; - } + AppGroupGetResult entityConvertToAppGroupResult(AppGroupEntity entity); /** * 将分组修改对象转换为entity @@ -139,12 +112,12 @@ public interface AppGroupConverter { * @param param {@link AppGroupUpdateParam} * @return {@link AppGroupEntity} */ + @Mapping(target = "enabled", ignore = true) @Mapping(target = "deleted", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "updateBy", ignore = true) @Mapping(target = "createTime", ignore = true) @Mapping(target = "createBy", ignore = true) - @Mapping(target = "enabled", ignore = false) AppGroupEntity appGroupUpdateParamConverterToEntity(AppGroupUpdateParam param); /** @@ -153,6 +126,7 @@ public interface AppGroupConverter { * @param param {@link AppAccountCreateParam} * @return {@link AppAccountEntity} */ + @Mapping(target = "enabled", expression = "java(Boolean.TRUE)") @Mapping(target = "deleted", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "updateTime", ignore = true) diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java index c8acdbf5..e32cf3a6 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/result/app/AppGroupListResult.java @@ -18,6 +18,7 @@ package cn.topiam.employee.console.pojo.result.app; import java.io.Serializable; +import java.time.LocalDateTime; import lombok.Data; @@ -58,6 +59,12 @@ public class AppGroupListResult implements Serializable { @Parameter(description = "是否启用") private Boolean enabled; + /** + * 创建时间 + */ + @Parameter(description = "创建时间") + private LocalDateTime createTime; + /** * 备注 */ diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java index b3210144..580f59d2 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/save/app/AppGroupCreateParam.java @@ -31,7 +31,7 @@ import jakarta.validation.constraints.NotBlank; * Created by support@topiam.cn on 2023/8/31 23:26 */ @Data -@Schema(description = "分组保存入参") +@Schema(description = "应用分组保存入参") public class AppGroupCreateParam implements Serializable { /** @@ -41,16 +41,17 @@ public class AppGroupCreateParam implements Serializable { @Schema(description = "分组名称") private String name; - /** - * 备注 - */ - @Schema(description = "备注") - private String remark; - /** * 分组编码 */ + @NotBlank(message = "分组编码不能为空") @Schema(description = "分组编码") private String code; + /** + * 备注 + */ + @Schema(description = "备注") + private String remark; + } diff --git a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/update/app/AppGroupUpdateParam.java b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/update/app/AppGroupUpdateParam.java index b0fff9ec..903d74f1 100644 --- a/eiam-console/src/main/java/cn/topiam/employee/console/pojo/update/app/AppGroupUpdateParam.java +++ b/eiam-console/src/main/java/cn/topiam/employee/console/pojo/update/app/AppGroupUpdateParam.java @@ -53,12 +53,6 @@ public class AppGroupUpdateParam implements Serializable { @Schema(description = "分组编码") private String code; - /** - * 分组是否启用 - */ - @Schema(description = "分组是否启用") - private Boolean enabled; - /** * 备注 */ diff --git a/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java b/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java index ab6c80f0..73a3881a 100644 --- a/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java +++ b/eiam-portal/src/main/java/cn/topiam/employee/portal/converter/AppGroupConverter.java @@ -30,6 +30,7 @@ import cn.topiam.employee.common.entity.app.AppGroupEntity; import cn.topiam.employee.common.entity.app.QAppGroupAssociationEntity; import cn.topiam.employee.common.entity.app.QAppGroupEntity; import cn.topiam.employee.portal.pojo.result.AppGroupListResult; +import org.mapstruct.Mapping; /** * 分组映射 @@ -61,9 +62,7 @@ public interface AppGroupConverter { */ default Predicate queryAppGroupAssociationPredicate() { QAppGroupAssociationEntity appGroupAssociation = QAppGroupAssociationEntity.appGroupAssociationEntity; - Predicate predicate = appGroupAssociation.deleted.eq(Boolean.FALSE); - //@formatter:on - return predicate; + return appGroupAssociation.deleted.eq(Boolean.FALSE); } /** @@ -78,9 +77,9 @@ public interface AppGroupConverter { List results = new ArrayList<>(); for (AppGroupEntity entity : list) { AppGroupListResult result = appGroupEntityConverterToResult(entity); - Long count = appGroupAssociationList.stream() + long count = appGroupAssociationList.stream() .filter(t -> t.getGroupId().equals(entity.getId())).count(); - result.setAppCount(Integer.valueOf(count.toString())); + result.setAppCount(Integer.valueOf(Long.toString(count))); results.add(result); } return results; @@ -92,6 +91,7 @@ public interface AppGroupConverter { * @param entity {@link AppGroupEntity} * @return {@link AppGroupEntity} */ + @Mapping(target = "appCount", ignore = true) AppGroupListResult appGroupEntityConverterToResult(AppGroupEntity entity); }