💥更换API文档,编写示例代码

This commit is contained in:
孙晓龙
2024-01-17 20:42:56 +08:00
parent 4d1b92e236
commit 919db2edeb
7 changed files with 2654 additions and 15 deletions

View File

@@ -7,6 +7,11 @@ func GetRemoteHost() (string, error) {
return remoteHost, err
}
func GetShopHost() (string, error) {
remoteHost, err := web.AppConfig.String("remoteHost")
return remoteHost, err
}
func GetRedisCfg() (RedisCfg, error) {
host, err := web.AppConfig.String("redis::host")
if err != nil {

16
controllers/download.go Normal file
View File

@@ -0,0 +1,16 @@
package controllers
import "merchant/sys/enum"
type DownloadController struct {
KeepSession
}
func (c *DownloadController) Code() {
ranMd5 := encrypt.EncodeMd5([]byte(pubMethod.RandomString(46)))
c.Ctx.SetCookie(enum.UserCookie, ranMd5, enum.CookieExpireTime)
c.Ctx.SetSecureCookie(ranMd5, enum.UserCookie, ranMd5, enum.CookieExpireTime)
_ = c.SetSession(enum.UserCookie, ranMd5)
c.Ctx.Output.Download(enum.CodePath, enum.CodeName)
}

View File

@@ -154,14 +154,23 @@ func (c *Login) PayDoc() {
u := us.(merchant.MerchantInfo)
remoteHost, err := config.GetRemoteHost()
if err != nil {
c.Data["errorMsg"] = "获取文档出错!"
c.TplName = "error.html"
} else {
c.Data["remoteHost"] = remoteHost
c.Data["payKey"] = u.MerchantKey
c.Data["paySecret"] = u.MerchantSecret
c.TplName = "api_doc/pay_doc.html"
return
}
shopHost, err := config.GetShopHost()
if err != nil {
c.Data["errorMsg"] = "获取文档出错!"
c.TplName = "error.html"
return
}
c.Data["shopHost"] = shopHost
c.Data["remoteHost"] = remoteHost
c.Data["payKey"] = u.MerchantKey
c.Data["paySecret"] = u.MerchantSecret
c.TplName = "api_doc/pay_doc_v2.html"
}

View File

@@ -59,4 +59,7 @@ func init() {
beego.Router("/withdraw/list_record/?:params", &controllers.Withdraw{}, "*:WithdrawQueryAndListPage")
beego.Router("/gen_link/gen_link", &controllers.GenLink{}, "*:ShowGenLinkUI")
beego.Router("/download/code", &controllers.DownloadController{}, "*:Code")
}

BIN
static/code/demo.zip Normal file

Binary file not shown.

View File

@@ -1,12 +1,3 @@
/***************************************************
** @Desc : This file for 系统常量
** @Time : 19.11.30 11:28
** @Author : Joker
** @File : constant
** @Last Modified by : Joker
** @Last Modified time: 19.11.30 11:28
** @Software: GoLand
****************************************************/
package enum
const (
@@ -23,4 +14,7 @@ const (
ExcelModelPath = "static/excel/batch_daifa_template.xlsx"
ExcelPath = "static/excel/temp/"
ExcelDownloadPath = "static/excel/download/"
CodePath = "static/code/demo.zip"
CodeName = "code.zip"
)

File diff suppressed because it is too large Load Diff