From 3bc1285e4ff7e208a7e38b2cf12efb8eac7942f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A7=E6=A1=90?= <1058165620@qq.com> Date: Thu, 26 Dec 2024 17:32:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(model):=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=BB=93=E6=9E=84=E5=92=8C=E5=AD=97=E6=AE=B5=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了不必要的导入语句 - 更新了字段标签,明确主键和索引 - 统一了字段定义的格式 - 删除了未使用的 EasyModel 和 BaseModel 基类 --- pkg/palace/model/alarmmodel/realtime_arlarm_page.go | 9 ++------- pkg/palace/model/alarmmodel/realtime_arlarm_receiver.go | 9 ++------- pkg/palace/model/bizmodel/strategy_group_categories.go | 4 ++-- pkg/palace/model/bizmodel/sys_team_member_roles.go | 6 ++---- pkg/palace/model/bizmodel/sys_team_role_apis.go | 6 ++---- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/pkg/palace/model/alarmmodel/realtime_arlarm_page.go b/pkg/palace/model/alarmmodel/realtime_arlarm_page.go index f04f40e48..7713740f7 100644 --- a/pkg/palace/model/alarmmodel/realtime_arlarm_page.go +++ b/pkg/palace/model/alarmmodel/realtime_arlarm_page.go @@ -1,16 +1,11 @@ package alarmmodel -import ( - "github.com/aide-family/moon/pkg/palace/model" -) - const tableNameRealtimeAlarmPage = "realtime_alarm_page" // RealtimeAlarmPage represents the realtime alarm pages model type RealtimeAlarmPage struct { - model.EasyModel - RealtimeAlarmID uint32 `gorm:"column:realtime_alarm_id;type:int;not null;comment:告警ID" json:"realtime_alarm_id"` - PageID uint32 `gorm:"column:page_id;type:int;not null;comment:页面ID" json:"page_id"` + RealtimeAlarmID uint32 `gorm:"primaryKey;column:realtime_alarm_id;type:int;not null;comment:告警ID;" json:"realtime_alarm_id"` + PageID uint32 `gorm:"primaryKey;column:page_id;type:int;not null;comment:页面ID" json:"page_id"` } // TableName overrides the default table name generated by gorm diff --git a/pkg/palace/model/alarmmodel/realtime_arlarm_receiver.go b/pkg/palace/model/alarmmodel/realtime_arlarm_receiver.go index 5d76a4b50..df6798a89 100644 --- a/pkg/palace/model/alarmmodel/realtime_arlarm_receiver.go +++ b/pkg/palace/model/alarmmodel/realtime_arlarm_receiver.go @@ -1,16 +1,11 @@ package alarmmodel -import ( - "github.com/aide-family/moon/pkg/palace/model" -) - const tableNameRealtimeAlarmReceiver = "realtime_alarm_receiver" // RealtimeAlarmReceiver represents the realtime alarm receiver model type RealtimeAlarmReceiver struct { - model.EasyModel - RealtimeAlarmID uint32 `gorm:"column:realtime_alarm_id;type:int;not null;comment:告警ID" json:"realtime_alarm_id"` - AlarmNoticeGroupID uint32 `gorm:"column:alarm_notice_group_id;type:int;not null;comment:告警通知组ID" json:"alarm_notice_group_id"` + RealtimeAlarmID uint32 `gorm:"primaryKey;column:realtime_alarm_id;type:int;not null;comment:告警ID" json:"realtime_alarm_id"` + AlarmNoticeGroupID uint32 `gorm:"primaryKey;column:alarm_notice_group_id;type:int;not null;comment:告警通知组ID" json:"alarm_notice_group_id"` } // TableName overrides the default table name generated by gorm diff --git a/pkg/palace/model/bizmodel/strategy_group_categories.go b/pkg/palace/model/bizmodel/strategy_group_categories.go index f6909cdd1..d4ba002a0 100644 --- a/pkg/palace/model/bizmodel/strategy_group_categories.go +++ b/pkg/palace/model/bizmodel/strategy_group_categories.go @@ -8,8 +8,8 @@ const tableNameStrategyGroupCategories = "strategy_group_categories" // StrategyGroupCategories 策略分组类型中间表 type StrategyGroupCategories struct { - StrategyGroupID uint32 `gorm:"column:strategy_group_id;type:int unsigned;primaryKey" json:"strategy_group_id"` - SysDictID uint32 `gorm:"column:sys_dict_id;type:int unsigned;primaryKey" json:"sys_dict_id"` + StrategyGroupID uint32 `gorm:"primaryKey;column:strategy_group_id;type:int unsigned;primaryKey" json:"strategy_group_id"` + SysDictID uint32 `gorm:"primaryKey;column:sys_dict_id;type:int unsigned;primaryKey" json:"sys_dict_id"` } // UnmarshalBinary redis存储实现 diff --git a/pkg/palace/model/bizmodel/sys_team_member_roles.go b/pkg/palace/model/bizmodel/sys_team_member_roles.go index 2b7bcdd5a..2d0c29f76 100644 --- a/pkg/palace/model/bizmodel/sys_team_member_roles.go +++ b/pkg/palace/model/bizmodel/sys_team_member_roles.go @@ -1,7 +1,6 @@ package bizmodel import ( - "github.com/aide-family/moon/pkg/palace/model" "github.com/aide-family/moon/pkg/util/types" ) @@ -9,9 +8,8 @@ const tableNameSysTeamMemberRole = "sys_team_member_roles" // SysTeamMemberRole mapped from table type SysTeamMemberRole struct { - model.BaseModel - SysTeamMemberID uint32 `gorm:"column:sys_team_member_id;type:int unsigned;primaryKey;uniqueIndex:idx__user_id__team_id__role_id,priority:1;comment:团队用户ID" json:"sys_team_member_id"` // 团队用户ID - SysTeamRoleID uint32 `gorm:"column:sys_team_role_id;type:int unsigned;primaryKey;uniqueIndex:idx__user_id__team_id__role_id,priority:2;comment:团队角色ID" json:"sys_team_role_id"` // 团队角色ID + SysTeamMemberID uint32 `gorm:"primaryKey;column:sys_team_member_id;type:int unsigned;primaryKey;uniqueIndex:idx__user_id__team_id__role_id,priority:1;comment:团队用户ID" json:"sys_team_member_id"` // 团队用户ID + SysTeamRoleID uint32 `gorm:"primaryKey;column:sys_team_role_id;type:int unsigned;primaryKey;uniqueIndex:idx__user_id__team_id__role_id,priority:2;comment:团队角色ID" json:"sys_team_role_id"` // 团队角色ID } // String json string diff --git a/pkg/palace/model/bizmodel/sys_team_role_apis.go b/pkg/palace/model/bizmodel/sys_team_role_apis.go index 806f7ca21..7af91afc7 100644 --- a/pkg/palace/model/bizmodel/sys_team_role_apis.go +++ b/pkg/palace/model/bizmodel/sys_team_role_apis.go @@ -1,7 +1,6 @@ package bizmodel import ( - "github.com/aide-family/moon/pkg/palace/model" "github.com/aide-family/moon/pkg/util/types" ) @@ -9,9 +8,8 @@ const tableNameSysTeamRoleAPI = "sys_team_role_apis" // SysTeamRoleAPI mapped from table type SysTeamRoleAPI struct { - model.BaseModel - SysTeamRoleID uint32 `gorm:"column:sys_team_role_id;type:int unsigned;primaryKey" json:"sys_team_role_id"` - SysTeamAPIID uint32 `gorm:"column:sys_api_id;type:int unsigned;primaryKey" json:"sys_team_api_id"` + SysTeamRoleID uint32 `gorm:"primaryKey;column:sys_team_role_id;type:int unsigned;primaryKey" json:"sys_team_role_id"` + SysTeamAPIID uint32 `gorm:"primaryKey;column:sys_api_id;type:int unsigned;primaryKey" json:"sys_team_api_id"` } // String json string