2025-04-30 15:46:14 +08:00
|
|
|
package permission
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetProjectResourcePermission(projectId int, resource string, method string) string {
|
|
|
|
return fmt.Sprintf("project:%v:%v:%v", projectId, resource, strings.ToLower(method))
|
|
|
|
}
|
|
|
|
|
2025-07-10 18:22:25 +08:00
|
|
|
func GetProjectResourceBtnPermission(projectId int, resource string, btn string) string {
|
|
|
|
return fmt.Sprintf("project:btn:%v:%v:%v", projectId, resource, strings.ToLower(btn))
|
|
|
|
}
|
|
|
|
|
2025-04-30 15:46:14 +08:00
|
|
|
func ParseProjectResourcePermission(permission string) (int, string, string, error) {
|
|
|
|
projectId := 0
|
|
|
|
resource := ""
|
|
|
|
method := ""
|
|
|
|
_, err := fmt.Scanf(permission, &projectId, resource, method)
|
|
|
|
return projectId, resource, method, err
|
|
|
|
}
|