|
@@ -19,6 +19,7 @@ type Drugs struct {
|
|
|
MeatExpiredDays int32 `json:"meat_expired_days"`
|
|
|
Remarks string `json:"remarks"`
|
|
|
OperationId int32 `json:"operation_id"`
|
|
|
+ OperationName string `json:"operation_name"`
|
|
|
CreatedAt int64 `json:"created_at"`
|
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
|
}
|
|
@@ -29,36 +30,29 @@ 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),
|
|
|
+ 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,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
type DrugsSlice []*Drugs
|
|
|
|
|
|
-func (d DrugsSlice) ToPB(systemUserList []*SystemUser, drugsCategoryMap map[pasturePb.DrugCategory_Kind]string,
|
|
|
+func (d DrugsSlice) ToPB(drugsCategoryMap map[pasturePb.DrugCategory_Kind]string,
|
|
|
unitMap map[pasturePb.Unit_Kind]string, drugUsageMap map[pasturePb.DrugUsage_Kind]string) []*pasturePb.SearchDrugsList {
|
|
|
res := make([]*pasturePb.SearchDrugsList, len(d))
|
|
|
for i, v := range d {
|
|
|
- operationName := ""
|
|
|
- for _, u := range systemUserList {
|
|
|
- if int64(v.OperationId) != u.Id {
|
|
|
- continue
|
|
|
- }
|
|
|
- operationName = u.Name
|
|
|
- }
|
|
|
-
|
|
|
res[i] = &pasturePb.SearchDrugsList{
|
|
|
Id: int32(v.Id),
|
|
|
Name: v.Name,
|
|
@@ -79,7 +73,7 @@ func (d DrugsSlice) ToPB(systemUserList []*SystemUser, drugsCategoryMap map[past
|
|
|
MilkExpiredDays: v.MilkExpiredDays,
|
|
|
Remarks: v.Remarks,
|
|
|
OperationId: v.OperationId,
|
|
|
- OperationName: operationName,
|
|
|
+ OperationName: v.OperationName,
|
|
|
CreatedAt: int32(v.CreatedAt),
|
|
|
UpdatedAt: int32(v.UpdatedAt),
|
|
|
}
|