From 24b37e929995da36a9a4020d10fce7ff9308bf0d Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Wed, 8 Jan 2025 12:53:00 +0800 Subject: [PATCH] config --- server/controller/qyweixin.go | 13 +++++++++---- server/service/qyweixin_approve.go | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/server/controller/qyweixin.go b/server/controller/qyweixin.go index a7d3935..a83666a 100644 --- a/server/controller/qyweixin.go +++ b/server/controller/qyweixin.go @@ -23,13 +23,18 @@ type QyWeixin struct { func (q *QyWeixin) Approve(ctx *gin.Context) { cfg := config.GetConfig() cid := cast.ToInt64(ctx.Param("cid")) + corp, err := dao.NewCorpDao().Get(cid) + if err != nil || corp == nil { + panic(config.ErrParam.New().Append(err)) + } - approve := service.NewApprove(cid) + corpConfig := corp.GetConfig() + approve := service.NewApprove(corp) reply := approve.Reply qyApp := qyweixin.NewApp(&qyweixin.AppConfig{ - Corpid: cfg.QyWeixin.Corpid, - Secret: cfg.QyWeixin.ApproveSecret, - Agent: cfg.QyWeixin.ApproveAgent, + Corpid: corpConfig.CorpId, + Secret: corpConfig.ApproveSecret, + Agent: corpConfig.ApproveAgent, Token: config.QyWeixinAgentToken, AesKey: config.QyWeixinAgentAesKey, Replay: reply, diff --git a/server/service/qyweixin_approve.go b/server/service/qyweixin_approve.go index 1654335..8564354 100644 --- a/server/service/qyweixin_approve.go +++ b/server/service/qyweixin_approve.go @@ -32,8 +32,7 @@ type Approve struct { approveClient *qyweixin.AppApprove } -func NewApprove(cid int64) *Approve { - corp, _ := dao.NewCorpDao().Get(cid) +func NewApprove(corp *model.Corp) *Approve { return &Approve{ corp: corp, corpConfig: corp.GetConfig(),