后台,应用加密取消必填

This commit is contained in:
wolter 2024-08-12 18:27:22 +08:00
parent 45bc1e9cf0
commit 54a93ef082
1 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package backend
import (
"PaymentCenter/app/constants/pojo"
"PaymentCenter/app/http/entities"
"PaymentCenter/app/models/appmodel"
"errors"
@ -49,11 +50,11 @@ type AppCreateRequest struct {
AppRemark string `json:"app_remark" label:"应用备注"`
Status int32 `json:"status" validate:"oneof=0 1 2" label:"应用状态"`
KeyType int32 `json:"key_type" label:"应用密钥类型"`
PublicKey string `json:"public_key" validate:"required" label:"应用公钥"`
PrivateKey string `json:"private_key" validate:"required" label:"应用私钥"`
PublicKey string `json:"public_key" label:"应用公钥"`
PrivateKey string `json:"private_key" label:"应用私钥"`
MerchantPublicKey string `json:"merchant_public_key" label:"商户公钥"`
WhiteIp string `json:"white_ip"`
NotifyUrl string `json:"notify_url" validate:"required" label:"通知地址"`
NotifyUrl string `json:"notify_url" label:"通知地址"`
}
func (a *AppCreateRequest) RequestToDb() (db appmodel.App, err error) {
@ -64,6 +65,10 @@ func (a *AppCreateRequest) RequestToDb() (db appmodel.App, err error) {
db.AppRemark = a.AppRemark
db.Status = a.Status
db.KeyType = a.KeyType
if a.KeyType != pojo.NO_CRYPT && (a.PublicKey == "" || a.PrivateKey == "") {
err = errors.New("请填写密钥")
return
}
db.PublicKey = a.PublicKey
db.PrivateKey = a.PrivateKey
db.MerchantPublicKey = a.MerchantPublicKey