uint/uint64全部改为uint32
This commit is contained in:
@@ -14,12 +14,12 @@ import (
|
||||
// DeviceTemplateRepository 定义了设备模板数据访问的接口
|
||||
type DeviceTemplateRepository interface {
|
||||
Create(ctx context.Context, deviceTemplate *models.DeviceTemplate) error
|
||||
FindByID(ctx context.Context, id uint) (*models.DeviceTemplate, error)
|
||||
FindByID(ctx context.Context, id uint32) (*models.DeviceTemplate, error)
|
||||
FindByName(ctx context.Context, name string) (*models.DeviceTemplate, error)
|
||||
ListAll(ctx context.Context) ([]*models.DeviceTemplate, error)
|
||||
Update(ctx context.Context, deviceTemplate *models.DeviceTemplate) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
IsInUse(ctx context.Context, id uint) (bool, error)
|
||||
Delete(ctx context.Context, id uint32) error
|
||||
IsInUse(ctx context.Context, id uint32) (bool, error)
|
||||
}
|
||||
|
||||
// gormDeviceTemplateRepository 是 DeviceTemplateRepository 的 GORM 实现
|
||||
@@ -40,7 +40,7 @@ func (r *gormDeviceTemplateRepository) Create(ctx context.Context, deviceTemplat
|
||||
}
|
||||
|
||||
// FindByID 根据ID查找设备模板
|
||||
func (r *gormDeviceTemplateRepository) FindByID(ctx context.Context, id uint) (*models.DeviceTemplate, error) {
|
||||
func (r *gormDeviceTemplateRepository) FindByID(ctx context.Context, id uint32) (*models.DeviceTemplate, error) {
|
||||
repoCtx := logs.AddFuncName(ctx, r.ctx, "FindByID")
|
||||
var deviceTemplate models.DeviceTemplate
|
||||
if err := r.db.WithContext(repoCtx).First(&deviceTemplate, id).Error; err != nil {
|
||||
@@ -82,7 +82,7 @@ func (r *gormDeviceTemplateRepository) Update(ctx context.Context, deviceTemplat
|
||||
}
|
||||
|
||||
// IsInUse 检查设备模板是否正在被设备使用
|
||||
func (r *gormDeviceTemplateRepository) IsInUse(ctx context.Context, id uint) (bool, error) {
|
||||
func (r *gormDeviceTemplateRepository) IsInUse(ctx context.Context, id uint32) (bool, error) {
|
||||
repoCtx := logs.AddFuncName(ctx, r.ctx, "IsInUse")
|
||||
var count int64
|
||||
if err := r.db.WithContext(repoCtx).Model(&models.Device{}).Where("device_template_id = ?", id).Count(&count).Error; err != nil {
|
||||
@@ -92,7 +92,7 @@ func (r *gormDeviceTemplateRepository) IsInUse(ctx context.Context, id uint) (bo
|
||||
}
|
||||
|
||||
// Delete 软删除数据库中的设备模板
|
||||
func (r *gormDeviceTemplateRepository) Delete(ctx context.Context, id uint) error {
|
||||
func (r *gormDeviceTemplateRepository) Delete(ctx context.Context, id uint32) error {
|
||||
repoCtx := logs.AddFuncName(ctx, r.ctx, "Delete")
|
||||
if err := r.db.WithContext(repoCtx).Delete(&models.DeviceTemplate{}, id).Error; err != nil {
|
||||
return fmt.Errorf("删除设备模板失败: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user