|
|
@@ -1,6 +1,7 @@ |
|
|
|
package com.hz.pm.api.projectlib.model.enumeration.status; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.Getter; |
|
|
|
|
|
|
@@ -33,17 +34,18 @@ public enum TenderStatus implements IStatus<Integer, String> { |
|
|
|
private final String desc; |
|
|
|
|
|
|
|
|
|
|
|
public static TenderStatus getByStatus(Integer tenderStatus) { |
|
|
|
private static Optional<TenderStatus> get(Integer tenderStatus) { |
|
|
|
return Arrays.stream(values()) |
|
|
|
.filter(w -> w.eq(tenderStatus)) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
.findFirst(); |
|
|
|
} |
|
|
|
|
|
|
|
public static TenderStatus getNoNull(Integer tenderStatus) { |
|
|
|
return get(tenderStatus).orElseThrow(() -> BizException.wrap("无效的标段状态:%s", tenderStatus)); |
|
|
|
} |
|
|
|
|
|
|
|
public static String getDescByStatus(Integer tenderStatus) { |
|
|
|
return Optional.ofNullable(getByStatus(tenderStatus)) |
|
|
|
.flatMap(w -> Optional.of(w.getDesc())) |
|
|
|
.orElse(StrUtil.EMPTY); |
|
|
|
return get(tenderStatus).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
} |