123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package model
- import (
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type ImmunizationPlan struct {
- Id int64 `json:"id"`
- PastureId int64 `json:"pastureId"`
- Name string `json:"name"`
- CowType pasturePb.CowType_Kind `json:"cowType"`
- Conditions pasturePb.ImmunizationConditions_Kind `json:"conditions"`
- Value int64 `json:"value"`
- IsShow pasturePb.IsShow_Kind `json:"isShow"`
- ImmunizationPlanId int64 `json:"immunizationPlanId"`
- ImmunizationPlanName string `json:"immunizationPlanName"`
- OperationId int64 `json:"operationId"`
- OperationName string `json:"operationName"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (i *ImmunizationPlan) TableName() string {
- return "immunization_plan"
- }
- func NewImmunizationPlan(pastureId int64, systemUser *SystemUser, req *pasturePb.ImmunizationRequest) *ImmunizationPlan {
- return &ImmunizationPlan{
- PastureId: pastureId,
- Name: req.Name,
- CowType: req.CowType,
- Conditions: req.Conditions,
- Value: int64(req.Value),
- ImmunizationPlanId: int64(req.ImmunizationPlanId),
- ImmunizationPlanName: req.ImmunizationPlanName,
- IsShow: req.IsShow,
- OperationId: systemUser.Id,
- OperationName: systemUser.Name,
- }
- }
- type ImmunizationPlanSlice []*ImmunizationPlan
- func (i ImmunizationPlanSlice) ToPB(cowTypeOptions []*pasturePb.ConfigOptionsList, conditionsOptions []*pasturePb.ConfigOptionsList) []*pasturePb.ImmunizationRequest {
- res := make([]*pasturePb.ImmunizationRequest, len(i))
- for d, v := range i {
- cowTypeName, conditionsName := "", ""
- for _, c := range cowTypeOptions {
- if c.Value != int32(v.CowType) {
- continue
- }
- cowTypeName = c.Label
- }
- for _, cd := range conditionsOptions {
- if cd.Value != int32(v.Conditions) {
- continue
- }
- conditionsName = cd.Label
- }
- res[d] = &pasturePb.ImmunizationRequest{
- Id: int32(v.Id),
- Name: v.Name,
- CowType: v.CowType,
- CowTypeName: cowTypeName,
- Conditions: v.Conditions,
- ConditionsName: conditionsName,
- Value: int32(v.Value),
- IsShow: v.IsShow,
- ImmunizationPlanId: int32(v.ImmunizationPlanId),
- ImmunizationPlanName: v.ImmunizationPlanName,
- OperationId: int32(v.OperationId),
- OperationName: v.OperationName,
- CreatedAt: int32(v.CreatedAt),
- UpdatedAt: int32(v.UpdatedAt),
- }
- }
- return res
- }
|