This commit is contained in:
jiangyong27 2025-01-08 12:53:00 +08:00
parent 566a03e1e3
commit 24b37e9299
2 changed files with 10 additions and 6 deletions

View File

@ -23,13 +23,18 @@ type QyWeixin struct {
func (q *QyWeixin) Approve(ctx *gin.Context) { func (q *QyWeixin) Approve(ctx *gin.Context) {
cfg := config.GetConfig() cfg := config.GetConfig()
cid := cast.ToInt64(ctx.Param("cid")) 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 reply := approve.Reply
qyApp := qyweixin.NewApp(&qyweixin.AppConfig{ qyApp := qyweixin.NewApp(&qyweixin.AppConfig{
Corpid: cfg.QyWeixin.Corpid, Corpid: corpConfig.CorpId,
Secret: cfg.QyWeixin.ApproveSecret, Secret: corpConfig.ApproveSecret,
Agent: cfg.QyWeixin.ApproveAgent, Agent: corpConfig.ApproveAgent,
Token: config.QyWeixinAgentToken, Token: config.QyWeixinAgentToken,
AesKey: config.QyWeixinAgentAesKey, AesKey: config.QyWeixinAgentAesKey,
Replay: reply, Replay: reply,

View File

@ -32,8 +32,7 @@ type Approve struct {
approveClient *qyweixin.AppApprove approveClient *qyweixin.AppApprove
} }
func NewApprove(cid int64) *Approve { func NewApprove(corp *model.Corp) *Approve {
corp, _ := dao.NewCorpDao().Get(cid)
return &Approve{ return &Approve{
corp: corp, corp: corp,
corpConfig: corp.GetConfig(), corpConfig: corp.GetConfig(),