mirror of https://gitee.com/topiam/eiam
⚡ 优化代码
parent
7720cc377d
commit
e974422086
|
@ -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 {
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 分组编码
|
||||
*/
|
||||
@NotBlank(message = "分组编码不能为空")
|
||||
@Schema(description = "分组编码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 分组编码
|
||||
*/
|
||||
@Schema(description = "分组编码")
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
|
|
@ -53,12 +53,6 @@ public class AppGroupUpdateParam implements Serializable {
|
|||
@Schema(description = "分组编码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 分组是否启用
|
||||
*/
|
||||
@Schema(description = "分组是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
|
|
@ -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<AppGroupListResult> 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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue