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(),