初始化
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Fix Compilation Error: `undefined: parseTime`
|
||||
|
||||
The error occurs because the `parseTime` helper function is used in `role_repository.go` and `permission_repository.go` but is not defined in the codebase.
|
||||
|
||||
## Root Cause
|
||||
- The code attempts to manually parse time bytes (`[]uint8`) into `time.Time`.
|
||||
- However, the database connection (`config/db.go`) is already configured with `parseTime=True`.
|
||||
- This means the MySQL driver can automatically scan `DATETIME` columns directly into `time.Time` struct fields.
|
||||
|
||||
## Solution Plan
|
||||
Instead of adding the missing helper function, I will refactor the code to use the driver's built-in time parsing capabilities, which is cleaner and consistent with `user_repository.go`.
|
||||
|
||||
1. **Modify `server/repositories/role_repository.go`**:
|
||||
- Update `GetRoles`, `GetRoleByID`, `GetRoleByName` functions.
|
||||
- Remove temporary `[]uint8` variables for `createdAt` and `updatedAt`.
|
||||
- Scan directly into `&role.CreatedAt` and `&role.UpdatedAt`.
|
||||
|
||||
2. **Modify `server/repositories/permission_repository.go`**:
|
||||
- Update `GetPermissions` and `GetPermissionsByRoleID` functions.
|
||||
- Remove temporary `[]uint8` variables.
|
||||
- Scan directly into `&permission.CreatedAt` and `&permission.UpdatedAt`.
|
||||
|
||||
This will resolve all "undefined: parseTime" errors and ensure the server compiles successfully.
|
||||
Reference in New Issue
Block a user