Skip to content

Commit 3ad56b0

Browse files
authored
Merge pull request #2346 from actiontech/fix-issue1441-1
Fix issue1441 1
2 parents dc4d1ab + 796a968 commit 3ad56b0

File tree

8 files changed

+83
-30
lines changed

8 files changed

+83
-30
lines changed

sqle/api/controller/v1/configuration.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ type GetWechatAuditConfigurationResV1 struct {
281281
}
282282

283283
type WechatConfigurationV1 struct {
284-
CorpID string `json:"corp_id"`
285-
TemplateId string `json:"template_id"`
284+
CorpID string `json:"corp_id"`
286285

287286
IsWechatNotificationEnabled bool `json:"is_wechat_notification_enabled"`
288287
}
@@ -296,16 +295,12 @@ type WechatConfigurationV1 struct {
296295
// @Success 200 {object} v1.GetWechatAuditConfigurationResV1
297296
// @router /v1/configurations/wechat_audit [get]
298297
func GetWechatAuditConfigurationV1(c echo.Context) error {
299-
return c.JSON(http.StatusOK, &GetWechatAuditConfigurationResV1{
300-
BaseRes: controller.NewBaseReq(nil),
301-
Data: WechatConfigurationV1{},
302-
})
298+
return getWechatAuditConfigurationV1(c)
303299
}
304300

305301
type UpdateWechatConfigurationReqV1 struct {
306302
CorpID *string `json:"corp_id" from:"corp_id" description:"微信企业号ID"`
307303
CorpSecret *string `json:"corp_secret" from:"corp_secret" description:"企业微信ID对应密码"`
308-
TemplateId *string `json:"template_id" from:"template_id" description:"企业微信审批模板ID"`
309304
IsWechatNotificationEnabled *bool `json:"is_wechat_notification_enabled" from:"is_wechat_notification_enabled" validate:"required" description:"是否启用微信对接流程"`
310305
}
311306

@@ -320,7 +315,7 @@ type UpdateWechatConfigurationReqV1 struct {
320315
// @Success 200 {object} controller.BaseRes
321316
// @router /v1/configurations/wechat_audit [patch]
322317
func UpdateWechatAuditConfigurationV1(c echo.Context) error {
323-
return controller.JSONBaseErrorReq(c, nil)
318+
return updateWechatAuditConfigurationV1(c)
324319
}
325320

326321
type TestWechatConfigResDataV1 struct {
@@ -333,20 +328,20 @@ type TestWechatConfigResV1 struct {
333328
Data TestWechatConfigResDataV1 `json:"data"`
334329
}
335330

331+
type TestWechatConfigurationReqV1 struct {
332+
WechatId string `json:"wechat_id" form:"wechat_id" valid:"required" description:"用户个人企业微信ID"`
333+
}
334+
336335
// TestWechatAuditConfigV1
337336
// @Summary 测试微信审批配置
338337
// @Description test wechat audit configuration
339338
// @Accept json
340339
// @Id testWechatAuditConfigV1
341340
// @Tags configuration
342341
// @Security ApiKeyAuth
342+
// @Param req body v1.TestWechatConfigurationReqV1 true "test wechat configuration req"
343343
// @Success 200 {object} v1.TestWechatConfigResV1
344344
// @router /v1/configurations/wechat_audit/test [post]
345345
func TestWechatAuditConfigV1(c echo.Context) error {
346-
return c.JSON(http.StatusOK, &TestWechatConfigResV1{
347-
BaseRes: controller.NewBaseReq(nil),
348-
Data: TestWechatConfigResDataV1{
349-
IsMessageSentNormally: true,
350-
},
351-
})
346+
return testWechatAuditConfigV1(c)
352347
}

sqle/api/controller/v1/configuration_ce.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
var (
1616
errCommunityEditionNotSupportFeishuAudit = errors.New(errors.EnterpriseEditionFeatures, e.New("feishu audit is enterprise version feature"))
1717
errCommunityEditionNotSupportDingDingAudit = errors.New(errors.EnterpriseEditionFeatures, e.New("dingding audit is enterprise version feature"))
18+
errCommunityEditionNotSupportWechatAudit = errors.New(errors.EnterpriseEditionFeatures, e.New("wechat audit is enterprise version feature"))
1819
)
1920

2021
func updateFeishuAuditConfigurationV1(c echo.Context) error {
@@ -40,3 +41,15 @@ func updateDingTalkConfigurationV1(c echo.Context) error {
4041
func testDingTalkConfigV1(c echo.Context) error {
4142
return controller.JSONBaseErrorReq(c, errCommunityEditionNotSupportDingDingAudit)
4243
}
44+
45+
func getWechatAuditConfigurationV1(c echo.Context) error {
46+
return controller.JSONBaseErrorReq(c, errCommunityEditionNotSupportWechatAudit)
47+
}
48+
49+
func updateWechatAuditConfigurationV1(c echo.Context) error {
50+
return controller.JSONBaseErrorReq(c, errCommunityEditionNotSupportWechatAudit)
51+
}
52+
53+
func testWechatAuditConfigV1(c echo.Context) error {
54+
return controller.JSONBaseErrorReq(c, errCommunityEditionNotSupportWechatAudit)
55+
}

sqle/docs/docs.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,17 @@ var doc = `{
622622
],
623623
"summary": "测试微信审批配置",
624624
"operationId": "testWechatAuditConfigV1",
625+
"parameters": [
626+
{
627+
"description": "test wechat configuration req",
628+
"name": "req",
629+
"in": "body",
630+
"required": true,
631+
"schema": {
632+
"$ref": "#/definitions/v1.TestWechatConfigurationReqV1"
633+
}
634+
}
635+
],
625636
"responses": {
626637
"200": {
627638
"description": "OK",
@@ -11516,6 +11527,14 @@ var doc = `{
1151611527
}
1151711528
}
1151811529
},
11530+
"v1.TestWechatConfigurationReqV1": {
11531+
"type": "object",
11532+
"properties": {
11533+
"wechat_id": {
11534+
"type": "string"
11535+
}
11536+
}
11537+
},
1151911538
"v1.TimeResV1": {
1152011539
"type": "object",
1152111540
"properties": {
@@ -11785,9 +11804,6 @@ var doc = `{
1178511804
},
1178611805
"is_wechat_notification_enabled": {
1178711806
"type": "boolean"
11788-
},
11789-
"template_id": {
11790-
"type": "string"
1179111807
}
1179211808
}
1179311809
},
@@ -11852,9 +11868,6 @@ var doc = `{
1185211868
},
1185311869
"is_wechat_notification_enabled": {
1185411870
"type": "boolean"
11855-
},
11856-
"template_id": {
11857-
"type": "string"
1185811871
}
1185911872
}
1186011873
},

sqle/docs/swagger.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,17 @@
606606
],
607607
"summary": "测试微信审批配置",
608608
"operationId": "testWechatAuditConfigV1",
609+
"parameters": [
610+
{
611+
"description": "test wechat configuration req",
612+
"name": "req",
613+
"in": "body",
614+
"required": true,
615+
"schema": {
616+
"$ref": "#/definitions/v1.TestWechatConfigurationReqV1"
617+
}
618+
}
619+
],
609620
"responses": {
610621
"200": {
611622
"description": "OK",
@@ -11500,6 +11511,14 @@
1150011511
}
1150111512
}
1150211513
},
11514+
"v1.TestWechatConfigurationReqV1": {
11515+
"type": "object",
11516+
"properties": {
11517+
"wechat_id": {
11518+
"type": "string"
11519+
}
11520+
}
11521+
},
1150311522
"v1.TimeResV1": {
1150411523
"type": "object",
1150511524
"properties": {
@@ -11769,9 +11788,6 @@
1176911788
},
1177011789
"is_wechat_notification_enabled": {
1177111790
"type": "boolean"
11772-
},
11773-
"template_id": {
11774-
"type": "string"
1177511791
}
1177611792
}
1177711793
},
@@ -11836,9 +11852,6 @@
1183611852
},
1183711853
"is_wechat_notification_enabled": {
1183811854
"type": "boolean"
11839-
},
11840-
"template_id": {
11841-
"type": "string"
1184211855
}
1184311856
}
1184411857
},

sqle/docs/swagger.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,11 @@ definitions:
26222622
example: ok
26232623
type: string
26242624
type: object
2625+
v1.TestWechatConfigurationReqV1:
2626+
properties:
2627+
wechat_id:
2628+
type: string
2629+
type: object
26252630
v1.TimeResV1:
26262631
properties:
26272632
hour:
@@ -2805,8 +2810,6 @@ definitions:
28052810
type: string
28062811
is_wechat_notification_enabled:
28072812
type: boolean
2808-
template_id:
2809-
type: string
28102813
required:
28112814
- is_wechat_notification_enabled
28122815
type: object
@@ -2851,8 +2854,6 @@ definitions:
28512854
type: string
28522855
is_wechat_notification_enabled:
28532856
type: boolean
2854-
template_id:
2855-
type: string
28562857
type: object
28572858
v1.WorkFlowStepTemplateReqV1:
28582859
properties:
@@ -4207,6 +4208,13 @@ paths:
42074208
- application/json
42084209
description: test wechat audit configuration
42094210
operationId: testWechatAuditConfigV1
4211+
parameters:
4212+
- description: test wechat configuration req
4213+
in: body
4214+
name: req
4215+
required: true
4216+
schema:
4217+
$ref: '#/definitions/v1.TestWechatConfigurationReqV1'
42104218
responses:
42114219
"200":
42124220
description: OK

sqle/model/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const (
100100
ImTypeDingTalk = "dingTalk"
101101
ImTypeFeishu = "feishu"
102102
ImTypeFeishuAudit = "feishu_audit"
103+
ImTypeWechatAudit = "wechat_audit"
103104
)
104105

105106
type IM struct {

sqle/pkg/im/im.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func CreateApprovalTemplate(imType string) {
4141
log.NewEntry().Errorf("create feishu audit template error: %v", err)
4242
return
4343
}
44+
case model.ImTypeWechatAudit:
45+
if err := CreateWechatAuditTemplate(context.TODO(), im); err != nil {
46+
log.NewEntry().Errorf("create wechat audit template error: %v", err)
47+
return
48+
}
4449
}
4550
}
4651

sqle/pkg/im/im_ce.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
var ErrCommunityEditionNotSupportFeishuAudit = e.New("community edition not support feishu audit")
1414
var ErrCommunityEditionNotSupportDingDingAudit = e.New("community edition not support dingding audit")
15+
var ErrCommunityEditionNotSupportWechatAudit = e.New("community edition not support wechat audit")
1516

1617
func CreateFeishuAuditTemplate(ctx context.Context, im model.IM) error {
1718
return ErrCommunityEditionNotSupportFeishuAudit
@@ -44,3 +45,7 @@ func UpdateDingdingAuditStatus(ctx context.Context, im model.IM, workflowId stri
4445
func CancelDingdingAuditInst(ctx context.Context, im model.IM, workflowIDs []string, user *model.User) error {
4546
return ErrCommunityEditionNotSupportDingDingAudit
4647
}
48+
49+
func CreateWechatAuditTemplate(ctx context.Context, im model.IM) error {
50+
return ErrCommunityEditionNotSupportWechatAudit
51+
}

0 commit comments

Comments
 (0)