diff --git a/api/.golangci.yml b/api/.golangci.yml index c56b3b424..882c523b7 100644 --- a/api/.golangci.yml +++ b/api/.golangci.yml @@ -32,7 +32,6 @@ linters: - asasalint - bodyclose - unparam - - tagalign - revive - predeclared - interfacebloat diff --git a/api/repo/file_repo.go b/api/repo/file_repo.go index 10cfe6851..8d3b7f3ac 100644 --- a/api/repo/file_repo.go +++ b/api/repo/file_repo.go @@ -54,17 +54,17 @@ func NewFile() model.File { } type fileEntity struct { - ID string `json:"id" gorm:"column:id"` - WorkspaceID string `json:"workspaceId" gorm:"column:workspace_id"` - Name string `json:"name" gorm:"column:name"` - Type string `json:"type" gorm:"column:type"` - ParentID *string `json:"parentId,omitempty" gorm:"column:parent_id"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Text *string `json:"text,omitempty" gorm:"-"` - SnapshotID *string `json:"snapshotId,omitempty" gorm:"column:snapshot_id"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + WorkspaceID string `gorm:"column:workspace_id" json:"workspaceId"` + Name string `gorm:"column:name" json:"name"` + Type string `gorm:"column:type" json:"type"` + ParentID *string `gorm:"column:parent_id" json:"parentId,omitempty"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Text *string `gorm:"-" json:"text,omitempty"` + SnapshotID *string `gorm:"column:snapshot_id" json:"snapshotId,omitempty"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*fileEntity) TableName() string { diff --git a/api/repo/group_repo.go b/api/repo/group_repo.go index c505b9d0c..33ad17eab 100644 --- a/api/repo/group_repo.go +++ b/api/repo/group_repo.go @@ -47,14 +47,14 @@ func NewGroup() model.Group { } type groupEntity struct { - ID string `json:"id" gorm:"column:id"` - Name string `json:"name" gorm:"column:name"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Members []string `json:"members" gorm:"-"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + Name string `gorm:"column:name" json:"name"` + OrganizationID string `gorm:"column:organization_id" json:"organizationId"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Members []string `gorm:"-" json:"members"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime"` } func (*groupEntity) TableName() string { diff --git a/api/repo/invitation_repo.go b/api/repo/invitation_repo.go index 52776d983..0816207b9 100644 --- a/api/repo/invitation_repo.go +++ b/api/repo/invitation_repo.go @@ -37,13 +37,13 @@ func NewInvitationRepo() InvitationRepo { } type invitationEntity struct { - ID string `json:"id" gorm:"column:id"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id"` - OwnerID string `json:"ownerId" gorm:"column:owner_id"` - Email string `json:"email" gorm:"column:email"` - Status string `json:"status" gorm:"column:status"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + OrganizationID string `gorm:"column:organization_id" json:"organizationId"` + OwnerID string `gorm:"column:owner_id" json:"ownerId"` + Email string `gorm:"column:email" json:"email"` + Status string `gorm:"column:status" json:"status"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime"` } func (*invitationEntity) TableName() string { diff --git a/api/repo/organization_repo.go b/api/repo/organization_repo.go index be30b1a08..a61ed832f 100644 --- a/api/repo/organization_repo.go +++ b/api/repo/organization_repo.go @@ -46,13 +46,13 @@ func NewOrganization() model.Organization { } type organizationEntity struct { - ID string `json:"id" gorm:"column:id"` - Name string `json:"name" gorm:"column:name"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Members []string `json:"members" gorm:"-"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + Name string `gorm:"column:name" json:"name"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Members []string `gorm:"-" json:"members"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*organizationEntity) TableName() string { diff --git a/api/repo/permission_repo.go b/api/repo/permission_repo.go index 5b24d61fb..a3d374f06 100644 --- a/api/repo/permission_repo.go +++ b/api/repo/permission_repo.go @@ -37,11 +37,11 @@ func NewGroupPermission() model.GroupPermission { } type userPermissionEntity struct { - ID string `json:"id" gorm:"column:id"` - UserID string `json:"userId" gorm:"column:user_id"` - ResourceID string `json:"resourceId" gorm:"column:resource_id"` - Permission string `json:"permission" gorm:"column:permission"` - CreateTime string `json:"createTime" gorm:"column:create_time"` + ID string `gorm:"column:id" json:"id"` + UserID string `gorm:"column:user_id" json:"userId"` + ResourceID string `gorm:"column:resource_id" json:"resourceId"` + Permission string `gorm:"column:permission" json:"permission"` + CreateTime string `gorm:"column:create_time" json:"createTime"` } func (*userPermissionEntity) TableName() string { @@ -94,11 +94,11 @@ func (u *userPermissionEntity) SetCreateTime(createTime string) { } type groupPermissionEntity struct { - ID string `json:"id" gorm:"column:id"` - GroupID string `json:"groupId" gorm:"column:group_id"` - ResourceID string `json:"resourceId" gorm:"column:resource_id"` - Permission string `json:"permission" gorm:"column:permission"` - CreateTime string `json:"createTime" gorm:"column:create_time"` + ID string `gorm:"column:id" json:"id"` + GroupID string `gorm:"column:group_id" json:"groupId"` + ResourceID string `gorm:"column:resource_id" json:"resourceId"` + Permission string `gorm:"column:permission" json:"permission"` + CreateTime string `gorm:"column:create_time" json:"createTime"` } func (*groupPermissionEntity) TableName() string { diff --git a/api/repo/snapshot_repo.go b/api/repo/snapshot_repo.go index 8773c9928..e51767fee 100644 --- a/api/repo/snapshot_repo.go +++ b/api/repo/snapshot_repo.go @@ -54,21 +54,21 @@ func NewSnapshot() model.Snapshot { } type snapshotEntity struct { - ID string `json:"id" gorm:"column:id;size:36"` - Version int64 `json:"version" gorm:"column:version"` - Original datatypes.JSON `json:"original,omitempty" gorm:"column:original"` - Preview datatypes.JSON `json:"preview,omitempty" gorm:"column:preview"` - Text datatypes.JSON `json:"text,omitempty" gorm:"column:text"` - OCR datatypes.JSON `json:"ocr,omitempty" gorm:"column:ocr"` - Entities datatypes.JSON `json:"entities,omitempty" gorm:"column:entities"` - Mosaic datatypes.JSON `json:"mosaic,omitempty" gorm:"column:mosaic"` - Watermark datatypes.JSON `json:"watermark,omitempty" gorm:"column:watermark"` - Thumbnail datatypes.JSON `json:"thumbnail,omitempty" gorm:"column:thumbnail"` - Status string `json:"status,omitempty" gorm:"column,status"` - Language *string `json:"language,omitempty" gorm:"column:language"` - TaskID *string `json:"taskID,omitempty" gorm:"column:task_id"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id;size:36" json:"id"` + Version int64 `gorm:"column:version" json:"version"` + Original datatypes.JSON `gorm:"column:original" json:"original,omitempty"` + Preview datatypes.JSON `gorm:"column:preview" json:"preview,omitempty"` + Text datatypes.JSON `gorm:"column:text" json:"text,omitempty"` + OCR datatypes.JSON `gorm:"column:ocr" json:"ocr,omitempty"` + Entities datatypes.JSON `gorm:"column:entities" json:"entities,omitempty"` + Mosaic datatypes.JSON `gorm:"column:mosaic" json:"mosaic,omitempty"` + Watermark datatypes.JSON `gorm:"column:watermark" json:"watermark,omitempty"` + Thumbnail datatypes.JSON `gorm:"column:thumbnail" json:"thumbnail,omitempty"` + Status string `gorm:"column,status" json:"status,omitempty"` + Language *string `gorm:"column:language" json:"language,omitempty"` + TaskID *string `gorm:"column:task_id" json:"taskID,omitempty"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*snapshotEntity) TableName() string { diff --git a/api/repo/task_repo.go b/api/repo/task_repo.go index 74de855eb..b6d89b943 100644 --- a/api/repo/task_repo.go +++ b/api/repo/task_repo.go @@ -25,16 +25,16 @@ import ( ) type taskEntity struct { - ID string `json:"id" gorm:"column:id"` - Name string `json:"name" gorm:"column:name"` - Error *string `json:"error,omitempty" gorm:"column:error"` - Percentage *int `json:"percentage,omitempty" gorm:"column:percentage"` - IsIndeterminate bool `json:"isIndeterminate" gorm:"column:is_indeterminate"` - UserID string `json:"userId" gorm:"column:user_id"` - Status string `json:"status" gorm:"column:status"` - Payload datatypes.JSON `json:"payload" gorm:"column:payload"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + Name string `gorm:"column:name" json:"name"` + Error *string `gorm:"column:error" json:"error,omitempty"` + Percentage *int `gorm:"column:percentage" json:"percentage,omitempty"` + IsIndeterminate bool `gorm:"column:is_indeterminate" json:"isIndeterminate"` + UserID string `gorm:"column:user_id" json:"userId"` + Status string `gorm:"column:status" json:"status"` + Payload datatypes.JSON `gorm:"column:payload" json:"payload"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*taskEntity) TableName() string { diff --git a/api/repo/user_repo.go b/api/repo/user_repo.go index 7e66278e5..db3db3fdc 100644 --- a/api/repo/user_repo.go +++ b/api/repo/user_repo.go @@ -35,19 +35,19 @@ func NewUser() model.User { } type userEntity struct { - ID string `json:"id" gorm:"column:id"` - FullName string `json:"fullName" gorm:"column:full_name"` - Username string `json:"username" gorm:"column:username"` - Email string `json:"email" gorm:"column:email"` - Picture *string `json:"picture" gorm:"column:picture"` - IsEmailConfirmed bool `json:"isEmailConfirmed" gorm:"column:is_email_confirmed"` - PasswordHash string `json:"passwordHash" gorm:"column:password_hash"` - RefreshTokenValue *string `json:"refreshTokenValue" gorm:"column:refresh_token_value"` - RefreshTokenValidTo *int64 `json:"refreshTokenValidTo" gorm:"column:refresh_token_valid_to"` - ResetPasswordToken *string `json:"resetPasswordToken" gorm:"column:reset_password_token"` - EmailConfirmationToken *string `json:"emailConfirmationToken" gorm:"column:email_confirmation_token"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime" gorm:"column:update_time"` + ID string `gorm:"column:id" json:"id"` + FullName string `gorm:"column:full_name" json:"fullName"` + Username string `gorm:"column:username" json:"username"` + Email string `gorm:"column:email" json:"email"` + Picture *string `gorm:"column:picture" json:"picture"` + IsEmailConfirmed bool `gorm:"column:is_email_confirmed" json:"isEmailConfirmed"` + PasswordHash string `gorm:"column:password_hash" json:"passwordHash"` + RefreshTokenValue *string `gorm:"column:refresh_token_value" json:"refreshTokenValue"` + RefreshTokenValidTo *int64 `gorm:"column:refresh_token_valid_to" json:"refreshTokenValidTo"` + ResetPasswordToken *string `gorm:"column:reset_password_token" json:"resetPasswordToken"` + EmailConfirmationToken *string `gorm:"column:email_confirmation_token" json:"emailConfirmationToken"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime"` } func (userEntity) TableName() string { diff --git a/api/repo/workspace_repo.go b/api/repo/workspace_repo.go index 195909f36..62addbf67 100644 --- a/api/repo/workspace_repo.go +++ b/api/repo/workspace_repo.go @@ -43,16 +43,16 @@ func NewWorkspace() model.Workspace { } type workspaceEntity struct { - ID string `json:"id," gorm:"column:id;size:36"` - Name string `json:"name" gorm:"column:name;size:255"` - StorageCapacity int64 `json:"storageCapacity" gorm:"column:storage_capacity"` - RootID string `json:"rootId" gorm:"column:root_id;size:36"` - OrganizationID string `json:"organizationId" gorm:"column:organization_id;size:36"` - UserPermissions []*UserPermissionValue `json:"userPermissions" gorm:"-"` - GroupPermissions []*GroupPermissionValue `json:"groupPermissions" gorm:"-"` - Bucket string `json:"bucket" gorm:"column:bucket;size:255"` - CreateTime string `json:"createTime" gorm:"column:create_time"` - UpdateTime *string `json:"updateTime,omitempty" gorm:"column:update_time"` + ID string `gorm:"column:id;size:36" json:"id"` + Name string `gorm:"column:name;size:255" json:"name"` + StorageCapacity int64 `gorm:"column:storage_capacity" json:"storageCapacity"` + RootID string `gorm:"column:root_id;size:36" json:"rootId"` + OrganizationID string `gorm:"column:organization_id;size:36" json:"organizationId"` + UserPermissions []*UserPermissionValue `gorm:"-" json:"userPermissions"` + GroupPermissions []*GroupPermissionValue `gorm:"-" json:"groupPermissions"` + Bucket string `gorm:"column:bucket;size:255" json:"bucket"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateTime *string `gorm:"column:update_time" json:"updateTime,omitempty"` } func (*workspaceEntity) TableName() string { diff --git a/api/router/file_router.go b/api/router/file_router.go index fa52c3a90..ca73fdbd7 100644 --- a/api/router/file_router.go +++ b/api/router/file_router.go @@ -235,7 +235,7 @@ func (r *FileRouter) Patch(c *fiber.Ctx) error { type FileCreateFolderOptions struct { WorkspaceID string `json:"workspaceId" validate:"required"` - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` ParentID *string `json:"parentId"` } @@ -594,8 +594,8 @@ func (r *FileRouter) GetCount(c *fiber.Ctx) error { } type FileGrantUserPermissionOptions struct { - UserID string `json:"userId" validate:"required"` - IDs []string `json:"ids" validate:"required"` + UserID string `json:"userId" validate:"required"` + IDs []string `json:"ids" validate:"required"` Permission string `json:"permission" validate:"required,oneof=viewer editor owner"` } @@ -627,7 +627,7 @@ func (r *FileRouter) GrantUserPermission(c *fiber.Ctx) error { } type FileRevokeUserPermissionOptions struct { - IDs []string `json:"ids" validate:"required"` + IDs []string `json:"ids" validate:"required"` UserID string `json:"userId" validate:"required"` } @@ -659,8 +659,8 @@ func (r *FileRouter) RevokeUserPermission(c *fiber.Ctx) error { } type FileGrantGroupPermissionOptions struct { - GroupID string `json:"groupId" validate:"required"` - IDs []string `json:"ids" validate:"required"` + GroupID string `json:"groupId" validate:"required"` + IDs []string `json:"ids" validate:"required"` Permission string `json:"permission" validate:"required,oneof=viewer editor owner"` } @@ -692,7 +692,7 @@ func (r *FileRouter) GrantGroupPermission(c *fiber.Ctx) error { } type FileRevokeGroupPermissionOptions struct { - IDs []string `json:"ids" validate:"required"` + IDs []string `json:"ids" validate:"required"` GroupID string `json:"groupId" validate:"required"` } diff --git a/api/service/file_service.go b/api/service/file_service.go index df1e130c0..74810a293 100644 --- a/api/service/file_service.go +++ b/api/service/file_service.go @@ -90,9 +90,9 @@ func NewFileService() *FileService { type FileCreateOptions struct { WorkspaceID string `json:"workspaceId" validate:"required"` - Name string `json:"name" validate:"required,max=255"` - Type string `json:"type" validate:"required,oneof=file folder"` - ParentID *string `json:"parentId" validate:"required"` + Name string `json:"name" validate:"required,max=255"` + Type string `json:"type" validate:"required,oneof=file folder"` + ParentID *string `json:"parentId" validate:"required"` } type File struct { @@ -592,8 +592,8 @@ func (svc *FileService) ListByPath(path string, userID string) ([]*File, error) } type FileQuery struct { - Text string `json:"text" validate:"required"` - Type *string `json:"type,omitempty" validate:"omitempty,oneof=file folder"` + Text string `json:"text" validate:"required"` + Type *string `json:"type,omitempty" validate:"omitempty,oneof=file folder"` CreateTimeAfter *int64 `json:"createTimeAfter,omitempty"` CreateTimeBefore *int64 `json:"createTimeBefore,omitempty"` UpdateTimeAfter *int64 `json:"updateTimeAfter,omitempty"` diff --git a/api/service/group_service.go b/api/service/group_service.go index 2c83e055b..0c20bb361 100644 --- a/api/service/group_service.go +++ b/api/service/group_service.go @@ -66,7 +66,7 @@ func NewGroupService() *GroupService { } type GroupCreateOptions struct { - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` Image *string `json:"image"` OrganizationID string `json:"organizationId" validate:"required"` } diff --git a/api/service/invitation_service.go b/api/service/invitation_service.go index ada2992b9..138a1278e 100644 --- a/api/service/invitation_service.go +++ b/api/service/invitation_service.go @@ -52,7 +52,7 @@ func NewInvitationService() *InvitationService { type InvitationCreateOptions struct { OrganizationID string `json:"organizationId" validate:"required"` - Emails []string `json:"emails" validate:"required,dive,email"` + Emails []string `json:"emails" validate:"required,dive,email"` } func (svc *InvitationService) Create(opts InvitationCreateOptions, userID string) error { diff --git a/api/service/organization_service.go b/api/service/organization_service.go index cf939361a..6fc484440 100644 --- a/api/service/organization_service.go +++ b/api/service/organization_service.go @@ -56,7 +56,7 @@ func NewOrganizationService() *OrganizationService { } type OrganizationCreateOptions struct { - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` Image *string `json:"image"` } diff --git a/api/service/workspace_service.go b/api/service/workspace_service.go index 76886583d..b674cce03 100644 --- a/api/service/workspace_service.go +++ b/api/service/workspace_service.go @@ -71,9 +71,9 @@ type Workspace struct { } type WorkspaceCreateOptions struct { - Name string `json:"name" validate:"required,max=255"` + Name string `json:"name" validate:"required,max=255"` Image *string `json:"image"` - OrganizationID string `json:"organizationId" validate:"required"` + OrganizationID string `json:"organizationId" validate:"required"` StorageCapacity int64 `json:"storageCapacity"` }