refactor platform logic modules
This commit is contained in:
21
backend/api/internal/logic/common/operator.go
Normal file
21
backend/api/internal/logic/common/operator.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package common
|
||||
|
||||
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/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// PlatformOperator returns the authenticated platform account identity and display name.
|
||||
func PlatformOperator(ctx *gin.Context) (string, string) {
|
||||
claims, err := middleware.ParseAuth(ctx)
|
||||
if err != nil {
|
||||
return "", ""
|
||||
}
|
||||
var account models.PlatformAccount
|
||||
if err := impl.DBService.Select("display_name").Where("identity = ?", claims.Identity).First(&account).Error; err != nil {
|
||||
return claims.Identity, ""
|
||||
}
|
||||
return claims.Identity, account.DisplayName
|
||||
}
|
||||
Reference in New Issue
Block a user