Skip to content
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

Develop #490

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
}
2 changes: 1 addition & 1 deletion src/work/oa/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (comp *Client) CreateApproval(ctx context.Context, data *power.HashMap) (*r

// 批量获取审批单号
// https://developer.work.weixin.qq.com/document/path/91816
func (comp *Client) GetApprovalInfo(ctx context.Context, startTime int, endTime int, nextCursor int, size int, filters *object.HashMap) (*response.ResponseApprovalNoList, error) {
func (comp *Client) GetApprovalInfo(ctx context.Context, startTime int, endTime int, nextCursor int, size int, filters []*object.HashMap) (*response.ResponseApprovalNoList, error) {

result := &response.ResponseApprovalNoList{}

Expand Down
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

}
Loading