chore: init bj_power monorepo (dashboard/mes/wms/wms_client/workstation), clear subproject git metadata and align naming to folder names

This commit is contained in:
SunYF
2026-08-27 10:09:54 +08:00
commit 1f0ee844a4
408 changed files with 102201 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package token
import (
"encoding/base64"
"fmt"
"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
)
const RefreshTokenKeyPrefix = "token:refresh:"
func GenToken(secretKey string, iat int64, expireSeconds int64, payloads map[string]any) (string, error) {
claims := make(jwt.MapClaims)
claims["exp"] = iat + expireSeconds
claims["iat"] = iat
for k, v := range payloads {
claims[k] = v
}
token := jwt.New(jwt.SigningMethodHS256)
token.Claims = claims
return token.SignedString([]byte(secretKey))
}
func GenRefreshToken() string {
return base64.StdEncoding.EncodeToString([]byte(uuid.New().String()))
}
func GenRefreshTokenCacheKey(userId int64) string {
return fmt.Sprintf("%s%d", RefreshTokenKeyPrefix, userId)
}