Feat/audit/model #7
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
yingmo/PharmacyERP!7
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/audit/model"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request overview
Adds initial GORM model layer for the new
internal/auditdomain, providing DB mappings for audit events, audit reviews, and operation logs, plus required module dependencies.Changes:
AuditEvent,AuditReview, andOperationLogmodels underinternal/audit/model.gorm.io/datatypesto support JSONB detail storage in operation logs.go.mod/go.sumto reflect the new dependency graph.Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
OperationLogmodel with JSONBdetailpayload for operation auditing.AuditReviewmodel and status constants for pharmacist review results.AuditEventmodel to track auditable events and their lifecycle.gorm.io/datatypesand several new indirect dependencies.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -15,3 +16,4 @@)require (filippo.io/edwards25519 v1.1.0 // indirect本 PR 仅新增审计模型,但这里额外新增了
filippo.io/edwards25519(indirect)。当前仓库代码中未找到相关 import/使用痕迹,建议确认是否误引入;若无实际用途请移除并在最后执行go mod tidy。本 PR 仅新增审计模型,但这里新增了
github.com/go-sql-driver/mysql/github.com/google/uuid(indirect)。在仓库 Go 代码中未搜索到对应 import(例如gorm.io/driver/mysql、github.com/google/uuid),建议确认是否误引入;若无使用请移除并运行go mod tidy,避免不必要的依赖膨胀。这里新增了
gorm.io/driver/mysql(indirect),但仓库内未找到gorm.io/driver/mysql的 import。若项目目前仅使用 Postgres(已直接依赖 driver/postgres),建议去掉该 driver 依赖并go mod tidy,避免引入额外数据库 driver 及其传递依赖。@ -0,0 +9,4 @@const (// AuditReviewStatusPassed 审核通过。AuditReviewStatusPassed = "PASSED"// AuditReviewStatusRejected 审核驳回。AuditReview 的状态常量使用了全大写值("PASSED"/"REJECTED"),与仓库里其他业务状态字段普遍使用的 lower snake-case(如 inbound_order.go / trace_inventory.go 中的 "draft"、"pending_shelving" 等)不一致。建议统一状态取值风格,避免跨模块状态值难以复用/比对;如果数据库已固定为大写,请至少在注释中说明该取值来自 DB/外部系统且不可更改。
@ -0,0 +18,4 @@core.BaseModelOrderID int64 `gorm:"column:order_id;type:bigint;not null;index:idx_audit_review_order" json:"order_id"`PharmacistID int64 `gorm:"column:pharmacist_id;type:bigint;not null" json:"pharmacist_id"`Status string `gorm:"column:status;type:varchar(20);not null" json:"status"`Status 字段为 not null 的 string,但没有 default 或约束;在未显式赋值时,GORM 仍可能写入空字符串(""),从而产生不符合 PASSED/REJECTED 预期的记录。建议在 DB 层加 CHECK 约束/枚举约束,或在模型/写入逻辑中增加校验并(如有需要)为初始状态设置默认值。