contexts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SUC_LOGIN  = &State{0, "登录成功"}
	ERR_PARAMS = &State{10001, "参数错误"}
	ERR_SYSTEM = &State{10002, "系统异常,请稍后重试。"}
	// common
	ERR_NO_DATA = &State{30001, "没有数据"}
	ERR_INSERT  = &State{30002, "新增失败"}
	ERR_UPDATE  = &State{30003, "更新失败"}
	ERR_DELETE  = &State{30004, "删除失败"}
)
View Source
var (
	ERR_USER_NOT_EXISTS              = &State{20001, "该用户不存在。"}
	ERR_USER_FORBIDDEN               = &State{20002, "该用户被禁止登录系统。"}
	ERR_USER_PASSWORD                = &State{20003, "密码错误。"}
	ERR_USER_PASSWORD_INCONFORMITY   = &State{20003, "密码和确认密码不一致。"}
	ERR_USER_CAN_NOT_DELETE_LOGIN    = &State{20004, "不能删除当前登录用户。"}
	ERR_USER_NO_LOGIN                = &State{20005, "未登录,请先登录。"}
	ERR_USER_SYSTEM_UNSAFE           = &State{20006, "系统异常,请重新登录。"}
	ERR_USER_LOGIN_OUT_TIME          = &State{20007, "登录失效,请重新登录。"}
	ERR_USER_CAN_NOT_FORBIDDEN_LOGIN = &State{20004, "不能禁用当前登录用户。"}
)

定义用户相关状态码

Functions

This section is empty.

Types

type COUNT

type COUNT struct {
	Count int `json:"count" db:"count"` // 数量
}

type DATA

type DATA struct {
	ID       uint      `json:"id" db:"id"`               // id
	Status   int       `json:"status" db:"status"`       // 状态 1:启用 2:禁用
	IsDelete int       `json:"-" db:"is_delete"`         // 是否删除  1:是 2:否
	InsertAt time.Time `json:"insert_at" db:"insert_at"` // 入库时间
	UpdateAt time.Time `json:"update_at" db:"update_at"` // 更新时间
}

base context

type PAGEANDLIMIT

type PAGEANDLIMIT struct {
	Page  uint64 `json:"page" form:"page" default:"1" page:"page"`      // 页数
	Limit uint64 `json:"limit" form:"limit" default:"20" limit:"limit"` // 页数量
}

type RESPONSE

type RESPONSE struct {
	Code int         `json:"code" default:"0"`      // 状态码 0:成功 非0:失败 失败可直接提示msg信息
	Msg  string      `json:"msg" default:"success"` // 状态信息
	Data interface{} `json:"data"`                  // 数据 成功返回指定数据 失败返回nil
}

response context

func NewRESPONSE

func NewRESPONSE() *RESPONSE

func (*RESPONSE) DATA

func (resp *RESPONSE) DATA(data interface{})

func (*RESPONSE) STATE

func (resp *RESPONSE) STATE(s *State) *RESPONSE

type RESPONSEWITHCOUNT

type RESPONSEWITHCOUNT struct {
	RESPONSE
	Count int `json:"count"` // 数量
}

func (*RESPONSEWITHCOUNT) COUNT

func (resp *RESPONSEWITHCOUNT) COUNT(count int)

type RemoveRequest

type RemoveRequest struct {
	Id       uint `json:"id" where:"id"`                    // 用户ID
	IsDelete int  `json:"-" default:"1" update:"is_delete"` // 是否删除 1:是 0:否
}

type RemovesRequest

type RemovesRequest struct {
	Ids      []uint `json:"ids" where:"id"`                   // 用户IDS
	IsDelete int    `json:"-" default:"1" update:"is_delete"` // 是否删除 1:是 0:否
}

type State

type State struct {
	Code int
	Msg  string
}

state context

func (*State) Error

func (s *State) Error() string

type StatusRequest

type StatusRequest struct {
	Id     uint `json:"id" where:"id"`          // 用户ID
	Status int  `json:"status" update:"status"` // 状态 1:启用 2:禁用
}

type UserData

type UserData struct {
	*DATA
	Account  string `json:"account" db:"account"`   // 账户
	UserName string `json:"username" db:"username"` // 用户名
	Password string `json:"-" db:"password"`
	Salt     string `json:"-" db:"salt"`
}

用户表数据

type UserGetRequest

type UserGetRequest struct {
	Id       uint `form:"id" where:"id"` // 用户ID
	IsDelete int  `where:"is_delete" default:"2"`
}

type UserInsertRequest

type UserInsertRequest struct {
	Account         string `json:"account" insert:"account"`           // 账户
	UserName        string `json:"username" insert:"username"`         // 用户名
	Password        string `json:"password" insert:"password"`         // 密码
	ComfirmPassword string `json:"confirmPassword"`                    // 确认密码
	Salt            string `insert:"salt"`                             // 盐
	Status          int    `json:"status" default:"2" insert:"status"` // 状态 1:启用 2:禁用
	IsDelete        int    `default:"2" insert:"is_delete"`            // 是否删除 1:是 0:否
}

type UserListRequest

type UserListRequest struct {
	Id       uint   `order:"id desc"`
	Account  string `form:"account" where:"account,like"` // 账户
	Status   int    `form:"status" where:"status"`        // 状态
	IsDelete int    `where:"is_delete" default:"2"`       // 是否删除
	*PAGEANDLIMIT
}

type UserLoginRequest

type UserLoginRequest struct {
	Account  string `json:"account" where:"account,"` // 账号
	Password string `json:"password"`                 // 密码
}

type UserLoginResponse

type UserLoginResponse struct {
	RESPONSE
	Data struct {
		Authorization string `json:"authorization"` // 登录授权令牌
	} `json:"data"` // 数据
}

type UserUpdateRequest

type UserUpdateRequest struct {
	Id              uint   `json:"id" where:"id"`              // 用户ID
	Account         string `json:"account" update:"account"`   // 账户
	UserName        string `json:"username" update:"username"` // 用户名
	Password        string `json:"password" update:"password"` // 密码
	ComfirmPassword string `json:"confirmPassword"`            // 确认密码
	IsDelete        int    `default:"2" where:"is_delete"`     // 是否删除 1:是 0:否
}

Jump to

Keyboard shortcuts

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