修复:管理员默认商户与账户设置

This commit is contained in:
yml2213
2026-08-13 14:12:25 +08:00
parent 6dae7fafa8
commit 538be52636
7 changed files with 181 additions and 23 deletions
+26
View File
@@ -49,6 +49,13 @@ type changePasswordReq struct {
NewPassword string `json:"new_password" binding:"required,min=8"`
}
type updateCurrentAccountReq struct {
CurrentPassword string `json:"current_password" binding:"required"`
Username string `json:"username" binding:"required"`
Nickname string `json:"nickname"`
NewPassword string `json:"new_password" binding:"omitempty,min=8"`
}
func (h *AuthHandler) ChangePassword(c *gin.Context) {
var req changePasswordReq
if err := c.ShouldBindJSON(&req); err != nil {
@@ -61,3 +68,22 @@ func (h *AuthHandler) ChangePassword(c *gin.Context) {
}
response.OK(c, nil)
}
func (h *AuthHandler) UpdateCurrentAccount(c *gin.Context) {
var req updateCurrentAccountReq
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, "请填写用户名和当前密码;新密码至少 8 位")
return
}
user, err := h.svc.UpdateCurrentAccount(middleware.GetUserID(c), service.UpdateCurrentAccountInput{
CurrentPassword: req.CurrentPassword,
Username: req.Username,
Nickname: req.Nickname,
NewPassword: req.NewPassword,
})
if err != nil {
response.BadRequest(c, err.Error())
return
}
response.OK(c, user)
}