sdk

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeNotAllow int = 401
	CodeNotFound int = 404
	CodeSuccess  int = 200
)
View Source
const (
	AuthHeader = "Authorization"
	Realm      = "Bearer "
)
View Source
const (
	ApiUserRole = "/userRole"
)

Variables

View Source
var (
	InnerServerErr = errors.New("500")
	NotFoundErr    = errors.New("404")
)
View Source
var DebugEnable bool

Functions

func Debug

func Debug(enable bool)

Debug 输出sdk中的log

Types

type Client

type Client interface {
	GetUserRoleList(request UserRoleRequest) (resp ResponseOne, err error) //获取单个用户权限列表
	GetRoles(request UserRoleRequest) (resp ResponseOne, err error)        //获取单个用户权限列表
}

func New

func New(options ...Option) (m Client)

New 初始化.

内部存储了Credentials,应该确保复用,而不是每次新建

Client 内置了刷新credentials功能,不需要考虑credentials的获取问题.

type CommonPageRequest

type CommonPageRequest struct {
	PageNo   int `json:"pageNo,omitempty"`
	PageSize int `json:"pageSize,omitempty"`
}

type Option

type Option func(*messageClient)

func WithHost

func WithHost(host string) Option

type ResponseOne

type ResponseOne struct {
	Code      int         `json:"code,omitempty"`
	Success   string      `json:"success,omitempty"`
	Message   string      `json:"message,omitempty"`
	MessageId int         `json:"messageId,omitempty"`
	Data      interface{} `json:"data,omitempty"`
}

type ResponsePage

type ResponsePage struct {
	Code      int           `json:"code,omitempty"`
	Success   string        `json:"success,omitempty"`
	Message   string        `json:"message,omitempty"`
	MessageId int           `json:"messageId,omitempty"`
	Data      []interface{} `json:"items,omitempty"`
}

type RestClient

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

func NewRest

func NewRest(host string) *RestClient

func (*RestClient) Auth

func (rc *RestClient) Auth(token string) *RestClient

func (*RestClient) Form

func (rc *RestClient) Form(req map[string]string) (code int, err error)

func (*RestClient) FormUrl

func (rc *RestClient) FormUrl(req map[string]string) (code int, err error)

func (*RestClient) Get

func (rc *RestClient) Get(query map[string]string) (code int, err error)

func (*RestClient) Header

func (rc *RestClient) Header(name, value string) *RestClient

func (*RestClient) Path

func (rc *RestClient) Path(name ...string) *RestClient

func (*RestClient) Post

func (rc *RestClient) Post(payload any) (code int, err error)

func (*RestClient) ResponseJson

func (rc *RestClient) ResponseJson(respPtr any) *RestClient

type Rpc

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

func NewRpc

func NewRpc(host string) *Rpc

func (*Rpc) BuildReq

func (r *Rpc) BuildReq(handler func(*RestClient) (int, error)) *Rpc

func (*Rpc) Exec

func (r *Rpc) Exec() (err error)

type UserRoleRequest

type UserRoleRequest struct {
	UserCode string `json:"userCode,omitempty"`
	//RoleCode        string `json:"roleCode,omitempty"`
	ApplicationCode string `json:"applicationCode,omitempty"`
	ApplicationName string `json:"applicationName,omitempty"`
	Token           string `json:"token,omitempty"`
}

Jump to

Keyboard shortcuts

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