feat(cp/oa): add phonenumber field to ContentValue for PhoneNumber control#3973
Open
tarzanwang wants to merge 1 commit intobinarywang:developfrom
Open
feat(cp/oa): add phonenumber field to ContentValue for PhoneNumber control#3973tarzanwang wants to merge 1 commit intobinarywang:developfrom
tarzanwang wants to merge 1 commit intobinarywang:developfrom
Conversation
…ntrol
The WeCom approval API returns PhoneNumber control values as:
value.phonenumber = { area: "+62", number: "87827717730" }
Without this field, Gson silently drops the value during getApprovalDetail
deserialization, causing phone number to be empty when parsing form data.
Fixes: ContentValue missing phonenumber field for PhoneNumber control type.
Comment on lines
+65
to
+67
| private PhoneNumber phonenumber; | ||
|
|
||
| /** |
There was a problem hiding this comment.
字段名 phonenumber 不符合本类其他字段的驼峰命名风格(如 newNumber、bankAccount 等),会导致生成的 getter/setter 为 getPhonenumber/setPhonenumber,对 Java 调用方不够一致。建议将字段改为 phoneNumber(保持 @SerializedName("phonenumber") 不变);如确实需要兼容 getPhonenumber() 命名,可额外提供一个委托方法作为别名。
Suggested change
| private PhoneNumber phonenumber; | |
| /** | |
| private PhoneNumber phoneNumber; | |
| /** | |
| * 兼容历史命名的 getter。 | |
| * | |
| * @return 手机号控件值 | |
| */ | |
| public PhoneNumber getPhonenumber() { | |
| return this.phoneNumber; | |
| } | |
| /** | |
| * 兼容历史命名的 setter。 | |
| * | |
| * @param phonenumber 手机号控件值 | |
| * @return 当前对象 | |
| */ | |
| public ContentValue setPhonenumber(PhoneNumber phonenumber) { | |
| this.phoneNumber = phonenumber; | |
| return this; | |
| } | |
| /** |
Comment on lines
+64
to
+76
| @SerializedName("phonenumber") | ||
| private PhoneNumber phonenumber; | ||
|
|
||
| /** | ||
| * Phone number control value: {@code value.phonenumber = { area, number }}. | ||
| * e.g. area="+62", number="87827717730" | ||
| */ | ||
| @Data | ||
| public static class PhoneNumber implements Serializable { | ||
| private static final long serialVersionUID = 1L; | ||
| private String area; | ||
| private String number; | ||
| } |
There was a problem hiding this comment.
本 PR 为 ContentValue 新增了 phonenumber 反序列化能力,但当前改动未包含对应的单元测试。仓库中已有对 OA JSON 序列化/反序列化的 TestNG 用例(例如 WxCpOaServiceImplTest 中的 testApprovalDetailSumMoney),建议补充一个最小化测试:将 { "phonenumber": { "area": "+62", "number": "87827717730" } } 反序列化为 ContentValue 并断言 getPhoneNumber()/getPhonenumber() 的 number 字段正确,避免后续回归。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The WeCom approval API returns PhoneNumber control values as:
ContentValuehas nophonenumberfield, so Gson silently drops it duringgetApprovalDetaildeserialization. Any code callingvalueObj.getPhonenumber()always gets
null, even when the user filled in a valid phone number.Fix
Add a
PhoneNumbernested class and a correspondingphonenumberfieldwith
@SerializedName("phonenumber")toContentValue.Test
Deserialize the following JSON fragment into
ContentValueand assertgetPhonenumber().getNumber()equals"87827717730":{ "phonenumber": { "area": "+62", "number": "87827717730" } }