💥更换API文档,编写示例代码
This commit is contained in:
@@ -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
16
controllers/download.go
Normal 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)
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
}
|
||||
|
||||
@@ -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
BIN
static/code/demo.zip
Normal file
Binary file not shown.
@@ -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"
|
||||
)
|
||||
|
||||
2612
views/api_doc/pay_doc_v2.html
Normal file
2612
views/api_doc/pay_doc_v2.html
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user