🆕新增了一个破逼头像生成
This commit is contained in:
parent
b51dfea18b
commit
8de68413c1
@ -1,7 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"wireguard-ui/global/constant"
|
"wireguard-ui/global/constant"
|
||||||
"wireguard-ui/http/param"
|
"wireguard-ui/http/param"
|
||||||
@ -250,3 +252,17 @@ func (UserApi) ResetPassword(c *gin.Context) {
|
|||||||
|
|
||||||
response.R(c).OK()
|
response.R(c).OK()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenerateAvatar
|
||||||
|
// @description: 生成头像
|
||||||
|
// @receiver UserApi
|
||||||
|
// @param c
|
||||||
|
func (UserApi) GenerateAvatar(c *gin.Context) {
|
||||||
|
avatar, err := utils.Avatar().GenerateAvatar(false)
|
||||||
|
if err != nil {
|
||||||
|
response.R(c).FailedWithError(fmt.Errorf("生成头像失败: %s", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
response.R(c).OkWithData(fmt.Sprintf("data:image/png;base64,%s", base64.StdEncoding.EncodeToString([]byte(avatar))))
|
||||||
|
}
|
||||||
|
@ -19,5 +19,6 @@ func UserApi(r *gin.RouterGroup) {
|
|||||||
userApi.PUT("/status/:id", api.User().Status) // 修改用户状态
|
userApi.PUT("/status/:id", api.User().Status) // 修改用户状态
|
||||||
userApi.PUT("/change-password", api.User().ChangePassword) // 修改用户密码
|
userApi.PUT("/change-password", api.User().ChangePassword) // 修改用户密码
|
||||||
userApi.PUT("/reset-password/:id", api.User().ResetPassword) // 重置用户密码
|
userApi.PUT("/reset-password/:id", api.User().ResetPassword) // 重置用户密码
|
||||||
|
userApi.POST("/generate-avatar", api.User().GenerateAvatar) // 生成头像
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user