up username length to 32 #70
This commit is contained in:
@@ -81,3 +81,44 @@ func (ct *UserToken) Delete(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BatchDelete 批量删除
|
||||||
|
// @Tags 登录凭证
|
||||||
|
// @Summary 登录凭证批量删除
|
||||||
|
// @Description 登录凭证批量删除
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body model.UserToken true "登录凭证信息"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 500 {object} response.Response
|
||||||
|
// @Router /admin/user_token/delete [post]
|
||||||
|
// @Security token
|
||||||
|
func (ct *UserToken) BatchDelete(c *gin.Context) {
|
||||||
|
f := &model.UserToken{}
|
||||||
|
if err := c.ShouldBindJSON(f); err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
id := f.Id
|
||||||
|
errList := global.Validator.ValidVar(c, id, "required,gt=0")
|
||||||
|
if len(errList) > 0 {
|
||||||
|
response.Fail(c, 101, errList[0])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l := service.AllService.UserService.TokenInfoById(f.Id)
|
||||||
|
u := service.AllService.UserService.CurUser(c)
|
||||||
|
if !service.AllService.UserService.IsAdmin(u) && l.UserId != u.Id {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "NoAccess"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if l.Id > 0 {
|
||||||
|
err := service.AllService.UserService.DeleteToken(l)
|
||||||
|
if err == nil {
|
||||||
|
response.Success(c, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Fail(c, 101, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
type UserForm struct {
|
type UserForm struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Username string `json:"username" validate:"required,gte=2,lte=10"`
|
Username string `json:"username" validate:"required,gte=2,lte=32"`
|
||||||
Email string `json:"email"` //validate:"required,email" email不强制
|
Email string `json:"email"` //validate:"required,email" email不强制
|
||||||
//Password string `json:"password" validate:"required,gte=4,lte=20"`
|
//Password string `json:"password" validate:"required,gte=4,lte=20"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
@@ -51,12 +51,12 @@ type UserQuery struct {
|
|||||||
}
|
}
|
||||||
type UserPasswordForm struct {
|
type UserPasswordForm struct {
|
||||||
Id uint `json:"id" validate:"required"`
|
Id uint `json:"id" validate:"required"`
|
||||||
Password string `json:"password" validate:"required,gte=4,lte=20"`
|
Password string `json:"password" validate:"required,gte=4,lte=32"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChangeCurPasswordForm struct {
|
type ChangeCurPasswordForm struct {
|
||||||
OldPassword string `json:"old_password" validate:"required,gte=4,lte=20"`
|
OldPassword string `json:"old_password" validate:"required,gte=4,lte=32"`
|
||||||
NewPassword string `json:"new_password" validate:"required,gte=4,lte=20"`
|
NewPassword string `json:"new_password" validate:"required,gte=4,lte=32"`
|
||||||
}
|
}
|
||||||
type GroupUsersQuery struct {
|
type GroupUsersQuery struct {
|
||||||
IsMy int `json:"is_my"`
|
IsMy int `json:"is_my"`
|
||||||
@@ -64,8 +64,8 @@ type GroupUsersQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RegisterForm struct {
|
type RegisterForm struct {
|
||||||
Username string `json:"username" validate:"required,gte=2,lte=10"`
|
Username string `json:"username" validate:"required,gte=2,lte=32"`
|
||||||
Email string `json:"email"` // validate:"required,email"
|
Email string `json:"email"` // validate:"required,email"
|
||||||
Password string `json:"password" validate:"required,gte=4,lte=20"`
|
Password string `json:"password" validate:"required,gte=4,lte=32"`
|
||||||
ConfirmPassword string `json:"confirm_password" validate:"required,gte=4,lte=20"`
|
ConfirmPassword string `json:"confirm_password" validate:"required,gte=4,lte=32"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ type LoginForm struct {
|
|||||||
Id string `json:"id" label:"id"`
|
Id string `json:"id" label:"id"`
|
||||||
Type string `json:"type" label:"type"`
|
Type string `json:"type" label:"type"`
|
||||||
Uuid string `json:"uuid" label:"uuid"`
|
Uuid string `json:"uuid" label:"uuid"`
|
||||||
Username string `json:"username" validate:"required,gte=2,lte=10" label:"用户名"`
|
Username string `json:"username" validate:"required,gte=2,lte=32" label:"用户名"`
|
||||||
Password string `json:"password,omitempty" validate:"gte=4,lte=20" label:"密码"`
|
Password string `json:"password,omitempty" validate:"gte=4,lte=32" label:"密码"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserListQuery struct {
|
type UserListQuery struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user