user

package
v0.0.0-...-629b230 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(c *gin.Context)

ChangePassword godoc @tags user @summary 修改密码 @description 通过旧密码修改密码 @security ApiKeyAuth @accept json @produce json @param RequestBody body ChangePasswordReqBody true "Request Body" @router /user/{username}/password [put]

func Deactivate

func Deactivate(c *gin.Context)

Deactivate godoc @tags user @summary 用户注销 @description 用户自行注销帐号 @security ApiKeyAuth @accept json @produce json @router /user/{username}/status [put]

func SignIn

func SignIn(c *gin.Context)

SignIn godoc @tags user @summary 获取 JSON Web Token @description 由用户输入帐号(手机号)和密码,验证后返回一个有效期为 3 小时的 JSON Web Token @accept json @produce json @param RequestBody body SignInReqBody true "Request Body" @router /users/token [post]

func SignUp

func SignUp(c *gin.Context)

SignUp godoc @tags user @summary 用户注册 @description 用户须输入真实姓名、密码、手机号码、年龄、性别、住址,返回新创建的用户的基本资料 @accept json @produce json @param RequestBody body SignUpReqBody true "Request Body" @router /users [post]

func UpdateProfile

func UpdateProfile(c *gin.Context)

UpdateProfile godoc @tags user @summary 修改个人基本资料 @description 只能修改年龄和地址 @security ApiKeyAuth @accept json @produce json @param RequestBody body UpdateProfileReqBody true "Request Body" @router /user/{username}/profile [put]

Types

type ChangePasswordReqBody

type ChangePasswordReqBody struct {
	OldPassword string `json:"old_password" binding:"required"`
	NewPassword string `json:"new_password" binding:"required"`
}

type SignInReqBody

type SignInReqBody struct {
	// Username 手机号,长度必须为 11
	Username string `json:"username" binding:"required,len=11"`
	Password string `json:"password" binding:"required"`
}

SignInReqBody 接收登录请求数据

type SignUpReqBody

type SignUpReqBody struct {
	RealName    string `json:"real_name" binding:"required,min=1,max=20"`
	Password    string `json:"password" binding:"required"`
	PhoneNumber string `json:"phone_number" binding:"required,len=11"`
	Age         uint8  `json:"age" binding:"required,min=0,max=255"`
	// Gender 1:男,0:女
	Gender  uint8  `json:"gender" binding:"oneof=0 1"`
	Address string `json:"address" binding:"required,min=1,max=100"`
}

func (SignUpReqBody) CreateUser

func (b SignUpReqBody) CreateUser(passwordHash []byte) user.User

type UpdateProfileReqBody

type UpdateProfileReqBody struct {
	Age     uint8  `json:"age" binding:"required,min=0,max=255"`
	Address string `json:"address" binding:"required,min=1,max=100"`
}

Jump to

Keyboard shortcuts

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