service

package
v0.0.0-...-c8500e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachmentDAO

type AttachmentDAO interface {
	Create(ctx context.Context, records []*models.Attachment) error
}

type AttachmentInfo

type AttachmentInfo struct {
	// contains filtered or unexported fields
}

type AttachmentService

type AttachmentService struct {
	*BasicService
	// contains filtered or unexported fields
}

func NewAttachmentService

func NewAttachmentService(basic *BasicService, dao AttachmentDAO) *AttachmentService

func (*AttachmentService) SaveFile

func (*AttachmentService) SaveFiles

type BasicService

type BasicService struct {
	// contains filtered or unexported fields
}

func NewBasicService

func NewBasicService(
	logger *logger.Logger,
	db *gorm.DB,
	locksmith *utils.RedisLocksmith,
	conf *conf.Config,
	emailClient *initialize.EmailClient,
) *BasicService

func (*BasicService) Transaction

func (s *BasicService) Transaction(ctx context.Context, join bool, fn database.Action, options ...*sql.TxOptions) error

Transaction 开启事务,join为true则加入上下文中的事务,如果上下文中没有事务则开启新事务,join为false时直接开启新事务

type CaptchaService

type CaptchaService struct {
	// contains filtered or unexported fields
}

func NewCaptchaService

func NewCaptchaService(store base64Captcha.Store) *CaptchaService

func (*CaptchaService) Generate

func (*CaptchaService) Verify

func (c *CaptchaService) Verify(t constant.CaptchaType, id, answer string) bool

type DepartmentCache

type DepartmentCache interface {
	CacheDepartment(ctx context.Context, key constant.CacheKey, depts []*models.Department) error
	GetDepartmentCache(ctx context.Context, key constant.CacheKey) ([]*models.Department, error)
	RemoveDepartmentCache(ctx context.Context, keys ...constant.CacheKey) error
}

type DepartmentDAO

type DepartmentDAO interface {
	Create(ctx context.Context, dept *models.Department) error
	GetByName(ctx context.Context, name string) (*models.Department, error)
	GetById(ctx context.Context, id uint) (*models.Department, error)
	GetAll(ctx context.Context) ([]*models.Department, error)
	GetAllUserDepartment(ctx context.Context) ([]*models.UserDepartment, error)
	GetAllDepartmentLeader(ctx context.Context) ([]*models.DepartmentLeader, error)
}

type DepartmentService

type DepartmentService struct {
	*BasicService
	// contains filtered or unexported fields
}

func NewDepartmentService

func NewDepartmentService(
	basic *BasicService,
	deptDAO DepartmentDAO,
	deptCache DepartmentCache,
	userDAO UserDAO,
) *DepartmentService

func (*DepartmentService) Clean

func (p *DepartmentService) Clean(ctx context.Context) error

func (*DepartmentService) CreateDepartment

func (p *DepartmentService) CreateDepartment(ctx context.Context, operator uint, params *request.CreateDepartmentRequest) error

func (*DepartmentService) GetDepartmentTree

func (p *DepartmentService) GetDepartmentTree(ctx context.Context, withCrew bool) ([]*response.DepartmentTreeResponse, error)

func (*DepartmentService) Key

func (p *DepartmentService) Key() string

func (*DepartmentService) Refresh

func (p *DepartmentService) Refresh(ctx context.Context) error

type PermissionDAO

type PermissionDAO interface {
	Create(ctx context.Context, permission *models.Permission) error
	GetByIds(ctx context.Context, ids []uint, preload ...string) ([]*models.Permission, error)
	GetById(ctx context.Context, id uint, preload ...string) (*models.Permission, error)
	GetList(ctx context.Context, keyword string, limit, offset int) ([]*models.Permission, int64, error)
	DeleteById(ctx context.Context, id, updater uint) error
	GetRolesCount(ctx context.Context, id uint) int64
	Update(ctx context.Context, permission *models.Permission) error
	AssociateRoles(ctx context.Context, id uint, roles []*models.Role) error
	GetByNameOrResource(ctx context.Context, name, resource string) ([]*models.Permission, error)
}

type PermissionService

type PermissionService struct {
	*BasicService
	// contains filtered or unexported fields
}

func NewPermissionService

func NewPermissionService(basic *BasicService, permissionDAO PermissionDAO, roleDAO RoleDAO) *PermissionService

func (*PermissionService) Clean

func (*PermissionService) CreatePermission

func (p *PermissionService) CreatePermission(ctx context.Context, operator uint, params *request.CreatePermissionRequest) error

func (*PermissionService) DeletePermission

func (p *PermissionService) DeletePermission(ctx context.Context, id, operator uint) error

func (*PermissionService) GetPermissionDetail

func (p *PermissionService) GetPermissionDetail(ctx context.Context, id uint) (*response.PermissionDetailResponse, error)

func (*PermissionService) GetPermissionList

func (p *PermissionService) GetPermissionList(ctx context.Context, keyword string, limit, offset int) ([]*response.PermissionListRowResponse, int64, error)

func (*PermissionService) Key

func (p *PermissionService) Key() string

func (*PermissionService) Refresh

func (p *PermissionService) Refresh(context.Context) error

func (*PermissionService) UpdatePermission

func (p *PermissionService) UpdatePermission(ctx context.Context, operator uint, params *request.UpdatePermissionRequest) error

type PingService

type PingService struct {
	*BasicService
}

func NewPingService

func NewPingService(basic *BasicService) *PingService

func (*PingService) LockPermissionField

func (p *PingService) LockPermissionField(ctx context.Context) error

type RoleDAO

type RoleDAO interface {
	Create(ctx context.Context, role *models.Role) error
	GetByIds(ctx context.Context, ids []uint, preload ...string) ([]*models.Role, error)
	GetList(ctx context.Context, keyword string, limit, offset int) ([]*models.Role, int64, error)
	GetByName(ctx context.Context, name string) (*models.Role, error)
	GetById(ctx context.Context, id uint, preload ...string) (*models.Role, error)
	Update(ctx context.Context, role *models.Role) error
	AssociateUsers(ctx context.Context, id uint, users []*models.User) error
	AssociatePermissions(ctx context.Context, id uint, permissions []*models.Permission) error
	DeleteById(ctx context.Context, id, updater uint) error
	GetUsersCount(ctx context.Context, id uint) int64
	GetPermissionsCount(ctx context.Context, id uint) int64
}

type RoleService

type RoleService struct {
	*BasicService
	// contains filtered or unexported fields
}

func NewRoleService

func NewRoleService(basic *BasicService, roleDAO RoleDAO, userDAO UserDAO, permissionDAO PermissionDAO) *RoleService

func (*RoleService) CreateRole

func (r *RoleService) CreateRole(ctx context.Context, operator uint, params *request.CreateRoleRequest) error

func (*RoleService) DeleteRole

func (r *RoleService) DeleteRole(ctx context.Context, id, operator uint) error

func (*RoleService) GetRoleDetail

func (r *RoleService) GetRoleDetail(ctx context.Context, id uint) (*response.RoleDetailResponse, error)

func (*RoleService) GetRoleList

func (r *RoleService) GetRoleList(ctx context.Context, keyword string, limit, offset int) ([]*response.RoleListRowResponse, int64, error)

func (*RoleService) UpdateRole

func (r *RoleService) UpdateRole(ctx context.Context, operator uint, params *request.UpdateRoleRequest) error

type UserCache

type UserCache interface {
	CacheTokenPair(ctx context.Context, email string, pair *models.TokenPair) error
	GetTokenPairIsExist(ctx context.Context, email string) (bool, error)
	GetTokenPair(ctx context.Context, email string) (*models.TokenPair, error)
	CacheActiveAccountCode(ctx context.Context, id uint, code string, duration time.Duration) error
	GetActiveAccountCode(ctx context.Context, id uint) (string, error)
	RemoveActiveAccountCode(ctx context.Context, id uint) error
}

type UserDAO

type UserDAO interface {
	Create(ctx context.Context, user *models.User) error
	GetByEmail(ctx context.Context, email string, preload ...string) (*models.User, error)
	GetById(ctx context.Context, uid uint, preload ...string) (*models.User, error)
	GetByIds(ctx context.Context, ids []uint, preload ...string) ([]*models.User, error)
	GetList(ctx context.Context, keyword string, limit, offset int) ([]*models.User, int64, error)
	GetAll(ctx context.Context) ([]*models.User, error)
	UpdateAccountStatus(ctx context.Context, id uint, status constant.UserStatus) error
}

type UserEmailClient

type UserEmailClient interface {
	SendHTML(ctx context.Context, to string, subject constant.Subject, templatePath constant.Template, data any) error
}

type UserService

type UserService struct {
	*BasicService
	*CaptchaService
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(
	basic *BasicService,
	captchaService *CaptchaService,
	userDAO UserDAO,
	userCache UserCache,
	ec *initialize.EmailClient,
	tb *jwt.TokenBuilder,
) *UserService

func (*UserService) ActiveAccount

func (u *UserService) ActiveAccount(ctx context.Context, uid uint, activeCode string) error

func (*UserService) GetUserList

func (u *UserService) GetUserList(
	ctx context.Context, keyword string, limit, offset int,
) ([]*response.UserListRowResponse, int64, error)

func (*UserService) Login

func (u *UserService) Login(ctx context.Context, email string, password string) (*response.LoginResponse, error)

func (*UserService) Profile

func (u *UserService) Profile(ctx context.Context, uid uint) (*response.ProfileResponse, error)

func (*UserService) SignUp

func (u *UserService) SignUp(ctx context.Context, id string, code string, user *models.User) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL