Skip to content

Commit 625d2d8

Browse files
committed
fix: golint
Signed-off-by: jiuxia211 <2064166368@qq.com>
1 parent b0f37fb commit 625d2d8

8 files changed

Lines changed: 73 additions & 13 deletions

File tree

api/handler/api/common_service.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/model/api/api.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/model/model/model.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/router/api/api.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/common/service/get_toolbox_config.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ import (
2323
"github.com/west2-online/fzuhelper-server/pkg/db/model"
2424
)
2525

26+
const (
27+
// MaxVersionNumber 版本号最大值,支持7位数字
28+
MaxVersionNumber = 9999999
29+
// StudentIDMatchBit 学号匹配位位置(第25位)
30+
StudentIDMatchBit = 25
31+
)
32+
2633
// MatchResult 匹配结果
2734
type MatchResult struct {
2835
Config *model.ToolboxConfig
@@ -42,7 +49,7 @@ func getMatchScore(config *model.ToolboxConfig, studentID string, platform strin
4249
// 学号匹配检查(最高优先级,占第25位)
4350
if config.StudentID != "" {
4451
if studentID != "" && config.StudentID == studentID {
45-
matchBits |= (1 << 25) // 设置第25位,表示学号匹配
52+
matchBits |= (1 << StudentIDMatchBit) // 设置第25位,表示学号匹配
4653
} else if studentID != "" {
4754
return -1
4855
}
@@ -54,8 +61,8 @@ func getMatchScore(config *model.ToolboxConfig, studentID string, platform strin
5461
// 版本匹配,版本号越高分数越高
5562
// 占第1-24位,最多支持版本号到9,999,999(7位数字)
5663
versionScore := config.Version
57-
if versionScore > 9999999 {
58-
versionScore = 9999999 // 限制最大值为7位数字
64+
if versionScore > MaxVersionNumber {
65+
versionScore = MaxVersionNumber // 限制最大值为7位数字
5966
}
6067
matchBits |= (versionScore << 1)
6168
} else if version > 0 {

internal/common/service/update_toolbox_config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import (
2525
"github.com/west2-online/fzuhelper-server/pkg/errno"
2626
)
2727

28-
func (s *CommonService) PutToolboxConfig(ctx context.Context, secret string, toolID int64, studentID, platform string, version int64, visible bool, name, icon, toolType, message, extra string) (*model.ToolboxConfig, error) {
28+
func (s *CommonService) PutToolboxConfig(ctx context.Context, secret string, toolID int64, studentID,
29+
platform string, version int64, visible bool, name, icon, toolType, message, extra string,
30+
) (*model.ToolboxConfig, error) {
2931
// 验证管理员密钥
3032
if err := s.db.AdminSecret.ValidateSecret(ctx, "toolbox", secret); err != nil {
3133
return nil, err
@@ -52,7 +54,7 @@ func (s *CommonService) PutToolboxConfig(ctx context.Context, secret string, too
5254
}
5355

5456
// 验证版本号范围(7位数字最大值为9,999,999)
55-
if version > 9999999 {
57+
if version > MaxVersionNumber {
5658
return nil, errno.NewErrNo(errno.ParamErrorCode, "version cannot exceed 9,999,999 (7-digit limit)")
5759
}
5860
if version < 0 {

pkg/db/model/admin_secret.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
)
2424

2525
type AdminSecret struct {
26-
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"`
27-
ModuleName string `gorm:"column:module_name;type:varchar(255);not null" json:"module_name"`
28-
SecretKey string `gorm:"column:secret_key;type:varchar(255);not null" json:"secret_key"`
29-
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
30-
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
31-
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at,omitempty"`
26+
Id int64 `json:"id"`
27+
ModuleName string `json:"module_name"`
28+
SecretKey string `json:"secret_key"`
29+
CreatedAt time.Time `json:"created_at"`
30+
UpdatedAt time.Time `json:"updated_at"`
31+
DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty"`
3232
}

pkg/db/model/toolbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ToolboxConfig struct {
2727
ToolID int64 `json:"tool_id"`
2828
Visible bool `json:"visible"`
2929
Name string `json:"name"`
30-
Icon string `gorm:"column:icon;type:varchar(255);not null" json:"icon"`
30+
Icon string `json:"icon"`
3131
Type string `json:"type"`
3232
Message string `json:"message,omitempty"`
3333
Extra string `json:"extra"`

0 commit comments

Comments
 (0)