chie

package
v0.0.0-...-f1d6667 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CrudDBAll

func CrudDBAll(r chi.Router, sess sqlbuilder.Database)

CrudDBAll 自动生成针对于所有表的增删查改 `GET /table` 分页结果 `GET /table/{id}“ 根据id获取结果 `POST /table` 新增记录 `PUT /table` 更新记录 `DELETE /table/{id}` 删除记录 `GET /table/all` 所有结果

func CrudDBExcept

func CrudDBExcept(r chi.Router, sess sqlbuilder.Database, except []string)

CrudDBExcept 自动生成针对于排除指定表外所有表的增删查改

func CrudDBOnly

func CrudDBOnly(r chi.Router, sess sqlbuilder.Database, only []string)

CrudDBOnly 自动生成针对于指定表的增删查改

func CrudTable

func CrudTable(r chi.Router, sess sqlbuilder.Database, table string, prefix string)

CrudTable 自动生成针对指定表的增删查改

func FileServer

func FileServer(r chi.Router, path string, root http.FileSystem)

FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.

func ServeStatic

func ServeStatic(r chi.Router, path string, dir string)

ServeStatic 当前目录下的文件

Types

type CrudController

type CrudController struct {
	GetParam  func(*http.Request, string) string
	Sess      sqlbuilder.Database
	TableName string
}

CrudController Crud操作集合

func (*CrudController) All

All 一次性获取所有数据 orderby=-id

func (*CrudController) Create

func (c *CrudController) Create(w http.ResponseWriter, r *http.Request)

Create 新增实例

func (*CrudController) Delete

func (c *CrudController) Delete(w http.ResponseWriter, r *http.Request)

Delete 通过id删除实例

func (*CrudController) JSON

func (c *CrudController) JSON(w http.ResponseWriter, data interface{})

JSON 返回json结果

func (*CrudController) One

One 根据id获取单个实例

func (*CrudController) Pagination

func (c *CrudController) Pagination(w http.ResponseWriter, r *http.Request)

Pagination 分页显示 , 默认offset=0, limit=10, where={"key": "value"}, orderby=-id

func (*CrudController) Table

func (c *CrudController) Table() db.Collection

Table 表操作

func (*CrudController) Update

func (c *CrudController) Update(w http.ResponseWriter, r *http.Request)

Update 更新实例

Jump to

Keyboard shortcuts

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