Documentation ¶
Index ¶
- Constants
- Variables
- func AcceptTempWords(twords []TempWord) error
- func AccountIsExist(appid string) bool
- func AddCount(appid string) error
- func AddNewTempWord(word string, contact string) error
- func App(writer http.ResponseWriter, request *http.Request)
- func Connect() *gorm.DB
- func DeleteTempWords(twords []TempWord) error
- func GetErrMsg(errno int) string
- func Linklog()
- func ListCountOfTempwords() int64
- func Log(msg string)
- func ResetCount()
- func Run(c *cli.Context) error
- func Submit(writer http.ResponseWriter, request *http.Request)
- type AppResponseJson
- type GoogleAuth
- func (gauth *GoogleAuth) GetCode(secret string) (string, error)
- func (gauth *GoogleAuth) GetQrcode(user, secret string) string
- func (gauth *GoogleAuth) GetQrcodeUrl(user, secret string) string
- func (gauth *GoogleAuth) GetSecret() string
- func (gauth *GoogleAuth) VerifyCode(secret, code string) (bool, error)
- type ResponseJson
- type TempWord
- type User
- type Word
Constants ¶
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 ¶
var DB *gorm.DB = Connect()
var LogFile *os.File
var Loger *log.Logger
var PgLoc, _ = os.Executable()
var PgPath = filepath.Dir(PgLoc)
Functions ¶
Types ¶
type AppResponseJson ¶
type GoogleAuth ¶
type GoogleAuth struct { }
func NewGoogleAuth ¶
func NewGoogleAuth() *GoogleAuth
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 TempWord ¶
type Word ¶
func GetNewest ¶
* * @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 ¶
* * @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 ¶
* * @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": [ * "用来提供说明,也是一种值得骄傲的事情" * ] * } * }