Переглянути джерело

perm URL指令添加privilege,用于指示知否特权权限条目

yjp 4 днів тому
батько
коміт
c9cf6f4377

+ 1 - 0
framework/core/api/router.go

@@ -46,6 +46,7 @@ type PermissionItem struct {
 	Action             string `json:"action"`
 	NeedCheckExpire    bool   `json:"needCheckExpire"`
 	SensitiveWordScene int    `json:"sensitiveWordScene"`
+	Privilege          bool   `json:"privilege"`
 }
 
 func (p *PermissionItem) check() error {

+ 5 - 0
framework/core/api/url_instruction.go

@@ -53,6 +53,7 @@ type PermUrlInstruction struct {
 	Description        string
 	NeedCheckExpire    bool
 	SensitiveWordScene int
+	Privilege          bool
 }
 
 func (cmd *PermUrlInstruction) check() error {
@@ -95,6 +96,7 @@ const (
 	permTagPartDescription        = "description"
 	permTagPartNeedCheckExpire    = "needCheckExpire"
 	permTagPartSensitiveWordScene = "sensitiveWordScene"
+	permTagPartPrivilege          = "privilege"
 )
 
 func parseRelativePathPerm(basePath string, relativePathPattern string, method string) (string, *PermissionItem, error) {
@@ -129,6 +131,7 @@ func parseRelativePathPerm(basePath string, relativePathPattern string, method s
 		Action:             method,
 		NeedCheckExpire:    false,
 		SensitiveWordScene: 0,
+		Privilege:          false,
 	}
 
 	for _, tagPart := range tagParts {
@@ -158,6 +161,8 @@ func parseRelativePathPerm(basePath string, relativePathPattern string, method s
 			}
 
 			permissionItem.SensitiveWordScene = scene
+		case permTagPartPrivilege:
+			permissionItem.Privilege = true
 		default:
 			err := errors.New(permTagKey + "不支持的tag: " + tagPartKeyValue[0])
 			logger.GetInstance().Error(err)

+ 1 - 0
test/url_instruction_test.go

@@ -13,6 +13,7 @@ func TestFormUrlInstruction(t *testing.T) {
 		Description:        "description",
 		NeedCheckExpire:    true,
 		SensitiveWordScene: 1,
+		IsPrivilege:        true,
 	}
 
 	formed := api.FormUrlInstruction(instruction)