diff --git a/Makefile b/Makefile index c374948..5157169 100644 --- a/Makefile +++ b/Makefile @@ -253,7 +253,7 @@ format: tools.verify.golines tools.verify.goimports @echo "===========> Formating codes" @$(FIND) -type f -name '*.go' | $(XARGS) gofmt -s -w @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/goimports -w -local $(ROOT_PACKAGE) - @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=120 --reformat-tags --shorten-comments --ignore-generated . + @$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=200 --reformat-tags --shorten-comments --ignore-generated . @cd $(SERVER_DIR) && $(GO) mod edit -fmt ## updates: Check for updates to go.mod dependencies diff --git a/server/internal/dal/gen/sys_community.gen.go b/server/internal/dal/gen/sys_community.gen.go index 87e6ed7..11ee552 100644 --- a/server/internal/dal/gen/sys_community.gen.go +++ b/server/internal/dal/gen/sys_community.gen.go @@ -7,11 +7,12 @@ package gen import ( "context" - systemroles "github.com/OpenIMSDK/OpenKF/server/internal/models/system_roles" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" + systemroles "github.com/OpenIMSDK/OpenKF/server/internal/models/system_roles" + "gorm.io/gen" "gorm.io/gen/field" diff --git a/server/internal/models/base/model.go b/server/internal/models/base/model.go index 184baf9..638a99a 100644 --- a/server/internal/models/base/model.go +++ b/server/internal/models/base/model.go @@ -20,8 +20,8 @@ import ( // Model base model. type Model struct { - Id uint `json:"id" gorm:"column:id;primary_key;auto_increment" ` + Id uint `json:"id" gorm:"column:id;primary_key;auto_increment"` CreatedAt *time.Time `json:"created_at" gorm:"column:created_at"` UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"` - DeletedAt *time.Time `json:"deleted_at" sql:"index" gorm:"column:deleted_at"` + DeletedAt *time.Time `json:"deleted_at" gorm:"column:deleted_at" sql:"index"` } diff --git a/server/internal/models/base/user_base.go b/server/internal/models/base/user_base.go index 9562f08..a1d5b55 100644 --- a/server/internal/models/base/user_base.go +++ b/server/internal/models/base/user_base.go @@ -20,9 +20,9 @@ import "github.com/gofrs/uuid" type UserBase struct { Model - UUID uuid.UUID `json:"uuid" gorm:"index;type:varchar(36);not null;comment:UUID"` - Email string `json:"email" gorm:"type:varchar(255);not null;unique;comment:Email"` + UUID uuid.UUID `json:"uuid" gorm:"index;type:varchar(36);not null;comment:UUID"` + Email string `json:"email" gorm:"type:varchar(255);not null;unique;comment:Email"` Nickname string `json:"nickname" gorm:"type:varchar(20);not null;comment:Nickname"` - Avatar string `json:"avatar" gorm:"type:varchar(255);not null;comment:Avatar"` - IsEnable bool `json:"enable" gorm:"type:tinyint(1);not null;default:1;comment:IsEnable,1:enable,0:disable"` + Avatar string `json:"avatar" gorm:"type:varchar(255);not null;comment:Avatar"` + IsEnable bool `json:"enable" gorm:"type:tinyint(1);not null;default:1;comment:IsEnable,1:enable,0:disable"` } diff --git a/server/internal/models/system_roles/sys_bot.go b/server/internal/models/system_roles/sys_bot.go index a9fa4e5..82f7d7d 100644 --- a/server/internal/models/system_roles/sys_bot.go +++ b/server/internal/models/system_roles/sys_bot.go @@ -27,8 +27,8 @@ type SysBot struct { BotToken string `gorm:"column:bot_token;type:varchar(255);not null;comment:'AI bot token'"` Nickname string `gorm:"column:nickname;type:varchar(255);not null;comment:'AI bot nickname'"` Avatar string `gorm:"column:avatar;type:varchar(255);not null;comment:'AI bot avatar'"` - CommunityId uint `json:"community_id" gorm:"index;column:community_id;type:int(11);not null;comment:'Community id'"` - Community SysCommunity `json:"community" gorm:"foreignKey:CommunityId;"` + CommunityId uint `gorm:"index;column:community_id;type:int(11);not null;comment:'Community id'" json:"community_id"` + Community SysCommunity `gorm:"foreignKey:CommunityId;" json:"community"` } // TableName table name. diff --git a/server/internal/models/system_roles/sys_customer.go b/server/internal/models/system_roles/sys_customer.go index 30f5f0a..414911e 100644 --- a/server/internal/models/system_roles/sys_customer.go +++ b/server/internal/models/system_roles/sys_customer.go @@ -22,9 +22,9 @@ import ( type SysCustomer struct { base.UserBase - Device string `gorm:"column:device;type:varchar(255);not null;default:'';comment:'Customer device'" json:"device"` - IPAddress string `gorm:"column:ip_address;type:varchar(255);not null;default:'';comment:'Customer IP address'" json:"ip_address"` - Source string `gorm:"column:source;type:varchar(255);not null;default:'';comment:'Visitor source'" json:"source"` + Device string `gorm:"column:device;type:varchar(255);not null;default:'';comment:'Customer device'" json:"device"` + IPAddress string `gorm:"column:ip_address;type:varchar(255);not null;default:'';comment:'Customer IP address'" json:"ip_address"` + Source string `gorm:"column:source;type:varchar(255);not null;default:'';comment:'Visitor source'" json:"source"` SourceType int `gorm:"column:source_type;type:int(11);not null;default:0;comment:'Visitor type, 0:web, 1: slack'" json:"source_type"` } diff --git a/server/internal/models/system_roles/sys_user.go b/server/internal/models/system_roles/sys_user.go index 7a6de61..32e00c7 100644 --- a/server/internal/models/system_roles/sys_user.go +++ b/server/internal/models/system_roles/sys_user.go @@ -22,10 +22,10 @@ import ( type SysUser struct { base.UserBase - IsAdmin bool `json:"is_admin" gorm:"index;column:is_admin;type:tinyint(1);not null;default:0;comment:'Is admin'"` - Password string `json:"-" gorm:"type:varchar(64);not null;comment:Password"` + IsAdmin bool `json:"is_admin" gorm:"index;column:is_admin;type:tinyint(1);not null;default:0;comment:'Is admin'"` + Password string `json:"-" gorm:"type:varchar(64);not null;comment:Password"` CommunityId uint `json:"community_id" gorm:"column:community_id;type:int(11);not null;comment:'Community id'"` - Community SysCommunity `json:"community" gorm:"foreignKey:CommunityId;"` + Community SysCommunity `json:"community" gorm:"foreignKey:CommunityId;"` } // TableName table name. diff --git a/server/internal/params/request/bot.go b/server/internal/params/request/bot.go index 88c899d..bb129c2 100644 --- a/server/internal/params/request/bot.go +++ b/server/internal/params/request/bot.go @@ -16,10 +16,10 @@ package requestparams // RegisterBotParams register params for bot. type RegisterBotParams struct { - BotAddr string `json:"bot_addr" binding:"required"` - BotPort int `json:"bot_port" binding:"required"` - BotToken string `json:"bot_token" binding:"required"` - Nickname string `json:"nickname" binding:"required"` - Avatar string `json:"avatar" binding:"required"` + BotAddr string `json:"bot_addr" binding:"required"` + BotPort int `json:"bot_port" binding:"required"` + BotToken string `json:"bot_token" binding:"required"` + Nickname string `json:"nickname" binding:"required"` + Avatar string `json:"avatar" binding:"required"` CommunityId uint `json:"community_id" binding:"required"` } diff --git a/server/internal/params/request/community.go b/server/internal/params/request/community.go index 5f86b52..ed71056 100644 --- a/server/internal/params/request/community.go +++ b/server/internal/params/request/community.go @@ -16,7 +16,7 @@ package requestparams // CommunityParams register params for community. type CommunityParams struct { - Name string `json:"name" binding:"required"` - Email string `json:"email" binding:"required"` + Name string `json:"name" binding:"required"` + Email string `json:"email" binding:"required"` Avatar *string `json:"avatar" binding:"required"` // Avatar is optional. } diff --git a/server/internal/params/request/user.go b/server/internal/params/request/user.go index 6160fc3..d2aede2 100644 --- a/server/internal/params/request/user.go +++ b/server/internal/params/request/user.go @@ -16,27 +16,27 @@ package requestparams // CreateUserParams register params for user. type CreateUserParams struct { - Email string `json:"email" binding:"required"` + Email string `json:"email" binding:"required"` Nickname string `json:"nickname" binding:"required"` - Avatar *string `json:"avatar" binding:"required"` // Avatar is optional. + Avatar *string `json:"avatar" binding:"required"` // Avatar is optional. Password string `json:"password" binding:"required"` } // RegisterAdminParams register params for admin. type RegisterAdminParams struct { - UserInfo CreateUserParams `json:"user_info" binding:"required"` + UserInfo CreateUserParams `json:"user_info" binding:"required"` CommunityInfo CommunityParams `json:"community_info" binding:"required"` - Code string `json:"code" binding:"required"` + Code string `json:"code" binding:"required"` } // RegisterStaffParams register params for staff. type RegisterStaffParams struct { - UserInfo CreateUserParams `json:"user_info" binding:"required"` + UserInfo CreateUserParams `json:"user_info" binding:"required"` CommunityId uint `json:"community_id" binding:"required"` } // LoginParamsWithAccount login params. type LoginParamsWithAccount struct { - Email string `json:"email" binding:"required"` + Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"` } diff --git a/server/pkg/openim/param/request/auth.go b/server/pkg/openim/param/request/auth.go index 77f66d2..748c43c 100644 --- a/server/pkg/openim/param/request/auth.go +++ b/server/pkg/openim/param/request/auth.go @@ -16,7 +16,7 @@ package request // UserTokenParams register admin params. type UserTokenParams struct { - Secret string `json:"secret" binding:"required"` + Secret string `json:"secret" binding:"required"` PlatformID uint `json:"platformID" binding:"required"` - UserID string `json:"userID" binding:"required"` + UserID string `json:"userID" binding:"required"` } diff --git a/server/pkg/openim/param/request/user.go b/server/pkg/openim/param/request/user.go index 354fcf8..96f0f87 100644 --- a/server/pkg/openim/param/request/user.go +++ b/server/pkg/openim/param/request/user.go @@ -17,12 +17,12 @@ package request // RegisterUserParams register user params. type RegisterUserParams struct { Secret string `json:"secret" binding:"required"` - Users []User `json:"users" binding:"required"` + Users []User `json:"users" binding:"required"` } // User user. type User struct { - UserID string `json:"userID" binding:"required"` + UserID string `json:"userID" binding:"required"` Nickname string `json:"nickname" binding:"required"` - FaceURL string `json:"faceURL" binding:"required"` + FaceURL string `json:"faceURL" binding:"required"` } diff --git a/web/src/views/login/components/LoginHeader.vue b/web/src/views/login/components/LoginHeader.vue index 5874fc8..5183adb 100644 --- a/web/src/views/login/components/LoginHeader.vue +++ b/web/src/views/login/components/LoginHeader.vue @@ -1,6 +1,5 @@ @@ -87,7 +89,8 @@ const changeModeAction = () => { .operations-container { display: flex; align-items: center; - .t-button, .t-switch { + .t-button, + .t-switch { margin-left: var(--td-comp-margin-l); } } diff --git a/web/src/views/login/index.vue b/web/src/views/login/index.vue index 84c9252..52c5cbd 100644 --- a/web/src/views/login/index.vue +++ b/web/src/views/login/index.vue @@ -12,19 +12,18 @@ const switchType = (val: string) => { }; const changeMode = (value: boolean) => { console.log(value); - isDark.value = value + isDark.value = value; if (isDark.value) { document.documentElement.setAttribute('theme-mode', 'dark'); } else { document.documentElement.setAttribute('theme-mode', 'light'); } -} - +};