fix: admin database charset
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v4.25.8
|
||||
// protoc v3.19.4
|
||||
// source: proto/admin.proto
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||
@@ -514,7 +515,7 @@ var File_proto_admin_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_proto_admin_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x11proto/admin.proto\x12\x05admin\x1a\x19google/protobuf/any.proto\"\xac\x01\n" +
|
||||
"\x11proto/admin.proto\x12\x05admin\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/api/annotations.proto\"\xac\x01\n" +
|
||||
"\x10AdminEditRequest\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x1a\n" +
|
||||
@@ -547,9 +548,9 @@ const file_proto_admin_proto_rawDesc = "" +
|
||||
"\x06status\x18\a \x01(\x05R\x06status\"K\n" +
|
||||
"\x11AdminLoginRequest\x12\x1a\n" +
|
||||
"\busername\x18\x01 \x01(\x05R\busername\x12\x1a\n" +
|
||||
"\bpassword\x18\x02 \x01(\x05R\bpassword2\xc3\x03\n" +
|
||||
"\x05Admin\x124\n" +
|
||||
"\bAdminAdd\x12\x17.admin.AdminEditRequest\x1a\x0f.admin.Response\x125\n" +
|
||||
"\bpassword\x18\x02 \x01(\x05R\bpassword2\xe3\x03\n" +
|
||||
"\x05Admin\x12T\n" +
|
||||
"\bAdminAdd\x12\x17.admin.AdminEditRequest\x1a\x0f.admin.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/admin/v3/admin/add\x125\n" +
|
||||
"\tAdminEdit\x12\x17.admin.AdminEditRequest\x1a\x0f.admin.Response\x124\n" +
|
||||
"\vAdminStatus\x12\x14.admin.StatusRequest\x1a\x0f.admin.Response\x123\n" +
|
||||
"\bPassword\x12\x16.admin.PasswordRequest\x1a\x0f.admin.Response\x129\n" +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc v4.25.8
|
||||
// - protoc v3.19.4
|
||||
// source: proto/admin.proto
|
||||
|
||||
package admin
|
||||
|
||||
@@ -4,6 +4,7 @@ package admin;
|
||||
option go_package="./admin";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
message AdminEditRequest {
|
||||
int64 id = 1;
|
||||
@@ -15,6 +16,7 @@ message AdminEditRequest {
|
||||
repeated int64 roles = 7;
|
||||
}
|
||||
|
||||
|
||||
message StatusRequest {
|
||||
int64 id = 1 ;
|
||||
int32 status = 2 ;
|
||||
@@ -55,7 +57,13 @@ message AdminLoginRequest {
|
||||
}
|
||||
|
||||
service Admin {
|
||||
rpc AdminAdd(AdminEditRequest) returns(Response);
|
||||
rpc AdminAdd(AdminEditRequest) returns(Response){
|
||||
option (google.api.http) = {
|
||||
post: "/admin/v3/admin/add"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
|
||||
rpc AdminEdit(AdminEditRequest) returns(Response);
|
||||
rpc AdminStatus(StatusRequest) returns(Response);
|
||||
rpc Password(PasswordRequest) returns(Response);
|
||||
|
||||
Binary file not shown.
+1
-10
@@ -20,19 +20,10 @@ Upstreams:
|
||||
Timeout: 5000
|
||||
ProtoSets:
|
||||
- etc/product.pb
|
||||
|
||||
- Name: admin
|
||||
Grpc:
|
||||
Target: admin-service
|
||||
Timeout: 5000
|
||||
ProtoSets:
|
||||
- etc/admin.pb
|
||||
Mappings:
|
||||
- Method: post
|
||||
Path: /admin/v3/admin/add
|
||||
RpcPath: admin.Admin/Add
|
||||
- Method: post
|
||||
Path: /admin/v3/admin/edit
|
||||
RpcPath: admin.Admin/Edit
|
||||
- Method: post
|
||||
Path: /admin/v3/admin/status
|
||||
RpcPath: admin.Admin/Status
|
||||
@@ -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