Skip to content

Commit

Permalink
chore: api: enable and apply tagalign
Browse files Browse the repository at this point in the history
  • Loading branch information
dsonck92 committed Jul 9, 2024
1 parent 79dabac commit f6810e9
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 109 deletions.
1 change: 0 additions & 1 deletion api/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ linters:
- asasalint
- bodyclose
- unparam
- tagalign
- revive
- predeclared
- interfacebloat
Expand Down
22 changes: 11 additions & 11 deletions api/repo/file_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions api/repo/group_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions api/repo/invitation_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions api/repo/organization_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions api/repo/permission_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
30 changes: 15 additions & 15 deletions api/repo/snapshot_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions api/repo/task_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 13 additions & 13 deletions api/repo/user_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions api/repo/workspace_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions api/router/file_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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"`
}

Expand Down
10 changes: 5 additions & 5 deletions api/service/file_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion api/service/group_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
2 changes: 1 addition & 1 deletion api/service/invitation_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit f6810e9

Please sign in to comment.