|
@@ -5,15 +5,18 @@ import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
type Drugs struct {
|
|
|
Id int64 `json:"id"`
|
|
|
Name string `json:"name"`
|
|
|
- CategoryId pasturePb.DrugCategory_Kind `json:"category_id"`
|
|
|
+ CategoryId pasturePb.DrugCategory_Kind `json:"categoryId"`
|
|
|
+ CategoryName string `json:"categoryName"`
|
|
|
Producer string `json:"producer"`
|
|
|
- BatchNumber string `json:"batch_number"`
|
|
|
- ProductionAt int64 `json:"production_at"`
|
|
|
- ExpirationAt int64 `json:"expiration_at"`
|
|
|
+ BatchNumber string `json:"batchNumber"`
|
|
|
+ ProductionAt int64 `json:"productionAt"`
|
|
|
+ ExpirationAt int64 `json:"expirationAt"`
|
|
|
Unit pasturePb.Unit_Kind `json:"unit"`
|
|
|
+ UnitName string `json:"unitName"`
|
|
|
Specs string `json:"specs"`
|
|
|
Inventory int32 `json:"inventory"`
|
|
|
UsageMethod pasturePb.DrugUsage_Kind `json:"usage_method"`
|
|
|
+ UsageMethodName string `json:"usageMethodName"`
|
|
|
Price int32 `json:"price"`
|
|
|
MilkExpiredDays int32 `json:"milk_expired_days"`
|
|
|
MeatExpiredDays int32 `json:"meat_expired_days"`
|
|
@@ -30,44 +33,46 @@ func (d *Drugs) TableName() string {
|
|
|
|
|
|
func NewDrugs(req *pasturePb.SearchDrugsList, currentUser *SystemUser) *Drugs {
|
|
|
return &Drugs{
|
|
|
- Name: req.Name,
|
|
|
- CategoryId: req.CategoryId,
|
|
|
- Producer: req.Producer,
|
|
|
- BatchNumber: req.BatchNumber,
|
|
|
- ProductionAt: int64(req.ProductionAt),
|
|
|
- ExpirationAt: int64(req.ExpirationAt),
|
|
|
- Unit: req.Unit,
|
|
|
- Specs: req.Specs,
|
|
|
- Inventory: req.Inventory,
|
|
|
- UsageMethod: req.Usage,
|
|
|
- Price: int32(req.Price * 100),
|
|
|
- Remarks: req.Remarks,
|
|
|
- OperationId: int32(currentUser.Id),
|
|
|
- OperationName: currentUser.Name,
|
|
|
+ Name: req.Name,
|
|
|
+ CategoryId: req.CategoryId,
|
|
|
+ CategoryName: req.CategoryName,
|
|
|
+ Producer: req.Producer,
|
|
|
+ BatchNumber: req.BatchNumber,
|
|
|
+ ProductionAt: int64(req.ProductionAt),
|
|
|
+ ExpirationAt: int64(req.ExpirationAt),
|
|
|
+ Unit: req.Unit,
|
|
|
+ UnitName: req.UnitName,
|
|
|
+ Specs: req.Specs,
|
|
|
+ Inventory: req.Inventory,
|
|
|
+ UsageMethod: req.Usage,
|
|
|
+ UsageMethodName: req.UsageName,
|
|
|
+ Price: int32(req.Price * 100),
|
|
|
+ Remarks: req.Remarks,
|
|
|
+ OperationId: int32(currentUser.Id),
|
|
|
+ OperationName: currentUser.Name,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
type DrugsSlice []*Drugs
|
|
|
|
|
|
-func (d DrugsSlice) ToPB(drugsCategoryMap map[pasturePb.DrugCategory_Kind]string,
|
|
|
- unitMap map[pasturePb.Unit_Kind]string, drugUsageMap map[pasturePb.DrugUsage_Kind]string) []*pasturePb.SearchDrugsList {
|
|
|
+func (d DrugsSlice) ToPB() []*pasturePb.SearchDrugsList {
|
|
|
res := make([]*pasturePb.SearchDrugsList, len(d))
|
|
|
for i, v := range d {
|
|
|
res[i] = &pasturePb.SearchDrugsList{
|
|
|
Id: int32(v.Id),
|
|
|
Name: v.Name,
|
|
|
CategoryId: v.CategoryId,
|
|
|
- CategoryName: drugsCategoryMap[v.CategoryId],
|
|
|
+ CategoryName: v.CategoryName,
|
|
|
Producer: v.Producer,
|
|
|
BatchNumber: v.BatchNumber,
|
|
|
ProductionAt: int32(v.ProductionAt),
|
|
|
ExpirationAt: int32(v.ExpirationAt),
|
|
|
Unit: v.Unit,
|
|
|
- UnitName: unitMap[v.Unit],
|
|
|
+ UnitName: v.UnitName,
|
|
|
Specs: v.Specs,
|
|
|
Inventory: v.Inventory,
|
|
|
Usage: v.UsageMethod,
|
|
|
- UsageName: drugUsageMap[v.UsageMethod],
|
|
|
+ UsageName: v.UsageMethodName,
|
|
|
Price: float32(v.Price) / 100,
|
|
|
MeatExpiredDays: v.MeatExpiredDays,
|
|
|
MilkExpiredDays: v.MilkExpiredDays,
|