| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 | 
							- package backend
 
- import (
 
- 	"bytes"
 
- 	"context"
 
- 	"io"
 
- 	"kpt-tmr-group/config"
 
- 	"kpt-tmr-group/model"
 
- 	"kpt-tmr-group/pkg/di"
 
- 	operationPb "kpt-tmr-group/proto/go/backend/operation"
 
- 	"kpt-tmr-group/service/wechat"
 
- 	"kpt-tmr-group/store/kptstore"
 
- 	"go.uber.org/dig"
 
- )
 
- var Module = di.Options(di.Provide(NewStore))
 
- type Hub struct {
 
- 	dig.In
 
- 	OpsService KptService
 
- }
 
- type StoreEntry struct {
 
- 	dig.In
 
- 	Cfg *config.AppConfig
 
- 	DB  *kptstore.DB
 
- 	// SSO *sso.Cache
 
- 	// AsynqClient asynqsvc.Client
 
- 	// Cache *redis.Client
 
- 	WxClient *wechat.ClientService
 
- }
 
- func NewStore(store StoreEntry) KptService {
 
- 	return &store
 
- }
 
- func NewStoreEntry(cfg *config.AppConfig, Db *kptstore.DB) *StoreEntry {
 
- 	return &StoreEntry{
 
- 		Cfg:      cfg,
 
- 		DB:       Db,
 
- 		WxClient: nil,
 
- 	}
 
- }
 
- //go:generate mockgen -destination mock/kptservice.go -package kptservicemock kpt-tmr-group/module/backend KptService
 
- type KptService interface {
 
- 	PastureService   // 牧场相关操作
 
- 	SystemService    // 系统相关操作
 
- 	WxAppletService  // 小程序相关
 
- 	StatisticService // 统计分析
 
- }
 
- type PastureService interface {
 
- 	// CreateGroupPasture 牧场管理相关
 
- 	CreateGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
 
- 	EditGroupPasture(ctx context.Context, req *operationPb.AddPastureRequest) error
 
- 	SearchGroupPastureList(ctx context.Context, req *operationPb.SearchPastureRequest) (*operationPb.SearchPastureResponse, error)
 
- 	DeleteGroupPasture(ctx context.Context, pastureId int64) error
 
- 	ResetPasswordGroupPasture(ctx context.Context, pastureId int64) error
 
- 	IsShowGroupPasture(ctx context.Context, req *operationPb.IsShowGroupPasture) error
 
- 	// ParentCattleCategoryList 牧畜类别
 
- 	ParentCattleCategoryList(ctx context.Context) map[operationPb.CattleCategoryParent_Kind]string
 
- 	AddCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
 
- 	EditCattleCategory(ctx context.Context, req *operationPb.AddCattleCategoryRequest) error
 
- 	IsShowCattleCategory(ctx context.Context, req *operationPb.IsShowCattleCategory) error
 
- 	DeleteCattleCategory(ctx context.Context, cattleCategoryId int64) error
 
- 	SearchCattleCategoryList(ctx context.Context, req *operationPb.SearchCattleCategoryRequest) (*operationPb.SearchCattleCategoryResponse, error)
 
- 	// ParentForageCategoryList 饲料类别相关
 
- 	ParentForageCategoryList(ctx context.Context) map[operationPb.ForageCategoryParent_Kind]string
 
- 	AddForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
 
- 	EditForageCategory(ctx context.Context, req *operationPb.AddForageCategoryRequest) error
 
- 	IsShowForageCategory(ctx context.Context, req *operationPb.IsShowForageCategory) error
 
- 	DeleteForageCategory(ctx context.Context, cattleCategoryId int64) error
 
- 	SearchForageCategoryList(ctx context.Context, req *operationPb.SearchForageCategoryRequest) (*operationPb.SearchForageCategoryResponse, error)
 
- 	// CreateForage 饲料相关
 
- 	CreateForage(ctx context.Context, req *operationPb.AddForageRequest) error
 
- 	EditForage(ctx context.Context, req *operationPb.AddForageRequest) error
 
- 	SearchForageList(ctx context.Context, req *operationPb.SearchForageListRequest) (*operationPb.SearchForageListResponse, error)
 
- 	ForageEnumList(ctx context.Context) *operationPb.ForageEnumListResponse
 
- 	DeleteForageList(ctx context.Context, ids []int64) error
 
- 	IsShowForage(ctx context.Context, req *operationPb.IsShowForage) error
 
- 	ExcelImportForage(ctx context.Context, req io.Reader) error
 
- 	ExcelExportForage(ctx context.Context, req *operationPb.SearchForageListRequest) (*bytes.Buffer, error)
 
- 	ExcelTemplateForage(ctx context.Context) (*bytes.Buffer, error)
 
- 	// CreateFeedFormula 饲料配方
 
- 	CreateFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
 
- 	EditFeedFormula(ctx context.Context, req *operationPb.AddFeedFormulaRequest) error
 
- 	SearchFeedFormulaList(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*operationPb.SearchFeedFormulaListResponse, error)
 
- 	IsShowFeedFormula(ctx context.Context, req *operationPb.IsShowModifyFeedFormula) error
 
- 	DeleteFeedFormula(ctx context.Context, feedFormulaId int64) error
 
- 	ExcelImportFeedFormula(ctx context.Context, req io.Reader) error
 
- 	ExcelExportFeedFormula(ctx context.Context, req *operationPb.SearchFeedFormulaRequest) (*bytes.Buffer, error)
 
- 	ExcelTemplateFeedFormula(ctx context.Context) (*bytes.Buffer, error)
 
- }
 
- type SystemService interface {
 
- 	// Auth 系统用户相关
 
- 	Auth(ctx context.Context, auth *operationPb.UserAuthData) (*operationPb.SystemToken, error)
 
- 	GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error)
 
- 	CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
 
- 	SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error)
 
- 	EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error
 
- 	DeleteSystemUser(ctx context.Context, userId int64) error
 
- 	ResetPasswordSystemUser(ctx context.Context, userId int64) error
 
- 	DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error)
 
- 	IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error
 
- 	GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error)
 
- 	// CreateSystemRole 系统角色相关
 
- 	CreateSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
 
- 	EditSystemRole(ctx context.Context, req *operationPb.AddRoleRequest) error
 
- 	DeleteSystemRole(ctx context.Context, roleId int64) error
 
- 	GetRolePermissions(ctx context.Context, roleId int64) (*operationPb.RolePermissionsList, error)
 
- 	SearchSystemRoleList(ctx context.Context, req *operationPb.SearchRoleRequest) (*operationPb.SearchRoleResponse, error)
 
- 	// CreateSystemMenu 系统菜单权限
 
- 	CreateSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
 
- 	EditSystemMenu(ctx context.Context, req *operationPb.AddMenuRequest) error
 
- 	IsShowSystemMenu(ctx context.Context, req *operationPb.IsShowSystemMenuRequest) error
 
- 	SearchSystemMenuList(ctx context.Context, req *operationPb.SearchMenuRequest) (*operationPb.SearchMenuResponse, error)
 
- 	DeleteSystemMenu(ctx context.Context, menuId int64) error
 
- 	// SearchMobileList 移动端
 
- 	SearchMobileList(ctx context.Context, req *operationPb.SearchMobileRequest) (*operationPb.SearchMobileResponse, error)
 
- }
 
- type StatisticService interface {
 
- 	SearchFormulaEstimateList(ctx context.Context, req *operationPb.SearchFormulaEstimateRequest) (*operationPb.SearchFormulaEstimateResponse, error)
 
- 	SearchAnalysisAccuracy(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.SearchAnalysisAccuracyResponse, error)
 
- }
 
- type WxAppletService interface {
 
- 	GetOpenId(ctx context.Context, jsCode string) (*operationPb.WxOpenId, error)
 
- }
 
 
  |