后台,密钥对和api接口对应

This commit is contained in:
wolter 2024-08-08 14:19:07 +08:00
parent 342a247c67
commit 627e1c852c
3 changed files with 15 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package backend
import (
"PaymentCenter/app/constants/errorcode"
"PaymentCenter/app/constants/pojo"
"PaymentCenter/app/http/controllers"
"PaymentCenter/app/http/entities"
"PaymentCenter/app/http/entities/backend"
@ -62,11 +63,11 @@ func GenerateDecrypt(c *gin.Context) {
var publicKey, privateKey string
var err error
switch req.KeyType {
case "sm2":
case pojo.SM2:
publicKey, privateKey, err = sm2.GenerateSM2Key()
case "rsa":
case pojo.RSA:
publicKey, privateKey, err = rsa.GenerateKey()
case "sm4":
case pojo.SM4:
privateKey, publicKey = sm4.GenerateKey()
default:
controllers.HandCodeRes(c, "", errorcode.EncryptTypeNotFound)

View File

@ -96,5 +96,5 @@ func (a *AppUpdateRequest) RequestToDb() (db appmodel.App) {
}
type GenerateDecryptKeyRequest struct {
KeyType string `json:"key_type" form:"key_type" label:"密钥类型"`
KeyType int32 `json:"key_type" form:"key_type" label:"密钥类型"`
}

View File

@ -27,8 +27,16 @@ func (p *PayChannelResponse) ResponseFromDb(db paychannelmodel.PayChannel) {
p.MerchantId = db.MerchantId
p.ChannelType = db.ChannelType
p.AppId = db.AppId
p.ExpireTime = db.ExpireTime.Format("2006-01-02 15:04:05")
p.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
if db.ExpireTime.IsZero() {
p.ExpireTime = ""
} else {
p.ExpireTime = db.ExpireTime.Format("2006-01-02 15:04:05")
}
if db.CreateTime.IsZero() {
p.CreateTime = ""
} else {
p.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
}
switch db.ChannelType {
case common.PAY_CHANNEL_WECHAT_H5, common.PAY_CHANNEL_WECHAT_JSAPI, common.PAY_CHANNEL_WECHAT_NATIVE, common.PAY_CHANNEL_WECHAT_APP, common.PAY_CHANNEL_WECHAT_MINI: