fix
This commit is contained in:
parent
deed8bb14c
commit
1965692f0f
|
@ -21,9 +21,9 @@ type FsPreprocessLogo struct {
|
||||||
IsBranch *int64 `gorm:"default:0;" json:"is_branch"` // 是否分店
|
IsBranch *int64 `gorm:"default:0;" json:"is_branch"` // 是否分店
|
||||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||||
Source *string `gorm:"index;default:'';" json:"source"` //
|
Source *string `gorm:"index;default:'';" json:"source"` //
|
||||||
|
IsDel *int64 `gorm:"index;default:0;" json:"is_del"` // 是否删除
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
IsDel *int64 `gorm:"index;default:0;" json:"is_del"` // 是否删除
|
|
||||||
}
|
}
|
||||||
type FsPreprocessLogoModel struct {
|
type FsPreprocessLogoModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
|
|
@ -49,6 +49,7 @@ type AllModelsGen struct {
|
||||||
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
|
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
|
||||||
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
|
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
|
||||||
FsFaq *FsFaqModel // fs_faq 常见问题
|
FsFaq *FsFaqModel // fs_faq 常见问题
|
||||||
|
FsFeishuConfig *FsFeishuConfigModel // fs_feishu_config 飞书app配置表
|
||||||
FsFont *FsFontModel // fs_font 字体配置
|
FsFont *FsFontModel // fs_font 字体配置
|
||||||
FsGerent *FsGerentModel // fs_gerent 管理员表
|
FsGerent *FsGerentModel // fs_gerent 管理员表
|
||||||
FsGuest *FsGuestModel // fs_guest 游客表
|
FsGuest *FsGuestModel // fs_guest 游客表
|
||||||
|
@ -167,6 +168,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
||||||
FsFactoryProduct: NewFsFactoryProductModel(gdb),
|
FsFactoryProduct: NewFsFactoryProductModel(gdb),
|
||||||
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
|
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
|
||||||
FsFaq: NewFsFaqModel(gdb),
|
FsFaq: NewFsFaqModel(gdb),
|
||||||
|
FsFeishuConfig: NewFsFeishuConfigModel(gdb),
|
||||||
FsFont: NewFsFontModel(gdb),
|
FsFont: NewFsFontModel(gdb),
|
||||||
FsGerent: NewFsGerentModel(gdb),
|
FsGerent: NewFsGerentModel(gdb),
|
||||||
FsGuest: NewFsGuestModel(gdb),
|
FsGuest: NewFsGuestModel(gdb),
|
||||||
|
|
|
@ -14,8 +14,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/api/feishu/ticket_webhook",
|
Path: "/api/feishu/webhook",
|
||||||
Handler: TicketWebhookHandler(serverCtx),
|
Handler: WebhookHandler(serverCtx),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package handler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
|
|
||||||
"fusenapi/server/feishu-sync/internal/logic"
|
|
||||||
"fusenapi/server/feishu-sync/internal/svc"
|
|
||||||
"fusenapi/server/feishu-sync/internal/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TicketWebhookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
var req types.TicketWebhookReq
|
|
||||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//验证连接
|
|
||||||
if req.Type == "url_verification" {
|
|
||||||
challengeRsp := map[string]string{
|
|
||||||
"challenge": req.Challenge,
|
|
||||||
}
|
|
||||||
b, _ := json.Marshal(challengeRsp)
|
|
||||||
w.Write(b)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 创建一个业务逻辑层实例
|
|
||||||
l := logic.NewTicketWebhookLogic(r.Context(), svcCtx)
|
|
||||||
|
|
||||||
rl := reflect.ValueOf(l)
|
|
||||||
basic.BeforeLogic(w, r, rl)
|
|
||||||
|
|
||||||
resp := l.TicketWebhook(&req, userinfo, w)
|
|
||||||
|
|
||||||
if !basic.AfterLogic(w, r, rl, resp) {
|
|
||||||
basic.NormalAfterLogic(w, r, resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package logic
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fusenapi/utils/auth"
|
|
||||||
"fusenapi/utils/basic"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/feishu-sync/internal/svc"
|
|
||||||
"fusenapi/server/feishu-sync/internal/types"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TicketWebhookLogic struct {
|
|
||||||
logx.Logger
|
|
||||||
ctx context.Context
|
|
||||||
svcCtx *svc.ServiceContext
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTicketWebhookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TicketWebhookLogic {
|
|
||||||
return &TicketWebhookLogic{
|
|
||||||
Logger: logx.WithContext(ctx),
|
|
||||||
ctx: ctx,
|
|
||||||
svcCtx: svcCtx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理进入前逻辑w,r
|
|
||||||
// func (l *TicketWebhookLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (l *TicketWebhookLogic) TicketWebhook(req *types.TicketWebhookReq, userinfo *auth.UserInfo, w http.ResponseWriter) (resp *basic.Response) {
|
|
||||||
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
|
||||||
// func (l *TicketWebhookLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
|
||||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
// }
|
|
|
@ -5,19 +5,13 @@ import (
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TicketWebhookReq struct {
|
type WebhookReq struct {
|
||||||
Ts string `json:"ts,optional"` //webhook时间
|
Ts string `json:"ts,optional"` //webhook时间
|
||||||
Uuid string `json:"uuid,optional"` //事件唯一标识
|
Uuid string `json:"uuid,optional"` //事件唯一标识
|
||||||
Token string `json:"token,optional"` //即Verification Token
|
Token string `json:"token,optional"` //即Verification Token
|
||||||
Event Event `json:"event,optional"` //事件
|
Event map[string]interface{} `json:"event,optional"` //事件
|
||||||
Challenge string `json:"challenge,optional"` //设置飞书通知接口验证用
|
Challenge string `json:"challenge,optional"` //设置飞书通知接口验证用
|
||||||
Type string `json:"type,optional"` //设置飞书通知接口验证用
|
Type string `json:"type,optional"` //设置飞书通知接口验证用
|
||||||
}
|
|
||||||
|
|
||||||
type Event struct {
|
|
||||||
AppId string `json:"app_id"`
|
|
||||||
AppTicket string `json:"app_ticket"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
|
|
|
@ -11,21 +11,15 @@ import "basic.api"
|
||||||
|
|
||||||
service feishu-sync {
|
service feishu-sync {
|
||||||
//飞书ticket webhook事件接口
|
//飞书ticket webhook事件接口
|
||||||
@handler TicketWebhookHandler
|
@handler WebhookHandler
|
||||||
post /api/feishu/ticket_webhook (TicketWebhookReq) returns (response);
|
post /api/feishu/webhook (WebhookReq) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
type TicketWebhookReq {
|
type WebhookReq {
|
||||||
Ts string `json:"ts,optional"` //webhook时间
|
Ts string `json:"ts,optional"` //webhook时间
|
||||||
Uuid string `json:"uuid,optional"` //事件唯一标识
|
Uuid string `json:"uuid,optional"` //事件唯一标识
|
||||||
Token string `json:"token,optional"` //即Verification Token
|
Token string `json:"token,optional"` //即Verification Token
|
||||||
Event Event `json:"event,optional"` //事件
|
Event map[string]interface{} `json:"event,optional"` //事件
|
||||||
Challenge string `json:"challenge,optional"` //设置飞书通知接口验证用
|
Challenge string `json:"challenge,optional"` //设置飞书通知接口验证用
|
||||||
Type string `json:"type,optional"` //设置飞书通知接口验证用
|
Type string `json:"type,optional"` //设置飞书通知接口验证用
|
||||||
}
|
|
||||||
|
|
||||||
type Event {
|
|
||||||
AppId string `json:"app_id"`
|
|
||||||
AppTicket string `json:"app_ticket"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user