Browse Source

event: 转群事件

Yi 10 months ago
parent
commit
7cdc021719

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20240430082601-9300922bef83
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20240506090538-9d6beda359cb
 	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

+ 4 - 38
go.sum

@@ -36,44 +36,10 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
 cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240410062335-c8e3d2cdf42e h1:9ULDek9hY5Wwq2kowvlkP4cs0EHyit61Y5UXMm30qNQ=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240410062335-c8e3d2cdf42e/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423060400-7aab96199f28 h1:EE/krB13w6d+CM2QnJpiUIZvYupk1GRb0ibBwjtS87U=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423060400-7aab96199f28/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423064437-ed6e968b60b0 h1:UhgBHbYI3ZqPZsozo9syLfUA4MfDUpuR6/GfqChT7pE=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423064437-ed6e968b60b0/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423074707-38168d47d746 h1:aMUKy/NQwcHjVylqLiJmRkBCMzWxU6I2Vigamcs859Y=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423074707-38168d47d746/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423085407-1b1485d9ef23 h1:D9l7UJOaW9iEHysy1m0qWJKYucYkXkGfHszHouIzdPY=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423085407-1b1485d9ef23/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423091123-4c66ec606d44 h1:ZE8O4adX0eIntRVXwdYnSB0pGUcI/XVvAIKsO0rWwDY=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240423091123-4c66ec606d44/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240425052959-85ae9a2fe5bb h1:6IBpGt6kf7d7c+qLKOfvVxZ7Q46+qjcQbu5zzFqINf0=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240425052959-85ae9a2fe5bb/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240425055608-2c760fefec9e h1:YPxPCEeSxg+m47V4rk9Dl/idzLCnSME6E3rNzopSgyA=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240425055608-2c760fefec9e/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240425060737-5be481b3c899 h1:+Um88uwlW68BR+PL2KVXcZxTBimnMAPG9gNBm96WFs8=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240425060737-5be481b3c899/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426031212-ce26e36229f2 h1:+susVuhAgqoXhoQognNfDOug6/rUVBSj6Q+3JsBeUcM=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426031212-ce26e36229f2/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426032250-3453d0d3127c h1:0Klrgv7ofDqfmNscKdtWj+M8G7Seok5JcDowLMG1eSI=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426032250-3453d0d3127c/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426060603-a68c0321fda3 h1:CpeOukiJE82k2PCJM5qRyOrX01mesj3r19UVnYoxuWc=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426060603-a68c0321fda3/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426071708-b9b3ad7038bd h1:t/CNbQqjhxWVw53ZQz/4GV1e0eLw7eEmQhGCsIT1p9k=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240426071708-b9b3ad7038bd/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240428015639-7a6e0cd54b97 h1:J7A5DbtzqOJ77FlRXMDsHfWYQtFpllNIfSMsKaSPKHs=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240428015639-7a6e0cd54b97/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240428053026-cef7ffa85f63 h1:IwGT4Tfgj67D+7M+vYluYug8nSQ9Gl505cJvxDBl9Fo=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240428053026-cef7ffa85f63/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240429093353-bbb01da08b4e h1:d2iUF//PtvMnqV40NR1Wfh4qqrxexSnmAlKV9QR2kho=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240429093353-bbb01da08b4e/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240429093656-ddd0948ba705 h1:FURTtdTQjJnDc9SOA2bFgwH7f+gMWovVVHFb6SF3E5k=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240429093656-ddd0948ba705/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240430072830-f136f793f6b1 h1:cR+0spDUIeSDjB9Mdm6ThAJsBmMFZN40EYP08nrK93I=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240430072830-f136f793f6b1/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240430082601-9300922bef83 h1:CgxdEzvMp/OlWUsuGUGcYJjNqYSBFk79xJFf3MipJ7c=
-gitee.com/xuyiping_admin/go_proto v0.0.0-20240430082601-9300922bef83/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240506084300-6d0267e74122 h1:vqc20q4RvQ3ommNWGRN1h+61phXEllZdSwQIyrz8Mzg=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240506084300-6d0267e74122/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240506090538-9d6beda359cb h1:XZr1IuVNq6q9/KaoN/RiYHuy66BtJJ8cbOpeH8YXV2E=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240506090538-9d6beda359cb/go.mod h1:x47UOU+lOkZnrtAENAsOGd7mZ5I8D2JRkMKMqLLRlVw=
 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=

+ 18 - 0
http/handler/config/config.go

@@ -2,6 +2,9 @@ package config
 
 import (
 	"kpt-pasture/http/middleware"
+	"strconv"
+
+	"gitee.com/xuyiping_admin/pkg/valid"
 
 	"gitee.com/xuyiping_admin/pkg/apierr"
 	"gitee.com/xuyiping_admin/pkg/ginutil"
@@ -79,3 +82,18 @@ func CowTransferPenReasonOptions(c *gin.Context) {
 	}
 	ginutil.JSONResp(c, res)
 }
+
+func SystemUserOptions(c *gin.Context) {
+	depIdStr := c.Param("dep_id")
+	depId, _ := strconv.Atoi(depIdStr)
+	if err := valid.Validate(depId, valid.Required, valid.Min(-1)); err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+	res, err := middleware.Dependency(c).StoreEventHub.OpsService.SystemUserOptions(c, depId)
+	if err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+	ginutil.JSONResp(c, res)
+}

+ 1 - 1
http/handler/event/event.go

@@ -14,7 +14,7 @@ import (
 )
 
 func EnterEventList(c *gin.Context) {
-	var req pasturePb.SearchEnterEventRequest
+	var req pasturePb.SearchEventRequest
 	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return

+ 1 - 0
http/route/config_api.go

@@ -21,5 +21,6 @@ func ConfigAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		pastureRoute.GET("/cow/status/options", config.CowStatusOptions)
 		pastureRoute.GET("/cow/type/options", config.CowTypeOptions)
 		pastureRoute.GET("/cow/transfer/pen/reason/options", config.CowTransferPenReasonOptions)
+		pastureRoute.GET("/system/user/options", config.SystemUserOptions)
 	}
 }

+ 4 - 4
http/route/event_api.go

@@ -11,9 +11,9 @@ func EventAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		for _, opt := range opts {
 			opt(s)
 		}
-		// pasture API 组  牧场管理
-		pastureRoute := authRouteGroup(s, "/api/v1/event/")
-		pastureRoute.POST("/enter/list", event.EnterEventList)
-		pastureRoute.POST("/enter/create", event.EnterEventCreate)
+		// eventRoute API 组  事件管理
+		eventRoute := authRouteGroup(s, "/api/v1/event/")
+		eventRoute.POST("/enter/list", event.EnterEventList)
+		eventRoute.POST("/enter/create", event.EnterEventCreate)
 	}
 }

+ 18 - 0
model/event_transfer_group.go

@@ -0,0 +1,18 @@
+package model
+
+type EventTransferGroup struct {
+	Id               int64 `json:"id"`
+	CowId            int64 `json:"cow_id"`
+	TransferInPenId  int64 `json:"transfer_in_pen_id"`
+	TransferOutPenId int64 `json:"transfer_out_pen_id"`
+	TransferAt       int64 `json:"transfer_at"`
+	TransferReasonId int64 `json:"transfer_reason_id"`
+	StaffMemberId    int64 `json:"staff_member_id"`
+	OperationId      int64 `json:"operation_id"`
+	CreatedAt        int64 `json:"created_at"`
+	UpdatedAt        int64 `json:"updated_at"`
+}
+
+func (e *EventTransferGroup) TableName() string {
+	return "event_transfer_group"
+}

+ 12 - 0
model/system_user.go

@@ -99,3 +99,15 @@ func (s *SystemUser) ToPb() *operationPb.AddSystemUser {
 		RoleIds:         []int32{},
 	}
 }
+
+func (c SystemUserSlice) ToPB2() []*pasturePb.ConfigOptionsList {
+	res := make([]*pasturePb.ConfigOptionsList, len(c))
+	for i, d := range c {
+		res[i] = &pasturePb.ConfigOptionsList{
+			Value:    int32(d.Id),
+			Label:    d.Name,
+			Disabled: true,
+		}
+	}
+	return res
+}

+ 16 - 0
module/backend/config_data.go

@@ -110,3 +110,19 @@ func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pastureP
 		Data:    model.ConfigTransferPenReasonSlice(configTransferPenReasonList).ToPB2(),
 	}, 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())
+	if depId != -1 && depId > 0 {
+		pref = pref.Where("dep_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
+}

+ 10 - 4
module/backend/event.go

@@ -6,17 +6,19 @@ import (
 	"kpt-pasture/model"
 	"net/http"
 
-	"gorm.io/gorm"
-
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 	"gitee.com/xuyiping_admin/pkg/xerr"
+	"gorm.io/gorm"
 )
 
-func (s *StoreEntry) EnterList(ctx context.Context, req *pasturePb.SearchEnterEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchEnterEventResponse, error) {
+func (s *StoreEntry) EnterList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchEnterEventResponse, error) {
 	eventEnterList := make([]*pasturePb.SearchEnterData, 0)
 	var count int64 = 0
 	pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.EventEnter).TableName())).
-		Select("a.id,a.birth_at,a.weaning_at,a.dry_milk_at,a.cow_source_id,a.remarks,a.mating_at,a.status,a.lact,a.breed_status_id,a.mother_id,a.cow_kind_id,a.cow_id,b.name as breed_status_name,c.name as cow_source_name,d.name as cow_type_name,e.name as cow_kind_name,f.name as pen_name,g.name as operation_name").
+		Select(`a.id,a.birth_at,a.weaning_at,a.dry_milk_at,a.cow_source_id,a.remarks,a.mating_at,a.status,
+			a.lact,a.breed_status_id,a.mother_id,a.cow_kind_id,a.cow_id,a.ear_number,a.sex,a.created_at,
+			a.weight / 100 as weight,a.price / 100 as price,b.name as breed_status_name,
+			c.name as cow_source_name,d.name as cow_type_name,e.name as cow_kind_name,f.name as pen_name,g.name as operation_name`).
 		Joins(fmt.Sprintf("JOIN %s AS b ON a.breed_status_id = b.id", new(model.ConfigBreedStatus).TableName())).
 		Joins(fmt.Sprintf("JOIN %s AS c on a.cow_source_id = c.id", new(model.ConfigCowSource).TableName())).
 		Joins(fmt.Sprintf("JOIN %s AS d on a.cow_type_id = d.id", new(model.ConfigCowType).TableName())).
@@ -64,3 +66,7 @@ func (s *StoreEntry) CreateEnter(ctx context.Context, req *pasturePb.SearchEnter
 	}
 	return nil
 }
+
+func (s *StoreEntry) TransferGroup(ctx context.Context) {
+
+}

+ 2 - 2
module/backend/interface.go

@@ -8,7 +8,6 @@ import (
 
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 	"gitee.com/xuyiping_admin/pkg/di"
-
 	"go.uber.org/dig"
 )
 
@@ -116,10 +115,11 @@ type ConfigDataService interface {
 	CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
 	CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
 	CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error)
+	SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error)
 }
 
 //go:generate mockgen -destination mock/EventService.go -package kptservicemock kpt-pasture/module/backend EventService
 type EventService interface {
-	EnterList(ctx context.Context, req *pasturePb.SearchEnterEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchEnterEventResponse, error)
+	EnterList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchEnterEventResponse, error)
 	CreateEnter(ctx context.Context, req *pasturePb.SearchEnterData) error
 }