Skip to content

Commit

Permalink
feat(work): oa add approvial
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed May 16, 2024
1 parent 84868c3 commit 2aa083e
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/work/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
miniProgram "github.com/ArtisanCloud/PowerWeChat/v3/src/work/miniProgram"
msgaudit "github.com/ArtisanCloud/PowerWeChat/v3/src/work/msgAudit"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/approval"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/calendar"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/dial"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/journal"
Expand Down Expand Up @@ -127,6 +128,7 @@ type Work struct {
OAPSTNCC *pstncc.Client
OASchedule *schedule.Client
OAWebDrive *webdrive.Client
OAApproval *approval.Client

MsgAudit *msgaudit.Client

Expand Down Expand Up @@ -334,7 +336,9 @@ func NewWork(config *UserConfig) (*Work, error) {
app.OAMeetingRoom,
app.OAPSTNCC,
app.OASchedule,
app.OAWebDrive, err = oa.RegisterProvider(app)
app.OAWebDrive,
app.OAApproval,
err = oa.RegisterProvider(app)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -478,6 +482,8 @@ func (app *Work) GetComponent(name string) interface{} {
return app.OASchedule
case "OAWebDrive":
return app.OAWebDrive
case "OAApproval":
return app.OAApproval

case "MsgAudit":
return app.MsgAudit
Expand Down
33 changes: 33 additions & 0 deletions src/work/oa/approval/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package approval

import (
"context"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/approval/request"
)

type Client struct {
BaseClient *kernel.BaseClient
}

func NewClient(app kernel.ApplicationInterface) (*Client, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &Client{
baseClient,
}, nil
}

// 更新审批模板
// https://developer.work.weixin.qq.com/document/path/97438
func (comp *Client) UpdateTemplate(ctx context.Context, options *request.RequestUpdateTemplate) (*response.ResponseWork, error) {

result := &response.ResponseWork{}

_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/oa/approval/update_template", options, nil, nil, result)

return result, err
}
1 change: 1 addition & 0 deletions src/work/oa/approval/reponse/responseUpdateTemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package reponse
41 changes: 41 additions & 0 deletions src/work/oa/approval/request/requestUpdateTemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package request

type TemplateName struct {
Text string `json:"text"`
Lang string `json:"lang"`
}

type Title struct {
Text string `json:"text"`
Lang string `json:"lang"`
}

type Placeholder struct {
Text string `json:"text"`
Lang string `json:"lang"`
}

type Property struct {
Control string `json:"control"`
Id string `json:"id"`
Title []Title `json:"title"`
Placeholder []Placeholder `json:"placeholder"`
Require int `json:"require"`
UnPrint int `json:"un_print"`
}

type Control struct {
Property Property `json:"property"`
Config struct {
} `json:"config"`
}

type TemplateContent struct {
Controls []Control `json:"controls"`
}

type RequestUpdateTemplate struct {
TemplateId string `json:"template_id"`
TemplateName []TemplateName `json:"template_name"`
TemplateContent TemplateContent `json:"template_content"`
}
28 changes: 17 additions & 11 deletions src/work/oa/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package oa

import (
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/approval"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/calendar"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/dial"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/oa/journal"
Expand All @@ -23,52 +24,56 @@ func RegisterProvider(app kernel.ApplicationInterface) (*Client,
*pstncc.Client,
*schedule.Client,
*webdrive.Client,
*approval.Client,
error,

) {
//config := app.GetConfig()

Client, err := NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Calendar, err := calendar.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Dial, err := dial.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Journal, err := journal.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Living, err := living.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Meeting, err := meeting.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
MeetingRoom, err := meetingroom.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
PSTNCC, err := pstncc.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Schedule, err := schedule.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
WebDrive, err := webdrive.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
Approval, err := approval.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}

return Client,
Calendar,
Dial,
Expand All @@ -79,6 +84,7 @@ func RegisterProvider(app kernel.ApplicationInterface) (*Client,
PSTNCC,
Schedule,
WebDrive,
Approval,
nil

}

0 comments on commit 2aa083e

Please sign in to comment.