增加了app的配置文件
This commit is contained in:
parent
63ab3fc50c
commit
4f47c2922e
@ -70,3 +70,10 @@ amqp:
|
|||||||
user: gdxz_2022rabbitmq
|
user: gdxz_2022rabbitmq
|
||||||
password: qwr2p&¥e@3.2p
|
password: qwr2p&¥e@3.2p
|
||||||
vhost: gdxz_hepa
|
vhost: gdxz_hepa
|
||||||
|
|
||||||
|
# [app]
|
||||||
|
app:
|
||||||
|
apiUrl: https://dev-wx.igandan.com
|
||||||
|
secretKey: RY8pcn04#TSdzHVX6YgWnyCue9!T&QP^
|
||||||
|
imagePrefix: https://dev-doc.igandan.com/app
|
||||||
|
platform: suanyisuan
|
||||||
8
config/app.go
Normal file
8
config/app.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
type App struct {
|
||||||
|
ApiUrl string `mapstructure:"apiUrl" json:"apiUrl" yaml:"apiUrl"`
|
||||||
|
SecretKey string `mapstructure:"secretKey" json:"secretKey" yaml:"secretKey"`
|
||||||
|
ImagePrefix string `mapstructure:"imagePrefix" json:"imagePrefix" yaml:"imagePrefix"`
|
||||||
|
Platform string `mapstructure:"platform" json:"platform" yaml:"platform"`
|
||||||
|
}
|
||||||
@ -14,4 +14,5 @@ type Config struct {
|
|||||||
Dysms Dysms `mapstructure:"dysms" json:"dysms" yaml:"dysms"`
|
Dysms Dysms `mapstructure:"dysms" json:"dysms" yaml:"dysms"`
|
||||||
Wechat Wechat `mapstructure:"wechat" json:"wechat" yaml:"wechat"`
|
Wechat Wechat `mapstructure:"wechat" json:"wechat" yaml:"wechat"`
|
||||||
Amqp Amqp `mapstructure:"amqp" json:"amqp" yaml:"amqp"`
|
Amqp Amqp `mapstructure:"amqp" json:"amqp" yaml:"amqp"`
|
||||||
|
App App `mapstructure:"app" json:"app" yaml:"app"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,13 +8,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
//const (
|
||||||
apiUrl = "https://dev-wx.igandan.com" // 接口地址
|
// apiUrl = "https://dev-wx.igandan.com" // 接口地址
|
||||||
secretKey = "RY8pcn04#TSdzHVX6YgWnyCue9!T&QP^" // 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
|
// secretKey = "RY8pcn04#TSdzHVX6YgWnyCue9!T&QP^" // 产品私有密钥,服务端生成签名信息使用,请严格保管,避免泄露
|
||||||
platform = "suanyisuan" // 所属平台
|
// platform = "suanyisuan" // 所属平台
|
||||||
devImagePrefix = "https://dev-doc.igandan.com/app" // 测试环境图片地址前缀
|
// imagePrefix = "https://dev-doc.igandan.com/app" // 图片地址前缀
|
||||||
prodImagePrefix = "https://dev-doc.igandan.com/app" // 正式环境图片地址前缀
|
//)
|
||||||
)
|
|
||||||
|
|
||||||
// GenSignature 生成签名信息
|
// GenSignature 生成签名信息
|
||||||
func GenSignature(params map[string]interface{}) (string, error) {
|
func GenSignature(params map[string]interface{}) (string, error) {
|
||||||
@ -27,7 +26,7 @@ func GenSignature(params map[string]interface{}) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
sing := utils.HmacSHA256(string(jsonData), secretKey)
|
sing := utils.HmacSHA256(string(jsonData), config.C.App.SecretKey)
|
||||||
return sing, nil
|
return sing, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,12 +76,7 @@ func HandleImagePrefix(u string) (string, error) {
|
|||||||
// 去除oss前缀
|
// 去除oss前缀
|
||||||
u = utils.RemoveOssDomain(u)
|
u = utils.RemoveOssDomain(u)
|
||||||
|
|
||||||
var imgPath string
|
imgPath := strings.Replace(u, config.C.App.ImagePrefix, "", 1)
|
||||||
if config.C.Env == "prod" {
|
|
||||||
imgPath = strings.Replace(u, devImagePrefix, "", 1)
|
|
||||||
} else {
|
|
||||||
imgPath = strings.Replace(u, prodImagePrefix, "", 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if imgPath == "/null" {
|
if imgPath == "/null" {
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"hepa-calc-api/config"
|
||||||
"hepa-calc-api/utils"
|
"hepa-calc-api/utils"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -84,7 +85,7 @@ func GetUserCaseByAppIden(appIden string) (g *GetUserCaseByAppIdenResponse, err
|
|||||||
// 准备要发送的 JSON 数据
|
// 准备要发送的 JSON 数据
|
||||||
requestData := GetUserCaseByAppIdenRequest{
|
requestData := GetUserCaseByAppIdenRequest{
|
||||||
PatientUuid: appIden,
|
PatientUuid: appIden,
|
||||||
Platform: platform,
|
Platform: config.C.App.Platform,
|
||||||
Timestamp: strconv.FormatInt(time.Now().Unix(), 10),
|
Timestamp: strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ func GetUserCaseByAppIden(appIden string) (g *GetUserCaseByAppIdenResponse, err
|
|||||||
requestBody := bytes.NewBuffer(jsonData)
|
requestBody := bytes.NewBuffer(jsonData)
|
||||||
|
|
||||||
// 设置请求 URL
|
// 设置请求 URL
|
||||||
url := apiUrl + "/patient-api/getDiseaseInfo"
|
url := config.C.App.ApiUrl + "/patient-api/getDiseaseInfo"
|
||||||
|
|
||||||
// 创建 POST 请求
|
// 创建 POST 请求
|
||||||
req, err := http.NewRequest("POST", url, requestBody)
|
req, err := http.NewRequest("POST", url, requestBody)
|
||||||
@ -164,7 +165,7 @@ func GetUserCaseByAppIden(appIden string) (g *GetUserCaseByAppIdenResponse, err
|
|||||||
|
|
||||||
// UpdateUserCase 修改用户病例
|
// UpdateUserCase 修改用户病例
|
||||||
func UpdateUserCase(reqData UpdateUserCaseRequest) (g *UpdateUserCaseResponse, err error) {
|
func UpdateUserCase(reqData UpdateUserCaseRequest) (g *UpdateUserCaseResponse, err error) {
|
||||||
reqData.Platform = platform
|
reqData.Platform = config.C.App.Platform
|
||||||
reqData.Timestamp = strconv.FormatInt(time.Now().Unix(), 10)
|
reqData.Timestamp = strconv.FormatInt(time.Now().Unix(), 10)
|
||||||
|
|
||||||
// 将 JSON 数据编码为字节数组
|
// 将 JSON 数据编码为字节数组
|
||||||
@ -189,7 +190,7 @@ func UpdateUserCase(reqData UpdateUserCaseRequest) (g *UpdateUserCaseResponse, e
|
|||||||
requestBody := bytes.NewBuffer(jsonData)
|
requestBody := bytes.NewBuffer(jsonData)
|
||||||
|
|
||||||
// 设置请求 URL
|
// 设置请求 URL
|
||||||
url := apiUrl + "/patient-api/upDiseaseInfo"
|
url := config.C.App.ApiUrl + "/patient-api/upDiseaseInfo"
|
||||||
|
|
||||||
// 创建 POST 请求
|
// 创建 POST 请求
|
||||||
req, err := http.NewRequest("POST", url, requestBody)
|
req, err := http.NewRequest("POST", url, requestBody)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"hepa-calc-api/config"
|
||||||
"hepa-calc-api/utils"
|
"hepa-calc-api/utils"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -81,7 +82,7 @@ func GetInfoByMobile(mobile string) (g *GetInfoByMobileResponse, err error) {
|
|||||||
// 准备要发送的 JSON 数据
|
// 准备要发送的 JSON 数据
|
||||||
requestData := GetInfoByMobileRequest{
|
requestData := GetInfoByMobileRequest{
|
||||||
Mobile: mobile,
|
Mobile: mobile,
|
||||||
Platform: platform,
|
Platform: config.C.App.Platform,
|
||||||
Timestamp: strconv.FormatInt(time.Now().Unix(), 10),
|
Timestamp: strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +108,7 @@ func GetInfoByMobile(mobile string) (g *GetInfoByMobileResponse, err error) {
|
|||||||
requestBody := bytes.NewBuffer(jsonData)
|
requestBody := bytes.NewBuffer(jsonData)
|
||||||
|
|
||||||
// 设置请求 URL
|
// 设置请求 URL
|
||||||
url := apiUrl + "/patient-api/getInfo"
|
url := config.C.App.ApiUrl + "/patient-api/getInfo"
|
||||||
|
|
||||||
// 创建 POST 请求
|
// 创建 POST 请求
|
||||||
req, err := http.NewRequest("POST", url, requestBody)
|
req, err := http.NewRequest("POST", url, requestBody)
|
||||||
@ -161,7 +162,7 @@ func GetInfoByMobile(mobile string) (g *GetInfoByMobileResponse, err error) {
|
|||||||
|
|
||||||
// UpdateInfo 修改用户信息
|
// UpdateInfo 修改用户信息
|
||||||
func UpdateInfo(reqData UpdateInfoRequest) (g *UpdateInfoResponse, err error) {
|
func UpdateInfo(reqData UpdateInfoRequest) (g *UpdateInfoResponse, err error) {
|
||||||
reqData.Platform = platform
|
reqData.Platform = config.C.App.Platform
|
||||||
reqData.Timestamp = strconv.FormatInt(time.Now().Unix(), 10)
|
reqData.Timestamp = strconv.FormatInt(time.Now().Unix(), 10)
|
||||||
|
|
||||||
// 将 JSON 数据编码为字节数组
|
// 将 JSON 数据编码为字节数组
|
||||||
@ -186,7 +187,7 @@ func UpdateInfo(reqData UpdateInfoRequest) (g *UpdateInfoResponse, err error) {
|
|||||||
requestBody := bytes.NewBuffer(jsonData)
|
requestBody := bytes.NewBuffer(jsonData)
|
||||||
|
|
||||||
// 设置请求 URL
|
// 设置请求 URL
|
||||||
url := apiUrl + "/patient-api/updateInfo"
|
url := config.C.App.ApiUrl + "/patient-api/updateInfo"
|
||||||
|
|
||||||
// 创建 POST 请求
|
// 创建 POST 请求
|
||||||
req, err := http.NewRequest("POST", url, requestBody)
|
req, err := http.NewRequest("POST", url, requestBody)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user