mods

package
v0.0.0-...-3bdd32b Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS = 200
	ERROR   = 500

	ERROR_MISSING_DATA = 1001
	ERROR_VERIFY_FAIL  = 1002
	ERROR_VALUE_ERROR  = 1003
	ERROR_PERMISSION   = 1004
	ERROR_USECOUNT     = 1005
	ERROR_UNKNOWN      = 1006

	ERROR_DATABASE = 2001

	ERROR_POSTBODY = 3001

	ERROR_SIMILARWORD   = 4001
	ERROR_TEMPWORDSFULL = 4002
)

Variables

View Source
var DB *gorm.DB = Connect()
View Source
var LogFile *os.File
View Source
var Loger *log.Logger
View Source
var PgLoc, _ = os.Executable()
View Source
var PgPath = filepath.Dir(PgLoc)

Functions

func AcceptTempWords

func AcceptTempWords(twords []TempWord) error

通过待审核的鸡汤

func AccountIsExist

func AccountIsExist(appid string) bool

检测账户是否存在

func AddCount

func AddCount(appid string) error

添加使用次数

func AddNewTempWord

func AddNewTempWord(word string, contact string) error

添加一条待审核的鸡汤

func App

func App(writer http.ResponseWriter, request *http.Request)

route:admin 接口

func Connect

func Connect() *gorm.DB

连接数据库

func DeleteTempWords

func DeleteTempWords(twords []TempWord) error

删除待审核的鸡汤

func GetErrMsg

func GetErrMsg(errno int) string

func Linklog

func Linklog()

func ListCountOfTempwords

func ListCountOfTempwords() int64

获取待审核的鸡汤总数

func Log

func Log(msg string)

func ResetCount

func ResetCount()

* AutoRun

func Run

func Run(c *cli.Context) error

运行API服务

func Submit

func Submit(writer http.ResponseWriter, request *http.Request)

Types

type AppResponseJson

type AppResponseJson struct {
	Code int        `json:"code"`
	Info string     `json:"info"`
	Data []TempWord `json:"data"`
}

type GoogleAuth

type GoogleAuth struct {
}

func NewGoogleAuth

func NewGoogleAuth() *GoogleAuth

func (*GoogleAuth) GetCode

func (gauth *GoogleAuth) GetCode(secret string) (string, error)

func (*GoogleAuth) GetQrcode

func (gauth *GoogleAuth) GetQrcode(user, secret string) string

func (*GoogleAuth) GetQrcodeUrl

func (gauth *GoogleAuth) GetQrcodeUrl(user, secret string) string

func (*GoogleAuth) GetSecret

func (gauth *GoogleAuth) GetSecret() string

func (*GoogleAuth) VerifyCode

func (gauth *GoogleAuth) VerifyCode(secret, code string) (bool, error)

type ResponseJson

type ResponseJson struct {
	Code int         `json:"code"`
	Info string      `json:"info"`
	Data interface{} `json:"data"`
}

type TempWord

type TempWord struct {
	Id      int    `json:"id"`      // id
	Content string `json:"content"` // 内容
	Contact string `json:"contact"` // 联系方式
	Time    string `json:"time"`    // 添加时间
}

func GetTempWords

func GetTempWords() ([]TempWord, error)

从tempwords获取内容

func (TempWord) TableName

func (TempWord) TableName() string

type User

type User struct {
	Appid      string
	Secret     string
	Perm       int
	Usecount   int
	GoogleAuth string
}

func GetAccount

func GetAccount(appid string) User

获取用户信息

func (User) TableName

func (User) TableName() string

type Word

type Word struct {
	Id   int
	Word string
}

func GetNewest

func GetNewest() (Word, error)

* * @api {Get} /api 获取最新的一条鸡汤 * @apiGroup GetNewestWord * @apiDescription 获取最新的一条鸡汤 以[]string形式返回 * * @apiParam {String} value 参数(getlast|randget|getword) * @apiParam {String} appid 请求ID * @apiParam {String} secret 请求密钥 * @apiParamExample {json} 参数示例: * { * "value": "randget", * "appid": "test", * "secret": "test" * } * * @apiError (FAIL) {Number} code 错误码 * @apiError (FAIL) {String} info 错误信息 * @apiErrorExample 错误响应示例 * HTTP/1.1 200 OK * { * "code": 1002, * "info": "验证失败", * "data": {} * } * * @apiSuccess (Success) {Number} code 状态码 * @apiSuccess (Success) {String} info 状态码 * @apiSuccess (Success) {Json} data 数据 * @apiSuccess (Success) {[]String} data.words 内容 * @apiSuccessExample 成功响应示例 * HTTP/1.1 200 OK * { * "code": 200, * "info": "Get newest word", * "data": { * "words": [ * "哪怕是示例鸡汤,也是那么的美丽" * ] * } * }

func GetWords

func GetWords() ([]Word, error)

* * @api {Get} /api 获取所有鸡汤 * @apiGroup GetAllWords * @apiDescription 获取所有鸡汤 以[]string形式返回 * * @apiParam {String} value 参数(getlast|randget|getword) * @apiParam {String} appid 请求ID * @apiParam {String} secret 请求密钥 * @apiParamExample {json} 参数示例: * { * "value": "getword", * "appid": "test", * "secret": "test" * } * * @apiError (FAIL) {Number} code 错误码 * @apiError (FAIL) {String} info 错误信息 * @apiErrorExample 错误响应示例 * HTTP/1.1 200 OK * { * "code": 1002, * "info": "验证失败", * "data": {} * } * * @apiSuccess (Success) {Number} code 状态码 * @apiSuccess (Success) {String} info 状态码 * @apiSuccess (Success) {Json} data 数据 * @apiSuccess (Success) {[]String} data.words 内容 * @apiSuccessExample 成功响应示例 * HTTP/1.1 200 OK * { * "code": 200, * "info": "Get all words", * "data": { * "words": [ * "哪怕是示例鸡汤,也是那么的美丽", * "就算世界毁灭,我也是一条毒鸡汤", * "用来提供说明,也是一种值得骄傲的事情", * "叭叭叭叭叭,我是一条鸡汤", * "Cureword - 作者: 0o酱" * ] * } * }

func RandomGet

func RandomGet() (Word, error)

* * @api {Get} /api 随机获取一条鸡汤 * @apiGroup RandomGetWord * @apiDescription 随机获取一条鸡汤 以[]string形式返回 * * @apiParam {String} value 参数(getlast|randget|getword) * @apiParam {String} appid 请求ID * @apiParam {String} secret 请求密钥 * @apiParamExample {json} 参数示例: * { * "value": "randget", * "appid": "test", * "secret": "test" * } * * @apiError (FAIL) {Number} code 错误码 * @apiError (FAIL) {String} info 错误信息 * @apiErrorExample 错误响应示例 * HTTP/1.1 200 OK * { * "code": 1002, * "info": "验证失败", * "data": {} * } * * @apiSuccess (Success) {Number} code 状态码 * @apiSuccess (Success) {String} info 状态码 * @apiSuccess (Success) {Json} data 数据 * @apiSuccess (Success) {[]String} data.words 内容 * @apiSuccessExample 成功响应示例 * HTTP/1.1 200 OK * { * "code": 200, * "info": "Random get a word", * "data": { * "words": [ * "用来提供说明,也是一种值得骄傲的事情" * ] * } * }

func (Word) TableName

func (Word) TableName() string

Jump to

Keyboard shortcuts

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