From d377314b40594fd8a62f41a53165c6f1368afcd0 Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Wed, 5 Nov 2025 23:57:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E8=AE=B0=E4=BB=BB=E5=8A=A1=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provide-logger-with-mothed/task-list.md | 8 +- .../task-repository.md | 426 +++++++++--------- 2 files changed, 217 insertions(+), 217 deletions(-) diff --git a/design/provide-logger-with-mothed/task-list.md b/design/provide-logger-with-mothed/task-list.md index 861bc56..ebe76f8 100644 --- a/design/provide-logger-with-mothed/task-list.md +++ b/design/provide-logger-with-mothed/task-list.md @@ -71,12 +71,12 @@ #### 4. 日志调用点及方法内部逻辑改造 -- [ ] **遍历所有业务方法** (针对上述所有列出的组件的公共方法): - - [ ] **定位旧日志**: 搜索所有对旧 `z.logger.*` 成员的调用。 - - [ ] **改造方法入口** (对于非 Controller 方法): +- [x] **遍历所有业务方法** (针对上述所有列出的组件的公共方法): + - [x] **定位旧日志**: 搜索所有对旧 `z.logger.*` 成员的调用。 + - [x] **改造方法入口** (对于非 Controller 方法): 1. 在方法开始处,使用作为参数传入的 `ctx` (作为 `upstreamCtx`) 和组件自身持有的 `z.selfCtx`,调用 `logs.Trace`。 - `newCtx, logger := logs.Trace(ctx, z.selfCtx, 'MethodName')` 2. 将所有旧的 `z.logger.*(...)` 调用,替换为使用新获取的 `logger.*(...)`。 - - [ ] **改造下游调用**: + - [x] **改造下游调用**: 1. 在方法内部,当需要调用其他组件的方法时(如下游服务),**必须传递 `newCtx`**。 - `err := z.downstreamService.DoSomething(newCtx, data)` diff --git a/design/provide-logger-with-mothed/task-repository.md b/design/provide-logger-with-mothed/task-repository.md index ab0fabf..43592f6 100644 --- a/design/provide-logger-with-mothed/task-repository.md +++ b/design/provide-logger-with-mothed/task-repository.md @@ -1,396 +1,396 @@ - **`internal/infra/repository/unit_of_work.go` (`repository.UnitOfWork` - `gormUnitOfWork` 实现)** - **接口改造 (`UnitOfWork`)**: - - [ ] 修改 `UnitOfWork` 接口中的 `ExecuteInTransaction` 方法签名,使其接收 `ctx context.Context` 作为第一个参数: + - [x] 修改 `UnitOfWork` 接口中的 `ExecuteInTransaction` 方法签名,使其接收 `ctx context.Context` 作为第一个参数: `ExecuteInTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error`。 - **结构体改造 (`gormUnitOfWork`)**: - - [ ] 移除 `gormUnitOfWork` 结构体中的 `logger *logs.Logger` 成员。 - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 移除 `gormUnitOfWork` 结构体中的 `logger *logs.Logger` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormUnitOfWork`)**: - - [ ] 修改函数签名,移除 `logger *logs.Logger` 参数,改为接收 `ctx context.Context`。 - - [ ] 在函数内部,为 `gormUnitOfWork` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,移除 `logger *logs.Logger` 参数,改为接收 `ctx context.Context`。 + - [x] 在函数内部,为 `gormUnitOfWork` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "GormUnitOfWork")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormUnitOfWork` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormUnitOfWork` 结构体的 `selfCtx` 成员。 - **方法改造 (`ExecuteInTransaction`)**: - - [ ] 修改方法签名,使其接收 `ctx context.Context` 作为第一个参数: + - [x] 修改方法签名,使其接收 `ctx context.Context` 作为第一个参数: `(u *gormUnitOfWork) ExecuteInTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error`。 - - [ ] 在方法入口处,使用 `newCtx, logger := logs.Trace(ctx, u.selfCtx, "ExecuteInTransaction")` 获取新的 + - [x] 在方法入口处,使用 `newCtx, logger := logs.Trace(ctx, u.selfCtx, "ExecuteInTransaction")` 获取新的 `context.Context` 和 `logger` 实例。 - - [ ] 将所有对 `u.logger.Errorf` 的调用替换为 `logger.Errorf`。 - - [ ] 在开启事务时,使用 `tx := u.db.WithContext(newCtx).Begin()`,确保事务 `tx` 携带了正确的上下文。 + - [x] 将所有对 `u.logger.Errorf` 的调用替换为 `logger.Errorf`。 + - [x] 在开启事务时,使用 `tx := u.db.WithContext(newCtx).Begin()`,确保事务 `tx` 携带了正确的上下文。 - **`internal/infra/repository/plan_repository.go` (`repository.PlanRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPlanRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPlanRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPlanRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PlanRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPlanRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPlanRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/user_repository.go` (`repository.UserRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormUserRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormUserRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormUserRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "UserRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormUserRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormUserRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/device_repository.go` (`repository.DeviceRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormDeviceRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormDeviceRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormDeviceRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "DeviceRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormDeviceRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormDeviceRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_pen_repository.go` (`repository.PigPenRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigPenRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigPenRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigPenRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigPenRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigPenRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigPenRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_farm_repository.go` (`repository.PigFarmRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigFarmRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigFarmRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigFarmRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigFarmRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigFarmRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigFarmRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_sick_repository.go` (`repository.PigSickLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigSickLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigSickLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigSickLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigSickLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigSickLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigSickLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_batch_repository.go` (`repository.PigBatchRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigBatchRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigBatchRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigBatchRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigBatchRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigBatchRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigBatchRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_trade_repository.go` (`repository.PigTradeRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigTradeRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigTradeRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigTradeRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigTradeRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigTradeRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigTradeRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/sensor_data_repository.go` (`repository.SensorDataRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormSensorDataRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormSensorDataRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormSensorDataRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "SensorDataRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormSensorDataRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormSensorDataRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/notification_repository.go` (`repository.NotificationRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormNotificationRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormNotificationRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormNotificationRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "NotificationRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormNotificationRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormNotificationRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pending_task_repository.go` (`repository.PendingTaskRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPendingTaskRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPendingTaskRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPendingTaskRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PendingTaskRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPendingTaskRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPendingTaskRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/raw_material_repository.go` (`repository.RawMaterialRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormRawMaterialRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormRawMaterialRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormRawMaterialRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "RawMaterialRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormRawMaterialRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormRawMaterialRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/execution_log_repository.go` (`repository.ExecutionLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormExecutionLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormExecutionLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormExecutionLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "ExecutionLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormExecutionLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormExecutionLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_batch_log_repository.go` (`repository.PigBatchLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigBatchLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigBatchLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigBatchLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigBatchLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigBatchLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigBatchLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/medication_log_repository.go` (`repository.MedicationLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormMedicationLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormMedicationLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormMedicationLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "MedicationLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormMedicationLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormMedicationLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/area_controller_repository.go` (`repository.AreaControllerRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormAreaControllerRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormAreaControllerRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormAreaControllerRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "AreaControllerRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormAreaControllerRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormAreaControllerRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/device_template_repository.go` (`repository.DeviceTemplateRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormDeviceTemplateRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormDeviceTemplateRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormDeviceTemplateRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "DeviceTemplateRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormDeviceTemplateRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormDeviceTemplateRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/user_action_log_repository.go` (`repository.UserActionLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormUserActionLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormUserActionLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormUserActionLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "UserActionLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormUserActionLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormUserActionLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_transfer_log_repository.go` (`repository.PigTransferLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigTransferLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigTransferLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigTransferLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigTransferLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigTransferLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigTransferLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/device_command_log_repository.go` (`repository.DeviceCommandLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormDeviceCommandLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormDeviceCommandLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormDeviceCommandLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "DeviceCommandLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormDeviceCommandLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormDeviceCommandLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pending_collection_repository.go` (`repository.PendingCollectionRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPendingCollectionRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPendingCollectionRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPendingCollectionRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PendingCollectionRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPendingCollectionRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPendingCollectionRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/raw_material_repository.go` (`repository.RawMaterialRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormRawMaterialRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormRawMaterialRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormRawMaterialRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "RawMaterialRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormRawMaterialRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormRawMaterialRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/execution_log_repository.go` (`repository.ExecutionLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormExecutionLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormExecutionLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormExecutionLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "ExecutionLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormExecutionLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormExecutionLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_batch_log_repository.go` (`repository.PigBatchLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigBatchLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigBatchLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigBatchLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigBatchLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigBatchLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigBatchLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/medication_log_repository.go` (`repository.MedicationLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormMedicationLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormMedicationLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormMedicationLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "MedicationLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormMedicationLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormMedicationLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/area_controller_repository.go` (`repository.AreaControllerRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormAreaControllerRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormAreaControllerRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormAreaControllerRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "AreaControllerRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormAreaControllerRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormAreaControllerRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/device_template_repository.go` (`repository.DeviceTemplateRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormDeviceTemplateRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormDeviceTemplateRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormDeviceTemplateRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "DeviceTemplateRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormDeviceTemplateRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormDeviceTemplateRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/user_action_log_repository.go` (`repository.UserActionLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormUserActionLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormUserActionLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormUserActionLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "UserActionLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormUserActionLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormUserActionLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(newCtx)`。 - **`internal/infra/repository/pig_transfer_log_repository.go` (`repository.PigTransferLogRepository`)** - **结构体改造**: - - [ ] 新增 `selfCtx context.Context` 成员。 + - [x] 新增 `selfCtx context.Context` 成员。 - **构造函数改造 (`NewGormPigTransferLogRepository`)**: - - [ ] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在函数内部,为 `gormPigTransferLogRepository` 创建其专属的 `selfCtx`: + - [x] 修改函数签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在函数内部,为 `gormPigTransferLogRepository` 创建其专属的 `selfCtx`: `selfCtx := logs.AddCompName(ctx, "PigTransferLogRepository")`。 - - [ ] 将这个 `selfCtx` 赋值给 `gormPigTransferLogRepository` 结构体的 `selfCtx` 成员。 + - [x] 将这个 `selfCtx` 赋值给 `gormPigTransferLogRepository` 结构体的 `selfCtx` 成员。 - **公共方法改造 (所有公共方法)**: - - [ ] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 - - [ ] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 - - [ ] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(new \ No newline at end of file + - [x] 修改方法签名,添加 `ctx context.Context` 作为第一个参数。 + - [x] 在方法入口处,使用 `newCtx := logs.AddFuncName(ctx, r.selfCtx, "MethodName")`。 + - [x] 确保所有对 `r.db` 和 `tx` 的调用都使用 `r.db.WithContext(newCtx)` 或 `tx.WithContext(new \ No newline at end of file