30 KiB
-
internal/infra/repository/unit_of_work.go(repository.UnitOfWork-gormUnitOfWork实现)- 接口改造 (
UnitOfWork):- 修改
UnitOfWork接口中的ExecuteInTransaction方法签名,使其接收ctx context.Context作为第一个参数:ExecuteInTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error。
- 修改
- 结构体改造 (
gormUnitOfWork):- 移除
gormUnitOfWork结构体中的logger *logs.Logger成员。 - 新增
selfCtx context.Context成员。
- 移除
- 构造函数改造 (
NewGormUnitOfWork):- 修改函数签名,移除
logger *logs.Logger参数,改为接收ctx context.Context。 - 在函数内部,为
gormUnitOfWork创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "GormUnitOfWork")。 - 将这个
selfCtx赋值给gormUnitOfWork结构体的selfCtx成员。
- 修改函数签名,移除
- 方法改造 (
ExecuteInTransaction):- 修改方法签名,使其接收
ctx context.Context作为第一个参数:(u *gormUnitOfWork) ExecuteInTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error。 - 在方法入口处,使用
newCtx, logger := logs.Trace(ctx, u.selfCtx, "ExecuteInTransaction")获取新的context.Context和logger实例。 - 将所有对
u.logger.Errorf的调用替换为logger.Errorf。 - 在开启事务时,使用
tx := u.db.WithContext(newCtx).Begin(),确保事务tx携带了正确的上下文。
- 修改方法签名,使其接收
- 接口改造 (
-
internal/infra/repository/plan_repository.go(repository.PlanRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPlanRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPlanRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PlanRepository")。 - 将这个
selfCtx赋值给gormPlanRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/user_repository.go(repository.UserRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormUserRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormUserRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "UserRepository")。 - 将这个
selfCtx赋值给gormUserRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/device_repository.go(repository.DeviceRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormDeviceRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormDeviceRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "DeviceRepository")。 - 将这个
selfCtx赋值给gormDeviceRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_pen_repository.go(repository.PigPenRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigPenRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigPenRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigPenRepository")。 - 将这个
selfCtx赋值给gormPigPenRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_farm_repository.go(repository.PigFarmRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigFarmRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigFarmRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigFarmRepository")。 - 将这个
selfCtx赋值给gormPigFarmRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_sick_repository.go(repository.PigSickLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigSickLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigSickLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigSickLogRepository")。 - 将这个
selfCtx赋值给gormPigSickLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_batch_repository.go(repository.PigBatchRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigBatchRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigBatchRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigBatchRepository")。 - 将这个
selfCtx赋值给gormPigBatchRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_trade_repository.go(repository.PigTradeRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigTradeRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigTradeRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigTradeRepository")。 - 将这个
selfCtx赋值给gormPigTradeRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/sensor_data_repository.go(repository.SensorDataRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormSensorDataRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormSensorDataRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "SensorDataRepository")。 - 将这个
selfCtx赋值给gormSensorDataRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/notification_repository.go(repository.NotificationRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormNotificationRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormNotificationRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "NotificationRepository")。 - 将这个
selfCtx赋值给gormNotificationRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pending_task_repository.go(repository.PendingTaskRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPendingTaskRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPendingTaskRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PendingTaskRepository")。 - 将这个
selfCtx赋值给gormPendingTaskRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/raw_material_repository.go(repository.RawMaterialRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormRawMaterialRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormRawMaterialRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "RawMaterialRepository")。 - 将这个
selfCtx赋值给gormRawMaterialRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/execution_log_repository.go(repository.ExecutionLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormExecutionLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormExecutionLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "ExecutionLogRepository")。 - 将这个
selfCtx赋值给gormExecutionLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_batch_log_repository.go(repository.PigBatchLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigBatchLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigBatchLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigBatchLogRepository")。 - 将这个
selfCtx赋值给gormPigBatchLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/medication_log_repository.go(repository.MedicationLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormMedicationLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormMedicationLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "MedicationLogRepository")。 - 将这个
selfCtx赋值给gormMedicationLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/area_controller_repository.go(repository.AreaControllerRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormAreaControllerRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormAreaControllerRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "AreaControllerRepository")。 - 将这个
selfCtx赋值给gormAreaControllerRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/device_template_repository.go(repository.DeviceTemplateRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormDeviceTemplateRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormDeviceTemplateRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "DeviceTemplateRepository")。 - 将这个
selfCtx赋值给gormDeviceTemplateRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/user_action_log_repository.go(repository.UserActionLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormUserActionLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormUserActionLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "UserActionLogRepository")。 - 将这个
selfCtx赋值给gormUserActionLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_transfer_log_repository.go(repository.PigTransferLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigTransferLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigTransferLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigTransferLogRepository")。 - 将这个
selfCtx赋值给gormPigTransferLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/device_command_log_repository.go(repository.DeviceCommandLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormDeviceCommandLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormDeviceCommandLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "DeviceCommandLogRepository")。 - 将这个
selfCtx赋值给gormDeviceCommandLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pending_collection_repository.go(repository.PendingCollectionRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPendingCollectionRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPendingCollectionRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PendingCollectionRepository")。 - 将这个
selfCtx赋值给gormPendingCollectionRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/raw_material_repository.go(repository.RawMaterialRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormRawMaterialRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormRawMaterialRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "RawMaterialRepository")。 - 将这个
selfCtx赋值给gormRawMaterialRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/execution_log_repository.go(repository.ExecutionLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormExecutionLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormExecutionLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "ExecutionLogRepository")。 - 将这个
selfCtx赋值给gormExecutionLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_batch_log_repository.go(repository.PigBatchLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigBatchLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigBatchLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigBatchLogRepository")。 - 将这个
selfCtx赋值给gormPigBatchLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/medication_log_repository.go(repository.MedicationLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormMedicationLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormMedicationLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "MedicationLogRepository")。 - 将这个
selfCtx赋值给gormMedicationLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/area_controller_repository.go(repository.AreaControllerRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormAreaControllerRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormAreaControllerRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "AreaControllerRepository")。 - 将这个
selfCtx赋值给gormAreaControllerRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/device_template_repository.go(repository.DeviceTemplateRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormDeviceTemplateRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormDeviceTemplateRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "DeviceTemplateRepository")。 - 将这个
selfCtx赋值给gormDeviceTemplateRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/user_action_log_repository.go(repository.UserActionLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormUserActionLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormUserActionLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "UserActionLogRepository")。 - 将这个
selfCtx赋值给gormUserActionLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或tx.WithContext(newCtx)。
- 修改方法签名,添加
- 结构体改造:
-
internal/infra/repository/pig_transfer_log_repository.go(repository.PigTransferLogRepository)- 结构体改造:
- 新增
selfCtx context.Context成员。
- 新增
- 构造函数改造 (
NewGormPigTransferLogRepository):- 修改函数签名,添加
ctx context.Context作为第一个参数。 - 在函数内部,为
gormPigTransferLogRepository创建其专属的selfCtx:selfCtx := logs.AddCompName(ctx, "PigTransferLogRepository")。 - 将这个
selfCtx赋值给gormPigTransferLogRepository结构体的selfCtx成员。
- 修改函数签名,添加
- 公共方法改造 (所有公共方法):
- 修改方法签名,添加
ctx context.Context作为第一个参数。 - 在方法入口处,使用
newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")。 - 确保所有对
r.db和tx的调用都使用r.db.WithContext(newCtx)或 `tx.WithContext(new
- 修改方法签名,添加
- 结构体改造: