system

package
v0.0.0-...-9dab128 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mysql           = "mysql"
	Pgsql           = "pgsql"
	InitSuccess     = "\n[%v] --> 初始数据成功!\n"
	InitDataExist   = "\n[%v] --> %v 的初始数据已存在!\n"
	InitDataFailed  = "\n[%v] --> %v 初始数据失败! \nerr: %+v\n"
	InitDataSuccess = "\n[%v] --> %v 初始数据成功!\n"
)
View Source
const (
	InitOrderSystem   = 10
	InitOrderInternal = 1000
	InitOrderExternal = 100000
)

Variables

View Source
var (
	ErrMissingDBContext        = errors.New("missing db in context")
	ErrMissingDependentContext = errors.New("missing dependent value in context")
	ErrDBTypeMismatch          = errors.New("db type mismatch")
)
View Source
var ApiServiceApp = new(ApiService)
View Source
var AuthorityServiceApp = new(AuthorityService)
View Source
var AutoCodeHistoryServiceApp = new(AutoCodeHistoryService)
View Source
var AutoCodeMysql = new(autoCodeMysql)
View Source
var AutoCodePgsql = new(autoCodePgsql)
View Source
var AutoCodeServiceApp = new(AutoCodeService)
View Source
var CasbinServiceApp = new(CasbinService)
View Source
var ErrRoleExistence = errors.New("存在相同角色id")
View Source
var MenuServiceApp = new(MenuService)
View Source
var RepeatErr = errors.New("重复创建")

Functions

func ImportReference

func ImportReference(filepath, importCode, structName, packageName, groupName string) error

func Init

func Init(Package string)

func LoadAll

func LoadAll()

func RegisterInit

func RegisterInit(order int, i SubInitializer)

RegisterInit 注册要执行的初始化过程,会在 InitDB() 时调用

Types

type ApiService

type ApiService struct{}

func (*ApiService) CreateApi

func (apiService *ApiService) CreateApi(api system.SysApi) (err error)

func (*ApiService) DeleteApi

func (apiService *ApiService) DeleteApi(api system.SysApi) (err error)

func (*ApiService) DeleteApiByIds

func (apiService *ApiService) DeleteApiByIds(ids []string) (err error)

func (*ApiService) DeleteApisByIds

func (apiService *ApiService) DeleteApisByIds(ids request.IdsReq) (err error)

func (*ApiService) GetAPIInfoList

func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.PageInfo, order string, desc bool) (list interface{}, total int64, err error)

func (*ApiService) GetAllApis

func (apiService *ApiService) GetAllApis() (apis []system.SysApi, err error)

func (*ApiService) GetApiById

func (apiService *ApiService) GetApiById(id int) (api system.SysApi, err error)

func (*ApiService) UpdateApi

func (apiService *ApiService) UpdateApi(api system.SysApi) (err error)

type AuthorityBtnService

type AuthorityBtnService struct{}

func (*AuthorityBtnService) CanRemoveAuthorityBtn

func (a *AuthorityBtnService) CanRemoveAuthorityBtn(ID string) (err error)

func (*AuthorityBtnService) GetAuthorityBtn

func (*AuthorityBtnService) SetAuthorityBtn

func (a *AuthorityBtnService) SetAuthorityBtn(req request.SysAuthorityBtnReq) (err error)

type AuthorityService

type AuthorityService struct{}

func (*AuthorityService) CopyAuthority

func (authorityService *AuthorityService) CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (authority system.SysAuthority, err error)

func (*AuthorityService) CreateAuthority

func (authorityService *AuthorityService) CreateAuthority(auth system.SysAuthority) (authority system.SysAuthority, err error)

func (*AuthorityService) DeleteAuthority

func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthority) (err error)

func (*AuthorityService) GetAuthorityInfo

func (authorityService *AuthorityService) GetAuthorityInfo(auth system.SysAuthority) (sa system.SysAuthority, err error)

func (*AuthorityService) GetAuthorityInfoList

func (authorityService *AuthorityService) GetAuthorityInfoList(info request.PageInfo) (list interface{}, total int64, err error)

func (*AuthorityService) SetDataAuthority

func (authorityService *AuthorityService) SetDataAuthority(auth system.SysAuthority) error

func (*AuthorityService) SetMenuAuthority

func (authorityService *AuthorityService) SetMenuAuthority(auth *system.SysAuthority) error

func (*AuthorityService) UpdateAuthority

func (authorityService *AuthorityService) UpdateAuthority(auth system.SysAuthority) (authority system.SysAuthority, err error)

type AutoCodeHistoryService

type AutoCodeHistoryService struct{}

func (*AutoCodeHistoryService) CreateAutoCodeHistory

func (autoCodeHistoryService *AutoCodeHistoryService) CreateAutoCodeHistory(meta, structName, structCNName, autoCodePath string, injectionMeta string, tableName string, apiIds string, Package string) error

CreateAutoCodeHistory 创建代码生成器历史记录 RouterPath : RouterPath@RouterString;RouterPath2@RouterString2 Author [SliverHorn](https://github.com/SliverHorn) Author [songzhibin97](https://github.com/songzhibin97)

func (*AutoCodeHistoryService) Delete

func (autoCodeHistoryService *AutoCodeHistoryService) Delete(info *request.GetById) error

Delete 删除历史数据 Author [SliverHorn](https://github.com/SliverHorn) Author [songzhibin97](https://github.com/songzhibin97)

func (*AutoCodeHistoryService) First

func (autoCodeHistoryService *AutoCodeHistoryService) First(info *request.GetById) (string, error)

First 根据id获取代码生成器历史的数据 Author [SliverHorn](https://github.com/SliverHorn) Author [songzhibin97](https://github.com/songzhibin97)

func (*AutoCodeHistoryService) GetList

func (autoCodeHistoryService *AutoCodeHistoryService) GetList(info request.PageInfo) (list []response.AutoCodeHistory, total int64, err error)

GetList 获取系统历史数据 Author [SliverHorn](https://github.com/SliverHorn) Author [songzhibin97](https://github.com/songzhibin97)

func (*AutoCodeHistoryService) Repeat

func (autoCodeHistoryService *AutoCodeHistoryService) Repeat(structName string, Package string) bool

Repeat 检测重复 Author [SliverHorn](https://github.com/SliverHorn) Author [songzhibin97](https://github.com/songzhibin97)

func (*AutoCodeHistoryService) RollBack

func (autoCodeHistoryService *AutoCodeHistoryService) RollBack(info *systemReq.RollBack) error

RollBack 回滚 Author [SliverHorn](https://github.com/SliverHorn) Author [songzhibin97](https://github.com/songzhibin97)

type AutoCodeService

type AutoCodeService struct{}

func (*AutoCodeService) AutoCreateApi

func (autoCodeService *AutoCodeService) AutoCreateApi(a *system.AutoCodeStruct) (ids []uint, err error)

func (*AutoCodeService) CreateAutoCode

func (autoCodeService *AutoCodeService) CreateAutoCode(s *system.SysAutoCode) error

func (*AutoCodeService) CreatePackageTemp

func (autoCodeService *AutoCodeService) CreatePackageTemp(packageName string) error

func (*AutoCodeService) CreatePlug

func (autoCodeService *AutoCodeService) CreatePlug(plug system.AutoPlugReq) error

CreatePlug 自动创建插件模板

func (*AutoCodeService) CreateTemp

func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruct, ids ...uint) (err error)

func (*AutoCodeService) Database

func (autoCodeService *AutoCodeService) Database() Database

func (*AutoCodeService) DelPackage

func (autoCodeService *AutoCodeService) DelPackage(a system.SysAutoCode) error

func (*AutoCodeService) DropTable

func (autoCodeService *AutoCodeService) DropTable(tableName string) error

func (*AutoCodeService) GetAllTplFile

func (autoCodeService *AutoCodeService) GetAllTplFile(pathName string, fileList []string) ([]string, error)

func (*AutoCodeService) GetPackage

func (autoCodeService *AutoCodeService) GetPackage() (pkgList []system.SysAutoCode, err error)

func (*AutoCodeService) PreviewTemp

func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStruct) (map[string]string, error)

type BaseMenuService

type BaseMenuService struct{}

func (*BaseMenuService) DeleteBaseMenu

func (baseMenuService *BaseMenuService) DeleteBaseMenu(id int) (err error)

func (*BaseMenuService) GetBaseMenuById

func (baseMenuService *BaseMenuService) GetBaseMenuById(id int) (menu system.SysBaseMenu, err error)

func (*BaseMenuService) UpdateBaseMenu

func (baseMenuService *BaseMenuService) UpdateBaseMenu(menu system.SysBaseMenu) (err error)

type CasbinService

type CasbinService struct{}

func (*CasbinService) Casbin

func (casbinService *CasbinService) Casbin() *casbin.SyncedEnforcer

func (*CasbinService) ClearCasbin

func (casbinService *CasbinService) ClearCasbin(v int, p ...string) bool

func (*CasbinService) GetPolicyPathByAuthorityId

func (casbinService *CasbinService) GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinInfo)

func (*CasbinService) UpdateCasbin

func (casbinService *CasbinService) UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error

func (*CasbinService) UpdateCasbinApi

func (casbinService *CasbinService) UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error

type Database

type Database interface {
	GetDB() (data []response.Db, err error)
	GetTables(dbName string) (data []response.Table, err error)
	GetColumn(tableName string, dbName string) (data []response.Column, err error)
}

type DictionaryDetailService

type DictionaryDetailService struct{}

func (*DictionaryDetailService) CreateSysDictionaryDetail

func (dictionaryDetailService *DictionaryDetailService) CreateSysDictionaryDetail(sysDictionaryDetail system.SysDictionaryDetail) (err error)

func (*DictionaryDetailService) DeleteSysDictionaryDetail

func (dictionaryDetailService *DictionaryDetailService) DeleteSysDictionaryDetail(sysDictionaryDetail system.SysDictionaryDetail) (err error)

func (*DictionaryDetailService) GetSysDictionaryDetail

func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetail(id uint) (sysDictionaryDetail system.SysDictionaryDetail, err error)

func (*DictionaryDetailService) GetSysDictionaryDetailInfoList

func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (list interface{}, total int64, err error)

func (*DictionaryDetailService) UpdateSysDictionaryDetail

func (dictionaryDetailService *DictionaryDetailService) UpdateSysDictionaryDetail(sysDictionaryDetail *system.SysDictionaryDetail) (err error)

type DictionaryService

type DictionaryService struct{}

func (*DictionaryService) CreateSysDictionary

func (dictionaryService *DictionaryService) CreateSysDictionary(sysDictionary system.SysDictionary) (err error)

func (*DictionaryService) DeleteSysDictionary

func (dictionaryService *DictionaryService) DeleteSysDictionary(sysDictionary system.SysDictionary) (err error)

func (*DictionaryService) GetSysDictionary

func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uint) (sysDictionary system.SysDictionary, err error)

func (*DictionaryService) GetSysDictionaryInfoList

func (dictionaryService *DictionaryService) GetSysDictionaryInfoList(info request.SysDictionarySearch) (list interface{}, total int64, err error)

func (*DictionaryService) UpdateSysDictionary

func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *system.SysDictionary) (err error)

type InitDBService

type InitDBService struct{}

func (*InitDBService) InitDB

func (initDBService *InitDBService) InitDB(conf request.InitDB) (err error)

InitDB 创建数据库并初始化 总入口

type JwtService

type JwtService struct{}

func (*JwtService) GetRedisJWT

func (jwtService *JwtService) GetRedisJWT(userName string) (redisJWT string, err error)

func (*JwtService) IsBlacklist

func (jwtService *JwtService) IsBlacklist(jwt string) bool

func (*JwtService) JsonInBlacklist

func (jwtService *JwtService) JsonInBlacklist(jwtList system.JwtBlacklist) (err error)

func (*JwtService) SetRedisJWT

func (jwtService *JwtService) SetRedisJWT(jwt string, userName string) (err error)
type MenuService struct{}
func (menuService *MenuService) AddBaseMenu(menu system.SysBaseMenu) error
func (menuService *MenuService) AddMenuAuthority(menus []system.SysBaseMenu, authorityId string) (err error)
func (menuService *MenuService) GetBaseMenuTree() (menus []system.SysBaseMenu, err error)
func (menuService *MenuService) GetInfoList() (list interface{}, total int64, err error)
func (menuService *MenuService) GetMenuAuthority(info *request.GetAuthorityId) (menus []system.SysMenu, err error)
func (menuService *MenuService) GetMenuTree(authorityId string) (menus []system.SysMenu, err error)

type MysqlInitHandler

type MysqlInitHandler struct{}

func NewMysqlInitHandler

func NewMysqlInitHandler() *MysqlInitHandler

func (MysqlInitHandler) EnsureDB

func (h MysqlInitHandler) EnsureDB(ctx context.Context, conf *request.InitDB) (next context.Context, err error)

EnsureDB 创建数据库并初始化 mysql

func (MysqlInitHandler) InitData

func (h MysqlInitHandler) InitData(ctx context.Context, inits initSlice) error

func (MysqlInitHandler) InitTables

func (h MysqlInitHandler) InitTables(ctx context.Context, inits initSlice) error

func (MysqlInitHandler) WriteConfig

func (h MysqlInitHandler) WriteConfig(ctx context.Context) error

WriteConfig mysql回写配置

type OperationRecordService

type OperationRecordService struct{}

func (*OperationRecordService) CreateSysOperationRecord

func (operationRecordService *OperationRecordService) CreateSysOperationRecord(sysOperationRecord system.SysOperationRecord) (err error)

func (*OperationRecordService) DeleteSysOperationRecord

func (operationRecordService *OperationRecordService) DeleteSysOperationRecord(sysOperationRecord system.SysOperationRecord) (err error)

func (*OperationRecordService) DeleteSysOperationRecordByIds

func (operationRecordService *OperationRecordService) DeleteSysOperationRecordByIds(ids request.IdsReq) (err error)

func (*OperationRecordService) GetSysOperationRecord

func (operationRecordService *OperationRecordService) GetSysOperationRecord(id uint) (sysOperationRecord system.SysOperationRecord, err error)

func (*OperationRecordService) GetSysOperationRecordInfoList

func (operationRecordService *OperationRecordService) GetSysOperationRecordInfoList(info systemReq.SysOperationRecordSearch) (list interface{}, total int64, err error)

type PgsqlInitHandler

type PgsqlInitHandler struct{}

func NewPgsqlInitHandler

func NewPgsqlInitHandler() *PgsqlInitHandler

func (PgsqlInitHandler) EnsureDB

func (h PgsqlInitHandler) EnsureDB(ctx context.Context, conf *request.InitDB) (next context.Context, err error)

EnsureDB 创建数据库并初始化 pg

func (PgsqlInitHandler) InitData

func (h PgsqlInitHandler) InitData(ctx context.Context, inits initSlice) error

func (PgsqlInitHandler) InitTables

func (h PgsqlInitHandler) InitTables(ctx context.Context, inits initSlice) error

func (PgsqlInitHandler) WriteConfig

func (h PgsqlInitHandler) WriteConfig(ctx context.Context) error

WriteConfig pgsql 回写配置

type SubInitializer

type SubInitializer interface {
	InitializerName() string // 不一定代表单独一个表,所以改成了更宽泛的语义
	MigrateTable(ctx context.Context) (next context.Context, err error)
	InitializeData(ctx context.Context) (next context.Context, err error)
	TableCreated(ctx context.Context) bool
	DataInserted(ctx context.Context) bool
}

SubInitializer 提供 source/*/init() 使用的接口,每个 initializer 完成一个初始化过程

type SystemConfigService

type SystemConfigService struct{}

func (*SystemConfigService) GetServerInfo

func (systemConfigService *SystemConfigService) GetServerInfo() (server *utils.Server, err error)

func (*SystemConfigService) GetSystemConfig

func (systemConfigService *SystemConfigService) GetSystemConfig() (conf config.Server, err error)

func (*SystemConfigService) SetSystemConfig

func (systemConfigService *SystemConfigService) SetSystemConfig(system system.System) (err error)

type TypedDBInitHandler

type TypedDBInitHandler interface {
	EnsureDB(ctx context.Context, conf *request.InitDB) (context.Context, error) // 建库,失败属于 fatal error,因此让它 panic
	WriteConfig(ctx context.Context) error                                       // 回写配置
	InitTables(ctx context.Context, inits initSlice) error                       // 建表 handler
	InitData(ctx context.Context, inits initSlice) error                         // 建数据 handler
}

TypedDBInitHandler 执行传入的 initializer

type UserService

type UserService struct{}

func (*UserService) ChangePassword

func (userService *UserService) ChangePassword(u *system.SysUser, newPassword string) (userInter *system.SysUser, err error)

func (*UserService) DeleteUser

func (userService *UserService) DeleteUser(id int) (err error)

func (*UserService) FindUserById

func (userService *UserService) FindUserById(id int) (user *system.SysUser, err error)

func (*UserService) FindUserByUuid

func (userService *UserService) FindUserByUuid(uuid string) (user *system.SysUser, err error)

func (*UserService) GetUserInfo

func (userService *UserService) GetUserInfo(uuid uuid.UUID) (user system.SysUser, err error)

func (*UserService) GetUserInfoList

func (userService *UserService) GetUserInfoList(info request.PageInfo) (list interface{}, total int64, err error)

func (*UserService) Login

func (userService *UserService) Login(u *system.SysUser) (userInter *system.SysUser, err error)

func (*UserService) Register

func (userService *UserService) Register(u system.SysUser) (userInter system.SysUser, err error)

func (*UserService) ResetPassword

func (userService *UserService) ResetPassword(ID uint) (err error)

func (*UserService) SetUserAuthorities

func (userService *UserService) SetUserAuthorities(id uint, authorityIds []string) (err error)

func (*UserService) SetUserAuthority

func (userService *UserService) SetUserAuthority(id uint, uuid uuid.UUID, authorityId string) (err error)

func (*UserService) SetUserInfo

func (userService *UserService) SetUserInfo(req system.SysUser) error

type Visitor

type Visitor struct {
	ImportCode  string
	StructName  string
	PackageName string
	GroupName   string
}

func (*Visitor) Visit

func (vi *Visitor) Visit(node ast.Node) ast.Visitor

Jump to

Keyboard shortcuts

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