修复用户端个人头像展示

This commit is contained in:
czl231
2026-09-02 22:48:47 +08:00
parent 2033a9407e
commit 7cc56f955f
12 changed files with 334 additions and 23 deletions

View File

@@ -8,6 +8,7 @@ import (
"git.apinb.com/bsm-sdk/core/infra"
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
common "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/upload"
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
"github.com/gin-gonic/gin"
"golang.org/x/crypto/bcrypt"
@@ -129,6 +130,15 @@ func Profile(ctx *gin.Context) {
infra.Response.Success(ctx, gin.H{"identity": account.Identity, "name": account.Name, "phone": account.Phone, "avatar": account.Avatar, "real_name": account.RealName})
}
// Avatar 返回当前用户自己的受保护头像二进制内容。
func Avatar(ctx *gin.Context) {
account, ok := common.UserAccount(ctx)
if !ok {
return
}
upload.ServeAvatar(ctx, account.Avatar)
}
// UpdateProfile 只允许修改非认证资料。
func UpdateProfile(ctx *gin.Context) {
account, ok := common.UserAccount(ctx)

View File

@@ -31,6 +31,7 @@ func registerUserClient(serviceKey string, engine *gin.Engine) {
protected := engine.Group(basePath)
protected.Use(sdkmiddleware.JwtAuth(true), common.RequireClient("user_app"))
protected.GET("/auth/profile", userlogic.Profile)
protected.GET("/auth/avatar", userlogic.Avatar)
protected.PUT("/auth/profile", userlogic.UpdateProfile)
protected.PUT("/auth/password", userlogic.ChangePassword)
protected.GET("/addresses", userlogic.ListAddresses)

View File

@@ -14,6 +14,7 @@ func TestRegisterClientRoutes(t *testing.T) {
expected := map[string]bool{
"POST /heqi/client/v1/user/auth/register": false,
"POST /heqi/client/v1/user/auth/login": false,
"GET /heqi/client/v1/user/auth/avatar": false,
"POST /heqi/client/v1/user/wallet/recharges": false,
"POST /heqi/client/v1/user/shop/orders/:identity/pay": false,
"POST /heqi/client/v1/staff/auth/login": false,