fix
This commit is contained in:
57
server/feishu-sync/internal/logic/syncfeishugroupslogic.go
Normal file
57
server/feishu-sync/internal/logic/syncfeishugroupslogic.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/feishu"
|
||||
"log"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/feishu-sync/internal/svc"
|
||||
"fusenapi/server/feishu-sync/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type SyncFeiShuGroupsLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewSyncFeiShuGroupsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncFeiShuGroupsLogic {
|
||||
return &SyncFeiShuGroupsLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *SyncFeiShuGroupsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *SyncFeiShuGroupsLogic) SyncFeiShuGroups(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
feishuApi := &feishu.FeiShuApi{
|
||||
AppId: l.svcCtx.Config.FeiShu.AppId,
|
||||
AppSecret: l.svcCtx.Config.FeiShu.AppSecret,
|
||||
ApiHost: l.svcCtx.Config.FeiShu.ApiHost,
|
||||
}
|
||||
token, err := feishuApi.GetTenantAccessToken()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
users, err := feishuApi.FindUsersByDepartment(token.TenantAccessToken)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
fmt.Println(users)
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *SyncFeiShuGroupsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
Reference in New Issue
Block a user