128 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			128 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package v1
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"management/internal/erpserver/model/dto"
 | |
| 	"management/internal/erpserver/model/form"
 | |
| 	"management/internal/erpserver/model/system"
 | |
| 	"management/internal/erpserver/model/view"
 | |
| 	"management/internal/pkg/cache"
 | |
| 	"management/internal/pkg/session"
 | |
| 
 | |
| 	"github.com/drhin/logger"
 | |
| )
 | |
| 
 | |
| type Service struct {
 | |
| 	Log     *logger.Logger
 | |
| 	Session session.Manager
 | |
| 	Redis   cache.Cache
 | |
| }
 | |
| 
 | |
| func NewService(
 | |
| 	log *logger.Logger,
 | |
| 	session session.Manager,
 | |
| 	redis cache.Cache,
 | |
| ) *Service {
 | |
| 	return &Service{
 | |
| 		Log:     log,
 | |
| 		Session: session,
 | |
| 		Redis:   redis,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| type CaptchaService interface {
 | |
| 	Generate(height int, width int, length int, maxSkew float64, dotCount int) (id, b64s, answer string, err error)
 | |
| 	Verify(id, answer string, clear bool) bool
 | |
| }
 | |
| 
 | |
| type ConfigService interface {
 | |
| 	Create(ctx context.Context, obj *system.Config) error
 | |
| 	Update(ctx context.Context, obj *system.Config) error
 | |
| 	Get(ctx context.Context, id int32) (*system.Config, error)
 | |
| 	List(ctx context.Context, q dto.SearchDto) ([]*system.Config, int64, error)
 | |
| 	Pear(ctx context.Context) (*dto.PearConfig, error)
 | |
| 
 | |
| 	RefreshCache(ctx context.Context, key string) error
 | |
| 	ResetPear(ctx context.Context) error
 | |
| }
 | |
| 
 | |
| type UserService interface {
 | |
| 	Create(ctx context.Context, req *form.User) error
 | |
| 	Update(ctx context.Context, req *form.User) error
 | |
| 	All(ctx context.Context) ([]*system.User, error)
 | |
| 	List(ctx context.Context, q dto.SearchDto) ([]*system.User, int64, error)
 | |
| 	Get(ctx context.Context, id int32) (*system.User, error)
 | |
| 
 | |
| 	XmSelect(ctx context.Context) ([]*view.XmSelect, error)
 | |
| 	Login(ctx context.Context, req *form.Login) error
 | |
| }
 | |
| 
 | |
| type LoginLogService interface {
 | |
| 	Create(ctx context.Context, req *system.LoginLog) error
 | |
| 	List(ctx context.Context, q dto.SearchDto) ([]*system.LoginLog, int64, error)
 | |
| 
 | |
| 	LoginTime(ctx context.Context, email string) (dto.LoginTimeDto, error)
 | |
| 	LoginCount(ctx context.Context, email string) int64
 | |
| }
 | |
| 
 | |
| type AuditLogService interface {
 | |
| 	Create(ctx context.Context, req *system.AuditLog) error
 | |
| 	BatchCreate(ctx context.Context, objs []*system.AuditLog) error
 | |
| 	List(ctx context.Context, q dto.SearchDto) ([]*system.AuditLog, int64, error)
 | |
| }
 | |
| 
 | |
| type RoleService interface {
 | |
| 	Create(ctx context.Context, req *form.Role) error
 | |
| 	Update(ctx context.Context, req *form.Role) error
 | |
| 	Get(ctx context.Context, id int32) (*system.Role, error)
 | |
| 	All(ctx context.Context) ([]*system.Role, error)
 | |
| 	List(ctx context.Context, q dto.SearchDto) ([]*system.Role, int64, error)
 | |
| 	RefreshCache(ctx context.Context) error
 | |
| 	RebuildParentPath(ctx context.Context) error
 | |
| 
 | |
| 	Tree(ctx context.Context, id int32) ([]*view.LayuiTree, error)
 | |
| 	XmSelectTree(ctx context.Context, id int32) ([]*view.XmSelectTree, error)
 | |
| }
 | |
| 
 | |
| type DepartmentService interface {
 | |
| 	Create(ctx context.Context, req *form.Department) error
 | |
| 	Update(ctx context.Context, req *form.Department) error
 | |
| 	Get(ctx context.Context, id int32) (*system.Department, error)
 | |
| 	All(ctx context.Context) ([]*system.Department, error)
 | |
| 	List(ctx context.Context, q dto.SearchDto) ([]*system.Department, int64, error)
 | |
| 	RefreshCache(ctx context.Context) error
 | |
| 	RebuildParentPath(ctx context.Context) error
 | |
| 
 | |
| 	Tree(ctx context.Context, id int32) ([]*view.LayuiTree, error)
 | |
| 	XmSelectTree(ctx context.Context, id int32) ([]*view.XmSelectTree, error)
 | |
| }
 | |
| 
 | |
| type MenuService interface {
 | |
| 	Create(ctx context.Context, req *system.Menu) error
 | |
| 	Update(ctx context.Context, req *system.Menu) error
 | |
| 	Get(ctx context.Context, id int32) (*system.Menu, error)
 | |
| 	GetByUrl(ctx context.Context, url string) (*system.Menu, error)
 | |
| 	All(ctx context.Context) ([]*system.Menu, error)
 | |
| 	ListMenuTree(ctx context.Context) ([]*view.MenuTree, error)
 | |
| 	ListByRoleID(ctx context.Context, roleID int32) ([]*dto.OwnerMenuDto, error)
 | |
| 	SetListByRoleID(ctx context.Context, roleID int32) ([]*dto.OwnerMenuDto, error)
 | |
| 	ListByRoleIDToMap(ctx context.Context, roleID int32) (map[string]*dto.OwnerMenuDto, error)
 | |
| 	SetListByRoleIDToMap(ctx context.Context, roleID int32) (map[string]*dto.OwnerMenuDto, error)
 | |
| 	OwerMenus(ctx context.Context, roleID int32) ([]*dto.MenuUIDto, error)
 | |
| 	SetOwerMenus(ctx context.Context, roleID int32) ([]*dto.MenuUIDto, error)
 | |
| 	MenuViewData(ctx context.Context, roleID int32) ([]*dto.SetMenuDto, error)
 | |
| 	SetRoleMenu(ctx context.Context, roleID int32, rms []*system.RoleMenu) error
 | |
| 	RefreshCache(ctx context.Context) error
 | |
| 	RebuildParentPath(ctx context.Context) error
 | |
| 
 | |
| 	Tree(ctx context.Context, id int32) ([]*view.LayuiTree, error)
 | |
| 	XmSelectTree(ctx context.Context, id int32) ([]*view.XmSelectTree, error)
 | |
| }
 | |
| 
 | |
| type RoleMenuService interface {
 | |
| 	Create(ctx context.Context, req []*system.RoleMenu) error
 | |
| 	DeleteByRoleID(ctx context.Context, roleID int32) error
 | |
| 	ListByRoleID(ctx context.Context, roleID int32) ([]*system.RoleMenu, error)
 | |
| }
 |