Browse Source

frozenSemen: 冻精管理添加牛只种类字段

Yi 7 months ago
parent
commit
fb3def3005

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20240812084330-1dca101fe7e7
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20240814032337-1d198707737c
 	gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/getsentry/sentry-go v0.23.0

+ 6 - 0
go.sum

@@ -88,6 +88,12 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20240812080243-38f667fd91e7 h1:GfXdHwc4
 gitee.com/xuyiping_admin/go_proto v0.0.0-20240812080243-38f667fd91e7/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20240812084330-1dca101fe7e7 h1:S0anZ8cTjnVGPvGSx3vRjjazKNFnaIH3Sdt65sIV1Rk=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20240812084330-1dca101fe7e7/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240813051219-04b62c4b2217 h1:kkYmLkz5X45GGiTlzNEK7IR/+/SZuKovOfMQerEcyao=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240813051219-04b62c4b2217/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240813081418-0fe70f4328c6 h1:Qaz7HlPvW4+b2L9uydLzJphldHo4QXFwFPM+2YFrsKU=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240813081418-0fe70f4328c6/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240814032337-1d198707737c h1:h8TDm6PMxEQoBaYc7wyfqsDW4T34/jb8CO7jY6G1gac=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240814032337-1d198707737c/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015 h1:dfb5dRd57L2HKjdwLT93UFmPYFPOmEl56gtZmqcNnaE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015/go.mod h1:Fk4GYI/v0IK3XFrm1Gn+VkgCz5Y7mfswD5hsTJYOG6A=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

+ 6 - 0
model/event_frozen_semen.go

@@ -7,6 +7,8 @@ type EventFrozenSemen struct {
 	ParentId        int64                          `json:"parent_id"`
 	Producer        string                         `json:"producer"`
 	BullId          string                         `json:"bull_id"`
+	KindId          pasturePb.CowKind_Kind         `json:"kind_id"`
+	KindName        string                         `json:"kind_name"`
 	FrozenSemenType pasturePb.FrozenSemenType_Kind `json:"frozen_semen_type"`
 	Quantity        int32                          `json:"quantity"`
 	Unit            pasturePb.Unit_Kind            `json:"unit"`
@@ -20,6 +22,8 @@ func NewEventFrozenSemen(req *pasturePb.SearchFrozenSemenList, currentUser *Syst
 	return &EventFrozenSemen{
 		Producer:        req.Producer,
 		BullId:          req.BullId,
+		KindId:          req.CowKind,
+		KindName:        req.CowKindName,
 		FrozenSemenType: req.FrozenSemenType,
 		Quantity:        req.Quantity,
 		Unit:            req.Unit,
@@ -44,6 +48,8 @@ func (e EventFrozenSemenSlice) ToPB(
 			ParentId:            int32(v.ParentId),
 			Producer:            v.Producer,
 			BullId:              v.BullId,
+			CowKind:             v.KindId,
+			CowKindName:         v.KindName,
 			FrozenSemenType:     v.FrozenSemenType,
 			FrozenSemenTypeName: frozenSemenTypeMap[v.FrozenSemenType],
 			Quantity:            v.Quantity,

+ 5 - 266
module/backend/config_data.go

@@ -1,54 +1,14 @@
 package backend
 
 import (
-	"context"
 	"kpt-pasture/model"
-	"net/http"
 
 	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
 	"go.uber.org/zap"
 
-	xxerr "gitee.com/xuyiping_admin/pkg/xerr"
-
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 )
 
-var DrugCategoryMap = map[pasturePb.DrugCategory_Kind]string{
-	pasturePb.DrugCategory_Antibiotics:    "抗生素类",
-	pasturePb.DrugCategory_Antivirals:     "抗病毒类",
-	pasturePb.DrugCategory_Antifungals:    "抗真菌类",
-	pasturePb.DrugCategory_Antiparasitics: "驱虫类",
-	pasturePb.DrugCategory_Analgesics:     "镇痛类",
-	pasturePb.DrugCategory_Antipyretic:    "退烧类",
-	pasturePb.DrugCategory_Vitamin:        "维生素类",
-	pasturePb.DrugCategory_Brine:          "盐水",
-	pasturePb.DrugCategory_Glucose:        "葡萄糖",
-	pasturePb.DrugCategory_Hormone:        "激素类",
-	pasturePb.DrugCategory_Anti_Stress:    "抗应激类",
-	pasturePb.DrugCategory_Disinfect:      "消毒类",
-	pasturePb.DrugCategory_Chinese_Herbal: "中药合剂",
-	pasturePb.DrugCategory_Tocolytic:      "保胎类",
-	pasturePb.DrugCategory_Immunity:       "免疫类",
-}
-var UnitMap = map[pasturePb.Unit_Kind]string{
-	pasturePb.Unit_Pieces:  "个",
-	pasturePb.Unit_Package: "包/袋",
-	pasturePb.Unit_Bottle:  "瓶",
-	pasturePb.Unit_Box:     "盒",
-	pasturePb.Unit_Boxful:  "箱",
-	pasturePb.Unit_Branch:  "支",
-	pasturePb.Unit_Barrel:  "桶",
-	pasturePb.Unit_Pot:     "罐",
-	pasturePb.Unit_ML:      "毫升",
-	pasturePb.Unit_L:       "升",
-}
-var DrugUsageMap = map[pasturePb.DrugUsage_Kind]string{
-	pasturePb.DrugUsage_Oral_Medications:       "口服",
-	pasturePb.DrugUsage_Injectable_Medications: "肌注",
-	pasturePb.DrugUsage_Topical_Medications:    "外用",
-	pasturePb.DrugUsage_Drink_Medications:      "饮水",
-}
-
 func (s *StoreEntry) BarnTypeEnumList() []*pasturePb.ConfigOptionsList {
 	barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
 	barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
@@ -295,6 +255,10 @@ func (s *StoreEntry) ImmunizationConditionsEnumList() []*pasturePb.ConfigOptions
 		Value:    int32(pasturePb.ImmunizationConditions_Month),
 		Label:    "每年月份",
 		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.ImmunizationConditions_Admission_Days),
+		Label:    "入场天数",
+		Disabled: true,
 	})
 	return cowTypeList
 }
@@ -498,7 +462,7 @@ func (s *StoreEntry) DrugCategoryEnumList() []*pasturePb.ConfigOptionsList {
 		Disabled: true,
 	}, &pasturePb.ConfigOptionsList{
 		Value:    int32(pasturePb.DrugCategory_Immunity),
-		Label:    "疫类",
+		Label:    "疫类",
 		Disabled: true,
 	})
 	return configOptions
@@ -659,228 +623,3 @@ func (s *StoreEntry) WeekEnumList() []*pasturePb.ConfigOptionsList {
 		})
 	return configOptions
 }
-
-func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
-	res := make(map[pasturePb.DrugUsage_Kind]string)
-	for _, v := range s.DrugUsageEnumList() {
-		res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
-	res := make(map[pasturePb.ExposeEstrusType_Kind]string)
-	for _, v := range s.ExposeEstrusTypeEnumList() {
-		res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
-	res := make(map[pasturePb.FrozenSemenType_Kind]string)
-	for _, v := range s.FrozenSemenTypeEnumList() {
-		res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
-	res := make(map[pasturePb.Unit_Kind]string)
-	for _, v := range s.UnitEnumList() {
-		res[pasturePb.Unit_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
-	res := make(map[pasturePb.Week_Kind]string)
-	for _, v := range s.WeekEnumList() {
-		res[pasturePb.Week_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
-	res := make(map[pasturePb.CowType_Kind]string)
-	for _, v := range s.CowTypeEnumList() {
-		res[pasturePb.CowType_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) CowStatusMap() map[pasturePb.CowStatus_Kind]string {
-	res := make(map[pasturePb.CowStatus_Kind]string)
-	for _, v := range s.CowStatusEnumList() {
-		res[pasturePb.CowStatus_Kind(v.Value)] = v.Label
-	}
-	return res
-}
-
-func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.BarnTypeEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
-	penList := make([]*model.Pen, 0)
-	pref := s.DB.Table(new(model.Pen).TableName()).
-		Where("is_delete = ?", pasturePb.IsShow_Ok)
-	if penType != -1 {
-		pref.Where("pen_type = ?", penType)
-	}
-	if err := pref.Find(&penList).Error; err != nil {
-		return nil, err
-	}
-
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
-	}, nil
-}
-
-func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
-	pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
-		Where("is_show =? ", pasturePb.IsShow_Ok)
-
-	if err := pref.Find(&diseaseTypeList).Error; err != nil {
-		return nil, xxerr.WithStack(err)
-	}
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(),
-	}, nil
-}
-
-func (s *StoreEntry) DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	diseaseList := make([]*model.Disease, 0)
-	pref := s.DB.Table(new(model.Disease).TableName()).
-		Where("is_show =? ", pasturePb.IsShow_Ok)
-
-	if err := pref.Find(&diseaseList).Error; err != nil {
-		return nil, xxerr.WithStack(err)
-	}
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    model.DiseaseSlice(diseaseList).ToPB2(),
-	}, nil
-}
-
-func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.BreedStatusEnumList(),
-	}, nil
-}
-func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.CowKindEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.CowSourceEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.CowStatusEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.CowTypeEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.TransferPenEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
-	systemUserList := make([]*model.SystemUser, 0)
-	pref := s.DB.Table(new(model.SystemUser).TableName()).
-		Where("is_delete = ?", pasturePb.IsShow_Ok).
-		Where("is_show =? ", pasturePb.IsShow_Ok)
-	if depId != -1 && depId > 0 {
-		pref = pref.Where("dept_id = ?", depId)
-	}
-	if err := pref.Find(&systemUserList).Error; err != nil {
-		return nil, xxerr.WithStack(err)
-	}
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    model.SystemUserSlice(systemUserList).ToPB2(),
-	}, nil
-}
-
-func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
-	return &pasturePb.BullOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    s.BullNumberEnumList(),
-	}, nil
-}
-
-func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	switch optionsName {
-	case "childNumber":
-		configOptions = s.ChildNumberEnumList()
-	case "calvingLevel":
-		configOptions = s.CalvingLevelEnumList()
-	case "dystociaReason":
-		configOptions = s.DystociaReasonEnumList()
-	case "drugCategory":
-		configOptions = s.DrugCategoryEnumList()
-	case "drugUsage":
-		configOptions = s.DrugUsageEnumList()
-	case "unit":
-		configOptions = s.UnitEnumList()
-	case "pregnantCheckResult":
-		configOptions = s.PregnantCheckResultEnumList()
-	case "pregnantCheckMethod":
-		configOptions = s.PregnantCheckMethodEnumList()
-	case "exposeEstrusType":
-		configOptions = s.ExposeEstrusTypeEnumList()
-	case "frozenSemenType":
-		configOptions = s.FrozenSemenTypeEnumList()
-	case "week":
-		configOptions = s.WeekEnumList()
-	case "sameTimeCowType":
-		configOptions = s.SemeTimeCowTypeEnumList()
-	case "immunizationCowType":
-		configOptions = s.ImmunizationCowTypeEnumList()
-	case "immunizationConditions":
-		configOptions = s.ImmunizationConditionsEnumList()
-	}
-
-	return &pasturePb.ConfigOptionsListResponse{
-		Code:    http.StatusOK,
-		Message: "ok",
-		Data:    configOptions,
-	}, nil
-}

+ 103 - 0
module/backend/enum_map.go

@@ -0,0 +1,103 @@
+package backend
+
+import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+
+var DrugCategoryMap = map[pasturePb.DrugCategory_Kind]string{
+	pasturePb.DrugCategory_Antibiotics:    "抗生素类",
+	pasturePb.DrugCategory_Antivirals:     "抗病毒类",
+	pasturePb.DrugCategory_Antifungals:    "抗真菌类",
+	pasturePb.DrugCategory_Antiparasitics: "驱虫类",
+	pasturePb.DrugCategory_Analgesics:     "镇痛类",
+	pasturePb.DrugCategory_Antipyretic:    "退烧类",
+	pasturePb.DrugCategory_Vitamin:        "维生素类",
+	pasturePb.DrugCategory_Brine:          "盐水",
+	pasturePb.DrugCategory_Glucose:        "葡萄糖",
+	pasturePb.DrugCategory_Hormone:        "激素类",
+	pasturePb.DrugCategory_Anti_Stress:    "抗应激类",
+	pasturePb.DrugCategory_Disinfect:      "消毒类",
+	pasturePb.DrugCategory_Chinese_Herbal: "中药合剂",
+	pasturePb.DrugCategory_Tocolytic:      "保胎类",
+	pasturePb.DrugCategory_Immunity:       "疫苗类",
+}
+var UnitMap = map[pasturePb.Unit_Kind]string{
+	pasturePb.Unit_Pieces:  "个",
+	pasturePb.Unit_Package: "包/袋",
+	pasturePb.Unit_Bottle:  "瓶",
+	pasturePb.Unit_Box:     "盒",
+	pasturePb.Unit_Boxful:  "箱",
+	pasturePb.Unit_Branch:  "支",
+	pasturePb.Unit_Barrel:  "桶",
+	pasturePb.Unit_Pot:     "罐",
+	pasturePb.Unit_ML:      "毫升",
+	pasturePb.Unit_L:       "升",
+}
+var DrugUsageMap = map[pasturePb.DrugUsage_Kind]string{
+	pasturePb.DrugUsage_Oral_Medications:       "口服",
+	pasturePb.DrugUsage_Injectable_Medications: "肌注",
+	pasturePb.DrugUsage_Topical_Medications:    "外用",
+	pasturePb.DrugUsage_Drink_Medications:      "饮水",
+}
+
+func (s *StoreEntry) DrugUsageMaps() map[pasturePb.DrugUsage_Kind]string {
+	res := make(map[pasturePb.DrugUsage_Kind]string)
+	for _, v := range s.DrugUsageEnumList() {
+		res[pasturePb.DrugUsage_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) ExposeEstrusTypeMap() map[pasturePb.ExposeEstrusType_Kind]string {
+	res := make(map[pasturePb.ExposeEstrusType_Kind]string)
+	for _, v := range s.ExposeEstrusTypeEnumList() {
+		res[pasturePb.ExposeEstrusType_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) FrozenSemenTypeMap() map[pasturePb.FrozenSemenType_Kind]string {
+	res := make(map[pasturePb.FrozenSemenType_Kind]string)
+	for _, v := range s.FrozenSemenTypeEnumList() {
+		res[pasturePb.FrozenSemenType_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) UnitMap() map[pasturePb.Unit_Kind]string {
+	res := make(map[pasturePb.Unit_Kind]string)
+	for _, v := range s.UnitEnumList() {
+		res[pasturePb.Unit_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) WeekMap() map[pasturePb.Week_Kind]string {
+	res := make(map[pasturePb.Week_Kind]string)
+	for _, v := range s.WeekEnumList() {
+		res[pasturePb.Week_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) CowTypeMap() map[pasturePb.CowType_Kind]string {
+	res := make(map[pasturePb.CowType_Kind]string)
+	for _, v := range s.CowTypeEnumList() {
+		res[pasturePb.CowType_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) CowStatusMap() map[pasturePb.CowStatus_Kind]string {
+	res := make(map[pasturePb.CowStatus_Kind]string)
+	for _, v := range s.CowStatusEnumList() {
+		res[pasturePb.CowStatus_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
+func (s *StoreEntry) CowKindMap() map[pasturePb.CowKind_Kind]string {
+	res := make(map[pasturePb.CowKind_Kind]string)
+	for _, v := range s.CowKindEnumList() {
+		res[pasturePb.CowKind_Kind(v.Value)] = v.Label
+	}
+	return res
+}

+ 180 - 0
module/backend/enum_options.go

@@ -0,0 +1,180 @@
+package backend
+
+import (
+	"context"
+	"kpt-pasture/model"
+	"net/http"
+
+	"gitee.com/xuyiping_admin/pkg/xerr"
+
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+)
+
+func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.BarnTypeEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
+	penList := make([]*model.Pen, 0)
+	pref := s.DB.Table(new(model.Pen).TableName()).
+		Where("is_delete = ?", pasturePb.IsShow_Ok)
+	if penType != -1 {
+		pref.Where("pen_type = ?", penType)
+	}
+	if err := pref.Find(&penList).Error; err != nil {
+		return nil, err
+	}
+
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
+	}, nil
+}
+
+func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
+	pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
+		Where("is_show =? ", pasturePb.IsShow_Ok)
+
+	if err := pref.Find(&diseaseTypeList).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(),
+	}, nil
+}
+
+func (s *StoreEntry) DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	diseaseList := make([]*model.Disease, 0)
+	pref := s.DB.Table(new(model.Disease).TableName()).
+		Where("is_show =? ", pasturePb.IsShow_Ok)
+
+	if err := pref.Find(&diseaseList).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    model.DiseaseSlice(diseaseList).ToPB2(),
+	}, nil
+}
+
+func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.BreedStatusEnumList(),
+	}, nil
+}
+func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.CowKindEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.CowSourceEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.CowStatusEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.CowTypeEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.TransferPenEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
+	systemUserList := make([]*model.SystemUser, 0)
+	pref := s.DB.Table(new(model.SystemUser).TableName()).
+		Where("is_delete = ?", pasturePb.IsShow_Ok).
+		Where("is_show =? ", pasturePb.IsShow_Ok)
+	if depId != -1 && depId > 0 {
+		pref = pref.Where("dept_id = ?", depId)
+	}
+	if err := pref.Find(&systemUserList).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    model.SystemUserSlice(systemUserList).ToPB2(),
+	}, nil
+}
+
+func (s *StoreEntry) BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error) {
+	return &pasturePb.BullOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    s.BullNumberEnumList(),
+	}, nil
+}
+
+func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	switch optionsName {
+	case "childNumber":
+		configOptions = s.ChildNumberEnumList()
+	case "calvingLevel":
+		configOptions = s.CalvingLevelEnumList()
+	case "dystociaReason":
+		configOptions = s.DystociaReasonEnumList()
+	case "drugCategory":
+		configOptions = s.DrugCategoryEnumList()
+	case "drugUsage":
+		configOptions = s.DrugUsageEnumList()
+	case "unit":
+		configOptions = s.UnitEnumList()
+	case "pregnantCheckResult":
+		configOptions = s.PregnantCheckResultEnumList()
+	case "pregnantCheckMethod":
+		configOptions = s.PregnantCheckMethodEnumList()
+	case "exposeEstrusType":
+		configOptions = s.ExposeEstrusTypeEnumList()
+	case "frozenSemenType":
+		configOptions = s.FrozenSemenTypeEnumList()
+	case "week":
+		configOptions = s.WeekEnumList()
+	case "sameTimeCowType":
+		configOptions = s.SemeTimeCowTypeEnumList()
+	case "immunizationCowType":
+		configOptions = s.ImmunizationCowTypeEnumList()
+	case "immunizationConditions":
+		configOptions = s.ImmunizationConditionsEnumList()
+	}
+
+	return &pasturePb.ConfigOptionsListResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data:    configOptions,
+	}, nil
+}

+ 1 - 0
module/backend/event.go

@@ -535,6 +535,7 @@ func (s *StoreEntry) FrozenSemenList(ctx context.Context, req *pasturePb.FrozenS
 
 func (s *StoreEntry) FrozenSemenCreate(ctx context.Context, req *pasturePb.SearchFrozenSemenList) error {
 	currentUser, _ := s.GetCurrentSystemUser(ctx)
+	req.CowKindName = s.CowKindMap()[req.CowKind]
 	newFrozenSemen := model.NewEventFrozenSemen(req, currentUser)
 	if err := s.DB.Create(newFrozenSemen).Error; err != nil {
 		return xerr.WithStack(err)

+ 3 - 0
module/backend/interface.go

@@ -169,15 +169,18 @@ type CowService interface {
 	CowList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchCowListResponse, error)
 }
 
+//go:generate mockgen -destination mock/GoodsService.go -package kptservicemock kpt-pasture/module/backend GoodsService
 type GoodsService interface {
 	DrugsList(ctx context.Context, req *pasturePb.SearchDrugsRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchDrugsResponse, error)
 	DrugsCreate(ctx context.Context, req *pasturePb.SearchDrugsList) error
 }
 
+//go:generate mockgen -destination mock/AnalyseService.go -package kptservicemock kpt-pasture/module/backend AnalyseService
 type AnalyseService interface {
 	GrowthCurve(ctx context.Context, req *pasturePb.SearchGrowthCurvesRequest) (*pasturePb.GrowthCurvesResponse, error)
 }
 
+//go:generate mockgen -destination mock/DashboardService.go -package kptservicemock kpt-pasture/module/backend DashboardService
 type DashboardService interface {
 	Bar(ctx context.Context) (*pasturePb.BarCowStructResponse, error)
 }