feat:新增商户列表/保存用户信息
This commit is contained in:
26
utils/validate/user_info.go
Normal file
26
utils/validate/user_info.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type MerchantCategory struct {
|
||||
CategoryId int64 `json:"category_id"`
|
||||
}
|
||||
|
||||
func Validate(module *string, metadata *string) (interface{}, error) {
|
||||
if *module == "merchant_category" {
|
||||
var merchantCategory MerchantCategory
|
||||
err := json.Unmarshal([]byte(*metadata), &merchantCategory)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
if merchantCategory.CategoryId == 0 {
|
||||
return nil, errors.New("merchant_category.category_id is required")
|
||||
}
|
||||
return merchantCategory, nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user