Skip to content

Commit 8bb6b02

Browse files
committed
🎨 binarywang#1580 企业微信成员信息里性别字段枚举类增加0值
1 parent d650bb6 commit 8bb6b02

File tree

1 file changed

+15
-20
lines changed
  • weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean

1 file changed

+15
-20
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/Gender.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.chanjar.weixin.cp.bean;
22

3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
36
/**
47
* <pre>
58
* 性别枚举
@@ -8,7 +11,13 @@
811
*
912
* @author <a href="https://github.com/binarywang">Binary Wang</a>
1013
*/
14+
@Getter
15+
@AllArgsConstructor
1116
public enum Gender {
17+
/**
18+
* 未定义
19+
*/
20+
UNDEFINED("未定义", "0"),
1221
/**
1322
* 男
1423
*/
@@ -18,28 +27,14 @@ public enum Gender {
1827
*/
1928
FEMALE("女", "2");
2029

21-
private String genderName;
22-
private String code;
23-
24-
Gender(String genderName, String code) {
25-
this.genderName = genderName;
26-
this.code = code;
27-
}
28-
29-
public String getGenderName() {
30-
return this.genderName;
31-
}
32-
33-
public String getCode() {
34-
return this.code;
35-
}
30+
private final String genderName;
31+
private final String code;
3632

3733
public static Gender fromCode(String code) {
38-
if ("1".equals(code)) {
39-
return Gender.MALE;
40-
}
41-
if ("2".equals(code)) {
42-
return Gender.FEMALE;
34+
for(Gender a: Gender.values()){
35+
if(a.code.equals(code)){
36+
return a;
37+
}
4338
}
4439

4540
return null;

0 commit comments

Comments
 (0)