package dingtalk import ( "ai_scheduler/internal/config" errorcode "ai_scheduler/internal/data/error" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" notable "github.com/alibabacloud-go/dingtalk/notable_1_0" util "github.com/alibabacloud-go/tea-utils/v2/service" "github.com/alibabacloud-go/tea/tea" ) type NotableClient struct { config *config.Config cli *notable.Client } func NewNotableClient(config *config.Config) (*NotableClient, error) { cfg := &openapi.Config{ AccessKeyId: tea.String(config.Tools.DingTalkBot.APIKey), AccessKeySecret: tea.String(config.Tools.DingTalkBot.APISecret), Protocol: tea.String("https"), RegionId: tea.String("central"), } c, err := notable.NewClient(cfg) if err != nil { return nil, err } return &NotableClient{config: config, cli: c}, nil } type UpdateRecordReq struct { BaseId string SheetId string RecordId string OperatorId string CreatorUnionId string } type UpdateRecordsserResp struct { Body interface{} } func (c *NotableClient) UpdateRecord(accessToken string, req *UpdateRecordReq) (bool, error) { headers := ¬able.UpdateRecordsHeaders{} headers.XAcsDingtalkAccessToken = tea.String(accessToken) resp, err := c.cli.UpdateRecordsWithOptions( tea.String(req.BaseId), tea.String(req.SheetId), ¬able.UpdateRecordsRequest{ OperatorId: tea.String(req.OperatorId), Records: []*notable.UpdateRecordsRequestRecords{ { Fields: map[string]any{ "提交人": []map[string]any{ { "unionId": req.CreatorUnionId, }, }, }, Id: tea.String(req.RecordId), }, }, }, headers, &util.RuntimeOptions{}) if err != nil { return false, err } if resp.Body == nil { return false, errorcode.ParamErr("empty response body") } return true, nil }