feat: 添加 DrugInfo 模型,包含状态常量及表映射 #2
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!2
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/drug/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
This PR introduces a new GORM model for representing drug master data in the drug module, including status constants and explicit table mapping.
Changes:
DrugInfomodel embeddingcore.BaseModelwith GORM/JSON tags for drug attributes.DrugStatusDisabled,DrugStatusEnabled) for representing drug availability.TableName()to map the model to thedrug_infotable.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -0,0 +18,4 @@Specification string `gorm:"column:specification;size:50;not null" json:"specification"`DosageForm string `gorm:"column:dosage_form;size:50" json:"dosage_form"`Manufacturer string `gorm:"column:manufacturer;size:100;not null" json:"manufacturer"`ApprovalNumber string `gorm:"column:approval_number;size:50" json:"approval_number"`TradeName/DosageForm/ApprovalNumber are defined as non-pointer strings but do not declare
not null. In Postgres, a nullable VARCHAR column that ever contains NULL will fail to scan into a Gostring(database/sql can’t convert NULL to string). Either mark these columnsnot null(optionally with a default empty string) or change the Go fields to*string/sql.NullStringto match nullable semantics.@ -0,0 +21,4 @@ApprovalNumber string `gorm:"column:approval_number;size:50" json:"approval_number"`IsPrescription bool `gorm:"column:is_prescription;default:false" json:"is_prescription"`IsMedicare bool `gorm:"column:is_medicare;default:false" json:"is_medicare"`Status int8 `gorm:"column:status;default:1" json:"status"`IsPrescription/IsMedicare/Status are non-pointer scalar types but the GORM tags don’t specify
not null. If the DB schema allows NULL (e.g., via manual SQL, partial updates, or migrations), queries can fail scanning NULL intobool/int8. Consider addingnot nullalongside the defaults to enforce data integrity at the schema level.