Merge branch 'feature/REQ-3488-zhh' into 'feature/REQ-3488'
feat(REQ-3488): 添加resolve See merge request universal/infrastructure/backend/orgmanax!112
This commit is contained in:
commit
430db66b14
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -59,4 +60,28 @@ public class OrgNodeBriefDTO implements Serializable {
|
||||
*/
|
||||
private JSONObject profile;
|
||||
|
||||
/**
|
||||
* 解析profile
|
||||
* 调用方需要根据nodeType来解析profile,自行使用正确的对象来接收<br>
|
||||
* <pre>
|
||||
* NodeProfile.ProjectTeamProfile projectTeamProfile = projectTeamNode.resolveProfile(); // nodeType = 4
|
||||
* NodeProfile.PlatTeamProfile platTeamProfile = platTeamNode.resolveProfile(); // nodeType = 2
|
||||
* JSONObject normalProfile = normalNode.resolveProfile(); // nodeType = 1
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
* @see NodeProfile#resolveProfileClass(Integer)
|
||||
*/
|
||||
public <T> T resolveProfile() {
|
||||
if (profile == null || profile.isEmpty()) {
|
||||
return (T) profile;
|
||||
}
|
||||
Class<?> clazz = NodeProfile.resolveProfileClass(nodeType);
|
||||
if (clazz == null) {
|
||||
return (T) profile;
|
||||
}
|
||||
return (T) Optional.ofNullable(profile).map(p -> JSONObject.parseObject(p.toString(), clazz)).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user