Prechádzať zdrojové kódy

config: 增加疾病类型接口

Yi 5 mesiacov pred
rodič
commit
417cc8d34b

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 go 1.17
 
 
 require (
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20241021095634-62b455bd33a1
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20241022063225-d34353c88fd2
 	gitee.com/xuyiping_admin/pkg v0.0.0-20241010101255-0c6bd229b939
 	gitee.com/xuyiping_admin/pkg v0.0.0-20241010101255-0c6bd229b939
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eko/gocache v1.1.0
 	github.com/eko/gocache v1.1.0

+ 2 - 0
go.sum

@@ -96,6 +96,8 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20241021094122-8c83f9d0bd28 h1:JW+Xqeef
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241021094122-8c83f9d0bd28/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241021094122-8c83f9d0bd28/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241021095634-62b455bd33a1 h1:umkLXvBmP5RVv50FHhQo3Z0U50BdmLwtSAXEmDWpIoI=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241021095634-62b455bd33a1 h1:umkLXvBmP5RVv50FHhQo3Z0U50BdmLwtSAXEmDWpIoI=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241021095634-62b455bd33a1/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241021095634-62b455bd33a1/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241022063225-d34353c88fd2 h1:oDKwxyg5gnNuHIcjSIJXFIGhPxEUcAXJTTevZShpL5g=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241022063225-d34353c88fd2/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 h1:dfb5dRd57L2HKjdwLT93UFmPYFPOmEl56gtZmqcNnaE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015/go.mod h1:Fk4GYI/v0IK3XFrm1Gn+VkgCz5Y7mfswD5hsTJYOG6A=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015/go.mod h1:Fk4GYI/v0IK3XFrm1Gn+VkgCz5Y7mfswD5hsTJYOG6A=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241008063555-121a776fd331 h1:qJcpJ3o+O7uxDqR0I9LijQmi607IKvhf4mGum/ZUPT0=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241008063555-121a776fd331 h1:qJcpJ3o+O7uxDqR0I9LijQmi607IKvhf4mGum/ZUPT0=

+ 2 - 1
http/handler/config/config.go

@@ -37,7 +37,8 @@ func BarnListOptions(c *gin.Context) {
 }
 }
 
 
 func DiseaseTypeOptions(c *gin.Context) {
 func DiseaseTypeOptions(c *gin.Context) {
-	res, err := middleware.Dependency(c).StoreEventHub.OpsService.DiseaseTypeOptions(c)
+	isAll := c.Query("is_children")
+	res, err := middleware.Dependency(c).StoreEventHub.OpsService.DiseaseTypeOptions(c, isAll)
 	if err != nil {
 	if err != nil {
 		apierr.ClassifiedAbort(c, err)
 		apierr.ClassifiedAbort(c, err)
 		return
 		return

+ 15 - 1
model/config_disease_type.go

@@ -34,13 +34,27 @@ func (c ConfigDiseaseTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
 	return res
 	return res
 }
 }
 
 
-func (c ConfigDiseaseTypeSlice) ToPB2() []*pasturePb.ConfigOptionsList {
+func (c ConfigDiseaseTypeSlice) ToPB2(diseaseList []*Disease) []*pasturePb.ConfigOptionsList {
 	res := make([]*pasturePb.ConfigOptionsList, len(c))
 	res := make([]*pasturePb.ConfigOptionsList, len(c))
 	for i, d := range c {
 	for i, d := range c {
+		children := make([]*pasturePb.ConfigOptionsList, 0)
+		if len(diseaseList) > 0 {
+			for _, v := range diseaseList {
+				if int64(v.DiseaseType) != d.Id {
+					continue
+				}
+				children = append(children, &pasturePb.ConfigOptionsList{
+					Value:    int32(v.Id),
+					Label:    v.Name,
+					Disabled: true,
+				})
+			}
+		}
 		res[i] = &pasturePb.ConfigOptionsList{
 		res[i] = &pasturePb.ConfigOptionsList{
 			Value:    int32(d.Id),
 			Value:    int32(d.Id),
 			Label:    d.Name,
 			Label:    d.Name,
 			Disabled: true,
 			Disabled: true,
+			Children: children,
 		}
 		}
 	}
 	}
 	return res
 	return res

+ 2 - 2
model/event_cow_same_time.go

@@ -106,9 +106,9 @@ func (s SameTimeBodySlice) ToPB(
 	return res
 	return res
 }
 }
 
 
-type CowSameTimeSlice []*EventCowSameTime
+type EventCowSameTimeSlice []*EventCowSameTime
 
 
-func (s CowSameTimeSlice) ToPB() []*pasturePb.EventSameTime {
+func (s EventCowSameTimeSlice) ToPB() []*pasturePb.EventSameTime {
 	res := make([]*pasturePb.EventSameTime, len(s))
 	res := make([]*pasturePb.EventSameTime, len(s))
 	for i, v := range s {
 	for i, v := range s {
 		res[i] = &pasturePb.EventSameTime{
 		res[i] = &pasturePb.EventSameTime{

+ 10 - 3
module/backend/enum_options.go

@@ -37,18 +37,25 @@ func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int, isAll str
 	}, nil
 	}, nil
 }
 }
 
 
-func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
+func (s *StoreEntry) DiseaseTypeOptions(ctx context.Context, isAll string) (*pasturePb.ConfigOptionsListResponse, error) {
 	diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
 	diseaseTypeList := make([]*model.ConfigDiseaseType, 0)
 	pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
 	pref := s.DB.Table(new(model.ConfigDiseaseType).TableName()).
 		Where("is_show =? ", pasturePb.IsShow_Ok)
 		Where("is_show =? ", pasturePb.IsShow_Ok)
-
 	if err := pref.Find(&diseaseTypeList).Error; err != nil {
 	if err := pref.Find(&diseaseTypeList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 		return nil, xerr.WithStack(err)
 	}
 	}
+	diseaseList := make([]*model.Disease, 0)
+	if isAll == model.IsAllYes {
+		if err := s.DB.Table(new(model.Disease).TableName()).
+			Where("is_show =? ", pasturePb.IsShow_Ok).Find(&diseaseList).Error; err != nil {
+			return nil, xerr.WithStack(err)
+		}
+	}
+
 	return &pasturePb.ConfigOptionsListResponse{
 	return &pasturePb.ConfigOptionsListResponse{
 		Code:    http.StatusOK,
 		Code:    http.StatusOK,
 		Message: "ok",
 		Message: "ok",
-		Data:    model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(),
+		Data:    model.ConfigDiseaseTypeSlice(diseaseTypeList).ToPB2(diseaseList),
 	}, nil
 	}, nil
 }
 }
 
 

+ 5 - 2
module/backend/event_breed.go

@@ -595,7 +595,10 @@ func (s *StoreEntry) SameTimeList(
 		pref.Where("cow_id IN ?", cowIds)
 		pref.Where("cow_id IN ?", cowIds)
 	}
 	}
 
 
-	if err := pref.Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).Find(&cowSameTimeList).Error; err != nil {
+	if err := pref.Count(&count).
+		Limit(int(pagination.PageSize)).
+		Offset(int(pagination.PageOffset)).
+		Find(&cowSameTimeList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 		return nil, xerr.WithStack(err)
 	}
 	}
 
 
@@ -603,7 +606,7 @@ func (s *StoreEntry) SameTimeList(
 		Code:    http.StatusOK,
 		Code:    http.StatusOK,
 		Message: "ok",
 		Message: "ok",
 		Data: &pasturePb.SameTimeData{
 		Data: &pasturePb.SameTimeData{
-			List:     model.CowSameTimeSlice(cowSameTimeList).ToPB(),
+			List:     model.EventCowSameTimeSlice(cowSameTimeList).ToPB(),
 			Total:    int32(count),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
 			Page:     pagination.Page,

+ 1 - 1
module/backend/interface.go

@@ -141,7 +141,7 @@ type ConfigDataService interface {
 	SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error)
 	SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error)
 	BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error)
 	BullOptions(ctx context.Context) (*pasturePb.BullOptionsListResponse, error)
 	SystemBaseConfigOptions(ctx context.Context, optionName, isAll string) (*pasturePb.ConfigOptionsListResponse, error)
 	SystemBaseConfigOptions(ctx context.Context, optionName, isAll string) (*pasturePb.ConfigOptionsListResponse, error)
-	DiseaseTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
+	DiseaseTypeOptions(ctx context.Context, isAll string) (*pasturePb.ConfigOptionsListResponse, error)
 	DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
 	DiseaseOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
 	PrescriptionOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
 	PrescriptionOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
 }
 }