枚举类回显赋值
This commit is contained in:
@@ -17,6 +17,7 @@ import com.openhis.common.constant.CommonConstants;
|
|||||||
import com.openhis.common.constant.PromptMsgConstant;
|
import com.openhis.common.constant.PromptMsgConstant;
|
||||||
import com.openhis.common.enums.AccountStatus;
|
import com.openhis.common.enums.AccountStatus;
|
||||||
import com.openhis.common.enums.WhetherContainUnknown;
|
import com.openhis.common.enums.WhetherContainUnknown;
|
||||||
|
import com.openhis.common.utils.EnumUtils;
|
||||||
import com.openhis.common.utils.HisQueryUtils;
|
import com.openhis.common.utils.HisQueryUtils;
|
||||||
import com.openhis.web.basicservice.dto.HealthcareServiceAddOrUpdateParam;
|
import com.openhis.web.basicservice.dto.HealthcareServiceAddOrUpdateParam;
|
||||||
import com.openhis.web.basicservice.dto.HealthcareServiceDto;
|
import com.openhis.web.basicservice.dto.HealthcareServiceDto;
|
||||||
@@ -106,6 +107,10 @@ public class HealthcareServiceController {
|
|||||||
new HashSet<>(Arrays.asList("name", "charge_name")), request);
|
new HashSet<>(Arrays.asList("name", "charge_name")), request);
|
||||||
IPage<HealthcareServiceDto> healthcareServicePage = healthcareServiceBizMapper.getHealthcareServicePage(
|
IPage<HealthcareServiceDto> healthcareServicePage = healthcareServiceBizMapper.getHealthcareServicePage(
|
||||||
new Page<>(pageNo, pageSize), CommonConstants.TableName.ADM_HEALTHCARE_SERVICE, queryWrapper);
|
new Page<>(pageNo, pageSize), CommonConstants.TableName.ADM_HEALTHCARE_SERVICE, queryWrapper);
|
||||||
|
// 枚举类回显赋值
|
||||||
|
healthcareServicePage.getRecords().forEach(e ->
|
||||||
|
e.setActiveFlag_enumText(EnumUtils.getInfoByValue(AccountStatus.class, e.getActiveFlag()))
|
||||||
|
);
|
||||||
return R.ok(healthcareServicePage, MessageUtils.createMessage(PromptMsgConstant.Common.M00009, null));
|
return R.ok(healthcareServicePage, MessageUtils.createMessage(PromptMsgConstant.Common.M00009, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class HealthcareServiceDto {
|
|||||||
* 活动标记
|
* 活动标记
|
||||||
*/
|
*/
|
||||||
private Integer activeFlag;
|
private Integer activeFlag;
|
||||||
|
private String activeFlag_enumText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供部门ID
|
* 提供部门ID
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum AccountStatus {
|
public enum AccountStatus implements ValueEnum {
|
||||||
|
|
||||||
ACTIVE (1, "active", "有效"),
|
ACTIVE (1, "active", "有效"),
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.openhis.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 枚举类通用接口
|
||||||
|
*/
|
||||||
|
public interface ValueEnum {
|
||||||
|
Integer getValue();
|
||||||
|
String getInfo();
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.openhis.common.utils;
|
||||||
|
|
||||||
|
import com.openhis.common.enums.ValueEnum;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class EnumUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 value 获取枚举的 info
|
||||||
|
*
|
||||||
|
* @param enumClass 枚举类
|
||||||
|
* @param value 枚举的 value
|
||||||
|
* @param <E> 枚举类型
|
||||||
|
* @return 对应的 info,如果未找到则返回 null
|
||||||
|
*/
|
||||||
|
public static <E extends Enum<E> & ValueEnum> String getInfoByValue(Class<E> enumClass, Integer value) {
|
||||||
|
return Arrays.stream(enumClass.getEnumConstants())
|
||||||
|
.filter(e -> e.getValue().equals(value))
|
||||||
|
.findFirst()
|
||||||
|
.map(ValueEnum::getInfo)
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user