瀏覽代碼

event: enter update

Yi 6 月之前
父節點
當前提交
029a843240

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20240924055824-5af0e461aca7
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20240926071515-d412d36b2dbe
 	gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eko/gocache v1.1.0

+ 6 - 0
go.sum

@@ -56,6 +56,12 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20240924054441-100cb4142f8f h1:QQCL4CvP
 gitee.com/xuyiping_admin/go_proto v0.0.0-20240924054441-100cb4142f8f/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20240924055824-5af0e461aca7 h1:X3n4Y1ucCBdZ7I8+iS88LqZwNtwSyvY1mWP7ajdPClg=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20240924055824-5af0e461aca7/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240926064559-37652d09b3c4 h1:11SeQqYU2kUiQBahGplMvgHzYgMEmkSPB/NYp3TBaKQ=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240926064559-37652d09b3c4/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240926070615-66351c94c78b h1:TQmLx5oTlLbFKUHTP2XP44s5lq/P9BQH8XCT/8EZfoE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240926070615-66351c94c78b/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240926071515-d412d36b2dbe h1:KTW/BuoqG+FhFEI0/JlcVmVaY7WakAGZREks5IIvy8U=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20240926071515-d412d36b2dbe/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 - 5
http/handler/event/event_base.go

@@ -35,7 +35,7 @@ func EnterEventList(c *gin.Context) {
 }
 
 func EnterEventCreate(c *gin.Context) {
-	var req pasturePb.EventEnterData
+	var req pasturePb.EventEnterRequest
 	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
@@ -45,12 +45,13 @@ func EnterEventCreate(c *gin.Context) {
 		valid.Field(&req.EarNumber, valid.Required),
 		valid.Field(&req.BirthAt, valid.Required),
 		valid.Field(&req.Sex, valid.Required),
-		valid.Field(&req.CowTypeId, valid.Required),
-		valid.Field(&req.CowKindId, valid.Required),
-		valid.Field(&req.CowSourceId, valid.Required),
+		valid.Field(&req.CowType, valid.Required),
+		valid.Field(&req.CowKind, valid.Required),
+		valid.Field(&req.CowSource, valid.Required),
 		valid.Field(&req.Lact, valid.Required),
 		valid.Field(&req.EnterAt, valid.Required),
-		valid.Field(&req.CowSourceId, valid.Required),
+		valid.Field(&req.CowSource, valid.Required),
+		valid.Field(&req.OperationId, valid.Required),
 	); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return

+ 3 - 12
http/handler/work/calendar.go

@@ -63,28 +63,19 @@ func CalendarTableDetail(c *gin.Context) {
 	c.JSON(http.StatusOK, res)
 }
 
-func UserList(c *gin.Context) {
-	var req pasturePb.CalendarTableRequest
+func CalendarToDoList(c *gin.Context) {
+	var req pasturePb.CalendarToDoRequest
 	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
-
-	if err := valid.ValidateStruct(&req,
-		valid.Field(&req.CalendarType, valid.Required),
-		valid.Field(&req.Start, valid.Required),
-	); err != nil {
-		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
-		return
-	}
-
 	pagination := &pasturePb.PaginationModel{
 		Page:       int32(c.GetInt(middleware.Page)),
 		PageSize:   int32(c.GetInt(middleware.PageSize)),
 		PageOffset: int32(c.GetInt(middleware.PageOffset)),
 	}
 
-	res, err := middleware.Dependency(c).StoreEventHub.OpsService.CalendarTableDetail(c, &req, pagination)
+	res, err := middleware.Dependency(c).StoreEventHub.OpsService.CalendarToDoList(c, &req, pagination)
 	if err != nil {
 		apierr.ClassifiedAbort(c, err)
 		return

+ 1 - 1
http/route/work_order.go

@@ -20,7 +20,7 @@ func WorkOrderAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 
 		workRoute.POST("/calendar/list", work.CalendarList)
 		workRoute.POST("/calendar/detail", work.CalendarTableDetail)
-		workRoute.POST("/calendar/user/list", work.UserList)
+		workRoute.POST("/calendar/todo/list", work.CalendarToDoList)
 
 	}
 }

+ 6 - 7
model/cow.go

@@ -92,21 +92,20 @@ func (c CowSlice) ToPB(
 	return res
 }
 
-func NewCow(req *pasturePb.EventEnterData) *Cow {
+func NewCow(req *pasturePb.EventEnterRequest) *Cow {
 	var isPregnant = pasturePb.IsShow_No
-	if req.BreedStatusId == pasturePb.BreedStatus_Pregnant {
+	if req.BreedStatus == pasturePb.BreedStatus_Pregnant {
 		isPregnant = pasturePb.IsShow_Ok
 	}
-
 	return &Cow{
 		Sex:                 req.Sex,
 		EarNumber:           req.EarNumber,
 		PenId:               req.PenId,
 		Lact:                req.Lact,
-		CowType:             req.CowTypeId,
-		BreedStatus:         req.BreedStatusId,
-		CowKind:             req.CowKindId,
-		SourceId:            req.CowSourceId,
+		CowType:             req.CowType,
+		BreedStatus:         req.BreedStatus,
+		CowKind:             req.CowKind,
+		SourceId:            req.CowSource,
 		FatherNumber:        req.FatherNumber,
 		MotherNumber:        req.MotherNumber,
 		IsRemove:            pasturePb.IsShow_Ok,

+ 56 - 33
model/event_enter.go

@@ -9,32 +9,34 @@ import (
 
 type EventEnter struct {
 	Id               int64                      `json:"id"`
-	BatchNumber      string                     `json:"batch_number"`
-	EarNumber        string                     `json:"ear_number"`
-	CowId            int64                      `json:"cow_id"`
+	BatchNumber      string                     `json:"batchNumber"`
+	EarNumber        string                     `json:"earNumber"`
+	CowId            int64                      `json:"cowId"`
 	Sex              pasturePb.Genders_Kind     `json:"sex"`
-	BirthAt          int64                      `json:"birth_at"`
-	CowSourceId      pasturePb.CowSource_Kind   `json:"cow_source_id"`
-	OldEarNumber     string                     `json:"old_ear_number"`
-	CowType          pasturePb.CowType_Kind     `json:"cow_type"`
-	BreedStatus      pasturePb.BreedStatus_Kind `json:"breed_status"`
+	BirthAt          int64                      `json:"birthAt"`
+	CowSource        pasturePb.CowSource_Kind   `json:"cowSource"`
+	OldEarNumber     string                     `json:"oldEarNumber"`
+	CowType          pasturePb.CowType_Kind     `json:"cowType"`
+	BreedStatus      pasturePb.BreedStatus_Kind `json:"breedStatus"`
 	Lact             int32                      `json:"lact"`
-	DayAge           int32                      `json:"day_age"`
-	PenId            int32                      `json:"pen_id"`
-	CowKind          pasturePb.CowKind_Kind     `json:"cow_kind"`
+	DayAge           int32                      `json:"dayAge"`
+	PenId            int32                      `json:"penId"`
+	CowKind          pasturePb.CowKind_Kind     `json:"cowKind"`
 	FatherNumber     string                     `json:"fatherNumber"`
 	MotherNumber     string                     `json:"motherNumber"`
-	MatingAt         int64                      `json:"mating_at"`
-	PregnancyCheckAt int64                      `json:"pregnancy_check_at"`
-	DryMilkAt        int64                      `json:"dry_milk_at"`
-	WeaningAt        int64                      `json:"weaning_at"`
-	EstrusAt         int64                      `json:"estrus_at"`
-	EnterAt          int64                      `json:"enter_at"`
+	MatingAt         int64                      `json:"matingAt"`
+	PregnancyCheckAt int64                      `json:"pregnancyCheckAt"`
+	DryMilkAt        int64                      `json:"dryMilkAt"`
+	WeaningAt        int64                      `json:"weaningAt"`
+	EstrusAt         int64                      `json:"estrusAt"`
+	EnterAt          int64                      `json:"enterAt"`
 	Remarks          string                     `json:"remarks"`
 	Weight           int64                      `json:"weight"`
 	Price            int64                      `json:"price"`
-	OperationId      int64                      `json:"operation_id"`
-	StaffMemberId    int64                      `json:"staff_member_id"`
+	OperationId      int64                      `json:"operationId"`
+	OperationName    string                     `json:"operationName"`
+	MessengerId      int64                      `json:"messengerId"`
+	MessengerName    string                     `json:"messengerName"`
 	CreatedAt        int64                      `json:"created_at"`
 	UpdatedAt        int64                      `json:"updated_at"`
 }
@@ -42,19 +44,19 @@ type EventEnter struct {
 func (e *EventEnter) TableName() string {
 	return "event_enter"
 }
-func NewEventEnter(cowId, operationId int64, req *pasturePb.EventEnterData) *EventEnter {
+func NewEventEnter(cowId int64, req *pasturePb.EventEnterRequest) *EventEnter {
 	return &EventEnter{
 		EarNumber:        req.EarNumber,
 		CowId:            cowId,
 		Sex:              req.Sex,
 		BirthAt:          int64(req.BirthAt),
-		CowSourceId:      req.CowSourceId,
-		CowType:          req.CowTypeId,
-		BreedStatus:      req.BreedStatusId,
+		CowSource:        req.CowSource,
+		CowType:          req.CowType,
+		BreedStatus:      req.BreedStatus,
 		Lact:             req.Lact,
 		DayAge:           int32(math.Floor(float64(int32(time.Now().Unix())-req.BirthAt) / 86400)),
 		PenId:            req.PenId,
-		CowKind:          req.CowKindId,
+		CowKind:          req.CowKind,
 		FatherNumber:     req.FatherNumber,
 		MotherNumber:     req.MotherNumber,
 		MatingAt:         int64(req.MatingAt),
@@ -66,28 +68,45 @@ func NewEventEnter(cowId, operationId int64, req *pasturePb.EventEnterData) *Eve
 		Remarks:          req.Remarks,
 		Weight:           int64(req.Weight * 100),
 		Price:            int64(req.Price * 100),
-		StaffMemberId:    int64(req.StaffMemberId),
-		OperationId:      operationId,
+		MessengerId:      int64(req.MessengerId),
+		MessengerName:    req.MessengerName,
+		OperationId:      int64(req.OperationId),
+		OperationName:    req.OperationName,
 	}
 }
 
 type EventEnterSlice []*EventEnter
 
-func (e EventEnterSlice) ToPB() []*pasturePb.EventEnterData {
-	res := make([]*pasturePb.EventEnterData, len(e))
+func (e EventEnterSlice) ToPB(
+	penMap map[int32]*Pen,
+	breedStatusMap map[pasturePb.BreedStatus_Kind]string,
+	cowSourceMap map[pasturePb.CowSource_Kind]string,
+	cowTypeMap map[pasturePb.CowType_Kind]string,
+	cowKindMap map[pasturePb.CowKind_Kind]string,
+) []*pasturePb.EventEnterRequest {
+	res := make([]*pasturePb.EventEnterRequest, len(e))
 	for i, d := range e {
-		res[i] = &pasturePb.EventEnterData{
+		penName := ""
+		if pen, ok := penMap[d.PenId]; ok {
+			penName = pen.Name
+		}
+		res[i] = &pasturePb.EventEnterRequest{
 			Id:               int32(d.Id),
 			EarNumber:        d.EarNumber,
 			CowId:            int32(d.CowId),
 			Sex:              d.Sex,
 			BirthAt:          int32(d.BirthAt),
-			CowSourceId:      d.CowSourceId,
-			CowTypeId:        d.CowType,
-			BreedStatusId:    d.BreedStatus,
+			CowSource:        d.CowSource,
+			CowSourceName:    cowSourceMap[d.CowSource],
+			CowType:          d.CowType,
+			CowTypeName:      cowTypeMap[d.CowType],
+			BreedStatus:      d.BreedStatus,
+			BreedStatusName:  breedStatusMap[d.BreedStatus],
 			Lact:             d.Lact,
 			PenId:            d.PenId,
-			CowKindId:        d.CowKind,
+			PenName:          penName,
+			CowKind:          d.CowKind,
+			CowKindName:      cowKindMap[d.CowKind],
 			FatherNumber:     d.FatherNumber,
 			MotherNumber:     d.MotherNumber,
 			MatingAt:         int32(d.MatingAt),
@@ -99,6 +118,10 @@ func (e EventEnterSlice) ToPB() []*pasturePb.EventEnterData {
 			Weight:           float32(d.Weight) / 100,
 			Price:            float32(d.Price) / 100,
 			Remarks:          d.Remarks,
+			MessengerId:      int32(d.MessengerId),
+			MessengerName:    d.MessengerName,
+			OperationId:      int32(d.OperationId),
+			OperationName:    d.OperationName,
 			CreatedAt:        int32(d.CreatedAt),
 			UpdatedAt:        int32(d.UpdatedAt),
 		}

+ 20 - 2
module/backend/calendar.go

@@ -12,8 +12,26 @@ import (
 )
 
 // CalendarToDoList 获取日历待办列表
-func (s *StoreEntry) CalendarToDoList(ctx context.Context, req *pasturePb.CalendarToDoRequest) (*pasturePb.CalendarToDoResponse, error) {
-	// todo 待办列表
+func (s *StoreEntry) CalendarToDoList(ctx context.Context, req *pasturePb.CalendarToDoRequest, pagination *pasturePb.PaginationModel) (*pasturePb.CalendarToDoResponse, error) {
+	currentUser, err := s.GetCurrentSystemUser(ctx)
+	if err != nil || currentUser.Id <= 0 {
+		return nil, xerr.WithStack(err)
+	}
+
+	calendarList := make([]*model.Calendar, 0)
+	nowDayTime := time.Now().Format(model.LayoutDate2)
+	if err = s.DB.Model(&model.Calendar{}).
+		Where("show_day == ?", nowDayTime).
+		Where("is_show = ?", pasturePb.IsShow_Ok).
+		Find(&calendarList).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	for _, v := range calendarList {
+		// todo 待办列表
+		fmt.Println(v)
+	}
+
 	return &pasturePb.CalendarToDoResponse{
 		Code:    http.StatusOK,
 		Message: "ok",

+ 8 - 0
module/backend/enum_map.go

@@ -82,6 +82,14 @@ func (s *StoreEntry) CowKindMap() map[pasturePb.CowKind_Kind]string {
 	return res
 }
 
+func (s *StoreEntry) CowSourceMap() map[pasturePb.CowSource_Kind]string {
+	res := make(map[pasturePb.CowSource_Kind]string)
+	for _, v := range s.CowSourceEnumList() {
+		res[pasturePb.CowSource_Kind(v.Value)] = v.Label
+	}
+	return res
+}
+
 func (s *StoreEntry) WorkOrderCategoryMap() map[pasturePb.WorkOrderCategory_Kind]string {
 	res := make(map[pasturePb.WorkOrderCategory_Kind]string)
 	for _, v := range s.WorkOrderCategoryEnumList() {

+ 28 - 23
module/backend/event_base.go

@@ -40,37 +40,32 @@ func (s *StoreEntry) ParseCowIds(ctx context.Context, cowId string) ([]*model.Co
 }
 
 func (s *StoreEntry) EnterList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchEnterEventResponse, error) {
-	eventEnterList := make([]*pasturePb.EventEnterData, 0)
+	eventEnterList := make([]*model.EventEnter, 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.lact,
-		a.breed_status,a.mother_number as ,a.cow_kind,a.cow_id,a.ear_number,a.sex,a.created_at,a.updated_at,a.enter_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,h.name as staff_member_name`).
-		Joins(fmt.Sprintf("JOIN %s AS b ON a.breed_status = 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 = d.id", new(model.ConfigCowType).TableName())).
-		Joins(fmt.Sprintf("JOIN %s AS e ON a.cow_kind = e.id", new(model.ConfigCowKind).TableName())).
-		Joins(fmt.Sprintf("JOIN %s AS f on a.pen_id = f.id", new(model.Pen).TableName())).
-		Joins(fmt.Sprintf("JOIN %s AS g on a.operation_id = g.id", new(model.SystemUser).TableName())).
-		Joins(fmt.Sprintf("JOIN %s AS h on a.staff_member_id = h.id", new(model.SystemUser).TableName()))
+	pref := s.DB.Model(new(model.EventEnter))
 	if len(req.CowId) > 0 {
 		cowIds := strings.Split(req.CowId, ",")
-		pref.Where("a.cow_id IN ?", cowIds)
+		pref.Where("cow_id IN ?", cowIds)
 	}
 
-	if err := pref.Order("a.id desc").
+	if err := pref.Order("id desc").
 		Count(&count).Limit(int(pagination.PageSize)).
 		Offset(int(pagination.PageOffset)).
 		Find(&eventEnterList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}
 
+	penMap := s.PenMap(ctx)
+	breedStatusMap := s.CowBreedStatusMap()
+	cowSourceMap := s.CowSourceMap()
+	cowTypeMap := s.CowTypeMap()
+	cowKindMap := s.CowKindMap()
+
 	return &pasturePb.SearchEnterEventResponse{
 		Code:    http.StatusOK,
 		Message: "ok",
 		Data: &pasturePb.SearchEnterEventData{
-			List:     eventEnterList,
+			List:     model.EventEnterSlice(eventEnterList).ToPB(penMap, breedStatusMap, cowSourceMap, cowTypeMap, cowKindMap),
 			Total:    int32(count),
 			PageSize: pagination.PageSize,
 			Page:     pagination.Page,
@@ -78,15 +73,25 @@ func (s *StoreEntry) EnterList(ctx context.Context, req *pasturePb.SearchEventRe
 	}, nil
 }
 
-func (s *StoreEntry) CreateEnter(ctx context.Context, req *pasturePb.EventEnterData) error {
-	if err := s.DB.Transaction(func(tx *gorm.DB) error {
-		newCowData := model.NewCow(req)
-		if err := tx.Create(newCowData).Error; err != nil {
+func (s *StoreEntry) CreateEnter(ctx context.Context, req *pasturePb.EventEnterRequest) error {
+	newCowData := model.NewCow(req)
+	currentUser, err := s.GetCurrentSystemUser(ctx)
+	if err != nil {
+		return xerr.Customf("当前用户信息错误")
+	}
+
+	req.MessengerName = currentUser.Name
+	if req.MessengerId > 0 {
+		systemUser, _ := s.GetSystemUserById(ctx, int64(req.MessengerId))
+		req.OperationName = systemUser.Name
+	}
+
+	newEventEnter := model.NewEventEnter(newCowData.Id, req)
+	if err = s.DB.Transaction(func(tx *gorm.DB) error {
+		if err = tx.Create(newCowData).Error; err != nil {
 			return xerr.WithStack(err)
 		}
-
-		operationUser, _ := s.GetCurrentSystemUser(ctx)
-		if err := tx.Create(model.NewEventEnter(newCowData.Id, operationUser.Id, req)).Error; err != nil {
+		if err = tx.Create(newEventEnter).Error; err != nil {
 			return xerr.WithStack(err)
 		}
 		return nil

+ 2 - 2
module/backend/interface.go

@@ -148,7 +148,7 @@ type ConfigDataService interface {
 type EventService interface {
 	// EnterList 入场列表
 	EnterList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchEnterEventResponse, error)
-	CreateEnter(ctx context.Context, req *pasturePb.EventEnterData) error
+	CreateEnter(ctx context.Context, req *pasturePb.EventEnterRequest) error
 	// GroupTransferList 转群
 	GroupTransferList(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchTransferGroupEventResponse, error)
 	CreateGroupTransfer(ctx context.Context, req *pasturePb.TransferGroupEventRequest) error
@@ -216,7 +216,7 @@ type WorkService interface {
 	OrderIsShow(ctx context.Context, id int64) error
 	UserWorkOrderList(ctx context.Context, workOrderStatus pasturePb.WorkOrderStatus_Kind, pagination *pasturePb.PaginationModel) (*pasturePb.UserWorkOrderResponse, error)
 
-	CalendarToDoList(ctx context.Context, req *pasturePb.CalendarToDoRequest) (*pasturePb.CalendarToDoResponse, error)
+	CalendarToDoList(ctx context.Context, req *pasturePb.CalendarToDoRequest, pagination *pasturePb.PaginationModel) (*pasturePb.CalendarToDoResponse, error)
 	CalendarList(ctx context.Context, req *pasturePb.CalendarRequest) (*pasturePb.CalendarResponse, error)
 	CalendarTableDetail(ctx context.Context, req *pasturePb.CalendarTableRequest, pagination *pasturePb.PaginationModel) (interface{}, error)
 }

+ 20 - 0
module/backend/sql.go

@@ -5,6 +5,8 @@ import (
 	"errors"
 	"kpt-pasture/model"
 
+	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
+
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 	"gitee.com/xuyiping_admin/pkg/xerr"
 	"gorm.io/gorm"
@@ -206,3 +208,21 @@ func (s *StoreEntry) GetSameTimeById(ctx context.Context, id int64) (*model.Same
 	}
 	return sameTime, nil
 }
+
+func (s *StoreEntry) SearchSystemDeptListByIds(ctx context.Context, ids []int64) ([]*model.SystemDept, error) {
+	systemDeptList := make([]*model.SystemDept, 0)
+	if err := s.DB.Model(new(model.SystemDept)).
+		Where("is_show = ?", operationPb.IsShow_OK).
+		Find(&systemDeptList, ids).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return systemDeptList, nil
+}
+
+func (s *StoreEntry) GetSystemDeptListById(ctx context.Context, id int64) (*model.SystemDept, error) {
+	systemDept := &model.SystemDept{Id: id}
+	if err := s.DB.Model(new(model.SystemDept)).First(systemDept).Error; err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return systemDept, nil
+}

+ 0 - 9
module/backend/system_service.go

@@ -653,12 +653,3 @@ func (s *StoreEntry) SystemDeptCreateOrUpdate(ctx context.Context, req *pastureP
 }
 
 // SearchSystemDeptListByIds 根据id查询部门列表
-func (s *StoreEntry) SearchSystemDeptListByIds(ctx context.Context, ids []int64) ([]*model.SystemDept, error) {
-	systemDeptList := make([]*model.SystemDept, 0)
-	if err := s.DB.Model(new(model.SystemDept)).
-		Where("is_show = ?", operationPb.IsShow_OK).
-		Find(&systemDeptList, ids).Error; err != nil {
-		return nil, xerr.WithStack(err)
-	}
-	return systemDeptList, nil
-}