feat: 标准资源使用独立页面并优化详情布局
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"git.apinb.com/bsm-sdk/core/middleware"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
"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"
|
||||
@@ -61,6 +62,26 @@ func GetPlatformAccount(ctx *gin.Context) {
|
||||
infra.Response.Success(ctx, common.ProtectPreciseLocation(ctx, &models.PlatformAccount{}, view))
|
||||
}
|
||||
|
||||
// GetPlatformAccountAvatar 返回已鉴权平台账户资料页使用的头像二进制内容。
|
||||
func GetPlatformAccountAvatar(ctx *gin.Context) {
|
||||
claims, err := middleware.ParseAuth(ctx)
|
||||
if err != nil {
|
||||
infra.Response.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
// 平台账户头像沿用账户资料权限:root 可查看全部,普通管理员只可查看自己。
|
||||
if claims.Role != "root" && claims.Identity != ctx.Param("identity") {
|
||||
infra.Response.Error(ctx, errcode.ErrPermissionDenied)
|
||||
return
|
||||
}
|
||||
var account models.PlatformAccount
|
||||
if err := common.ActiveRecords(impl.DBService).Select("avatar").Where("identity = ?", ctx.Param("identity")).First(&account).Error; err != nil {
|
||||
common.RespondRecordError(ctx, err)
|
||||
return
|
||||
}
|
||||
upload.ServeAvatar(ctx, account.Avatar)
|
||||
}
|
||||
|
||||
func CreatePlatformAccount(ctx *gin.Context) {
|
||||
if !common.RequirePlatformRoot(ctx) {
|
||||
return
|
||||
@@ -95,7 +116,7 @@ func CreatePlatformAccount(ctx *gin.Context) {
|
||||
func UpdatePlatformAccount(ctx *gin.Context) {
|
||||
var request struct {
|
||||
DisplayName string `json:"display_name" binding:"max=64"`
|
||||
Avatar string `json:"avatar" binding:"max=512"`
|
||||
Avatar *string `json:"avatar" binding:"omitempty,max=512"`
|
||||
PlatformRoleCode *string `json:"platform_role_code" binding:"omitempty,max=64"`
|
||||
Phone string `json:"phone" binding:"max=32"`
|
||||
}
|
||||
@@ -112,7 +133,11 @@ func UpdatePlatformAccount(ctx *gin.Context) {
|
||||
infra.Response.Error(ctx, errcode.ErrPermissionDenied)
|
||||
return
|
||||
}
|
||||
values := gin.H{"display_name": request.DisplayName, "avatar": request.Avatar, "phone": request.Phone}
|
||||
values := gin.H{"display_name": request.DisplayName, "phone": request.Phone}
|
||||
// 未选择新头像时不提交 avatar,避免普通资料编辑误清空现有头像。
|
||||
if request.Avatar != nil {
|
||||
values["avatar"] = *request.Avatar
|
||||
}
|
||||
if request.PlatformRoleCode != nil {
|
||||
if !common.RequirePlatformRoot(ctx) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user