swagger

package
v0.0.0-...-f0119a6 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: GPL-2.0 Imports: 14 Imported by: 0

README

Go API Server for swagger

This is a blog about books.

Overview

This server was generated by the [swagger-codegen] (https://github.com/swagger-api/swagger-codegen) project.
By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

To see how to make this your own, look here:

README

  • API version: 0.0.7
  • Build date: 2021-01-01T15:10:01.227Z
Running the server

To run the server, follow these simple steps:

go run main.go

Documentation

Index

Constants

View Source
const (
	//SecretKey 用于加密的token密匙
	SecretKey = "The book Blog of Fentende"
)

Variables

This section is empty.

Functions

func AddBookInBookshelf

func AddBookInBookshelf(w http.ResponseWriter, r *http.Request)

AddBookInBookshelf 根据请求在数据库中创建Book数据

func CreateBookshelf

func CreateBookshelf(w http.ResponseWriter, r *http.Request)

CreateBookshelf 根据请求在数据库中创建Bookshelf数据

func DbCreateBook

func DbCreateBook(db *bolt.DB, BookName string, Autor string, Info string)

DbCreateBook 创建一个Book键值对

func DbCreateReview

func DbCreateReview(db *bolt.DB, BookID int32, Content string, Autor string)

DbCreateReview 创建一个Review键值对

func DbCreateToken

func DbCreateToken(db *bolt.DB, Username string, Token string)

DbCreateToken 创建一个Token键值对

func DbCreateUser

func DbCreateUser(db *bolt.DB, Username string, Password string)

DbCreateUser 创建一个User键值对

func DbDelBook

func DbDelBook(db *bolt.DB, BookID int32)

DbDelBook 删除一个Book

func DbDelReview

func DbDelReview(db *bolt.DB, BookID int32, ReviewID int32)

DbDelReview 删除一个Review

func DbDelToken

func DbDelToken(db *bolt.DB, Username string)

DbDelToken 删除Token键值对

func DbDelUser

func DbDelUser(db *bolt.DB, Username string)

DbDelUser 删除一个User

func DbGetToken

func DbGetToken(db *bolt.DB, Username string) []byte

DbGetToken 得到目标键值对

func DbKeyofToken

func DbKeyofToken(db *bolt.DB, Token string) []byte

DbKeyofToken 得到Token的用户名

func DeleteBookInBookshelf

func DeleteBookInBookshelf(w http.ResponseWriter, r *http.Request)

DeleteBookInBookshelf 根据请求删除数据库中对应数据

func DeleteBookshelf

func DeleteBookshelf(w http.ResponseWriter, r *http.Request)

DeleteBookshelf 根据请求删除数据库中对应数据

func GetBook

func GetBook(w http.ResponseWriter, r *http.Request)

GetBook 根据请求读取Book,并返回

func GetBooks

func GetBooks(w http.ResponseWriter, r *http.Request)

GetBooks 根据请求读取相应Book[]并返回

func GetBookshelf

func GetBookshelf(w http.ResponseWriter, r *http.Request)

GetBookshelf 根据请求在数据库中查询Bookshelf数据并返回

func GetBookshelfs

func GetBookshelfs(w http.ResponseWriter, r *http.Request)

GetBookshelfs 根据请求在数据库中查询Bookshelf数据并返回

func GetReview

func GetReview(w http.ResponseWriter, r *http.Request)

GetReview 根据请求读取review,并返回

func GetReviews

func GetReviews(w http.ResponseWriter, r *http.Request)

GetReviews 根据请求读取review[],并返回

func GetUser

func GetUser(w http.ResponseWriter, r *http.Request)

GetUser 根据请求从数据库中读取User信息,并返回

func Index

func Index(w http.ResponseWriter, r *http.Request)

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter() *mux.Router

func Options

func Options(w http.ResponseWriter, r *http.Request)

Options Options请求处理

func SignIn

func SignIn(w http.ResponseWriter, r *http.Request)

SignIn 验证请求中的账号数据并发放token

func SignOut

func SignOut(w http.ResponseWriter, r *http.Request)

SignOut 退出登录,并根据请求头中的token删除数据库中对应数据

func SignUp

func SignUp(w http.ResponseWriter, r *http.Request)

SignUp 根据请求的数据注册账号,并发放token

Types

type Book

type Book struct {
	BookId int32 `json:"bookId"`

	BookName string `json:"bookName,omitempty"`

	Autor string `json:"autor,omitempty"`

	Info string `json:"info,omitempty"`
}

func DbGetBook

func DbGetBook(db *bolt.DB, BookID int32) Book

DbGetBook 得到一个Book对象

type Books

type Books struct {
	Num int32 `json:"num"`

	Books []Book `json:"books"`
}

type Bookshelf

type Bookshelf struct {
	Num int32 `json:"num"`

	Bookshelf []BookshelfBookshelf `json:"bookshelf"`
}

type BookshelfBookshelf

type BookshelfBookshelf struct {
	BookName string `json:"bookName,omitempty"`

	BookId int32 `json:"bookId,omitempty"`
}

type BookshelfInfo

type BookshelfInfo struct {
	Name string `json:"name"`
}

type Bookshelfs

type Bookshelfs struct {
	Num int32 `json:"num"`

	Bookshelfs []BookshelfsBookshelfs `json:"bookshelfs"`
}

type BookshelfsBookshelfs

type BookshelfsBookshelfs struct {
	BookshelfName string `json:"bookshelfName,omitempty"`
}

type Review

type Review struct {
	ID int32 `json:"ID"`

	Content string `json:"Content,omitempty"`

	Autor string `json:"autor,omitempty"`
}

func DbGetReview

func DbGetReview(db *bolt.DB, BookID int32, ReviewID int32) Review

DbGetReview 得到一个Review对象

type Reviews

type Reviews struct {
	Num int32 `json:"num"`

	Reviews []Review `json:"reviews"`
}

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
	// contains filtered or unexported fields
}

type Routes

type Routes []Route

type Token

type Token struct {
	Token string `json:"Token"`
}

type User

type User struct {
	Username string `json:"Username"`

	Password string `json:"Password"`
}

func DbGetUser

func DbGetUser(db *bolt.DB, Username string) User

DbGetUser 得到一个User对象

Jump to

Keyboard shortcuts

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