-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b94a78
commit 59adc14
Showing
17 changed files
with
448 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "SCRM基础接口" | ||
desc: "公共管理" | ||
author: "YourName" | ||
email: "[email protected]" | ||
) | ||
|
||
@server( | ||
group: admin/scrm/common | ||
prefix: /api/v1/admin/scrm/common | ||
) | ||
|
||
service PowerX { | ||
@doc "[Public] SCRM是否可用" | ||
@handler AvailabilityCheck | ||
post /availability-check | ||
|
||
@doc "[Public] 获取SCRM通用选项" | ||
@handler GetOptions | ||
get /options (GetOptionsRequest) returns (GetOptionsReply) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "企业微信客户群发" | ||
desc: "企业微信客户群发" | ||
author: "Northseadl" | ||
email: "[email protected]" | ||
version: "v1" | ||
) | ||
|
||
@server( | ||
group: admin/scrm/operation | ||
prefix: /api/v1/admin/scrm/operation/group-send | ||
middleware: EmployeeJWTAuth | ||
) | ||
|
||
service PowerX { | ||
@doc "企业微信客户群发" | ||
@handler GroupSend | ||
post /group-send (GroupSendRequest) | ||
|
||
@doc "获取企业群发记录" | ||
@handler ListGroupSendLog | ||
get /group-send-log (ListGroupSendLogRequest) returns(ListGroupSendLogReply) | ||
} | ||
|
||
type ( | ||
GroupSendText { | ||
Content string `json:"content"` | ||
} | ||
|
||
GroupSendRequest { | ||
ChatType string `json:"chatType"` | ||
ExternalUserIds []string `json:"userIds"` | ||
Text GroupSendText `json:"text"` | ||
} | ||
|
||
ListGroupSendLogRequest { | ||
Limit int `json:"limit"` | ||
Cursor string `json:"cursor"` | ||
ChatType string `json:"chatType"` | ||
StartTime string `json:"startTime"` | ||
EndTime string `json:"EndTime"` | ||
Creator string `json:"creator"` | ||
} | ||
|
||
WeWorkSendList { | ||
ExternalUserID string `json:"externalUserid"` | ||
ChatID string `json:"chat_id"` | ||
UserID string `json:"userid"` | ||
Status int `json:"status"` | ||
} | ||
|
||
ListGroupSendLogReply { | ||
NextCursor string `json:"nextCursor"` | ||
SendList []WeWorkSendList `json:"sendList"` | ||
} | ||
) |
21 changes: 21 additions & 0 deletions
21
internal/handler/admin/scrm/common/availabilitycheckhandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package common | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/scrm/common" | ||
"PowerX/internal/svc" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func AvailabilityCheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
l := common.NewAvailabilityCheckLogic(r.Context(), svcCtx) | ||
err := l.AvailabilityCheck() | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.Ok(w) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package common | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/scrm/common" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func GetOptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.GetOptionsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := common.NewGetOptionsLogic(r.Context(), svcCtx) | ||
resp, err := l.GetOptions(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package operation | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/scrm/operation" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func GroupSendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.GroupSendRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := operation.NewGroupSendLogic(r.Context(), svcCtx) | ||
err := l.GroupSend(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.Ok(w) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/scrm/operation/listgroupsendloghandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package operation | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/scrm/operation" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func ListGroupSendLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.ListGroupSendLogRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := operation.NewListGroupSendLogLogic(r.Context(), svcCtx) | ||
resp, err := l.ListGroupSendLog(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
internal/logic/admin/scrm/common/availabilitychecklogic.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
|
||
"PowerX/internal/svc" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type AvailabilityCheckLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewAvailabilityCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AvailabilityCheckLogic { | ||
return &AvailabilityCheckLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *AvailabilityCheckLogic) AvailabilityCheck() (err error) { | ||
if err = l.svcCtx.PowerX.SCRM.AvailabilityCheck(); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"PowerX/internal/uc/powerx/scrm/wechat" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type GetOptionsLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewGetOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOptionsLogic { | ||
return &GetOptionsLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *GetOptionsLogic) GetOptions(req *types.GetOptionsRequest) (resp *types.GetOptionsReply, err error) { | ||
switch req.Type { | ||
case "customer-external": | ||
result, err := l.svcCtx.PowerX.SCRM.Wechat.FindManyWeWorkCustomerPage(l.ctx, &types.PageOption[wechat.FindManyWechatCustomerOption]{ | ||
PageIndex: 1, | ||
PageSize: 10, | ||
Option: wechat.FindManyWechatCustomerOption{ | ||
Name: req.Search, | ||
}, | ||
}, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
options := make([]map[string]any, len(result.List)) | ||
for i, v := range result.List { | ||
options[i] = map[string]any{ | ||
"label": v.Name, | ||
"value": v.ExternalUserId, | ||
} | ||
} | ||
resp.Options = options | ||
default: | ||
err = fmt.Errorf("invalid type: %s", req.Type) | ||
} | ||
return resp, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package operation | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/externalContact/messageTemplate/request" | ||
|
||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type GroupSendLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewGroupSendLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupSendLogic { | ||
return &GroupSendLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *GroupSendLogic) GroupSend(req *types.GroupSendRequest) error { | ||
result, err := l.svcCtx.PowerX.SCRM.Wework.ExternalContactMessageTemplate.AddMsgTemplate(l.ctx, &request.RequestAddMsgTemplate{ | ||
ChatType: "single", | ||
ExternalUserID: req.ExternalUserIds, | ||
Text: &request.TextOfMessage{ | ||
Content: req.Text.Content, | ||
}, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
if result.ErrCode != 0 { | ||
return fmt.Errorf("errcode: %d, errmsg: %s", result.ErrCode, result.ErrMsg) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.