refactor platform logic modules
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Package platform 提供平台总后台的同步 HTTP 业务逻辑。
|
||||
// Package common provides shared HTTP and persistence helpers for business logic modules.
|
||||
package common
|
||||
|
||||
import (
|
||||
@@ -12,9 +12,16 @@ import (
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// PasswordHash creates the shared password representation used by account modules.
|
||||
func PasswordHash(password string) (string, error) {
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
return string(hash), err
|
||||
}
|
||||
|
||||
// FilterFields keeps only explicitly allowed persistence fields.
|
||||
func FilterFields(values map[string]any, allowedFields []string) gin.H {
|
||||
allowed := make(map[string]struct{}, len(allowedFields))
|
||||
|
||||
Reference in New Issue
Block a user