gosinex

package
v0.0.0-...-7c465ed Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GSX_USERID = "gsx-userid"
	GSX_DEPTS  = "gsx-depts"
	GSX_ROLES  = "gsx-roles"
)

ctx常量

View Source
const Login_Audience = "login"

登录审批者

Variables

This section is empty.

Functions

func Auth

func Auth(ctx context.Context, req *protocol.Message, token string) error

gosinex的接口鉴权

func GetCtxUserDepts

func GetCtxUserDepts(ctx context.Context) []string

获取用户部门

func GetCtxUserId

func GetCtxUserId(ctx context.Context) string

获取用户id

func GetCtxUserRoles

func GetCtxUserRoles(ctx context.Context) []string

获取用户角色

Types

type AppConfig

type AppConfig struct {
	Host               string             `mapstructure:"host"`
	Port               int                `mapstructure:"port"`
	Secret             SecretConfig       `mapstructure:"secret"`
	Rpc                bgateway.RpcConfig `mapstructure:"rpc"`
	Auth               AuthConfig         `mapstructure:"auth"`
	Log                logx.LogConfig     `mapstructure:"log"`
	SwitchStrategyFunc dbx.StrategyFunc
	Datasource         []dbx.DatasourceConfig `mapstructure:"datasource"`
	Cache              cachex.CacheConfig     `mapstructure:"cache"`
}

基本配置

type AuthConfig

type AuthConfig struct {
	IgnoreList []string  `mapstructure:"ignore-list"`
	Jwt        JwtConfig `mapstructure:"jwt"`
	AuthFunc   func(ctx context.Context, req *protocol.Message, token string) error
}

type BaseEntity

type BaseEntity struct {
	zorm.EntityStruct

	Id        int       `column:"id" json:"-" name:"主键"`
	Version   int       `column:"version" name:"乐观锁" json:"-"`
	UserPerms string    `column:"user_perms" name:"用户权限" json:"-"`
	DeptPerms string    `column:"dept_perms" name:"部门权限" json:"-"`
	CreatedAt time.Time `column:"created_at" name:"创建时间" json:"createdAt"`
	UpdatedAt time.Time `column:"updated_at" name:"更新时间" json:"updatedAt"`
}

func (*BaseEntity) GetVersion

func (entity *BaseEntity) GetVersion() int

func (*BaseEntity) SetCreatedAt

func (entity *BaseEntity) SetCreatedAt(createdAt time.Time)

func (*BaseEntity) SetUpdatedAt

func (entity *BaseEntity) SetUpdatedAt(updatedAt time.Time)

func (*BaseEntity) SetVersion

func (entity *BaseEntity) SetVersion(version int)

type BasePageArg

type BasePageArg struct {
	PageSize int `json:"page_size" name:"每页条数"`
	PageNum  int `json:"page_num" name:"当前页"`
}

type BasePageReply

type BasePageReply struct {
	Total int `json:"total" name:"总记录条数"`
}

type BaseService

type BaseService struct{}

func (*BaseService) BatchDeleteByPks

func (svc *BaseService) BatchDeleteByPks(ctx context.Context, tableName, pkName string, pkValues []string, cfg IdHashConfig) (int, error)

根据主键批量删除

func (*BaseService) DeleteByFreeField

func (svc *BaseService) DeleteByFreeField(ctx context.Context, tableName, columnName string, value any) (int, error)

根据任意字段删除

func (*BaseService) GetPage

func (svc *BaseService) GetPage(arg BasePageArg) *zorm.Page

获取分页设置

type EmptyArg

type EmptyArg struct{}

空参数

type EmptyReply

type EmptyReply struct{}

空返回值

type GoSineX

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

定义GoSine+

func NewGoSineX

func NewGoSineX(appConfig AppConfig) *GoSineX

初始化一个空的GoSinePlus对象指针

func (*GoSineX) RegisterService

func (gsp *GoSineX) RegisterService(services ...RpcService)

注册service

func (*GoSineX) Run

func (gsp *GoSineX) Run()

运行服务

type IdArg

type IdArg struct {
	Id string `json:"id" name:"主键" validate:"required"`
}

通用id参数

func (*IdArg) GetIntValue

func (arg *IdArg) GetIntValue(cfg IdHashConfig) int

type IdHashConfig

type IdHashConfig struct {
	Alphabet  string `mapstructure:"alphabet"`
	Salt      string `mapstructure:"salt"`
	MinLength int    `mapstructure:"min-length"`
}

type JwtConfig

type JwtConfig struct {
	Issuer       string `mapstructure:"issuer"`
	Secret       string `mapstructure:"secret"`
	LoginExpired int    `mapstructure:"login-expired"`
}

jwt配置

type LoginUser

type LoginUser struct {
	Token string
	Depts []string
	Roles []string
}

存入缓存的对象

type Md5MixConfig

type Md5MixConfig struct {
	FirstLength int `mapstructure:"first-length"`
	LastLength  int `mapstructure:"last-length"`
}

type OptReply

type OptReply struct {
	Cnt int `json:"cnt" name:"影响记录数"`
}

通用单个实体保存返回值

type RpcService

type RpcService struct {
	Group   string
	Name    string
	Service any
}

定义注册的rpc service信息

type SaveReply

type SaveReply struct {
	Id string `json:"id"`
}

通用操作影响条数

type SecretConfig

type SecretConfig struct {
	IdHash IdHashConfig `mapstructure:"id-hash"`
	Md5Mix Md5MixConfig `mapstructure:"md5-mix"`
}

type ServerCodec

type ServerCodec struct{}

func (*ServerCodec) Decode

func (c *ServerCodec) Decode(data []byte, i interface{}) error

解码

func (*ServerCodec) Encode

func (c *ServerCodec) Encode(i interface{}) ([]byte, error)

编码

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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