fix: admin database charset
This commit is contained in:
@@ -22,13 +22,22 @@ Nacos:
|
||||
RegisterIP: product
|
||||
|
||||
Mysql:
|
||||
Host: mysql
|
||||
Port: 3306
|
||||
# Host: mysql
|
||||
# Port: 3306
|
||||
# User: root
|
||||
# Password: "123123"
|
||||
# Database: dms-product
|
||||
# Charset: utf8mb4
|
||||
# Prefix:
|
||||
|
||||
Host: "39.106.171.204"
|
||||
Port: 33066
|
||||
User: root
|
||||
Password: "123123"
|
||||
Password: "MOLXRZNOU4Y4"
|
||||
Database: dms-product
|
||||
Charset: utf8mb4
|
||||
Prefix:
|
||||
|
||||
# ReadHost: mysql-slave
|
||||
# ReadPort: 3306
|
||||
# ReadUser: root
|
||||
|
||||
@@ -39,14 +39,14 @@ func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogi
|
||||
func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) {
|
||||
var req validator.ProductCreateValidator
|
||||
if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return msgResponse(utils.Ok.Code, msg), nil
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
if req.Type == dao.ProductTypeNormal {
|
||||
if req.AgentPrice == 0 || req.StorePrice == 0 ||
|
||||
req.SalePrice == 0 || req.SharePrice == 0 ||
|
||||
req.SaleReward == "" {
|
||||
return msgResponse(int32(utils.ErrorMissingParams.GetCode()), "缺少相关价格"), nil
|
||||
return outResponse(utils.ErrorParams, "缺少相关价格"), nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) {
|
||||
if len(req.PublishTime) > 1 {
|
||||
t, err := parsePublishTime(req.PublishTime)
|
||||
if err != nil {
|
||||
return msgResponse(int32(utils.ErrorMissingParams.GetCode()), "时间错误"), nil
|
||||
return outResponse(utils.ErrorParams, "时间错误"), nil
|
||||
}
|
||||
publishTime = t
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) {
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
if check.Id > 0 {
|
||||
return failResponse(utils.ErrorDataIsExist), nil
|
||||
return failErr(utils.ErrorDataIsExist), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic {
|
||||
func (l *InfoLogic) Info(in *product.InfoReq) (*product.Response, error) {
|
||||
var req validator.ProductInfoValidator
|
||||
if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return msgResponse(utils.Ok.Code, msg), nil
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
var info dao.ProductInfo
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemsLogic
|
||||
func (l *ItemsLogic) Items(in *product.ItemsReq) (*product.Response, error) {
|
||||
var req validator.ProductItemsValidator
|
||||
if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return msgResponse(utils.Ok.Code, msg), nil
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
page := int(req.Page)
|
||||
|
||||
@@ -14,16 +14,24 @@ func okResponse(data string) *product.Response {
|
||||
}
|
||||
}
|
||||
|
||||
func failResponse(err utils.Error) *product.Response {
|
||||
func failResponse(status utils.Status) *product.Response {
|
||||
return &product.Response{
|
||||
Code: status.Code,
|
||||
Msg: status.Msg,
|
||||
}
|
||||
}
|
||||
|
||||
func outResponse(status utils.Status, msg string) *product.Response {
|
||||
return &product.Response{
|
||||
Code: status.Code,
|
||||
Msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
// failErr 兼容仍返回 utils.Error 的旧错误码
|
||||
func failErr(err utils.Error) *product.Response {
|
||||
return &product.Response{
|
||||
Code: int32(err.GetCode()),
|
||||
Msg: err.GetMsg(),
|
||||
}
|
||||
}
|
||||
|
||||
func msgResponse(code int32, msg string) *product.Response {
|
||||
return &product.Response{
|
||||
Code: code,
|
||||
Msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewSortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SortLogic {
|
||||
func (l *SortLogic) Sort(in *product.SortReq) (*product.Response, error) {
|
||||
var req validator.ProductSortValidator
|
||||
if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return msgResponse(utils.Ok.Code, msg), nil
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
var info dao.ProductSort
|
||||
|
||||
@@ -35,11 +35,11 @@ func NewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatusLogi
|
||||
func (l *StatusLogic) Status(in *product.StatusReq) (*product.Response, error) {
|
||||
var req validator.ProductStatusValidator
|
||||
if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return msgResponse(utils.Ok.Code, msg), nil
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
if req.Status == uint32(dao.ProductStatusDisabled) && len(req.Reason) < 1 {
|
||||
return failResponse(utils.ErrorReasonParams), nil
|
||||
return failErr(utils.ErrorReasonParams), nil
|
||||
}
|
||||
|
||||
var info dao.ProductCheckExist
|
||||
|
||||
Reference in New Issue
Block a user