hi-server/internal/handler/public/user/deleteAccountHandler.go
shanshanzhong 70c8811406
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
feat(用户): 添加账号注销功能
实现用户账号注销逻辑,包括删除用户所有关联数据并根据原设备信息创建新账号
2025-10-31 00:58:05 -07:00

24 lines
658 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package user
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/logic/public/user"
"github.com/perfect-panel/server/internal/svc"
)
// DeleteAccountHandler 注销账号处理器
// 根据当前token删除所有关联设备然后根据各自设备ID重新新建账号
func DeleteAccountHandler(serverCtx *svc.ServiceContext) gin.HandlerFunc {
return func(c *gin.Context) {
l := user.NewDeleteAccountLogic(c.Request.Context(), serverCtx)
resp, err := l.DeleteAccount()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, resp)
}
}