update admin
CI / changes (push) Successful in 14s
CI / docker-bff (push) Successful in 3s
CI / docker-product (push) Has been skipped
CI / docker-admin (push) Successful in 31s
CI / docker-user (push) Has been skipped
CI / docker-ad (push) Has been skipped
CI / docker-chore (push) Has been skipped
CI / docker-express (push) Has been skipped
CI / docker-sale (push) Successful in 24s

This commit is contained in:
2026-08-28 14:34:53 +08:00
parent 63b48941b9
commit a3d9238cea
8 changed files with 40 additions and 8 deletions
Binary file not shown.
+2
View File
@@ -12,6 +12,8 @@ message AdminEditRequest {
string phone = 5;
string email = 6;
repeated int64 roles = 7;
int32 type = 8;
int64 sale_id = 9;
}
message StatusRequest {
+20 -2
View File
@@ -31,6 +31,8 @@ type AdminEditRequest struct {
Phone string `protobuf:"bytes,5,opt,name=phone,proto3" json:"phone,omitempty"`
Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"`
Roles []int64 `protobuf:"varint,7,rep,packed,name=roles,proto3" json:"roles,omitempty"`
Type int32 `protobuf:"varint,8,opt,name=type,proto3" json:"type,omitempty"`
SaleId int64 `protobuf:"varint,9,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -114,6 +116,20 @@ func (x *AdminEditRequest) GetRoles() []int64 {
return nil
}
func (x *AdminEditRequest) GetType() int32 {
if x != nil {
return x.Type
}
return 0
}
func (x *AdminEditRequest) GetSaleId() int64 {
if x != nil {
return x.SaleId
}
return 0
}
type StatusRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
@@ -1422,7 +1438,7 @@ var File_admin_admin_proto protoreflect.FileDescriptor
const file_admin_admin_proto_rawDesc = "" +
"\n" +
"\x11admin/admin.proto\x12\x05admin\x1a\x1cgoogle/api/annotations.proto\"\xac\x01\n" +
"\x11admin/admin.proto\x12\x05admin\x1a\x1cgoogle/api/annotations.proto\"\xd9\x01\n" +
"\x10AdminEditRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x1a\n" +
@@ -1430,7 +1446,9 @@ const file_admin_admin_proto_rawDesc = "" +
"\x06avatar\x18\x04 \x01(\tR\x06avatar\x12\x14\n" +
"\x05phone\x18\x05 \x01(\tR\x05phone\x12\x14\n" +
"\x05email\x18\x06 \x01(\tR\x05email\x12\x14\n" +
"\x05roles\x18\a \x03(\x03R\x05roles\"O\n" +
"\x05roles\x18\a \x03(\x03R\x05roles\x12\x12\n" +
"\x04type\x18\b \x01(\x05R\x04type\x12\x17\n" +
"\asale_id\x18\t \x01(\x03R\x06saleId\"O\n" +
"\rStatusRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" +
"\x06status\x18\x02 \x01(\x05R\x06status\x12\x16\n" +
+4
View File
@@ -14,6 +14,8 @@ type Admin struct {
Salt string `gorm:"column:salt;type:char(5);comment:与密码混合搭配加密;NOT NULL" json:"salt"`
Roles string `gorm:"column:roles;type:varchar(255);comment:角色" json:"roles"`
Status uint8 `gorm:"column:status;type:tinyint(1);default:1;comment:状态,1为正常,2为禁用;NOT NULL" json:"status"`
Type uint8 `json:"type" gorm:"type"` // 1:销售,2:管理员
SaleId int64 `json:"sale_id" gorm:"sale_id"` // 销售ID
LastTime utils.CustomTime `gorm:"column:last_time;type:datetime;default:NULL;comment:最后一次登录时间" json:"last_time"`
FailNumber int `gorm:"column:fail_number;type:tinyint(2);default:0;comment:连续登录失败次数" json:"fail_number"`
Reason string `gorm:"column:reason;type:varchar(255);comment:原因" json:"reason"`
@@ -48,6 +50,8 @@ type AdminInfo struct {
Email string `gorm:"column:email;type:varchar(255);comment:邮箱" json:"email"`
Roles string `gorm:"column:roles;type:varchar(255);comment:角色" json:"roles"`
LastTime utils.CustomTime `gorm:"column:last_time;type:datetime;comment:最后一次登录时间" json:"last_time"`
Type uint8 `json:"type" gorm:"type"` // 1:销售,2:管理员
SaleId int64 `json:"sale_id" gorm:"sale_id"` // 销售ID
FailNumber int `gorm:"column:fail_number;type:tinyint(2);default:0;comment:连续登录失败次数" json:"fail_number"`
}
@@ -98,6 +98,8 @@ func (l *AdminEditLogic) AdminEdit(in *admin.AdminEditRequest) (*admin.Response,
info.Roles = strings.Join(roles, utils.DecollatorComma)
info.Email = in.Email
info.Avatar = in.Avatar
info.Type = uint8(in.Type)
info.SaleId = in.SaleId
var err error
var row int64
if info.Id > utils.NumberZero {
+5
View File
@@ -11,6 +11,8 @@ type AdminEditValidator struct {
Phone string `validate:"required"`
Email string `validate:"required,email"`
Roles []int
Type int32 `validate:"required,oneof=1 2"`
SaleId int64 `validate:"required_if=Type 2"`
}
// GetMessage 创建/编辑 - 提示消息
@@ -21,6 +23,9 @@ func (p AdminEditValidator) GetMessage() validate.ValidatorMessages {
"Email.required": "邮箱不能为空",
"Username.required": "账号不能为空",
"Name.required": "姓名不能为空",
"Type.required": "姓名不能为空",
"Type.oneof": "类型不对",
"SaleId.required_if": "销售ID不能为空",
}
}
+1
View File
@@ -1,2 +1,3 @@
services/sale/logs/
services/sale/run.toml
tmp
+1 -1
View File
@@ -2,7 +2,7 @@
login_out_time=43200 #api接口超时时间分
login_refresh_out_time=83200
name = "sale-service"
listenOn = "0.0.0.0:10300"
listenOn = "0.0.0.0:10900"
mode = "dev"
[log]
path = "logs"