app

package
v0.0.0-...-ec1e856 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

Index

Constants

View Source
const (
	SUCCESS        = 200
	ERROR          = 500
	INVALID_PARAMS = 400
	FAIL_ADD_DATA  = 800

	//用户相关
	ERROR_EXIST_USER     = 10001
	ERROR_NOT_EXIST_USER = 10002
	ERROR_PASS_USER      = 10003
	ERROR_CAPTCHA_USER   = 10004
	FAIL_LOGOUT_USER     = 10005

	//token相关
	ERROR_AUTH_CHECK_TOKEN_FAIL    = 20001
	ERROR_AUTH_CHECK_TOKEN_TIMEOUT = 20002
	ERROR_AUTH_TOKEN               = 20003
	ERROR_AUTH                     = 20004
	ERROR_AUTH_CHECK_FAIL          = 20005

	ERROR_UPLOAD_SAVE_IMAGE_FAIL    = 30001
	ERROR_UPLOAD_CHECK_IMAGE_FAIL   = 30002
	ERROR_UPLOAD_CHECK_IMAGE_FORMAT = 30003
)

Variables

View Source
var MsgFlags = map[int]string{
	SUCCESS:        "ok",
	ERROR:          "fail",
	INVALID_PARAMS: "请求参数错误",
	FAIL_ADD_DATA:  "操作数据失败",

	ERROR_EXIST_USER:     "已存在该用户名称",
	ERROR_NOT_EXIST_USER: "该用户不存在",
	ERROR_PASS_USER:      "用户密码错误",
	ERROR_CAPTCHA_USER:   "验证码错误",
	FAIL_LOGOUT_USER:     "退出失败",

	ERROR_AUTH_CHECK_TOKEN_FAIL:    "Token鉴权失败",
	ERROR_AUTH_CHECK_TOKEN_TIMEOUT: "Token已超时",
	ERROR_AUTH_TOKEN:               "Token生成失败",
	ERROR_AUTH:                     "Token错误",
	ERROR_AUTH_CHECK_FAIL:          "无权限,请联系管理员",

	ERROR_UPLOAD_SAVE_IMAGE_FAIL:    "保存图片失败",
	ERROR_UPLOAD_CHECK_IMAGE_FAIL:   "检查图片失败",
	ERROR_UPLOAD_CHECK_IMAGE_FORMAT: "校验图片错误,图片格式或大小有问题",
}

Functions

func BindAndValid

func BindAndValid(c *gin.Context, form interface{}) (int, int)

BindAndValid binds and validates data

func BindAndValidate

func BindAndValidate(c *gin.Context, form interface{}) error

func GetMsg

func GetMsg(code int) string

func GetParams

func GetParams(c *gin.Context) dto.BasePage

func MarkErrors

func MarkErrors(errors []*validation.Error)

MarkErrors logs error logs

Types

type Gin

type Gin struct {
	C *gin.Context
}

func (*Gin) Response

func (g *Gin) Response(httpCode int, errCode interface{}, data interface{})

Response setting gin.JSON

func (*Gin) ResponsePage

func (g *Gin) ResponsePage(httpCode int, errCode interface{}, data interface{}, total, totalPage int)

Response setting gin.JSON

type Response

type Response struct {
	Code int         `json:"status"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type ResponsePage

type ResponsePage struct {
	Code      int         `json:"status"`
	Msg       string      `json:"msg"`
	Data      interface{} `json:"data"`
	Total     int         `json:"total"`
	TotalPage int         `json:"totalPage"`
}

Directories

Path Synopsis
* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制
* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制
* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制
* * Copyright (C) 2021-2022 * All rights reserved, Designed By www.github.com/xiatian0716 * 注意:本软件为www.github.com/xiatian0716开发研制

Jump to

Keyboard shortcuts

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