diff --git a/app/http/entities/backend/app.go b/app/http/entities/backend/app.go index 2b8c8dd..b3b1939 100644 --- a/app/http/entities/backend/app.go +++ b/app/http/entities/backend/app.go @@ -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