This commit is contained in:
AstarF 2024-07-15 15:45:09 +08:00
parent 1a4131c938
commit 0fb8e9d077
5 changed files with 17 additions and 17 deletions

View File

@ -98,8 +98,8 @@ func Create(c *gin.Context) {
}
merchant := &merMod.Merchant{
Name: request.Name,
Key: request.Key,
Name: request.Name,
PrivateKey: request.PrivateKey,
}
affected, err := merServ.Create(merchant)
@ -124,9 +124,9 @@ func Update(c *gin.Context) {
}
merchant := &merMod.Merchant{
Id: request.Id,
Name: request.Name,
Key: request.Key,
Id: request.Id,
Name: request.Name,
PrivateKey: request.PrivateKey,
}
affected, err := merServ.Update(merchant)

View File

@ -25,8 +25,8 @@ type SearchResp struct {
}
type CreateReq struct {
Name string `json:"name" validate:"required"`
Key string `json:"key" validate:"required"`
Name string `json:"name" validate:"required"`
PrivateKey string `json:"private_key" validate:"required"`
}
type CreateResp struct {
@ -34,9 +34,9 @@ type CreateResp struct {
}
type UpdateReq struct {
Id int64 `json:"id" validate:"required"`
Name string `json:"name"`
Key string `json:"key"`
Id int64 `json:"id" validate:"required"`
Name string `json:"name"`
PrivateKey string `json:"private_key"`
}
type UpdateResp struct {

View File

@ -81,7 +81,7 @@ func VerifySign() gin.HandlerFunc {
return
}
//验证签名是否正确
hash := GenMD5Sign(data, merchant.Key)
hash := GenMD5Sign(data, merchant.PrivateKey)
logger.Info(c, "Sign", hash)
if hash != data["sign"] {
common.Error(c, 400, "签名错误")

View File

@ -16,10 +16,10 @@ var (
* Merchant
*/
type Merchant struct {
Id int64 `xorm:"pk autoincr"` //注使用getOne 或者ID() 需要设置主键
Name string
Key string
CreatedAt time.Time `xorm:"created"`
Id int64 `xorm:"pk autoincr"` //注使用getOne 或者ID() 需要设置主键
Name string
PrivateKey string
CreatedAt time.Time `xorm:"created"`
}
/**

View File

@ -1,7 +1,7 @@
create table merchant (
id int primary key auto_increment,
name varchar(255) not null,
key varchar(255),
private_key varchar(255),
created_at timestamp default current_timestamp
);
@ -20,7 +20,7 @@ create table orders (
status tinyint,
transfer_status tinyint,
created_at timestamp default current_timestamp,
created_at timestamp default current_timestamp
);
create table whitelist (