This commit is contained in:
2026-08-17 02:12:17 +08:00
parent 560ae46b82
commit 6a05803e08
96 changed files with 2888 additions and 685 deletions
+7 -4
View File
@@ -71,7 +71,10 @@ func (h *User) Create(c *gin.Context) {
httpx.Fail(c, err.Error())
return
}
httpx.Write(c, httpx.CodeError, gin.H{"user": dto.UserResponse{}}, "注册失败")
if result == nil {
result = &dto.UserResponse{}
}
httpx.Write(c, httpx.CodeError, gin.H{"user": result}, "注册失败")
return
}
httpx.Write(c, httpx.CodeSuccess, gin.H{"user": result}, "注册成功")
@@ -115,7 +118,7 @@ func (h *User) UpdateSelf(c *gin.Context) {
func (h *User) Delete(c *gin.Context) {
var req dto.IDRequest
if err := c.ShouldBind(&req); err != nil {
if err := c.ShouldBindJSON(&req); err != nil {
httpx.Fail(c, err.Error())
return
}
@@ -235,7 +238,7 @@ func (h *User) SwitchAuthority(c *gin.Context) {
}
c.Header("new-token", login.Token)
c.Header("new-expires-at", strconv.FormatInt(login.ExpiresAt/1000, 10))
maxAge := int(time.Until(time.UnixMilli(login.ExpiresAt)).Seconds())
maxAge := int(time.UnixMilli(login.ExpiresAt).Unix() - time.Now().Unix())
httpx.SetTokenCookie(c, login.Token, maxAge)
httpx.Write(c, httpx.CodeSuccess, gin.H{}, "修改成功")
}
@@ -246,7 +249,7 @@ func (h *User) Get(c *gin.Context) {
httpx.NoAuth(c, "未登录或非法访问")
return
}
result, err := h.service.User(c.Request.Context(), claims.ID)
result, err := h.service.UserByUUID(c.Request.Context(), claims.UUID)
if err != nil {
httpx.Fail(c, "获取失败")
return