任务三
This commit is contained in:
+11
-1
@@ -7,4 +7,14 @@ import (
|
||||
)
|
||||
|
||||
// ProviderSet is biz providers.
|
||||
var ProviderSet = wire.NewSet(system.NewUserUsecase, system.NewApiUsecase)
|
||||
var ProviderSet = wire.NewSet(
|
||||
system.NewUserUsecase,
|
||||
system.NewApiUsecase,
|
||||
system.NewAuthorityUsecase,
|
||||
system.NewAuthorityBtnUsecase,
|
||||
system.NewMenuUsecase,
|
||||
system.NewDictionaryUsecase,
|
||||
system.NewJwtBlacklistUsecase,
|
||||
system.NewOperationRecordUsecase,
|
||||
system.NewParamsUsecase,
|
||||
)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"kra/internal/conf"
|
||||
)
|
||||
|
||||
// Api API实体
|
||||
@@ -71,12 +73,12 @@ type RouterInfo struct {
|
||||
}
|
||||
|
||||
// NewApiUsecase 创建API用例
|
||||
func NewApiUsecase(repo ApiRepo, casbinRepo CasbinRepo, authRepo AuthorityRepo, useStrictAuth bool) *ApiUsecase {
|
||||
func NewApiUsecase(repo ApiRepo, casbinRepo CasbinRepo, authRepo AuthorityRepo, useStrictAuth conf.UseStrictAuth) *ApiUsecase {
|
||||
return &ApiUsecase{
|
||||
repo: repo,
|
||||
casbinRepo: casbinRepo,
|
||||
authRepo: authRepo,
|
||||
useStrictAuth: useStrictAuth,
|
||||
useStrictAuth: bool(useStrictAuth),
|
||||
routers: make([]RouterInfo, 0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"kra/internal/conf"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -84,11 +86,11 @@ type AuthorityUsecase struct {
|
||||
}
|
||||
|
||||
// NewAuthorityUsecase 创建角色用例
|
||||
func NewAuthorityUsecase(repo AuthorityRepo, casbinRepo CasbinRepo, useStrictAuth bool) *AuthorityUsecase {
|
||||
func NewAuthorityUsecase(repo AuthorityRepo, casbinRepo CasbinRepo, useStrictAuth conf.UseStrictAuth) *AuthorityUsecase {
|
||||
return &AuthorityUsecase{
|
||||
repo: repo,
|
||||
casbinRepo: casbinRepo,
|
||||
useStrictAuth: useStrictAuth,
|
||||
useStrictAuth: bool(useStrictAuth),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"kra/internal/conf"
|
||||
)
|
||||
|
||||
// BaseMenu 基础菜单实体
|
||||
@@ -84,11 +86,11 @@ type MenuUsecase struct {
|
||||
}
|
||||
|
||||
// NewMenuUsecase 创建菜单用例
|
||||
func NewMenuUsecase(repo MenuRepo, authRepo AuthorityRepo, useStrictAuth bool) *MenuUsecase {
|
||||
func NewMenuUsecase(repo MenuRepo, authRepo AuthorityRepo, useStrictAuth conf.UseStrictAuth) *MenuUsecase {
|
||||
return &MenuUsecase{
|
||||
repo: repo,
|
||||
authRepo: authRepo,
|
||||
useStrictAuth: useStrictAuth,
|
||||
useStrictAuth: bool(useStrictAuth),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Params 系统参数实体
|
||||
type Params struct {
|
||||
ID uint
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Name string // 参数名
|
||||
Key string // 参数键
|
||||
Value string // 参数值
|
||||
Desc string // 参数描述
|
||||
}
|
||||
|
||||
// ParamsRepo 系统参数仓储接口
|
||||
type ParamsRepo interface {
|
||||
Create(ctx context.Context, params *Params) error
|
||||
Delete(ctx context.Context, id uint) error
|
||||
DeleteByIds(ctx context.Context, ids []uint) error
|
||||
Update(ctx context.Context, params *Params) error
|
||||
FindByID(ctx context.Context, id uint) (*Params, error)
|
||||
FindByKey(ctx context.Context, key string) (*Params, error)
|
||||
FindList(ctx context.Context, page, pageSize int, filters map[string]interface{}) ([]*Params, int64, error)
|
||||
}
|
||||
|
||||
// ParamsUsecase 系统参数用例
|
||||
type ParamsUsecase struct {
|
||||
repo ParamsRepo
|
||||
}
|
||||
|
||||
// NewParamsUsecase 创建系统参数用例
|
||||
func NewParamsUsecase(repo ParamsRepo) *ParamsUsecase {
|
||||
return &ParamsUsecase{repo: repo}
|
||||
}
|
||||
|
||||
// Create 创建参数
|
||||
func (uc *ParamsUsecase) Create(ctx context.Context, params *Params) error {
|
||||
return uc.repo.Create(ctx, params)
|
||||
}
|
||||
|
||||
// Delete 删除参数
|
||||
func (uc *ParamsUsecase) Delete(ctx context.Context, id uint) error {
|
||||
return uc.repo.Delete(ctx, id)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除参数
|
||||
func (uc *ParamsUsecase) DeleteByIds(ctx context.Context, ids []uint) error {
|
||||
return uc.repo.DeleteByIds(ctx, ids)
|
||||
}
|
||||
|
||||
// Update 更新参数
|
||||
func (uc *ParamsUsecase) Update(ctx context.Context, params *Params) error {
|
||||
return uc.repo.Update(ctx, params)
|
||||
}
|
||||
|
||||
// GetByID 根据ID获取参数
|
||||
func (uc *ParamsUsecase) GetByID(ctx context.Context, id uint) (*Params, error) {
|
||||
return uc.repo.FindByID(ctx, id)
|
||||
}
|
||||
|
||||
// GetByKey 根据Key获取参数
|
||||
func (uc *ParamsUsecase) GetByKey(ctx context.Context, key string) (*Params, error) {
|
||||
return uc.repo.FindByKey(ctx, key)
|
||||
}
|
||||
|
||||
// GetList 获取参数列表
|
||||
func (uc *ParamsUsecase) GetList(ctx context.Context, page, pageSize int, filters map[string]interface{}) ([]*Params, int64, error) {
|
||||
return uc.repo.FindList(ctx, page, pageSize, filters)
|
||||
}
|
||||
Reference in New Issue
Block a user