api

package
v0.0.1-alpha11 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const TableName = "apis"

Variables

This section is empty.

Functions

func AuthorityTypeScope

func AuthorityTypeScope(authorityType int) func(db *gorm.DB) *gorm.DB

AuthorityTypeScope 根据 name 查询 - authorityType 权限类型

func BatcheDelete

func BatcheDelete(ids []uint) error

func CreateApi

func CreateApi(ctx *gin.Context)

CreateApi 创建基础api

func CreatenInBatches

func CreatenInBatches(db *gorm.DB, apis ApiCollection) error

CreatenInBatches 批量加入

func Delete

func Delete(id uint, req DeleteApiReq) error

func DeleteApi

func DeleteApi(ctx *gin.Context)

DeleteApi 删除api

func DeleteApisByIds

func DeleteApisByIds(ctx *gin.Context)

DeleteApisByIds 删除选中Api

func GetAllApis

func GetAllApis(ctx *gin.Context)

GetAllApis 获取所有的Api不分页

func GetApiById

func GetApiById(ctx *gin.Context)

GetApiById 根据id获取api

func GetApiList

func GetApiList(ctx *gin.Context)

GetApiList 分页获取API列表

func GetApisForRole

func GetApisForRole() (map[int][][]string, error)

GetApisForRole

func GetMigration

func GetMigration() *gormigrate.Migration

func Group

func Group(group *gin.RouterGroup)

func New

func New(routes []map[string]string, authorityTypes map[string]int) *source

func UpdateApi

func UpdateApi(ctx *gin.Context)

UpdateApi 更新基础api

Types

type Api

type Api struct {
	gorm.Model
	BaseApi
}

Api 权鉴模块

func (*Api) Create

func (item *Api) Create(db *gorm.DB) (uint, error)

Create 添加

func (*Api) Delete

func (item *Api) Delete(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

Delete 删除

func (*Api) Update

func (item *Api) Update(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

Update 更新

type ApiCollection

type ApiCollection []Api

type AuthorityType

type AuthorityType struct {
	AuthorityType int `json:"authorityType" form:"authorityType"`
}

type BaseApi

type BaseApi struct {
	Path          string `json:"path" gorm:"comment:api路径" binding:"required"`
	Description   string `json:"description" gorm:"comment:api中文描述" binding:"required"`
	ApiGroup      string `json:"apiGroup" gorm:"comment:api组" binding:"required"`
	Method        string `json:"method" gorm:"default:POST;comment:方法" binding:"required"`
	AuthorityType int    `json:"authorityType" gorm:"comment:角色类型"`
}

BaseApi 权鉴基础模块

type DeleteApiReq

type DeleteApiReq struct {
	Path   string `json:"path" form:"path" binding:"required"`
	Method string `json:"method" form:"method" binding:"required"`
}

type PageResponse

type PageResponse struct {
	Item []*Response
}

Paginate 分页

func (*PageResponse) Find

func (res *PageResponse) Find(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

func (*PageResponse) Paginate

func (res *PageResponse) Paginate(db *gorm.DB, pageScope func(db *gorm.DB) *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) (int64, error)

type ReqPaginate

type ReqPaginate struct {
	orm.Paginate
	Path        string `json:"path" form:"path"`
	Description string `json:"description" form:"description"`
	ApiGroup    string `json:"apiGroup" form:"apiGroup"`
	Method      string `json:"method" form:"method"`
	OrderKey    string `json:"orderKey" form:"orderKey"`
	Desc        bool   `json:"desc" form:"desc"`
}

type Response

type Response struct {
	orm.Model
	BaseApi
}

First 详情

func (*Response) First

func (res *Response) First(db *gorm.DB, scopes ...func(db *gorm.DB) *gorm.DB) error

Jump to

Keyboard shortcuts

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