New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add GetOATemplateDetail ApplyOAEvent GetOAApprovalInfo GetOAApprovalDetail EventSysApprovalChange #57
Conversation
`UseTemplateApprover`|`use_template_approver`|`uint8`| 审批人模式:0-通过接口指定审批人、抄送人(此时approver、notifyer等参数可用); 1-使用此模板在管理后台设置的审批流程,支持条件审批。默认为0 | ||
`Approver`|`approver`|`[]OAApprover`| 审批流程信息,用于指定审批申请的审批流程,支持单人审批、多人会签、多人或签,可能有多个审批节点,仅use_template_approver为0时生效。 | ||
`Notifier`|`notifyer`|`[]string`| 抄送人节点userid列表,仅use_template_approver为0时生效。 | ||
`NotifyType`|`notify_type`|`*uint8`| 抄送方式:1-提单时抄送(默认值); 2-单据通过后抄送;3-提单和单据通过后抄送。仅use_template_approver为0时生效。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notify_type
is optional parameter but it must be set null
or 1
(default value), when set the 0
value, Tencent response error { Code: 301025, Msg: "get approval param error:notify_type" }
, to slove this problem i choice *uint8
as the parameter type
oa.go
Outdated
// OAApprovalInfo 审批申请状态变化回调通知 | ||
type OAApprovalInfo struct { | ||
// SpNo 审批编号 | ||
SpNo string `xml:"SpNo"` | ||
// SpName 审批申请类型名称(审批模板名称) | ||
SpName string `xml:"SpName"` | ||
// SpStatus 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付 | ||
SpStatus string `xml:"SpStatus"` | ||
// TemplateID 审批模板id。可在“获取审批申请详情”、“审批状态变化回调通知”中获得,也可在审批模板的模板编辑页面链接中获得。 | ||
TemplateID string `xml:"TemplateId"` | ||
// ApplyTime 审批申请提交时间,Unix时间戳 | ||
ApplyTime string `xml:"ApplyTime"` | ||
// Applicant 申请人信息 | ||
Applicant struct { | ||
// UserID 申请人userid | ||
UserID string `xml:"UserId"` | ||
// Party 申请人所在部门pid | ||
Party string `xml:"Party"` | ||
} `xml:"Applyer"` | ||
// SpRecord 审批流程信息,可能有多个审批节点。 | ||
SpRecord []struct { | ||
// SpStatus 审批节点状态:1-审批中;2-已同意;3-已驳回;4-已转审 | ||
SpStatus string `xml:"SpStatus"` | ||
// ApproverAttr 节点审批方式:1-或签;2-会签 | ||
ApproverAttr string `xml:"ApproverAttr"` | ||
// Details 审批节点详情。当节点为标签或上级时,一个节点可能有多个分支 | ||
Details []struct { | ||
// Approver 分支审批人 | ||
Approver struct { | ||
// UserID 分支审批人userid | ||
UserID string `xml:"UserId"` | ||
} `xml:"Approver"` | ||
// Speech 审批意见字段 | ||
Speech string `xml:"Speech"` | ||
// SpStatus 分支审批人审批状态:1-审批中;2-已同意;3-已驳回;4-已转审 | ||
SpStatus string `xml:"SpStatus"` | ||
// SpTime 节点分支审批人审批操作时间,0为尚未操作 | ||
SpTime string `xml:"SpTime"` | ||
// Attach 节点分支审批人审批意见附件,赋值为media_id具体使用请参考:文档-获取临时素材 | ||
Attach []string `xml:"Attach"` | ||
} `xml:"Details"` | ||
} `xml:"SpRecord"` | ||
// Notifier 抄送信息,可能有多个抄送节点 | ||
Notifier struct { | ||
// UserID 节点抄送人userid | ||
UserID string `xml:"UserId"` | ||
} `xml:"Notifyer"` | ||
// Comments 审批申请备注信息,可能有多个备注节点 | ||
Comments []struct { | ||
// CommentUserInfo 备注人信息 | ||
CommentUserInfo struct { | ||
// UserID 备注人userid | ||
UserID string `xml:"UserId"` | ||
} `xml:"CommentUserInfo"` | ||
// CommentTime 备注提交时间 | ||
CommentTime string `xml:"CommentTime"` | ||
// CommentContent 备注文本内容 | ||
CommentContent string `xml:"CommentContent"` | ||
// CommentID 备注id | ||
CommentID string `xml:"CommentId"` | ||
// Attach 备注意见附件,值是附件media_id具体使用请参考:文档-获取临时素材 | ||
Attach []string `xml:"Attach"` | ||
} `xml:"Comments"` | ||
// StatusChangeEvent 审批申请状态变化类型:1-提单;2-同意;3-驳回;4-转审;5-催办;6-撤销;8-通过后撤销;10-添加备注 | ||
StatusChangeEvent string `xml:"StatuChangeEvent"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unfortunate because all the unconverted string
s and inline struct definitions, but writing out proper conversion adapters can hurt badly. I'm starting to think whether putting unpolished (but "working") interfaces inside a x
package is a good idea.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unconverted strings
at first i try to convert status
string type parameter to enum and time
string type to time.Time, but i find that both in req
and resp
with deep struct like OAContentValue
, it's hard to add convert adapter, yep you are right, i have not enough time and thought it too boring, so i give up
inline struct definitions
OAApprovalInfo
is callback value, that don't need to modify anything but just get value, about this special struct i think inline struct more clearly than separate. (Note: separate struct is also ok)
putting unpolished (but "working") interfaces inside a x package
no i don't think so, case oa.md.go
user_info.md.go
, these also contain some unpolished (but "working") interfaces, if code generate support xml
tag and time.Time
type, i will put OAApprovalInfo
into that, x package duplicate with {api_scope}.md.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About inline structs:
Giving every nested struct its own type name mainly benefits refactoring. For example you lift some logic out, that uses some fields of the nested struct and only uses those, now suddenly you have to spell out the complete struct definition in your function signature.
About the x
package suggestion:
Yeah maybe there're already some public interfaces that is not thoroughly strong-typed. That's unfortunate but my review bandwidth has always been limited these days, I can barely cope with workloads from $PAID_JOB
this year, to start with.
Then let's do this later for v2
maybe...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More about the inline structs, I'm okay with the code as it is, just that users might have some difficulty extracting code out that uses exclusively one of the inner fields. If I were you I'd add some precautionary messages in README, if somebody finds it annoying we can fix that afterwards.
P.S. I just realized we're still not v1.0.0
so nothing is set in stone. We can re-organize everything before releasing v1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you say now suddenly you have to spell out the complete struct definition, yes it's possibly do.
i will change inline structs to separate recently, keep the whole project in same style.
$PAID_JOB
first, same with you, XD
about v2/v1 and x
v1 or v2 is ok for me, make life work balance, no need release new version so quickly, maybe can find some new solution in refactor
…rovalDetail EventSysApprovalChange
LGTM after all the struct definition work. Thanks! bors r+ |
Build succeeded: |
57: feat: add GetOATemplateDetail ApplyOAEvent GetOAApprovalInfo GetOAApprovalDetail EventSysApprovalChange r=xen0n a=w3xse7en GetOATemplateDetail doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91982 ApplyOAEvent doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91853 GetOAApprovalInfo doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91816 GetOAApprovalDetail doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91983 EventSysApprovalChange doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91815 Co-authored-by: w3xse7en <w3xse7en@outlook.com>
GetOATemplateDetail doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91982
ApplyOAEvent doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91853
GetOAApprovalInfo doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91816
GetOAApprovalDetail doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91983
EventSysApprovalChange doc: https://open.work.weixin.qq.com/api/doc/90000/90135/91815