example

package
v0.0.0-...-10a0dff Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

接口文档

HTTP 接口

上传一本书

POST /api/upload_book

表单参数

参数 描述 取值
file 上传的文件 file
file_name 文件名 string
delta 偏移量 int

返回字段

参数 描述 取值
content 上传的内容 string

返回示例:

{
	"content": "A"
}
获取一本书的信息

GET /api/book

相关出版社有:

  • 机械工业出版社
  • 电子工业出版社
  • 人民邮电出版社

URL 参数

参数 描述 取值
isbn 书的 ISBN string

返回字段

参数 描述 取值
id 书籍 ID string
created_at 创建时间 string
isbn ISBN string
title 书名 string
authors 作者 object array
authors.id 作者 ID string
authors.created_at 创建时间 string
authors.name 姓名 string
authors.age 年龄 int
authors.sex 性别(0-男,1-女) int
press 出版社 string
publish_date 出版日期 string
price 定价 float

返回示例:

{
	"id": "xQ3Wmvrg",
	"created_at": "2018-11-14 11:31:35",
	"isbn": "9780262033848",
	"title": "Introduction to Algorithms, 3rd Edition",
	"authors": [
		{
			"id": "xQ3Wmvrg",
			"created_at": "2018-11-14T11:31:35.026345+08:00",
			"name": "Thomas H. Cormen",
			"age": 62,
			"sex": 0
		},
		{
			"id": "Rav4N3k2",
			"created_at": "2018-11-14T11:31:35.026345+08:00",
			"name": "Charles E. Leiserson",
			"age": 64,
			"sex": 0
		},
		{
			"id": "8rjZe3xL",
			"created_at": "2018-11-14T11:31:35.026345+08:00",
			"name": "Ronald L. Rivest",
			"age": 71,
			"sex": 0
		},
		{
			"id": "GV67K6zN",
			"created_at": "2018-11-14T11:31:35.026346+08:00",
			"name": "Clifford Stein",
			"age": 52,
			"sex": 0
		}
	],
	"press": "The MIT Press",
	"publish_date": "2009-07-31",
	"price": 94
}
更新一本书的信息

GET /api/update_book

POST 时注意作者需要存到一个数组中

JSON 参数

参数 描述 取值
id 书籍 ID string
created_at 创建时间 string
isbn ISBN string
title 书名 string
authors 作者 object array
authors.id 作者 ID string
authors.created_at 创建时间 string
authors.name 姓名 string
authors.age 年龄 int
authors.sex 性别(0-男,1-女) int
press 出版社 string
publish_date 出版日期 string
price 定价 float

返回字段

参数 描述 取值
error_code 错误码 int
error_msg 错误信息 string

返回示例:

{
	"error_code": 1000,
	"error_msg": "OK"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID        HashID    `json:"id" desc:"作者 ID"`
	CreatedAt time.Time `json:"created_at" desc:"创建时间"`

	Name string `json:"name" desc:"姓名"`
	Age  int    `json:"age" desc:"年龄"`
	Sex  int    `json:"sex" desc:"性别(0-男,1-女)"`
}

type Book

type Book struct {
	ID        HashID   `json:"id" desc:"书籍 ID"`
	CreatedAt JSONTime `json:"created_at" desc:"创建时间"`

	ISBN        string   `json:"isbn" desc:"ISBN"`
	Title       string   `json:"title" desc:"书名"`
	Authors     []Author `json:"authors" desc:"作者"`
	Press       string   `json:"press" desc:"出版社"`
	PublishDate string   `json:"publish_date" desc:"出版日期"`
	Price       float64  `json:"price" desc:"定价"`

	Ignored bool `json:"-"`
}

type HashID

type HashID uint

func (HashID) MarshalJSON

func (id HashID) MarshalJSON() ([]byte, error)

func (HashID) String

func (id HashID) String() string

type JSONTime

type JSONTime time.Time

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

func (JSONTime) String

func (t JSONTime) String() string

Jump to

Keyboard shortcuts

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