增加重置用户密码功能
This commit is contained in:
@@ -301,3 +301,21 @@ func (b *BaseApi) GetUserInfo(c *gin.Context) {
|
||||
response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "获取成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags SysUser
|
||||
// @Summary 用户修改密码
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Param data body system.SysUser true "ID"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
||||
// @Router /user/resetPassword [post]
|
||||
func (b *BaseApi) ResetPassword(c *gin.Context) {
|
||||
var user system.SysUser
|
||||
_ = c.ShouldBindJSON(&user)
|
||||
if err := userService.ResetPassword(user.ID); err != nil {
|
||||
global.GVA_LOG.Error("重置失败!", zap.Error(err))
|
||||
response.FailWithMessage("重置失败"+err.Error(), c)
|
||||
} else {
|
||||
response.OkWithMessage("重置成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func MysqlDataInitialize(inits ...InitData) error {
|
||||
|
||||
if err := inits[i].Initialize(); err != nil {
|
||||
color.Info.Printf(InitDataFailed, Mysql, err)
|
||||
continue
|
||||
return err
|
||||
} else {
|
||||
color.Info.Printf(InitDataSuccess, Mysql, inits[i].TableName())
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
|
||||
userRouter.DELETE("deleteUser", baseApi.DeleteUser) // 删除用户
|
||||
userRouter.PUT("setUserInfo", baseApi.SetUserInfo) // 设置用户信息
|
||||
userRouter.POST("setUserAuthorities", baseApi.SetUserAuthorities) // 设置用户权限组
|
||||
userRouter.POST("resetPassword", baseApi.ResetPassword) // 设置用户权限组
|
||||
}
|
||||
{
|
||||
userRouterWithoutRecord.POST("getUserList", baseApi.GetUserList) // 分页获取用户列表
|
||||
|
||||
@@ -110,7 +110,6 @@ func (initDBService *InitDBService) initMysqlData() error {
|
||||
system.AuthoritiesMenus,
|
||||
system.DictionaryDetail,
|
||||
system.ViewAuthorityMenuMysql,
|
||||
|
||||
example.File,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -187,3 +187,14 @@ func (userService *UserService) FindUserByUuid(uuid string) (err error, user *sy
|
||||
}
|
||||
return nil, &u
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: resetPassword
|
||||
//@description: 修改用户密码
|
||||
//@param: ID uint
|
||||
//@return: err error
|
||||
|
||||
func (userService *UserService) ResetPassword(ID uint) (err error) {
|
||||
err = global.GVA_DB.Model(&system.SysUser{}).Where("id = ?", ID).Update("password", utils.MD5V([]byte("123456"))).Error
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ var apis = []system.SysApi{
|
||||
{global.GVA_MODEL{ID: 89, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/delSysHistory", "删除回滚记录", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 90, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthorities", "设置权限组", "user", "POST"},
|
||||
{global.GVA_MODEL{ID: 91, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserInfo", "获取自身信息(必选)", "user", "GET"},
|
||||
{global.GVA_MODEL{ID: 92, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/resetPassword", "重置指定用户密码", "user", "POST"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
|
||||
@@ -92,6 +92,7 @@ var carbines = []gormadapter.CasbinRule{
|
||||
{PType: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/setUserAuthorities", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/getUserInfo", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/user/resetPassword", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
|
||||
|
||||
@@ -28,6 +28,7 @@ func (a *api) Initialize() error {
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/setUserAuthorities", Description: "设置权限组"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/changePassword", Description: "修改密码(建(选择)"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/setUserAuthority", Description: "修改用户角色(必选)"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/api/resetPassword", Description: "重置用户密码"},
|
||||
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/createApi", Description: "创建api"},
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/deleteApi", Description: "删除Api"},
|
||||
|
||||
Reference in New Issue
Block a user