diff --git a/activity.go b/activity.go new file mode 100644 index 0000000..521f7bc --- /dev/null +++ b/activity.go @@ -0,0 +1,189 @@ +package aeusadmin + +import ( + "context" + "encoding/json" + "time" + + "git.nobla.cn/golang/aeus-admin/models" + "git.nobla.cn/golang/rest" + "git.nobla.cn/golang/rest/types" + "gorm.io/gorm" +) + +type ( + recorder struct { + Domain string `json:"domain"` + User string `json:"user"` + Module string `json:"module"` + Table string `json:"table"` + Action string `json:"action"` + PrimaryKey any `json:"primary_key"` + Diffs []*types.DiffAttr `json:"diffs"` + } +) + +type ActivityRecorder struct { + db *gorm.DB + ctx context.Context + batchTimeout time.Duration + BatchSize int + ch chan *models.Activity +} + +func (s *ActivityRecorder) onAfterCreate(ctx context.Context, tx *gorm.DB, model any, diff []*types.DiffAttr) { + v := ctx.Value(rest.RuntimeScopeKey) + if v == nil { + return + } + runtimeScope, ok := v.(*types.RuntimeScope) + if !ok { + return + } + data := &models.Activity{} + data.Uid = runtimeScope.User + data.Module = runtimeScope.ModuleName + data.Table = runtimeScope.TableName + data.Action = types.ScenarioCreate + if buf, err := json.Marshal(diff); err == nil { + data.Data = string(buf) + } + select { + case s.ch <- data: + default: + } +} + +func (s *ActivityRecorder) onAfterUpdate(ctx context.Context, tx *gorm.DB, model any, diff []*types.DiffAttr) { + v := ctx.Value(rest.RuntimeScopeKey) + if v == nil { + return + } + runtimeScope, ok := v.(*types.RuntimeScope) + if !ok { + return + } + data := &models.Activity{} + data.Uid = runtimeScope.User + data.Module = runtimeScope.ModuleName + data.Table = runtimeScope.TableName + data.Action = types.ScenarioUpdate + if diff == nil { + diff = make([]*types.DiffAttr, 0) + } + diff = append(diff, &types.DiffAttr{ + Column: "primary_key", + NewValue: runtimeScope.PrimaryKeyValue, + }) + if buf, err := json.Marshal(diff); err == nil { + data.Data = string(buf) + } + select { + case s.ch <- data: + default: + } +} + +func (s *ActivityRecorder) onAfterDelete(ctx context.Context, tx *gorm.DB, model any) { + v := ctx.Value(rest.RuntimeScopeKey) + if v == nil { + return + } + runtimeScope, ok := v.(*types.RuntimeScope) + if !ok { + return + } + data := &models.Activity{} + data.Uid = runtimeScope.User + data.Module = runtimeScope.ModuleName + data.Table = runtimeScope.TableName + data.Action = types.ScenarioDelete + diff := make([]*types.DiffAttr, 0, 1) + diff = append(diff, &types.DiffAttr{ + Column: "primary_key", + NewValue: runtimeScope.PrimaryKeyValue, + }) + if buf, err := json.Marshal(diff); err == nil { + data.Data = string(buf) + } + select { + case s.ch <- data: + default: + } +} + +func (s *ActivityRecorder) batchWrite(values []*models.Activity) { + var ( + err error + ) + if len(values) <= 0 { + return + } + if err = s.db.Create(values).Error; err != nil { + for _, row := range values { + s.db.Create(row) + } + } +} + +func (s *ActivityRecorder) writeLoop() { + var ( + values []*models.Activity + ) + timer := time.NewTimer(s.batchTimeout) + defer func() { + timer.Stop() + if len(values) > 0 { + s.batchWrite(values) + } + }() + for { + select { + case <-s.ctx.Done(): + return + case <-timer.C: + if len(values) > 0 { + s.batchWrite(values) + values = nil + } + timer.Reset(s.batchTimeout) + case msg, ok := <-s.ch: + if ok { + values = append(values, msg) + if len(values) > s.BatchSize { + s.batchWrite(values) + values = nil + timer.Reset(s.batchTimeout) + } + } + } + } +} + +func (s *ActivityRecorder) Recoder(scenes ...string) { + if len(scenes) == 0 { + scenes = []string{types.ScenarioCreate, types.ScenarioUpdate, types.ScenarioDelete} + } + for _, str := range scenes { + switch str { + case types.ScenarioCreate: + rest.OnAfterCreate(s.onAfterCreate) + case types.ScenarioUpdate: + rest.OnAfterUpdate(s.onAfterUpdate) + case types.ScenarioDelete: + rest.OnAfterDelete(s.onAfterDelete) + } + } +} + +func NewActivityRecorder(ctx context.Context, db *gorm.DB) *ActivityRecorder { + s := &ActivityRecorder{ + db: db, + ctx: ctx, + batchTimeout: time.Second, + BatchSize: 50, + ch: make(chan *models.Activity, 100), + } + go s.writeLoop() + return s +} diff --git a/i18n/zh.go b/i18n/zh.go index 8ec158c..fd9d61d 100644 --- a/i18n/zh.go +++ b/i18n/zh.go @@ -34,6 +34,9 @@ func (t *ZH) Menu(model *rest.Model, label string) string { if _, ok := model.Value().Interface().(models.Setting); ok { return "参数设置" } + if _, ok := model.Value().Interface().(models.Activity); ok { + return "操作记录" + } return label } diff --git a/models/model.go b/models/model.go index 8a9425f..949a5f3 100644 --- a/models/model.go +++ b/models/model.go @@ -32,6 +32,10 @@ type ( Setting struct { pb.SettingModel } + + Activity struct { + pb.ActivityModel + } ) func (m *User) GetMenu() *types.Menu { @@ -123,3 +127,22 @@ func (m *Setting) GetMenu() *types.Menu { func (m *Setting) ModuleName() string { return "system" } + +func (m *Activity) GetMenu() *types.Menu { + return &types.Menu{ + Name: "SystemActivity", + Parent: "System", + } +} + +func (m *Activity) Scenario() []string { + return []string{restTypes.ScenarioList} +} + +func (m *Activity) ModuleName() string { + return "system" +} + +func (m *Activity) GetPermission(s string) string { + return "system:activity:list" +} diff --git a/pb/organize.pb.go b/pb/organize.pb.go index 927ca41..a6c6d24 100644 --- a/pb/organize.pb.go +++ b/pb/organize.pb.go @@ -808,6 +808,99 @@ func (x *Setting) GetDescription() string { return "" } +// Activity 活动记录 +type Activity struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + CreatedAt int64 `protobuf:"varint,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Uid string `protobuf:"bytes,3,opt,name=uid,proto3" json:"uid,omitempty"` + Action string `protobuf:"bytes,4,opt,name=action,proto3" json:"action,omitempty"` + Module string `protobuf:"bytes,5,opt,name=module,proto3" json:"module,omitempty"` + Table string `protobuf:"bytes,6,opt,name=table,proto3" json:"table,omitempty"` + Data string `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Activity) Reset() { + *x = Activity{} + mi := &file_organize_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Activity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Activity) ProtoMessage() {} + +func (x *Activity) ProtoReflect() protoreflect.Message { + mi := &file_organize_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Activity.ProtoReflect.Descriptor instead. +func (*Activity) Descriptor() ([]byte, []int) { + return file_organize_proto_rawDescGZIP(), []int{8} +} + +func (x *Activity) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Activity) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +func (x *Activity) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *Activity) GetAction() string { + if x != nil { + return x.Action + } + return "" +} + +func (x *Activity) GetModule() string { + if x != nil { + return x.Module + } + return "" +} + +func (x *Activity) GetTable() string { + if x != nil { + return x.Table + } + return "" +} + +func (x *Activity) GetData() string { + if x != nil { + return x.Data + } + return "" +} + type LabelValue struct { state protoimpl.MessageState `protogen:"open.v1"` Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` @@ -818,7 +911,7 @@ type LabelValue struct { func (x *LabelValue) Reset() { *x = LabelValue{} - mi := &file_organize_proto_msgTypes[8] + mi := &file_organize_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -830,7 +923,7 @@ func (x *LabelValue) String() string { func (*LabelValue) ProtoMessage() {} func (x *LabelValue) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[8] + mi := &file_organize_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -843,7 +936,7 @@ func (x *LabelValue) ProtoReflect() protoreflect.Message { // Deprecated: Use LabelValue.ProtoReflect.Descriptor instead. func (*LabelValue) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{8} + return file_organize_proto_rawDescGZIP(), []int{9} } func (x *LabelValue) GetLabel() string { @@ -870,7 +963,7 @@ type PermissionItem struct { func (x *PermissionItem) Reset() { *x = PermissionItem{} - mi := &file_organize_proto_msgTypes[9] + mi := &file_organize_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -882,7 +975,7 @@ func (x *PermissionItem) String() string { func (*PermissionItem) ProtoMessage() {} func (x *PermissionItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[9] + mi := &file_organize_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -895,7 +988,7 @@ func (x *PermissionItem) ProtoReflect() protoreflect.Message { // Deprecated: Use PermissionItem.ProtoReflect.Descriptor instead. func (*PermissionItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{9} + return file_organize_proto_rawDescGZIP(), []int{10} } func (x *PermissionItem) GetValue() string { @@ -930,7 +1023,7 @@ type MenuItem struct { func (x *MenuItem) Reset() { *x = MenuItem{} - mi := &file_organize_proto_msgTypes[10] + mi := &file_organize_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -942,7 +1035,7 @@ func (x *MenuItem) String() string { func (*MenuItem) ProtoMessage() {} func (x *MenuItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[10] + mi := &file_organize_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -955,7 +1048,7 @@ func (x *MenuItem) ProtoReflect() protoreflect.Message { // Deprecated: Use MenuItem.ProtoReflect.Descriptor instead. func (*MenuItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{10} + return file_organize_proto_rawDescGZIP(), []int{11} } func (x *MenuItem) GetLabel() string { @@ -1031,7 +1124,7 @@ type GetMenuRequest struct { func (x *GetMenuRequest) Reset() { *x = GetMenuRequest{} - mi := &file_organize_proto_msgTypes[11] + mi := &file_organize_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1043,7 +1136,7 @@ func (x *GetMenuRequest) String() string { func (*GetMenuRequest) ProtoMessage() {} func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[11] + mi := &file_organize_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1056,7 +1149,7 @@ func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenuRequest.ProtoReflect.Descriptor instead. func (*GetMenuRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{11} + return file_organize_proto_rawDescGZIP(), []int{12} } func (x *GetMenuRequest) GetPermission() bool { @@ -1076,7 +1169,7 @@ type GetMenuResponse struct { func (x *GetMenuResponse) Reset() { *x = GetMenuResponse{} - mi := &file_organize_proto_msgTypes[12] + mi := &file_organize_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1088,7 +1181,7 @@ func (x *GetMenuResponse) String() string { func (*GetMenuResponse) ProtoMessage() {} func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[12] + mi := &file_organize_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1101,7 +1194,7 @@ func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetMenuResponse.ProtoReflect.Descriptor instead. func (*GetMenuResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{12} + return file_organize_proto_rawDescGZIP(), []int{13} } func (x *GetMenuResponse) GetData() []*MenuItem { @@ -1121,7 +1214,7 @@ type GetProfileRequest struct { func (x *GetProfileRequest) Reset() { *x = GetProfileRequest{} - mi := &file_organize_proto_msgTypes[13] + mi := &file_organize_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1133,7 +1226,7 @@ func (x *GetProfileRequest) String() string { func (*GetProfileRequest) ProtoMessage() {} func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[13] + mi := &file_organize_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1146,7 +1239,7 @@ func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProfileRequest.ProtoReflect.Descriptor instead. func (*GetProfileRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{13} + return file_organize_proto_rawDescGZIP(), []int{14} } func (x *GetProfileRequest) GetUid() string { @@ -1172,7 +1265,7 @@ type GetProfileResponse struct { func (x *GetProfileResponse) Reset() { *x = GetProfileResponse{} - mi := &file_organize_proto_msgTypes[14] + mi := &file_organize_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1184,7 +1277,7 @@ func (x *GetProfileResponse) String() string { func (*GetProfileResponse) ProtoMessage() {} func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[14] + mi := &file_organize_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1197,7 +1290,7 @@ func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProfileResponse.ProtoReflect.Descriptor instead. func (*GetProfileResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{14} + return file_organize_proto_rawDescGZIP(), []int{15} } func (x *GetProfileResponse) GetUid() string { @@ -1260,7 +1353,7 @@ type ResetPasswordRequest struct { func (x *ResetPasswordRequest) Reset() { *x = ResetPasswordRequest{} - mi := &file_organize_proto_msgTypes[15] + mi := &file_organize_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1272,7 +1365,7 @@ func (x *ResetPasswordRequest) String() string { func (*ResetPasswordRequest) ProtoMessage() {} func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[15] + mi := &file_organize_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1285,7 +1378,7 @@ func (x *ResetPasswordRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordRequest.ProtoReflect.Descriptor instead. func (*ResetPasswordRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{15} + return file_organize_proto_rawDescGZIP(), []int{16} } func (x *ResetPasswordRequest) GetUid() string { @@ -1318,7 +1411,7 @@ type ResetPasswordResponse struct { func (x *ResetPasswordResponse) Reset() { *x = ResetPasswordResponse{} - mi := &file_organize_proto_msgTypes[16] + mi := &file_organize_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1330,7 +1423,7 @@ func (x *ResetPasswordResponse) String() string { func (*ResetPasswordResponse) ProtoMessage() {} func (x *ResetPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[16] + mi := &file_organize_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1343,7 +1436,7 @@ func (x *ResetPasswordResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetPasswordResponse.ProtoReflect.Descriptor instead. func (*ResetPasswordResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{16} + return file_organize_proto_rawDescGZIP(), []int{17} } func (x *ResetPasswordResponse) GetUid() string { @@ -1366,7 +1459,7 @@ type UpdateProfileRequest struct { func (x *UpdateProfileRequest) Reset() { *x = UpdateProfileRequest{} - mi := &file_organize_proto_msgTypes[17] + mi := &file_organize_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1378,7 +1471,7 @@ func (x *UpdateProfileRequest) String() string { func (*UpdateProfileRequest) ProtoMessage() {} func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[17] + mi := &file_organize_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1391,7 +1484,7 @@ func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileRequest.ProtoReflect.Descriptor instead. func (*UpdateProfileRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{17} + return file_organize_proto_rawDescGZIP(), []int{18} } func (x *UpdateProfileRequest) GetUid() string { @@ -1438,7 +1531,7 @@ type UpdateProfileResponse struct { func (x *UpdateProfileResponse) Reset() { *x = UpdateProfileResponse{} - mi := &file_organize_proto_msgTypes[18] + mi := &file_organize_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1450,7 +1543,7 @@ func (x *UpdateProfileResponse) String() string { func (*UpdateProfileResponse) ProtoMessage() {} func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[18] + mi := &file_organize_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1463,7 +1556,7 @@ func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileResponse.ProtoReflect.Descriptor instead. func (*UpdateProfileResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{18} + return file_organize_proto_rawDescGZIP(), []int{19} } func (x *UpdateProfileResponse) GetUid() string { @@ -1482,7 +1575,7 @@ type GetPermissionRequest struct { func (x *GetPermissionRequest) Reset() { *x = GetPermissionRequest{} - mi := &file_organize_proto_msgTypes[19] + mi := &file_organize_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1494,7 +1587,7 @@ func (x *GetPermissionRequest) String() string { func (*GetPermissionRequest) ProtoMessage() {} func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[19] + mi := &file_organize_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1507,7 +1600,7 @@ func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPermissionRequest.ProtoReflect.Descriptor instead. func (*GetPermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{19} + return file_organize_proto_rawDescGZIP(), []int{20} } func (x *GetPermissionRequest) GetUid() string { @@ -1527,7 +1620,7 @@ type GetPermissionResponse struct { func (x *GetPermissionResponse) Reset() { *x = GetPermissionResponse{} - mi := &file_organize_proto_msgTypes[20] + mi := &file_organize_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1539,7 +1632,7 @@ func (x *GetPermissionResponse) String() string { func (*GetPermissionResponse) ProtoMessage() {} func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[20] + mi := &file_organize_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1552,7 +1645,7 @@ func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPermissionResponse.ProtoReflect.Descriptor instead. func (*GetPermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{20} + return file_organize_proto_rawDescGZIP(), []int{21} } func (x *GetPermissionResponse) GetUid() string { @@ -1577,7 +1670,7 @@ type GetUserLabelRequest struct { func (x *GetUserLabelRequest) Reset() { *x = GetUserLabelRequest{} - mi := &file_organize_proto_msgTypes[21] + mi := &file_organize_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1589,7 +1682,7 @@ func (x *GetUserLabelRequest) String() string { func (*GetUserLabelRequest) ProtoMessage() {} func (x *GetUserLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[21] + mi := &file_organize_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1602,7 +1695,7 @@ func (x *GetUserLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserLabelRequest.ProtoReflect.Descriptor instead. func (*GetUserLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{21} + return file_organize_proto_rawDescGZIP(), []int{22} } type GetUserLabelResponse struct { @@ -1614,7 +1707,7 @@ type GetUserLabelResponse struct { func (x *GetUserLabelResponse) Reset() { *x = GetUserLabelResponse{} - mi := &file_organize_proto_msgTypes[22] + mi := &file_organize_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1626,7 +1719,7 @@ func (x *GetUserLabelResponse) String() string { func (*GetUserLabelResponse) ProtoMessage() {} func (x *GetUserLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[22] + mi := &file_organize_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1639,7 +1732,7 @@ func (x *GetUserLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserLabelResponse.ProtoReflect.Descriptor instead. func (*GetUserLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{22} + return file_organize_proto_rawDescGZIP(), []int{23} } func (x *GetUserLabelResponse) GetData() []*LabelValue { @@ -1657,7 +1750,7 @@ type GetUserTagRequest struct { func (x *GetUserTagRequest) Reset() { *x = GetUserTagRequest{} - mi := &file_organize_proto_msgTypes[23] + mi := &file_organize_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1669,7 +1762,7 @@ func (x *GetUserTagRequest) String() string { func (*GetUserTagRequest) ProtoMessage() {} func (x *GetUserTagRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[23] + mi := &file_organize_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1682,7 +1775,7 @@ func (x *GetUserTagRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserTagRequest.ProtoReflect.Descriptor instead. func (*GetUserTagRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{23} + return file_organize_proto_rawDescGZIP(), []int{24} } type GetUserTagResponse struct { @@ -1694,7 +1787,7 @@ type GetUserTagResponse struct { func (x *GetUserTagResponse) Reset() { *x = GetUserTagResponse{} - mi := &file_organize_proto_msgTypes[24] + mi := &file_organize_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1706,7 +1799,7 @@ func (x *GetUserTagResponse) String() string { func (*GetUserTagResponse) ProtoMessage() {} func (x *GetUserTagResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[24] + mi := &file_organize_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1719,7 +1812,7 @@ func (x *GetUserTagResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserTagResponse.ProtoReflect.Descriptor instead. func (*GetUserTagResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{24} + return file_organize_proto_rawDescGZIP(), []int{25} } func (x *GetUserTagResponse) GetData() []*LabelValue { @@ -1739,7 +1832,7 @@ type DepartmentLabelValue struct { func (x *DepartmentLabelValue) Reset() { *x = DepartmentLabelValue{} - mi := &file_organize_proto_msgTypes[25] + mi := &file_organize_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1751,7 +1844,7 @@ func (x *DepartmentLabelValue) String() string { func (*DepartmentLabelValue) ProtoMessage() {} func (x *DepartmentLabelValue) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[25] + mi := &file_organize_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1764,7 +1857,7 @@ func (x *DepartmentLabelValue) ProtoReflect() protoreflect.Message { // Deprecated: Use DepartmentLabelValue.ProtoReflect.Descriptor instead. func (*DepartmentLabelValue) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{25} + return file_organize_proto_rawDescGZIP(), []int{26} } func (x *DepartmentLabelValue) GetLabel() string { @@ -1789,7 +1882,7 @@ type GetDepartmentLabelRequest struct { func (x *GetDepartmentLabelRequest) Reset() { *x = GetDepartmentLabelRequest{} - mi := &file_organize_proto_msgTypes[26] + mi := &file_organize_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1801,7 +1894,7 @@ func (x *GetDepartmentLabelRequest) String() string { func (*GetDepartmentLabelRequest) ProtoMessage() {} func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[26] + mi := &file_organize_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1814,7 +1907,7 @@ func (x *GetDepartmentLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepartmentLabelRequest.ProtoReflect.Descriptor instead. func (*GetDepartmentLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{26} + return file_organize_proto_rawDescGZIP(), []int{27} } type GetDepartmentLabelResponse struct { @@ -1826,7 +1919,7 @@ type GetDepartmentLabelResponse struct { func (x *GetDepartmentLabelResponse) Reset() { *x = GetDepartmentLabelResponse{} - mi := &file_organize_proto_msgTypes[27] + mi := &file_organize_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1838,7 +1931,7 @@ func (x *GetDepartmentLabelResponse) String() string { func (*GetDepartmentLabelResponse) ProtoMessage() {} func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[27] + mi := &file_organize_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1851,7 +1944,7 @@ func (x *GetDepartmentLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepartmentLabelResponse.ProtoReflect.Descriptor instead. func (*GetDepartmentLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{27} + return file_organize_proto_rawDescGZIP(), []int{28} } func (x *GetDepartmentLabelResponse) GetData() []*DepartmentLabelValue { @@ -1869,7 +1962,7 @@ type GetRoleLabelRequest struct { func (x *GetRoleLabelRequest) Reset() { *x = GetRoleLabelRequest{} - mi := &file_organize_proto_msgTypes[28] + mi := &file_organize_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1881,7 +1974,7 @@ func (x *GetRoleLabelRequest) String() string { func (*GetRoleLabelRequest) ProtoMessage() {} func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[28] + mi := &file_organize_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1894,7 +1987,7 @@ func (x *GetRoleLabelRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRoleLabelRequest.ProtoReflect.Descriptor instead. func (*GetRoleLabelRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{28} + return file_organize_proto_rawDescGZIP(), []int{29} } type GetRoleLabelResponse struct { @@ -1906,7 +1999,7 @@ type GetRoleLabelResponse struct { func (x *GetRoleLabelResponse) Reset() { *x = GetRoleLabelResponse{} - mi := &file_organize_proto_msgTypes[29] + mi := &file_organize_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1918,7 +2011,7 @@ func (x *GetRoleLabelResponse) String() string { func (*GetRoleLabelResponse) ProtoMessage() {} func (x *GetRoleLabelResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[29] + mi := &file_organize_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1931,7 +2024,7 @@ func (x *GetRoleLabelResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRoleLabelResponse.ProtoReflect.Descriptor instead. func (*GetRoleLabelResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{29} + return file_organize_proto_rawDescGZIP(), []int{30} } func (x *GetRoleLabelResponse) GetData() []*LabelValue { @@ -1950,7 +2043,7 @@ type GetRolePermissionRequest struct { func (x *GetRolePermissionRequest) Reset() { *x = GetRolePermissionRequest{} - mi := &file_organize_proto_msgTypes[30] + mi := &file_organize_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1962,7 +2055,7 @@ func (x *GetRolePermissionRequest) String() string { func (*GetRolePermissionRequest) ProtoMessage() {} func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[30] + mi := &file_organize_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1975,7 +2068,7 @@ func (x *GetRolePermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolePermissionRequest.ProtoReflect.Descriptor instead. func (*GetRolePermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{30} + return file_organize_proto_rawDescGZIP(), []int{31} } func (x *GetRolePermissionRequest) GetRole() string { @@ -1995,7 +2088,7 @@ type GetRolePermissionResponse struct { func (x *GetRolePermissionResponse) Reset() { *x = GetRolePermissionResponse{} - mi := &file_organize_proto_msgTypes[31] + mi := &file_organize_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2007,7 +2100,7 @@ func (x *GetRolePermissionResponse) String() string { func (*GetRolePermissionResponse) ProtoMessage() {} func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[31] + mi := &file_organize_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2020,7 +2113,7 @@ func (x *GetRolePermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetRolePermissionResponse.ProtoReflect.Descriptor instead. func (*GetRolePermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{31} + return file_organize_proto_rawDescGZIP(), []int{32} } func (x *GetRolePermissionResponse) GetRole() string { @@ -2047,7 +2140,7 @@ type SaveRolePermissionRequest struct { func (x *SaveRolePermissionRequest) Reset() { *x = SaveRolePermissionRequest{} - mi := &file_organize_proto_msgTypes[32] + mi := &file_organize_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2059,7 +2152,7 @@ func (x *SaveRolePermissionRequest) String() string { func (*SaveRolePermissionRequest) ProtoMessage() {} func (x *SaveRolePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[32] + mi := &file_organize_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2072,7 +2165,7 @@ func (x *SaveRolePermissionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SaveRolePermissionRequest.ProtoReflect.Descriptor instead. func (*SaveRolePermissionRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{32} + return file_organize_proto_rawDescGZIP(), []int{33} } func (x *SaveRolePermissionRequest) GetRole() string { @@ -2098,7 +2191,7 @@ type SaveRolePermissionResponse struct { func (x *SaveRolePermissionResponse) Reset() { *x = SaveRolePermissionResponse{} - mi := &file_organize_proto_msgTypes[33] + mi := &file_organize_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2110,7 +2203,7 @@ func (x *SaveRolePermissionResponse) String() string { func (*SaveRolePermissionResponse) ProtoMessage() {} func (x *SaveRolePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[33] + mi := &file_organize_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2123,7 +2216,7 @@ func (x *SaveRolePermissionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SaveRolePermissionResponse.ProtoReflect.Descriptor instead. func (*SaveRolePermissionResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{33} + return file_organize_proto_rawDescGZIP(), []int{34} } func (x *SaveRolePermissionResponse) GetRole() string { @@ -2144,7 +2237,7 @@ type LoginRequest struct { func (x *LoginRequest) Reset() { *x = LoginRequest{} - mi := &file_organize_proto_msgTypes[34] + mi := &file_organize_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2156,7 +2249,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[34] + mi := &file_organize_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2169,7 +2262,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{34} + return file_organize_proto_rawDescGZIP(), []int{35} } func (x *LoginRequest) GetUsername() string { @@ -2205,7 +2298,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} - mi := &file_organize_proto_msgTypes[35] + mi := &file_organize_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2217,7 +2310,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[35] + mi := &file_organize_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2230,7 +2323,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{35} + return file_organize_proto_rawDescGZIP(), []int{36} } func (x *LoginResponse) GetUid() string { @@ -2270,7 +2363,7 @@ type LogoutRequest struct { func (x *LogoutRequest) Reset() { *x = LogoutRequest{} - mi := &file_organize_proto_msgTypes[36] + mi := &file_organize_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2282,7 +2375,7 @@ func (x *LogoutRequest) String() string { func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[36] + mi := &file_organize_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2295,7 +2388,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{36} + return file_organize_proto_rawDescGZIP(), []int{37} } func (x *LogoutRequest) GetToken() string { @@ -2314,7 +2407,7 @@ type LogoutResponse struct { func (x *LogoutResponse) Reset() { *x = LogoutResponse{} - mi := &file_organize_proto_msgTypes[37] + mi := &file_organize_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2326,7 +2419,7 @@ func (x *LogoutResponse) String() string { func (*LogoutResponse) ProtoMessage() {} func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[37] + mi := &file_organize_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2339,7 +2432,7 @@ func (x *LogoutResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{37} + return file_organize_proto_rawDescGZIP(), []int{38} } func (x *LogoutResponse) GetUid() string { @@ -2359,7 +2452,7 @@ type SettingItem struct { func (x *SettingItem) Reset() { *x = SettingItem{} - mi := &file_organize_proto_msgTypes[38] + mi := &file_organize_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2371,7 +2464,7 @@ func (x *SettingItem) String() string { func (*SettingItem) ProtoMessage() {} func (x *SettingItem) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[38] + mi := &file_organize_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2384,7 +2477,7 @@ func (x *SettingItem) ProtoReflect() protoreflect.Message { // Deprecated: Use SettingItem.ProtoReflect.Descriptor instead. func (*SettingItem) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{38} + return file_organize_proto_rawDescGZIP(), []int{39} } func (x *SettingItem) GetName() string { @@ -2409,7 +2502,7 @@ type GetSettingRequest struct { func (x *GetSettingRequest) Reset() { *x = GetSettingRequest{} - mi := &file_organize_proto_msgTypes[39] + mi := &file_organize_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2421,7 +2514,7 @@ func (x *GetSettingRequest) String() string { func (*GetSettingRequest) ProtoMessage() {} func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[39] + mi := &file_organize_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2434,7 +2527,7 @@ func (x *GetSettingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSettingRequest.ProtoReflect.Descriptor instead. func (*GetSettingRequest) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{39} + return file_organize_proto_rawDescGZIP(), []int{40} } type GetSettingResponse struct { @@ -2446,7 +2539,7 @@ type GetSettingResponse struct { func (x *GetSettingResponse) Reset() { *x = GetSettingResponse{} - mi := &file_organize_proto_msgTypes[40] + mi := &file_organize_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2458,7 +2551,7 @@ func (x *GetSettingResponse) String() string { func (*GetSettingResponse) ProtoMessage() {} func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_organize_proto_msgTypes[40] + mi := &file_organize_proto_msgTypes[41] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2471,7 +2564,7 @@ func (x *GetSettingResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSettingResponse.ProtoReflect.Descriptor instead. func (*GetSettingResponse) Descriptor() ([]byte, []int) { - return file_organize_proto_rawDescGZIP(), []int{40} + return file_organize_proto_rawDescGZIP(), []int{41} } func (x *GetSettingResponse) GetData() []*SettingItem { @@ -2605,15 +2698,15 @@ const file_organize_proto_rawDesc = "" + "\asize:20\x12\f部门名称:\brequiredR\x04name\x12q\n" + "\vdescription\x18\x06 \x01(\tBO\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19C\n" + "\tsize:1024\x12\f备注说明\x1a\x1ecreate;update;view;export;list*\btextareaR\vdescription:\x11\xba\xb9\x19\r\n" + - "\vdepartments\"\xa4\x05\n" + + "\vdepartments\"\x9e\x05\n" + "\x05Login\x12$\n" + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + "\n" + "primaryKey\x12\x02IDR\x02id\x12J\n" + "\n" + - "created_at\x18\x02 \x01(\x03B+\xb2\xb9\x19'\x12\f登录时间\x1a\x17list;search;view;exportR\tcreatedAt\x12]\n" + - "\x03uid\x18\x04 \x01(\tBK\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x19>\n" + - "\rindex;size:20\x12\f用户工号*\x04user2\x0freadonly:update:\brequiredR\x03uid\x12E\n" + + "created_at\x18\x02 \x01(\x03B+\xb2\xb9\x19'\x12\f登录时间\x1a\x17list;search;view;exportR\tcreatedAt\x12W\n" + + "\x03uid\x18\x04 \x01(\tBE\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x198\n" + + "\rindex;size:20\x12\x06用户*\x04user2\x0freadonly:update:\brequiredR\x03uid\x12E\n" + "\x02ip\x18\x05 \x01(\tB5\xb2\xb9\x191\n" + "\bsize:128\x12\f登录地址\x1a\x17list;search;view;exportR\x02ip\x12E\n" + "\abrowser\x18\x06 \x01(\tB+\xb2\xb9\x19'\n" + @@ -2644,7 +2737,25 @@ const file_organize_proto_rawDesc = "" + "\vdescription\x18\x06 \x01(\tBJ\xfaB\x05r\x03\x18\x80\b\xb2\xb9\x19>\n" + "\tsize:1024\x12\f备注说明\x1a\x19create;update;view;export*\btextareaR\vdescription:\x0e\xba\xb9\x19\n" + "\n" + - "\bsettings\"8\n" + + "\bsettings\"\xd8\x05\n" + + "\bActivity\x12$\n" + + "\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" + + "\n" + + "primaryKey\x12\x02IDR\x02id\x12L\n" + + "\n" + + "created_at\x18\x02 \x01(\x03B-\xb2\xb9\x19)\x12\f创建时间\x1a\x19search;search;view;exportR\tcreatedAt\x12W\n" + + "\x03uid\x18\x03 \x01(\tBE\xfaB\x06r\x04\x10\x05\x18\x14\xb2\xb9\x198\n" + + "\rindex;size:20\x12\x06用户*\x04user2\x0freadonly:update:\brequiredR\x03uid\x12\xbf\x01\n" + + "\x06action\x18\x04 \x01(\tB\xa6\x01\xb2\xb9\x19\xa1\x01\n" + + "!index;size:20;not null;default:''\x12\x06行为\x1a%search;list;create;update;view;export2\rmatch:exactlyR>create:新建#198754;update:更新#f09d00;delete:删除#e63757R\x06action\x12h\n" + + "\x06module\x18\x05 \x01(\tBP\xb2\xb9\x19L\n" + + "\x1bsize:60;not null;default:''\x12\x06模块\x1a%search;list;create;update;view;exportR\x06module\x12_\n" + + "\x05table\x18\x06 \x01(\tBI\xb2\xb9\x19E\n" + + "\x1bsize:60;not null;default:''\x12\x06数据\x1a\x1elist;create;update;view;exportR\x05table\x12`\n" + + "\x04data\x18\a \x01(\tBL\xb2\xb9\x19H\n" + + "\x1esize:10240;not null;default:''\x12\x06内容\x1a\x1elist;create;update;view;exportR\x04data:\x10\xba\xb9\x19\f\n" + + "\n" + + "activities\"8\n" + "\n" + "LabelValue\x12\x14\n" + "\x05label\x18\x01 \x01(\tR\x05label\x12\x14\n" + @@ -2776,7 +2887,7 @@ func file_organize_proto_rawDescGZIP() []byte { return file_organize_proto_rawDescData } -var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 41) +var file_organize_proto_msgTypes = make([]protoimpl.MessageInfo, 42) var file_organize_proto_goTypes = []any{ (*Menu)(nil), // 0: organize.Menu (*Role)(nil), // 1: organize.Role @@ -2786,77 +2897,78 @@ var file_organize_proto_goTypes = []any{ (*Department)(nil), // 5: organize.Department (*Login)(nil), // 6: organize.Login (*Setting)(nil), // 7: organize.Setting - (*LabelValue)(nil), // 8: organize.LabelValue - (*PermissionItem)(nil), // 9: organize.PermissionItem - (*MenuItem)(nil), // 10: organize.MenuItem - (*GetMenuRequest)(nil), // 11: organize.GetMenuRequest - (*GetMenuResponse)(nil), // 12: organize.GetMenuResponse - (*GetProfileRequest)(nil), // 13: organize.GetProfileRequest - (*GetProfileResponse)(nil), // 14: organize.GetProfileResponse - (*ResetPasswordRequest)(nil), // 15: organize.ResetPasswordRequest - (*ResetPasswordResponse)(nil), // 16: organize.ResetPasswordResponse - (*UpdateProfileRequest)(nil), // 17: organize.UpdateProfileRequest - (*UpdateProfileResponse)(nil), // 18: organize.UpdateProfileResponse - (*GetPermissionRequest)(nil), // 19: organize.GetPermissionRequest - (*GetPermissionResponse)(nil), // 20: organize.GetPermissionResponse - (*GetUserLabelRequest)(nil), // 21: organize.GetUserLabelRequest - (*GetUserLabelResponse)(nil), // 22: organize.GetUserLabelResponse - (*GetUserTagRequest)(nil), // 23: organize.GetUserTagRequest - (*GetUserTagResponse)(nil), // 24: organize.GetUserTagResponse - (*DepartmentLabelValue)(nil), // 25: organize.DepartmentLabelValue - (*GetDepartmentLabelRequest)(nil), // 26: organize.GetDepartmentLabelRequest - (*GetDepartmentLabelResponse)(nil), // 27: organize.GetDepartmentLabelResponse - (*GetRoleLabelRequest)(nil), // 28: organize.GetRoleLabelRequest - (*GetRoleLabelResponse)(nil), // 29: organize.GetRoleLabelResponse - (*GetRolePermissionRequest)(nil), // 30: organize.GetRolePermissionRequest - (*GetRolePermissionResponse)(nil), // 31: organize.GetRolePermissionResponse - (*SaveRolePermissionRequest)(nil), // 32: organize.SaveRolePermissionRequest - (*SaveRolePermissionResponse)(nil), // 33: organize.SaveRolePermissionResponse - (*LoginRequest)(nil), // 34: organize.LoginRequest - (*LoginResponse)(nil), // 35: organize.LoginResponse - (*LogoutRequest)(nil), // 36: organize.LogoutRequest - (*LogoutResponse)(nil), // 37: organize.LogoutResponse - (*SettingItem)(nil), // 38: organize.SettingItem - (*GetSettingRequest)(nil), // 39: organize.GetSettingRequest - (*GetSettingResponse)(nil), // 40: organize.GetSettingResponse + (*Activity)(nil), // 8: organize.Activity + (*LabelValue)(nil), // 9: organize.LabelValue + (*PermissionItem)(nil), // 10: organize.PermissionItem + (*MenuItem)(nil), // 11: organize.MenuItem + (*GetMenuRequest)(nil), // 12: organize.GetMenuRequest + (*GetMenuResponse)(nil), // 13: organize.GetMenuResponse + (*GetProfileRequest)(nil), // 14: organize.GetProfileRequest + (*GetProfileResponse)(nil), // 15: organize.GetProfileResponse + (*ResetPasswordRequest)(nil), // 16: organize.ResetPasswordRequest + (*ResetPasswordResponse)(nil), // 17: organize.ResetPasswordResponse + (*UpdateProfileRequest)(nil), // 18: organize.UpdateProfileRequest + (*UpdateProfileResponse)(nil), // 19: organize.UpdateProfileResponse + (*GetPermissionRequest)(nil), // 20: organize.GetPermissionRequest + (*GetPermissionResponse)(nil), // 21: organize.GetPermissionResponse + (*GetUserLabelRequest)(nil), // 22: organize.GetUserLabelRequest + (*GetUserLabelResponse)(nil), // 23: organize.GetUserLabelResponse + (*GetUserTagRequest)(nil), // 24: organize.GetUserTagRequest + (*GetUserTagResponse)(nil), // 25: organize.GetUserTagResponse + (*DepartmentLabelValue)(nil), // 26: organize.DepartmentLabelValue + (*GetDepartmentLabelRequest)(nil), // 27: organize.GetDepartmentLabelRequest + (*GetDepartmentLabelResponse)(nil), // 28: organize.GetDepartmentLabelResponse + (*GetRoleLabelRequest)(nil), // 29: organize.GetRoleLabelRequest + (*GetRoleLabelResponse)(nil), // 30: organize.GetRoleLabelResponse + (*GetRolePermissionRequest)(nil), // 31: organize.GetRolePermissionRequest + (*GetRolePermissionResponse)(nil), // 32: organize.GetRolePermissionResponse + (*SaveRolePermissionRequest)(nil), // 33: organize.SaveRolePermissionRequest + (*SaveRolePermissionResponse)(nil), // 34: organize.SaveRolePermissionResponse + (*LoginRequest)(nil), // 35: organize.LoginRequest + (*LoginResponse)(nil), // 36: organize.LoginResponse + (*LogoutRequest)(nil), // 37: organize.LogoutRequest + (*LogoutResponse)(nil), // 38: organize.LogoutResponse + (*SettingItem)(nil), // 39: organize.SettingItem + (*GetSettingRequest)(nil), // 40: organize.GetSettingRequest + (*GetSettingResponse)(nil), // 41: organize.GetSettingResponse } var file_organize_proto_depIdxs = []int32{ - 9, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem - 10, // 1: organize.MenuItem.children:type_name -> organize.MenuItem - 10, // 2: organize.GetMenuResponse.data:type_name -> organize.MenuItem - 8, // 3: organize.GetUserLabelResponse.data:type_name -> organize.LabelValue - 8, // 4: organize.GetUserTagResponse.data:type_name -> organize.LabelValue - 25, // 5: organize.GetDepartmentLabelResponse.data:type_name -> organize.DepartmentLabelValue - 8, // 6: organize.GetRoleLabelResponse.data:type_name -> organize.LabelValue - 38, // 7: organize.GetSettingResponse.data:type_name -> organize.SettingItem - 11, // 8: organize.UserService.GetMenus:input_type -> organize.GetMenuRequest - 13, // 9: organize.UserService.GetProfile:input_type -> organize.GetProfileRequest - 17, // 10: organize.UserService.UpdateProfile:input_type -> organize.UpdateProfileRequest - 15, // 11: organize.UserService.ResetPassword:input_type -> organize.ResetPasswordRequest - 19, // 12: organize.UserService.GetPermissions:input_type -> organize.GetPermissionRequest - 21, // 13: organize.UserService.GetUserLabels:input_type -> organize.GetUserLabelRequest - 23, // 14: organize.UserService.GetUserTags:input_type -> organize.GetUserTagRequest - 26, // 15: organize.DepartmentService.GetDepartmentLabels:input_type -> organize.GetDepartmentLabelRequest - 28, // 16: organize.RoleService.GetRoleLabels:input_type -> organize.GetRoleLabelRequest - 30, // 17: organize.RoleService.GetRolePermissions:input_type -> organize.GetRolePermissionRequest - 32, // 18: organize.RoleService.SaveRolePermission:input_type -> organize.SaveRolePermissionRequest - 34, // 19: organize.AuthService.Login:input_type -> organize.LoginRequest - 36, // 20: organize.AuthService.Logout:input_type -> organize.LogoutRequest - 39, // 21: organize.SettingService.GetSetting:input_type -> organize.GetSettingRequest - 12, // 22: organize.UserService.GetMenus:output_type -> organize.GetMenuResponse - 14, // 23: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse - 18, // 24: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse - 16, // 25: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse - 20, // 26: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse - 22, // 27: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse - 24, // 28: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse - 27, // 29: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse - 29, // 30: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse - 31, // 31: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse - 33, // 32: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse - 35, // 33: organize.AuthService.Login:output_type -> organize.LoginResponse - 37, // 34: organize.AuthService.Logout:output_type -> organize.LogoutResponse - 40, // 35: organize.SettingService.GetSetting:output_type -> organize.GetSettingResponse + 10, // 0: organize.MenuItem.permissions:type_name -> organize.PermissionItem + 11, // 1: organize.MenuItem.children:type_name -> organize.MenuItem + 11, // 2: organize.GetMenuResponse.data:type_name -> organize.MenuItem + 9, // 3: organize.GetUserLabelResponse.data:type_name -> organize.LabelValue + 9, // 4: organize.GetUserTagResponse.data:type_name -> organize.LabelValue + 26, // 5: organize.GetDepartmentLabelResponse.data:type_name -> organize.DepartmentLabelValue + 9, // 6: organize.GetRoleLabelResponse.data:type_name -> organize.LabelValue + 39, // 7: organize.GetSettingResponse.data:type_name -> organize.SettingItem + 12, // 8: organize.UserService.GetMenus:input_type -> organize.GetMenuRequest + 14, // 9: organize.UserService.GetProfile:input_type -> organize.GetProfileRequest + 18, // 10: organize.UserService.UpdateProfile:input_type -> organize.UpdateProfileRequest + 16, // 11: organize.UserService.ResetPassword:input_type -> organize.ResetPasswordRequest + 20, // 12: organize.UserService.GetPermissions:input_type -> organize.GetPermissionRequest + 22, // 13: organize.UserService.GetUserLabels:input_type -> organize.GetUserLabelRequest + 24, // 14: organize.UserService.GetUserTags:input_type -> organize.GetUserTagRequest + 27, // 15: organize.DepartmentService.GetDepartmentLabels:input_type -> organize.GetDepartmentLabelRequest + 29, // 16: organize.RoleService.GetRoleLabels:input_type -> organize.GetRoleLabelRequest + 31, // 17: organize.RoleService.GetRolePermissions:input_type -> organize.GetRolePermissionRequest + 33, // 18: organize.RoleService.SaveRolePermission:input_type -> organize.SaveRolePermissionRequest + 35, // 19: organize.AuthService.Login:input_type -> organize.LoginRequest + 37, // 20: organize.AuthService.Logout:input_type -> organize.LogoutRequest + 40, // 21: organize.SettingService.GetSetting:input_type -> organize.GetSettingRequest + 13, // 22: organize.UserService.GetMenus:output_type -> organize.GetMenuResponse + 15, // 23: organize.UserService.GetProfile:output_type -> organize.GetProfileResponse + 19, // 24: organize.UserService.UpdateProfile:output_type -> organize.UpdateProfileResponse + 17, // 25: organize.UserService.ResetPassword:output_type -> organize.ResetPasswordResponse + 21, // 26: organize.UserService.GetPermissions:output_type -> organize.GetPermissionResponse + 23, // 27: organize.UserService.GetUserLabels:output_type -> organize.GetUserLabelResponse + 25, // 28: organize.UserService.GetUserTags:output_type -> organize.GetUserTagResponse + 28, // 29: organize.DepartmentService.GetDepartmentLabels:output_type -> organize.GetDepartmentLabelResponse + 30, // 30: organize.RoleService.GetRoleLabels:output_type -> organize.GetRoleLabelResponse + 32, // 31: organize.RoleService.GetRolePermissions:output_type -> organize.GetRolePermissionResponse + 34, // 32: organize.RoleService.SaveRolePermission:output_type -> organize.SaveRolePermissionResponse + 36, // 33: organize.AuthService.Login:output_type -> organize.LoginResponse + 38, // 34: organize.AuthService.Logout:output_type -> organize.LogoutResponse + 41, // 35: organize.SettingService.GetSetting:output_type -> organize.GetSettingResponse 22, // [22:36] is the sub-list for method output_type 8, // [8:22] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name @@ -2875,7 +2987,7 @@ func file_organize_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_organize_proto_rawDesc), len(file_organize_proto_rawDesc)), NumEnums: 0, - NumMessages: 41, + NumMessages: 42, NumExtensions: 0, NumServices: 5, }, diff --git a/pb/organize.pb.validate.go b/pb/organize.pb.validate.go index 9c79d72..186e2e5 100644 --- a/pb/organize.pb.validate.go +++ b/pb/organize.pb.validate.go @@ -1188,6 +1188,128 @@ var _ interface { ErrorName() string } = SettingValidationError{} +// Validate checks the field values on Activity with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Activity) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Activity with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ActivityMultiError, or nil +// if none found. +func (m *Activity) ValidateAll() error { + return m.validate(true) +} + +func (m *Activity) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for CreatedAt + + if l := utf8.RuneCountInString(m.GetUid()); l < 5 || l > 20 { + err := ActivityValidationError{ + field: "Uid", + reason: "value length must be between 5 and 20 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Action + + // no validation rules for Module + + // no validation rules for Table + + // no validation rules for Data + + if len(errors) > 0 { + return ActivityMultiError(errors) + } + + return nil +} + +// ActivityMultiError is an error wrapping multiple validation errors returned +// by Activity.ValidateAll() if the designated constraints aren't met. +type ActivityMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ActivityMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ActivityMultiError) AllErrors() []error { return m } + +// ActivityValidationError is the validation error returned by +// Activity.Validate if the designated constraints aren't met. +type ActivityValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ActivityValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ActivityValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ActivityValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ActivityValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ActivityValidationError) ErrorName() string { return "ActivityValidationError" } + +// Error satisfies the builtin error interface +func (e ActivityValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sActivity.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ActivityValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ActivityValidationError{} + // Validate checks the field values on LabelValue with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. diff --git a/pb/organize.proto b/pb/organize.proto index 36efe94..7ad699f 100644 --- a/pb/organize.proto +++ b/pb/organize.proto @@ -103,7 +103,7 @@ message Login { }; int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}]; int64 created_at = 2 [(aeus.field)={scenarios:"list;search;view;export",comment:"登录时间"}]; - string uid = 4 [(aeus.field)={gorm:"index;size:20",rule:"required",props:"readonly:update",format:"user",comment: "用户工号"},(validate.rules).string = {min_len: 5, max_len: 20}]; + string uid = 4 [(aeus.field)={gorm:"index;size:20",rule:"required",props:"readonly:update",format:"user",comment: "用户"},(validate.rules).string = {min_len: 5, max_len: 20}]; string ip = 5 [(aeus.field)={gorm:"size:128",scenarios:"list;search;view;export",comment: "登录地址"}]; string browser = 6 [(aeus.field)={gorm:"size:128",scenarios:"list;view;export",comment: "浏览器"}]; string os = 7 [(aeus.field)={gorm:"size:128",scenarios:"list;view;export",comment: "操作系统"}]; @@ -126,6 +126,20 @@ message Setting { } +// Activity 活动记录 +message Activity { + option (aeus.rest) = { + table: "activities" + }; + int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}]; + int64 created_at = 2 [(aeus.field)={scenarios:"search;search;view;export",comment:"创建时间"}]; + string uid = 3 [(aeus.field)={gorm:"index;size:20",rule:"required",props:"readonly:update",format:"user",comment: "用户"},(validate.rules).string = {min_len: 5, max_len: 20}]; + string action = 4 [(aeus.field)={props:"match:exactly",gorm:"index;size:20;not null;default:''",comment:"行为",enum:"create:新建#198754;update:更新#f09d00;delete:删除#e63757",scenarios:"search;list;create;update;view;export"}]; + string module = 5 [(aeus.field)={gorm:"size:60;not null;default:''",comment:"模块",scenarios:"search;list;create;update;view;export"}]; + string table = 6 [(aeus.field)={gorm:"size:60;not null;default:''",comment:"数据",scenarios:"list;create;update;view;export"}]; + string data = 7 [(aeus.field)={gorm:"size:10240;not null;default:''",comment:"内容",scenarios:"list;create;update;view;export"}]; +} + message LabelValue { string label = 1; string value = 2; diff --git a/pb/organize_http.pb.go b/pb/organize_http.pb.go index bfd025c..c35df26 100644 --- a/pb/organize_http.pb.go +++ b/pb/organize_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-aeus. DO NOT EDIT. // source: organize.proto -// date: 2025-06-17 15:01:15 +// date: 2025-06-17 18:12:28 package pb diff --git a/pb/organize_model.pb.go b/pb/organize_model.pb.go index 40df4a1..63c3650 100644 --- a/pb/organize_model.pb.go +++ b/pb/organize_model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-aeus. DO NOT EDIT. // source: organize.proto -// date: 2025-06-17 15:01:15 +// date: 2025-06-17 18:12:28 package pb @@ -431,7 +431,7 @@ func NewDepartmentModel() *DepartmentModel { type LoginModel struct { Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"登录时间" scenarios:"list;search;view;export"` - Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20" comment:"用户工号" format:"user" props:"readonly:update" rule:"required"` + Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20" comment:"用户" format:"user" props:"readonly:update" rule:"required"` Ip string `json:"ip" yaml:"ip" xml:"ip" gorm:"size:128" comment:"登录地址" scenarios:"list;search;view;export"` Browser string `json:"browser" yaml:"browser" xml:"browser" gorm:"size:128" comment:"浏览器" scenarios:"list;view;export"` Os string `json:"os" yaml:"os" xml:"os" gorm:"size:128" comment:"操作系统" scenarios:"list;view;export"` @@ -566,3 +566,71 @@ func (m *SettingModel) FindAll(db *gorm.DB, query any, args ...any) (err error) func NewSettingModel() *SettingModel { return &SettingModel{} } + +type ActivityModel struct { + Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` + CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"search;search;view;export"` + Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20" comment:"用户" format:"user" props:"readonly:update" rule:"required"` + Action string `json:"action" yaml:"action" xml:"action" gorm:"index;size:20;not null;default:''" comment:"行为" scenarios:"search;list;create;update;view;export" props:"match:exactly" enum:"create:新建#198754;update:更新#f09d00;delete:删除#e63757"` + Module string `json:"module" yaml:"module" xml:"module" gorm:"size:60;not null;default:''" comment:"模块" scenarios:"search;list;create;update;view;export"` + Table string `json:"table" yaml:"table" xml:"table" gorm:"size:60;not null;default:''" comment:"数据" scenarios:"list;create;update;view;export"` + Data string `json:"data" yaml:"data" xml:"data" gorm:"size:10240;not null;default:''" comment:"内容" scenarios:"list;create;update;view;export"` +} + +func (m *ActivityModel) TableName() string { + return "activities" +} + +func (m *ActivityModel) FromValue(x *Activity) { + m.Id = x.Id + m.CreatedAt = x.CreatedAt + m.Uid = x.Uid + m.Action = x.Action + m.Module = x.Module + m.Table = x.Table + m.Data = x.Data +} + +func (m *ActivityModel) ToValue() (x *Activity) { + x = &Activity{} + x.Id = m.Id + x.CreatedAt = m.CreatedAt + x.Uid = m.Uid + x.Action = m.Action + x.Module = m.Module + x.Table = m.Table + x.Data = m.Data + return x +} + +func (m *ActivityModel) Create(db *gorm.DB) (err error) { + return db.Create(m).Error +} + +func (m *ActivityModel) UpdateColumn(db *gorm.DB, column string, value any) (err error) { + return db.Model(m).UpdateColumn(column, value).Error +} + +func (m *ActivityModel) Save(db *gorm.DB) (err error) { + return db.Save(m).Error +} + +func (m *ActivityModel) Delete(db *gorm.DB) (err error) { + return db.Delete(m).Error +} + +func (m *ActivityModel) Find(db *gorm.DB, pk any) (err error) { + return db.Where("data=?", pk).First(m).Error +} + +func (m *ActivityModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { + return db.Where(query, args...).First(m).Error +} + +func (m *ActivityModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { + return db.Where(query, args...).Find(m).Error +} + +func NewActivityModel() *ActivityModel { + return &ActivityModel{} +} diff --git a/server.go b/server.go index 0365188..a5a8fc0 100644 --- a/server.go +++ b/server.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "html/template" + httpkg "net/http" "os" "path" "reflect" @@ -14,6 +15,7 @@ import ( "git.nobla.cn/golang/aeus-admin/models" "git.nobla.cn/golang/aeus-admin/pkg/dbcache" adminTypes "git.nobla.cn/golang/aeus-admin/types" + "git.nobla.cn/golang/aeus/middleware/auth" "git.nobla.cn/golang/aeus/pkg/errors" "git.nobla.cn/golang/aeus/pkg/pool" "git.nobla.cn/golang/aeus/transport/http" @@ -35,6 +37,7 @@ func getModels() []any { &models.Permission{}, &models.RolePermission{}, &models.Setting{}, + &models.Activity{}, } } @@ -207,6 +210,19 @@ func generateVueFile(prefix string, apiPrefix string, mv *rest.Model) (err error return os.WriteFile(filename, writer.Bytes(), 0644) } +// restValueLookup 特殊字段获取方式 +func restValueLookup(column string, w httpkg.ResponseWriter, r *httpkg.Request) string { + switch column { + case "user": + // 从授权信息里面获取用户的ID + if t, ok := auth.FromContext(r.Context()); ok { + uid, _ := t.GetSubject() + return uid + } + } + return r.Header.Get(column) +} + // initREST 初始化REST模块 func initREST(ctx context.Context, o *options) (err error) { tx := o.db @@ -216,6 +232,7 @@ func initREST(ctx context.Context, o *options) (err error) { opts := make([]rest.Option, 0) opts = append(opts, o.restOpts...) opts = append(opts, rest.WithDB(tx)) + opts = append(opts, rest.WithValueLookup(restValueLookup)) if o.apiPrefix != "" { opts = append(opts, rest.WithUriPrefix(o.apiPrefix)) }