update proto

This commit is contained in:
Yavolte 2025-06-18 15:42:20 +08:00
parent 79a9746447
commit cb46385644
13 changed files with 1730 additions and 1564 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1057,265 +1057,6 @@ var _ interface {
ErrorName() string ErrorName() string
} = LoginValidationError{} } = LoginValidationError{}
// Validate checks the field values on Setting 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 *Setting) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Setting 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 SettingMultiError, or nil if none found.
func (m *Setting) ValidateAll() error {
return m.validate(true)
}
func (m *Setting) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Id
// no validation rules for CreatedAt
// no validation rules for UpdatedAt
if utf8.RuneCountInString(m.GetName()) > 20 {
err := SettingValidationError{
field: "Name",
reason: "value length must be at most 20 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if utf8.RuneCountInString(m.GetValue()) > 512 {
err := SettingValidationError{
field: "Value",
reason: "value length must be at most 512 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if utf8.RuneCountInString(m.GetDescription()) > 1024 {
err := SettingValidationError{
field: "Description",
reason: "value length must be at most 1024 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return SettingMultiError(errors)
}
return nil
}
// SettingMultiError is an error wrapping multiple validation errors returned
// by Setting.ValidateAll() if the designated constraints aren't met.
type SettingMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m SettingMultiError) 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 SettingMultiError) AllErrors() []error { return m }
// SettingValidationError is the validation error returned by Setting.Validate
// if the designated constraints aren't met.
type SettingValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e SettingValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e SettingValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e SettingValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e SettingValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e SettingValidationError) ErrorName() string { return "SettingValidationError" }
// Error satisfies the builtin error interface
func (e SettingValidationError) 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 %sSetting.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = SettingValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
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 // 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 // proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations. // error encountered is returned, or nil if there are no violations.
@ -5824,344 +5565,3 @@ var _ interface {
Cause() error Cause() error
ErrorName() string ErrorName() string
} = LogoutResponseValidationError{} } = LogoutResponseValidationError{}
// Validate checks the field values on SettingItem 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 *SettingItem) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on SettingItem 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 SettingItemMultiError, or
// nil if none found.
func (m *SettingItem) ValidateAll() error {
return m.validate(true)
}
func (m *SettingItem) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Name
// no validation rules for Value
if len(errors) > 0 {
return SettingItemMultiError(errors)
}
return nil
}
// SettingItemMultiError is an error wrapping multiple validation errors
// returned by SettingItem.ValidateAll() if the designated constraints aren't met.
type SettingItemMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m SettingItemMultiError) 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 SettingItemMultiError) AllErrors() []error { return m }
// SettingItemValidationError is the validation error returned by
// SettingItem.Validate if the designated constraints aren't met.
type SettingItemValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e SettingItemValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e SettingItemValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e SettingItemValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e SettingItemValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e SettingItemValidationError) ErrorName() string { return "SettingItemValidationError" }
// Error satisfies the builtin error interface
func (e SettingItemValidationError) 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 %sSettingItem.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = SettingItemValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = SettingItemValidationError{}
// Validate checks the field values on GetSettingRequest 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 *GetSettingRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on GetSettingRequest 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
// GetSettingRequestMultiError, or nil if none found.
func (m *GetSettingRequest) ValidateAll() error {
return m.validate(true)
}
func (m *GetSettingRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if len(errors) > 0 {
return GetSettingRequestMultiError(errors)
}
return nil
}
// GetSettingRequestMultiError is an error wrapping multiple validation errors
// returned by GetSettingRequest.ValidateAll() if the designated constraints
// aren't met.
type GetSettingRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m GetSettingRequestMultiError) 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 GetSettingRequestMultiError) AllErrors() []error { return m }
// GetSettingRequestValidationError is the validation error returned by
// GetSettingRequest.Validate if the designated constraints aren't met.
type GetSettingRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e GetSettingRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e GetSettingRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e GetSettingRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e GetSettingRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e GetSettingRequestValidationError) ErrorName() string {
return "GetSettingRequestValidationError"
}
// Error satisfies the builtin error interface
func (e GetSettingRequestValidationError) 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 %sGetSettingRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = GetSettingRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = GetSettingRequestValidationError{}
// Validate checks the field values on GetSettingResponse 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 *GetSettingResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on GetSettingResponse 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
// GetSettingResponseMultiError, or nil if none found.
func (m *GetSettingResponse) ValidateAll() error {
return m.validate(true)
}
func (m *GetSettingResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
for idx, item := range m.GetData() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, GetSettingResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, GetSettingResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return GetSettingResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return GetSettingResponseMultiError(errors)
}
return nil
}
// GetSettingResponseMultiError is an error wrapping multiple validation errors
// returned by GetSettingResponse.ValidateAll() if the designated constraints
// aren't met.
type GetSettingResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m GetSettingResponseMultiError) 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 GetSettingResponseMultiError) AllErrors() []error { return m }
// GetSettingResponseValidationError is the validation error returned by
// GetSettingResponse.Validate if the designated constraints aren't met.
type GetSettingResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e GetSettingResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e GetSettingResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e GetSettingResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e GetSettingResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e GetSettingResponseValidationError) ErrorName() string {
return "GetSettingResponseValidationError"
}
// Error satisfies the builtin error interface
func (e GetSettingResponseValidationError) 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 %sGetSettingResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = GetSettingResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = GetSettingResponseValidationError{}

View File

@ -115,34 +115,6 @@ message Login {
string user_agent = 10 [(aeus.field)={gorm:"size:1024",scenarios:"list;view;export",comment: "用户代理"}]; string user_agent = 10 [(aeus.field)={gorm:"size:1024",scenarios:"list;view;export",comment: "用户代理"}];
} }
// Setting
message Setting {
option (aeus.rest) = {
table: "settings"
};
int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}];
int64 created_at = 2 [(aeus.field)={scenarios:"search;view;export",comment:"创建时间"}];
int64 updated_at = 3 [(aeus.field)={scenarios:"search;view;export",comment:"更新时间"}];
string name = 4 [(aeus.field)={gorm:"size:60",rule:"required",props:"readonly:update",comment: "配置项"},(validate.rules).string = {max_len: 20}];
string value = 5 [(aeus.field)={gorm:"size:512",rule:"required",format:"textarea",comment: "配置值"},(validate.rules).string = {max_len: 512}];
string description = 6 [(aeus.field)={gorm:"size:1024",format:"textarea",scenarios:"create;update;view;export",comment: "备注说明"},(validate.rules).string = {max_len: 1024}];
}
// 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 { message LabelValue {
string label = 1; string label = 1;
string value = 2; string value = 2;
@ -450,22 +422,3 @@ service AuthService {
}; };
} }
} }
message SettingItem {
string name = 1;
string value = 2;
}
message GetSettingRequest{}
message GetSettingResponse{
repeated SettingItem data = 1;
}
service SettingService {
rpc GetSetting(GetSettingRequest) returns (GetSettingResponse) {
option (google.api.http) = {
get: "/system/setting"
};
}
}

View File

@ -973,105 +973,3 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "organize.proto", Metadata: "organize.proto",
} }
const (
SettingService_GetSetting_FullMethodName = "/organize.SettingService/GetSetting"
)
// SettingServiceClient is the client API for SettingService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SettingServiceClient interface {
GetSetting(ctx context.Context, in *GetSettingRequest, opts ...grpc.CallOption) (*GetSettingResponse, error)
}
type settingServiceClient struct {
cc grpc.ClientConnInterface
}
func NewSettingServiceClient(cc grpc.ClientConnInterface) SettingServiceClient {
return &settingServiceClient{cc}
}
func (c *settingServiceClient) GetSetting(ctx context.Context, in *GetSettingRequest, opts ...grpc.CallOption) (*GetSettingResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetSettingResponse)
err := c.cc.Invoke(ctx, SettingService_GetSetting_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// SettingServiceServer is the server API for SettingService service.
// All implementations must embed UnimplementedSettingServiceServer
// for forward compatibility.
type SettingServiceServer interface {
GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error)
mustEmbedUnimplementedSettingServiceServer()
}
// UnimplementedSettingServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedSettingServiceServer struct{}
func (UnimplementedSettingServiceServer) GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSetting not implemented")
}
func (UnimplementedSettingServiceServer) mustEmbedUnimplementedSettingServiceServer() {}
func (UnimplementedSettingServiceServer) testEmbeddedByValue() {}
// UnsafeSettingServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SettingServiceServer will
// result in compilation errors.
type UnsafeSettingServiceServer interface {
mustEmbedUnimplementedSettingServiceServer()
}
func RegisterSettingServiceServer(s grpc.ServiceRegistrar, srv SettingServiceServer) {
// If the following call pancis, it indicates UnimplementedSettingServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&SettingService_ServiceDesc, srv)
}
func _SettingService_GetSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetSettingRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SettingServiceServer).GetSetting(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: SettingService_GetSetting_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SettingServiceServer).GetSetting(ctx, req.(*GetSettingRequest))
}
return interceptor(ctx, in, info, handler)
}
// SettingService_ServiceDesc is the grpc.ServiceDesc for SettingService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SettingService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "organize.SettingService",
HandlerType: (*SettingServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetSetting",
Handler: _SettingService_GetSetting_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "organize.proto",
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT. // Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: organize.proto // source: organize.proto
// date: 2025-06-18 14:37:24 // date: 2025-06-18 15:37:30
package pb package pb
@ -52,10 +52,6 @@ type AuthServiceHttpServer interface {
Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error)
} }
type SettingServiceHttpServer interface {
GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error)
}
// 获取用户菜单 // 获取用户菜单
func handleUserServiceGetMenus(s UserServiceHttpServer) http.HandleFunc { func handleUserServiceGetMenus(s UserServiceHttpServer) http.HandleFunc {
@ -368,22 +364,6 @@ func handleAuthServiceLogout(s AuthServiceHttpServer) http.HandleFunc {
} }
} }
func handleSettingServiceGetSetting(s SettingServiceHttpServer) http.HandleFunc {
return func(ctx *http.Context) (err error) {
req := &GetSettingRequest{}
if res, err := s.GetSetting(ctx.Context(), req); err != nil {
if er, ok := err.(*errors.Error); ok {
return ctx.Error(er.Code, er.Message)
} else {
return ctx.Error(errors.Unavailable, err.Error())
}
} else {
return ctx.Success(res)
}
}
}
func RegisterUserServiceRouter(hs *http.Server, s UserServiceHttpServer) { func RegisterUserServiceRouter(hs *http.Server, s UserServiceHttpServer) {
// Register handle GetMenus route // Register handle GetMenus route
@ -451,10 +431,3 @@ func RegisterAuthServiceRouter(hs *http.Server, s AuthServiceHttpServer) {
hs.POST("/passport/logout", handleAuthServiceLogout(s)) hs.POST("/passport/logout", handleAuthServiceLogout(s))
} }
func RegisterSettingServiceRouter(hs *http.Server, s SettingServiceHttpServer) {
// Register handle GetSetting route
hs.GET("/system/setting", handleSettingServiceGetSetting(s))
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT. // Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: organize.proto // source: organize.proto
// date: 2025-06-18 14:37:24 // date: 2025-06-18 15:37:30
package pb package pb
@ -9,19 +9,19 @@ import (
) )
type MenuModel struct { type MenuModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"菜单ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"菜单ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index;column:updated_at" comment:"更新时间" scenarios:"view;export"`
Parent string `json:"parent" yaml:"parent" xml:"parent" gorm:"index;size:60" comment:"父级菜单" format:"menu" props:"readonly:update" live:"type:dropdown;url:/menu/level-labels"` Parent string `json:"parent" yaml:"parent" xml:"parent" gorm:"index;size:60;column:parent" comment:"父级菜单" format:"menu" props:"readonly:update" live:"type:dropdown;url:/menu/level-labels"`
Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60" comment:"组件名称" props:"readonly:update" rule:"unique;required"` Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60;column:name" comment:"组件名称" props:"readonly:update" rule:"unique;required"`
Label string `json:"label" yaml:"label" xml:"label" gorm:"size:120" comment:"菜单标题" rule:"required"` Label string `json:"label" yaml:"label" xml:"label" gorm:"size:120;column:label" comment:"菜单标题" rule:"required"`
Uri string `json:"uri" yaml:"uri" xml:"uri" gorm:"size:512" comment:"菜单链接" scenarios:"create;update;view;export" rule:"required"` Uri string `json:"uri" yaml:"uri" xml:"uri" gorm:"size:512;column:uri" comment:"菜单链接" scenarios:"create;update;view;export" rule:"required"`
ViewPath string `json:"view_path" yaml:"viewPath" xml:"viewPath" gorm:"size:512" comment:"视图路径" scenarios:"create;update;view;export"` ViewPath string `json:"view_path" yaml:"viewPath" xml:"viewPath" gorm:"size:512;column:view_path" comment:"视图路径" scenarios:"create;update;view;export"`
Icon string `json:"icon" yaml:"icon" xml:"icon" gorm:"size:60" comment:"菜单图标" scenarios:"create;update;view;export"` Icon string `json:"icon" yaml:"icon" xml:"icon" gorm:"size:60;column:icon" comment:"菜单图标" scenarios:"create;update;view;export"`
Hidden bool `json:"hidden" yaml:"hidden" xml:"hidden" comment:"是否隐藏" scenarios:"create;update;view;export"` Hidden bool `json:"hidden" yaml:"hidden" xml:"hidden" gorm:"column:hidden" comment:"是否隐藏" scenarios:"create;update;view;export"`
Public bool `json:"public" yaml:"public" xml:"public" comment:"是否公开" scenarios:"create;update;view;export"` Public bool `json:"public" yaml:"public" xml:"public" gorm:"column:public" comment:"是否公开" scenarios:"create;update;view;export"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"` Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"`
Position int64 `json:"position" yaml:"position" xml:"position" comment:"排序" scenarios:"create;update"` Position int64 `json:"position" yaml:"position" xml:"position" gorm:"column:position" comment:"排序" scenarios:"create;update"`
} }
func (m *MenuModel) TableName() string { func (m *MenuModel) TableName() string {
@ -79,14 +79,14 @@ func (m *MenuModel) Delete(db *gorm.DB) (err error) {
} }
func (m *MenuModel) Find(db *gorm.DB, pk any) (err error) { func (m *MenuModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("position=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *MenuModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *MenuModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *MenuModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *MenuModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
@ -95,12 +95,12 @@ func NewMenuModel() *MenuModel {
} }
type RoleModel struct { type RoleModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"角色ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"角色ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index;column:updated_at" comment:"更新时间" scenarios:"view;export"`
Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60" comment:"角色名称" props:"readonly:update"` Name string `json:"name" yaml:"name" xml:"name" gorm:"index;size:60;column:name" comment:"角色名称" props:"readonly:update"`
Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60" comment:"角色标题"` Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60;column:label" comment:"角色标题"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"list;create;update;export" format:"textarea"` Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"list;create;update;export" format:"textarea"`
} }
func (m *RoleModel) TableName() string { func (m *RoleModel) TableName() string {
@ -144,14 +144,14 @@ func (m *RoleModel) Delete(db *gorm.DB) (err error) {
} }
func (m *RoleModel) Find(db *gorm.DB, pk any) (err error) { func (m *RoleModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("description=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *RoleModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *RoleModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *RoleModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *RoleModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
@ -160,12 +160,12 @@ func NewRoleModel() *RoleModel {
} }
type PermissionModel struct { type PermissionModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"权限ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"权限ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index;column:updated_at" comment:"更新时间" scenarios:"view;export"`
Menu string `json:"menu" yaml:"menu" xml:"menu" gorm:"index;size:60" comment:"所属菜单" format:"menu" rule:"required"` Menu string `json:"menu" yaml:"menu" xml:"menu" gorm:"index;size:60;column:menu" comment:"所属菜单" format:"menu" rule:"required"`
Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"index;size:60" comment:"权限名称" rule:"required"` Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"index;size:60;column:permission" comment:"权限名称" rule:"required"`
Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60" comment:"权限标题" rule:"required"` Label string `json:"label" yaml:"label" xml:"label" gorm:"size:60;column:label" comment:"权限标题" rule:"required"`
} }
func (m *PermissionModel) TableName() string { func (m *PermissionModel) TableName() string {
@ -209,14 +209,14 @@ func (m *PermissionModel) Delete(db *gorm.DB) (err error) {
} }
func (m *PermissionModel) Find(db *gorm.DB, pk any) (err error) { func (m *PermissionModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("label=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *PermissionModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *PermissionModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *PermissionModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *PermissionModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
@ -225,9 +225,9 @@ func NewPermissionModel() *PermissionModel {
} }
type RolePermissionModel struct { type RolePermissionModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
Role string `json:"role" yaml:"role" xml:"role" gorm:"index;size:60" comment:"角色" rule:"required"` Role string `json:"role" yaml:"role" xml:"role" gorm:"index;size:60;column:role" comment:"角色" rule:"required"`
Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"size:60" comment:"权限" rule:"required"` Permission string `json:"permission" yaml:"permission" xml:"permission" gorm:"size:60;column:permission" comment:"权限" rule:"required"`
} }
func (m *RolePermissionModel) TableName() string { func (m *RolePermissionModel) TableName() string {
@ -265,14 +265,14 @@ func (m *RolePermissionModel) Delete(db *gorm.DB) (err error) {
} }
func (m *RolePermissionModel) Find(db *gorm.DB, pk any) (err error) { func (m *RolePermissionModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("permission=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *RolePermissionModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *RolePermissionModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *RolePermissionModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *RolePermissionModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
@ -281,21 +281,21 @@ func NewRolePermissionModel() *RolePermissionModel {
} }
type UserModel struct { type UserModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index;column:updated_at" comment:"更新时间" scenarios:"view;export"`
Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20" comment:"用户工号" props:"readonly:update" rule:"required;unique;regexp:^[a-zA-Z0-9]{3,8}$"` Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20;column:uid" comment:"用户工号" props:"readonly:update" rule:"required;unique;regexp:^[a-zA-Z0-9]{3,8}$"`
Username string `json:"username" yaml:"username" xml:"username" gorm:"size:20" comment:"用户名称" rule:"required"` Username string `json:"username" yaml:"username" xml:"username" gorm:"size:20;column:username" comment:"用户名称" rule:"required"`
Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60;not null;default:''" comment:"所属角色" format:"role" rule:"required" live:"type:dropdown;url:/role/labels"` Role string `json:"role" yaml:"role" xml:"role" gorm:"size:60;not null;default:'';column:role" comment:"所属角色" format:"role" rule:"required" live:"type:dropdown;url:/role/labels"`
Admin bool `json:"admin" yaml:"admin" xml:"admin" comment:"管理员" scenarios:"create"` Admin bool `json:"admin" yaml:"admin" xml:"admin" gorm:"column:admin" comment:"管理员" scenarios:"create"`
Status string `json:"status" yaml:"status" xml:"status" gorm:"size:20;default:normal" comment:"状态" scenarios:"create,update,list,search" enum:"normal:正常;disable:禁用"` Status string `json:"status" yaml:"status" xml:"status" gorm:"size:20;default:normal;column:status" comment:"状态" scenarios:"create,update,list,search" enum:"normal:正常;disable:禁用"`
DeptId int64 `json:"dept_id" yaml:"deptId" xml:"deptId" gorm:"not null;default:0" comment:"所属部门" format:"department" rule:"required" live:"type:dropdown;url:/department/labels"` DeptId int64 `json:"dept_id" yaml:"deptId" xml:"deptId" gorm:"not null;default:0;column:dept_id" comment:"所属部门" format:"department" rule:"required" live:"type:dropdown;url:/department/labels"`
Tag string `json:"tag" yaml:"tag" xml:"tag" gorm:"size:60" comment:"用户标签" scenarios:"list;create;update" live:"type:dropdown;url:/user/tags" dropdown:"created;filterable;default_first"` Tag string `json:"tag" yaml:"tag" xml:"tag" gorm:"size:60;column:tag" comment:"用户标签" scenarios:"list;create;update" live:"type:dropdown;url:/user/tags" dropdown:"created;filterable;default_first"`
Password string `json:"password" yaml:"password" xml:"password" gorm:"size:60" comment:"用户密码" scenarios:"create" rule:"required"` Password string `json:"password" yaml:"password" xml:"password" gorm:"size:60;column:password" comment:"用户密码" scenarios:"create" rule:"required"`
Email string `json:"email" yaml:"email" xml:"email" gorm:"size:60" comment:"用户邮箱" scenarios:"create;update;view;list;export"` Email string `json:"email" yaml:"email" xml:"email" gorm:"size:60;column:email" comment:"用户邮箱" scenarios:"create;update;view;list;export"`
Avatar string `json:"avatar" yaml:"avatar" xml:"avatar" gorm:"size:1024" comment:"用户头像" scenarios:"view"` Avatar string `json:"avatar" yaml:"avatar" xml:"avatar" gorm:"size:1024;column:avatar" comment:"用户头像" scenarios:"view"`
Gender string `json:"gender" yaml:"gender" xml:"gender" gorm:"size:20;default:man" comment:"用户性别" scenarios:"list;create;update;view;export" rule:"required" enum:"man:男;woman:女;other:其他"` Gender string `json:"gender" yaml:"gender" xml:"gender" gorm:"size:20;default:man;column:gender" comment:"用户性别" scenarios:"list;create;update;view;export" rule:"required" enum:"man:男;woman:女;other:其他"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"` Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"`
} }
func (m *UserModel) TableName() string { func (m *UserModel) TableName() string {
@ -357,14 +357,14 @@ func (m *UserModel) Delete(db *gorm.DB) (err error) {
} }
func (m *UserModel) Find(db *gorm.DB, pk any) (err error) { func (m *UserModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("description=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *UserModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *UserModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *UserModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *UserModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
@ -373,12 +373,12 @@ func NewUserModel() *UserModel {
} }
type DepartmentModel struct { type DepartmentModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"创建时间" scenarios:"view;export"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index" comment:"更新时间" scenarios:"view;export"` UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"index;column:updated_at" comment:"更新时间" scenarios:"view;export"`
ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" comment:"父级部门" format:"department" live:"type:dropdown;url:/department/level-labels"` ParentId int64 `json:"parent_id" yaml:"parentId" xml:"parentId" gorm:"column:parent_id" comment:"父级部门" format:"department" live:"type:dropdown;url:/department/level-labels"`
Name string `json:"name" yaml:"name" xml:"name" gorm:"size:20" comment:"部门名称" rule:"required"` Name string `json:"name" yaml:"name" xml:"name" gorm:"size:20;column:name" comment:"部门名称" rule:"required"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"` Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"create;update;view;export;list" format:"textarea"`
} }
func (m *DepartmentModel) TableName() string { func (m *DepartmentModel) TableName() string {
@ -422,14 +422,14 @@ func (m *DepartmentModel) Delete(db *gorm.DB) (err error) {
} }
func (m *DepartmentModel) Find(db *gorm.DB, pk any) (err error) { func (m *DepartmentModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("description=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *DepartmentModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *DepartmentModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *DepartmentModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *DepartmentModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
@ -438,15 +438,15 @@ func NewDepartmentModel() *DepartmentModel {
} }
type LoginModel struct { type LoginModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey" comment:"ID"` Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" comment:"登录时间" scenarios:"list;search;view;export"` CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" 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;column:uid" 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"` Ip string `json:"ip" yaml:"ip" xml:"ip" gorm:"size:128;column:ip" comment:"登录地址" scenarios:"list;search;view;export"`
Browser string `json:"browser" yaml:"browser" xml:"browser" gorm:"size:128" comment:"浏览器" scenarios:"list;view;export"` Browser string `json:"browser" yaml:"browser" xml:"browser" gorm:"size:128;column:browser" comment:"浏览器" scenarios:"list;view;export"`
Os string `json:"os" yaml:"os" xml:"os" gorm:"size:128" comment:"操作系统" scenarios:"list;view;export"` Os string `json:"os" yaml:"os" xml:"os" gorm:"size:128;column:os" comment:"操作系统" scenarios:"list;view;export"`
Platform string `json:"platform" yaml:"platform" xml:"platform" gorm:"size:128" comment:"系统平台" scenarios:"list;view;export"` Platform string `json:"platform" yaml:"platform" xml:"platform" gorm:"size:128;column:platform" comment:"系统平台" scenarios:"list;view;export"`
AccessToken string `json:"access_token" yaml:"accessToken" xml:"accessToken" gorm:"size:1024" comment:"访问令牌" scenarios:"list;view;export"` AccessToken string `json:"access_token" yaml:"accessToken" xml:"accessToken" gorm:"size:1024;column:access_token" comment:"访问令牌" scenarios:"list;view;export"`
UserAgent string `json:"user_agent" yaml:"userAgent" xml:"userAgent" gorm:"size:1024" comment:"用户代理" scenarios:"list;view;export"` UserAgent string `json:"user_agent" yaml:"userAgent" xml:"userAgent" gorm:"size:1024;column:user_agent" comment:"用户代理" scenarios:"list;view;export"`
} }
func (m *LoginModel) TableName() string { func (m *LoginModel) TableName() string {
@ -496,150 +496,17 @@ func (m *LoginModel) Delete(db *gorm.DB) (err error) {
} }
func (m *LoginModel) Find(db *gorm.DB, pk any) (err error) { func (m *LoginModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("user_agent=?", pk).First(m).Error return db.Where("id=?", pk).First(m).Error
} }
func (m *LoginModel) FindOne(db *gorm.DB, query any, args ...any) (err error) { func (m *LoginModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error return db.Where(query, args...).First(m).Error
} }
func (m *LoginModel) FindAll(db *gorm.DB, query any, args ...any) (err error) { func (m *LoginModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error return db.Where(query, args...).Find(m).Error
} }
func NewLoginModel() *LoginModel { func NewLoginModel() *LoginModel {
return &LoginModel{} return &LoginModel{}
} }
type SettingModel 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;view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" comment:"更新时间" scenarios:"search;view;export"`
Name string `json:"name" yaml:"name" xml:"name" gorm:"size:60" comment:"配置项" props:"readonly:update" rule:"required"`
Value string `json:"value" yaml:"value" xml:"value" gorm:"size:512" comment:"配置值" format:"textarea" rule:"required"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"`
}
func (m *SettingModel) TableName() string {
return "settings"
}
func (m *SettingModel) FromValue(x *Setting) {
m.Id = x.Id
m.CreatedAt = x.CreatedAt
m.UpdatedAt = x.UpdatedAt
m.Name = x.Name
m.Value = x.Value
m.Description = x.Description
}
func (m *SettingModel) ToValue() (x *Setting) {
x = &Setting{}
x.Id = m.Id
x.CreatedAt = m.CreatedAt
x.UpdatedAt = m.UpdatedAt
x.Name = m.Name
x.Value = m.Value
x.Description = m.Description
return x
}
func (m *SettingModel) Create(db *gorm.DB) (err error) {
return db.Create(m).Error
}
func (m *SettingModel) UpdateColumn(db *gorm.DB, column string, value any) (err error) {
return db.Model(m).UpdateColumn(column, value).Error
}
func (m *SettingModel) Save(db *gorm.DB) (err error) {
return db.Save(m).Error
}
func (m *SettingModel) Delete(db *gorm.DB) (err error) {
return db.Delete(m).Error
}
func (m *SettingModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("description=?", pk).First(m).Error
}
func (m *SettingModel) FindOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error
}
func (m *SettingModel) FindAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).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{}
}

440
pb/system.pb.go 100644
View File

@ -0,0 +1,440 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v5.29.3
// source: system.proto
package pb
import (
_ "git.nobla.cn/golang/aeus/pkg/proto/rest"
_ "github.com/envoyproxy/protoc-gen-validate/validate"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/descriptorpb"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// Setting 参数设置表
type Setting 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"`
UpdatedAt int64 `protobuf:"varint,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"`
Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Setting) Reset() {
*x = Setting{}
mi := &file_system_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Setting) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Setting) ProtoMessage() {}
func (x *Setting) ProtoReflect() protoreflect.Message {
mi := &file_system_proto_msgTypes[0]
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 Setting.ProtoReflect.Descriptor instead.
func (*Setting) Descriptor() ([]byte, []int) {
return file_system_proto_rawDescGZIP(), []int{0}
}
func (x *Setting) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *Setting) GetCreatedAt() int64 {
if x != nil {
return x.CreatedAt
}
return 0
}
func (x *Setting) GetUpdatedAt() int64 {
if x != nil {
return x.UpdatedAt
}
return 0
}
func (x *Setting) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Setting) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
func (x *Setting) GetDescription() string {
if x != nil {
return x.Description
}
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_system_proto_msgTypes[1]
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_system_proto_msgTypes[1]
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_system_proto_rawDescGZIP(), []int{1}
}
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 SettingItem struct {
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SettingItem) Reset() {
*x = SettingItem{}
mi := &file_system_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SettingItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SettingItem) ProtoMessage() {}
func (x *SettingItem) ProtoReflect() protoreflect.Message {
mi := &file_system_proto_msgTypes[2]
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 SettingItem.ProtoReflect.Descriptor instead.
func (*SettingItem) Descriptor() ([]byte, []int) {
return file_system_proto_rawDescGZIP(), []int{2}
}
func (x *SettingItem) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *SettingItem) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
type GetSettingRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetSettingRequest) Reset() {
*x = GetSettingRequest{}
mi := &file_system_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetSettingRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetSettingRequest) ProtoMessage() {}
func (x *GetSettingRequest) ProtoReflect() protoreflect.Message {
mi := &file_system_proto_msgTypes[3]
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 GetSettingRequest.ProtoReflect.Descriptor instead.
func (*GetSettingRequest) Descriptor() ([]byte, []int) {
return file_system_proto_rawDescGZIP(), []int{3}
}
type GetSettingResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Data []*SettingItem `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetSettingResponse) Reset() {
*x = GetSettingResponse{}
mi := &file_system_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetSettingResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetSettingResponse) ProtoMessage() {}
func (x *GetSettingResponse) ProtoReflect() protoreflect.Message {
mi := &file_system_proto_msgTypes[4]
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 GetSettingResponse.ProtoReflect.Descriptor instead.
func (*GetSettingResponse) Descriptor() ([]byte, []int) {
return file_system_proto_rawDescGZIP(), []int{4}
}
func (x *GetSettingResponse) GetData() []*SettingItem {
if x != nil {
return x.Data
}
return nil
}
var File_system_proto protoreflect.FileDescriptor
const file_system_proto_rawDesc = "" +
"\n" +
"\fsystem.proto\x12\x06system\x1a\x0faeus/rest.proto\x1a\x17validate/validate.proto\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/api/annotations.proto\"\xd8\x03\n" +
"\aSetting\x12$\n" +
"\x02id\x18\x01 \x01(\x03B\x14\xb2\xb9\x19\x10\n" +
"\n" +
"primaryKey\x12\x02IDR\x02id\x12E\n" +
"\n" +
"created_at\x18\x02 \x01(\x03B&\xb2\xb9\x19\"\x12\f创建时间\x1a\x12search;view;exportR\tcreatedAt\x12E\n" +
"\n" +
"updated_at\x18\x03 \x01(\x03B&\xb2\xb9\x19\"\x12\f更新时间\x1a\x12search;view;exportR\tupdatedAt\x12N\n" +
"\x04name\x18\x04 \x01(\tB:\xfaB\x04r\x02\x18\x14\xb2\xb9\x19/\n" +
"\asize:60\x12\t配置项2\x0freadonly:update:\brequiredR\x04name\x12K\n" +
"\x05value\x18\x05 \x01(\tB5\xfaB\x05r\x03\x18\x80\x04\xb2\xb9\x19)\n" +
"\bsize:512\x12\t配置值*\btextarea:\brequiredR\x05value\x12l\n" +
"\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\"\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\"7\n" +
"\vSettingItem\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value\"\x13\n" +
"\x11GetSettingRequest\"=\n" +
"\x12GetSettingResponse\x12'\n" +
"\x04data\x18\x01 \x03(\v2\x13.system.SettingItemR\x04data2n\n" +
"\x0eSettingService\x12\\\n" +
"\n" +
"GetSetting\x12\x19.system.GetSettingRequest\x1a\x1a.system.GetSettingResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/system/settingB&Z$git.nobla.cn/golang/aeis-admin/pb;pbb\x06proto3"
var (
file_system_proto_rawDescOnce sync.Once
file_system_proto_rawDescData []byte
)
func file_system_proto_rawDescGZIP() []byte {
file_system_proto_rawDescOnce.Do(func() {
file_system_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_proto_rawDesc), len(file_system_proto_rawDesc)))
})
return file_system_proto_rawDescData
}
var file_system_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_system_proto_goTypes = []any{
(*Setting)(nil), // 0: system.Setting
(*Activity)(nil), // 1: system.Activity
(*SettingItem)(nil), // 2: system.SettingItem
(*GetSettingRequest)(nil), // 3: system.GetSettingRequest
(*GetSettingResponse)(nil), // 4: system.GetSettingResponse
}
var file_system_proto_depIdxs = []int32{
2, // 0: system.GetSettingResponse.data:type_name -> system.SettingItem
3, // 1: system.SettingService.GetSetting:input_type -> system.GetSettingRequest
4, // 2: system.SettingService.GetSetting:output_type -> system.GetSettingResponse
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_system_proto_init() }
func file_system_proto_init() {
if File_system_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_proto_rawDesc), len(file_system_proto_rawDesc)),
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_system_proto_goTypes,
DependencyIndexes: file_system_proto_depIdxs,
MessageInfos: file_system_proto_msgTypes,
}.Build()
File_system_proto = out.File
file_system_proto_goTypes = nil
file_system_proto_depIdxs = nil
}

View File

@ -0,0 +1,636 @@
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: system.proto
package pb
import (
"bytes"
"errors"
"fmt"
"net"
"net/mail"
"net/url"
"regexp"
"sort"
"strings"
"time"
"unicode/utf8"
"google.golang.org/protobuf/types/known/anypb"
)
// ensure the imports are used
var (
_ = bytes.MinRead
_ = errors.New("")
_ = fmt.Print
_ = utf8.UTFMax
_ = (*regexp.Regexp)(nil)
_ = (*strings.Reader)(nil)
_ = net.IPv4len
_ = time.Duration(0)
_ = (*url.URL)(nil)
_ = (*mail.Address)(nil)
_ = anypb.Any{}
_ = sort.Sort
)
// Validate checks the field values on Setting 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 *Setting) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on Setting 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 SettingMultiError, or nil if none found.
func (m *Setting) ValidateAll() error {
return m.validate(true)
}
func (m *Setting) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Id
// no validation rules for CreatedAt
// no validation rules for UpdatedAt
if utf8.RuneCountInString(m.GetName()) > 20 {
err := SettingValidationError{
field: "Name",
reason: "value length must be at most 20 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if utf8.RuneCountInString(m.GetValue()) > 512 {
err := SettingValidationError{
field: "Value",
reason: "value length must be at most 512 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if utf8.RuneCountInString(m.GetDescription()) > 1024 {
err := SettingValidationError{
field: "Description",
reason: "value length must be at most 1024 runes",
}
if !all {
return err
}
errors = append(errors, err)
}
if len(errors) > 0 {
return SettingMultiError(errors)
}
return nil
}
// SettingMultiError is an error wrapping multiple validation errors returned
// by Setting.ValidateAll() if the designated constraints aren't met.
type SettingMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m SettingMultiError) 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 SettingMultiError) AllErrors() []error { return m }
// SettingValidationError is the validation error returned by Setting.Validate
// if the designated constraints aren't met.
type SettingValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e SettingValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e SettingValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e SettingValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e SettingValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e SettingValidationError) ErrorName() string { return "SettingValidationError" }
// Error satisfies the builtin error interface
func (e SettingValidationError) 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 %sSetting.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = SettingValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
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 SettingItem 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 *SettingItem) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on SettingItem 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 SettingItemMultiError, or
// nil if none found.
func (m *SettingItem) ValidateAll() error {
return m.validate(true)
}
func (m *SettingItem) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Name
// no validation rules for Value
if len(errors) > 0 {
return SettingItemMultiError(errors)
}
return nil
}
// SettingItemMultiError is an error wrapping multiple validation errors
// returned by SettingItem.ValidateAll() if the designated constraints aren't met.
type SettingItemMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m SettingItemMultiError) 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 SettingItemMultiError) AllErrors() []error { return m }
// SettingItemValidationError is the validation error returned by
// SettingItem.Validate if the designated constraints aren't met.
type SettingItemValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e SettingItemValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e SettingItemValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e SettingItemValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e SettingItemValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e SettingItemValidationError) ErrorName() string { return "SettingItemValidationError" }
// Error satisfies the builtin error interface
func (e SettingItemValidationError) 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 %sSettingItem.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = SettingItemValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = SettingItemValidationError{}
// Validate checks the field values on GetSettingRequest 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 *GetSettingRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on GetSettingRequest 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
// GetSettingRequestMultiError, or nil if none found.
func (m *GetSettingRequest) ValidateAll() error {
return m.validate(true)
}
func (m *GetSettingRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if len(errors) > 0 {
return GetSettingRequestMultiError(errors)
}
return nil
}
// GetSettingRequestMultiError is an error wrapping multiple validation errors
// returned by GetSettingRequest.ValidateAll() if the designated constraints
// aren't met.
type GetSettingRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m GetSettingRequestMultiError) 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 GetSettingRequestMultiError) AllErrors() []error { return m }
// GetSettingRequestValidationError is the validation error returned by
// GetSettingRequest.Validate if the designated constraints aren't met.
type GetSettingRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e GetSettingRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e GetSettingRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e GetSettingRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e GetSettingRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e GetSettingRequestValidationError) ErrorName() string {
return "GetSettingRequestValidationError"
}
// Error satisfies the builtin error interface
func (e GetSettingRequestValidationError) 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 %sGetSettingRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = GetSettingRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = GetSettingRequestValidationError{}
// Validate checks the field values on GetSettingResponse 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 *GetSettingResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on GetSettingResponse 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
// GetSettingResponseMultiError, or nil if none found.
func (m *GetSettingResponse) ValidateAll() error {
return m.validate(true)
}
func (m *GetSettingResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
for idx, item := range m.GetData() {
_, _ = idx, item
if all {
switch v := interface{}(item).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, GetSettingResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, GetSettingResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return GetSettingResponseValidationError{
field: fmt.Sprintf("Data[%v]", idx),
reason: "embedded message failed validation",
cause: err,
}
}
}
}
if len(errors) > 0 {
return GetSettingResponseMultiError(errors)
}
return nil
}
// GetSettingResponseMultiError is an error wrapping multiple validation errors
// returned by GetSettingResponse.ValidateAll() if the designated constraints
// aren't met.
type GetSettingResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m GetSettingResponseMultiError) 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 GetSettingResponseMultiError) AllErrors() []error { return m }
// GetSettingResponseValidationError is the validation error returned by
// GetSettingResponse.Validate if the designated constraints aren't met.
type GetSettingResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e GetSettingResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e GetSettingResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e GetSettingResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e GetSettingResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e GetSettingResponseValidationError) ErrorName() string {
return "GetSettingResponseValidationError"
}
// Error satisfies the builtin error interface
func (e GetSettingResponseValidationError) 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 %sGetSettingResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = GetSettingResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = GetSettingResponseValidationError{}

59
pb/system.proto 100644
View File

@ -0,0 +1,59 @@
syntax = "proto3";
package system;
import "aeus/rest.proto";
import "validate/validate.proto";
import "google/protobuf/descriptor.proto";
import "google/api/annotations.proto";
option go_package = "git.nobla.cn/golang/aeis-admin/pb;pb";
// Setting
message Setting {
option (aeus.rest) = {
table: "settings"
};
int64 id = 1 [(aeus.field) = {gorm:"primaryKey",comment:"ID"}];
int64 created_at = 2 [(aeus.field)={scenarios:"search;view;export",comment:"创建时间"}];
int64 updated_at = 3 [(aeus.field)={scenarios:"search;view;export",comment:"更新时间"}];
string name = 4 [(aeus.field)={gorm:"size:60",rule:"required",props:"readonly:update",comment: "配置项"},(validate.rules).string = {max_len: 20}];
string value = 5 [(aeus.field)={gorm:"size:512",rule:"required",format:"textarea",comment: "配置值"},(validate.rules).string = {max_len: 512}];
string description = 6 [(aeus.field)={gorm:"size:1024",format:"textarea",scenarios:"create;update;view;export",comment: "备注说明"},(validate.rules).string = {max_len: 1024}];
}
// 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 SettingItem {
string name = 1;
string value = 2;
}
message GetSettingRequest{}
message GetSettingResponse{
repeated SettingItem data = 1;
}
service SettingService {
rpc GetSetting(GetSettingRequest) returns (GetSettingResponse) {
option (google.api.http) = {
get: "/system/setting"
};
}
}

View File

@ -0,0 +1,121 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.3
// source: system.proto
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
SettingService_GetSetting_FullMethodName = "/system.SettingService/GetSetting"
)
// SettingServiceClient is the client API for SettingService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SettingServiceClient interface {
GetSetting(ctx context.Context, in *GetSettingRequest, opts ...grpc.CallOption) (*GetSettingResponse, error)
}
type settingServiceClient struct {
cc grpc.ClientConnInterface
}
func NewSettingServiceClient(cc grpc.ClientConnInterface) SettingServiceClient {
return &settingServiceClient{cc}
}
func (c *settingServiceClient) GetSetting(ctx context.Context, in *GetSettingRequest, opts ...grpc.CallOption) (*GetSettingResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetSettingResponse)
err := c.cc.Invoke(ctx, SettingService_GetSetting_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// SettingServiceServer is the server API for SettingService service.
// All implementations must embed UnimplementedSettingServiceServer
// for forward compatibility.
type SettingServiceServer interface {
GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error)
mustEmbedUnimplementedSettingServiceServer()
}
// UnimplementedSettingServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedSettingServiceServer struct{}
func (UnimplementedSettingServiceServer) GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSetting not implemented")
}
func (UnimplementedSettingServiceServer) mustEmbedUnimplementedSettingServiceServer() {}
func (UnimplementedSettingServiceServer) testEmbeddedByValue() {}
// UnsafeSettingServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SettingServiceServer will
// result in compilation errors.
type UnsafeSettingServiceServer interface {
mustEmbedUnimplementedSettingServiceServer()
}
func RegisterSettingServiceServer(s grpc.ServiceRegistrar, srv SettingServiceServer) {
// If the following call pancis, it indicates UnimplementedSettingServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&SettingService_ServiceDesc, srv)
}
func _SettingService_GetSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetSettingRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SettingServiceServer).GetSetting(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: SettingService_GetSetting_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SettingServiceServer).GetSetting(ctx, req.(*GetSettingRequest))
}
return interceptor(ctx, in, info, handler)
}
// SettingService_ServiceDesc is the grpc.ServiceDesc for SettingService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SettingService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "system.SettingService",
HandlerType: (*SettingServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetSetting",
Handler: _SettingService_GetSetting_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "system.proto",
}

View File

@ -0,0 +1,38 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: system.proto
// date: 2025-06-18 15:37:30
package pb
import (
"git.nobla.cn/golang/aeus/transport/http"
"context"
"git.nobla.cn/golang/aeus/pkg/errors"
)
type SettingServiceHttpServer interface {
GetSetting(context.Context, *GetSettingRequest) (*GetSettingResponse, error)
}
func handleSettingServiceGetSetting(s SettingServiceHttpServer) http.HandleFunc {
return func(ctx *http.Context) (err error) {
req := &GetSettingRequest{}
if res, err := s.GetSetting(ctx.Context(), req); err != nil {
if er, ok := err.(*errors.Error); ok {
return ctx.Error(er.Code, er.Message)
} else {
return ctx.Error(errors.Unavailable, err.Error())
}
} else {
return ctx.Success(res)
}
}
}
func RegisterSettingServiceRouter(hs *http.Server, s SettingServiceHttpServer) {
// Register handle GetSetting route
hs.GET("/system/setting", handleSettingServiceGetSetting(s))
}

View File

@ -0,0 +1,142 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: system.proto
// date: 2025-06-18 15:37:30
package pb
import (
"gorm.io/gorm"
)
type SettingModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"search;view;export"`
UpdatedAt int64 `json:"updated_at" yaml:"updatedAt" xml:"updatedAt" gorm:"column:updated_at" comment:"更新时间" scenarios:"search;view;export"`
Name string `json:"name" yaml:"name" xml:"name" gorm:"size:60;column:name" comment:"配置项" props:"readonly:update" rule:"required"`
Value string `json:"value" yaml:"value" xml:"value" gorm:"size:512;column:value" comment:"配置值" format:"textarea" rule:"required"`
Description string `json:"description" yaml:"description" xml:"description" gorm:"size:1024;column:description" comment:"备注说明" scenarios:"create;update;view;export" format:"textarea"`
}
func (m *SettingModel) TableName() string {
return "settings"
}
func (m *SettingModel) FromValue(x *Setting) {
m.Id = x.Id
m.CreatedAt = x.CreatedAt
m.UpdatedAt = x.UpdatedAt
m.Name = x.Name
m.Value = x.Value
m.Description = x.Description
}
func (m *SettingModel) ToValue() (x *Setting) {
x = &Setting{}
x.Id = m.Id
x.CreatedAt = m.CreatedAt
x.UpdatedAt = m.UpdatedAt
x.Name = m.Name
x.Value = m.Value
x.Description = m.Description
return x
}
func (m *SettingModel) Create(db *gorm.DB) (err error) {
return db.Create(m).Error
}
func (m *SettingModel) UpdateColumn(db *gorm.DB, column string, value any) (err error) {
return db.Model(m).UpdateColumn(column, value).Error
}
func (m *SettingModel) Save(db *gorm.DB) (err error) {
return db.Save(m).Error
}
func (m *SettingModel) Delete(db *gorm.DB) (err error) {
return db.Delete(m).Error
}
func (m *SettingModel) Find(db *gorm.DB, pk any) (err error) {
return db.Where("id=?", pk).First(m).Error
}
func (m *SettingModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error
}
func (m *SettingModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error
}
func NewSettingModel() *SettingModel {
return &SettingModel{}
}
type ActivityModel struct {
Id int64 `json:"id" yaml:"id" xml:"id" gorm:"primaryKey;column:id" comment:"ID"`
CreatedAt int64 `json:"created_at" yaml:"createdAt" xml:"createdAt" gorm:"column:created_at" comment:"创建时间" scenarios:"search;search;view;export"`
Uid string `json:"uid" yaml:"uid" xml:"uid" gorm:"index;size:20;column:uid" comment:"用户" format:"user" props:"readonly:update" rule:"required"`
Action string `json:"action" yaml:"action" xml:"action" gorm:"index;size:20;not null;default:'';column:action" 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:'';column:module" comment:"模块" scenarios:"search;list;create;update;view;export"`
Table string `json:"table" yaml:"table" xml:"table" gorm:"size:60;not null;default:'';column:table" comment:"数据" scenarios:"list;create;update;view;export"`
Data string `json:"data" yaml:"data" xml:"data" gorm:"size:10240;not null;default:'';column:data" 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("id=?", pk).First(m).Error
}
func (m *ActivityModel) QueryOne(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).First(m).Error
}
func (m *ActivityModel) QueryAll(db *gorm.DB, query any, args ...any) (err error) {
return db.Where(query, args...).Find(m).Error
}
func NewActivityModel() *ActivityModel {
return &ActivityModel{}
}

View File

@ -129,7 +129,7 @@ func (s *AuthService) Login(ctx context.Context, req *pb.LoginRequest) (res *pb.
if err = s.turnstileValidate(ctx, req.Token); err != nil { if err = s.turnstileValidate(ctx, req.Token); err != nil {
return nil, errors.Format(errors.Invalid, err.Error()) return nil, errors.Format(errors.Invalid, err.Error())
} }
if err = model.FindOne(tx, "uid=?", req.Username); err != nil { if err = model.QueryOne(tx, "uid=?", req.Username); err != nil {
return nil, errors.ErrAccessDenied return nil, errors.ErrAccessDenied
} }
if model.Status != types.UserStatusNormal { if model.Status != types.UserStatusNormal {