2 Commit-ok c2143b56c2 ... 5018b7b20f

Szerző SHA1 Üzenet Dátum
  haolongfei 5018b7b20f Merge remote-tracking branch 'origin/master' 1 hete
  haolongfei 6b947dee08 feat(query): 添加高级查询操作符支持和查询结果结构 1 hete
2 módosított fájl, 76 hozzáadás és 6 törlés
  1. 59 0
      advanced_query.go
  2. 17 6
      model.go

+ 59 - 0
advanced_query.go

@@ -19,6 +19,65 @@ const (
 	OperatorNotIn        QueryOperator = "not_in"
 )
 
+type QueryOperatorInfo struct {
+	Name  string        `json:"name"`
+	Value QueryOperator `json:"value"`
+}
+
+func GetQueryOperators() []QueryOperatorInfo {
+	return []QueryOperatorInfo{
+		{Name: "等于", Value: OperatorEqual},
+		{Name: "不等于", Value: OperatorNotEqual},
+		{Name: "大于", Value: OperatorGreaterThan},
+		{Name: "大于等于", Value: OperatorGreaterEqual},
+		{Name: "小于", Value: OperatorLessThan},
+		{Name: "小于等于", Value: OperatorLessEqual},
+		{Name: "模糊匹配", Value: OperatorLike},
+		{Name: "不模糊匹配", Value: OperatorNotLike},
+		{Name: "开头是", Value: OperatorStartsWith},
+		{Name: "结尾是", Value: OperatorEndsWith},
+		{Name: "为空", Value: OperatorIsNull},
+		{Name: "不为空", Value: OperatorIsNotNull},
+		{Name: "在列表中", Value: OperatorIn},
+		{Name: "不在列表中", Value: OperatorNotIn},
+	}
+}
+
+func StringToQueryOperator(op string) QueryOperator {
+	switch op {
+	case "eq", "=":
+		return OperatorEqual
+	case "ne", "!=":
+		return OperatorNotEqual
+	case "gt", ">":
+		return OperatorGreaterThan
+	case "gte", ">=":
+		return OperatorGreaterEqual
+	case "lt", "<":
+		return OperatorLessThan
+	case "lte", "<=":
+		return OperatorLessEqual
+	case "like":
+		return OperatorLike
+	case "not_like":
+		return OperatorNotLike
+	case "starts_with":
+		return OperatorStartsWith
+	case "ends_with":
+		return OperatorEndsWith
+	case "is_null":
+		return OperatorIsNull
+	case "is_not_null":
+		return OperatorIsNotNull
+	case "in":
+		return OperatorIn
+	case "not_in":
+		return OperatorNotIn
+	default:
+		return OperatorEqual
+	}
+}
+
 type LogicOperator string
 
 const (

+ 17 - 6
model.go

@@ -21,6 +21,11 @@ type BaseQueryParams struct {
 	PageSize int `form:"pageSize"`
 }
 
+type QueryResult struct {
+	Infos      []map[string]any `json:"infos"`
+	TotalCount int64            `json:"totalCount"`
+}
+
 type PersonInfo struct {
 	ID                   string         `json:"id"`
 	Name                 string         `json:"name"`
@@ -35,21 +40,27 @@ type SavePersonParams struct {
 	ID               string         `json:"id"`
 	Name             string         `json:"name"`
 	UserID           string         `json:"userId"`
+	UserName         string         `json:"operatorUserName"`
 	ExtendProperties map[string]any `json:"extendProperties"`
 	TenantID         string         `json:"tenantId"`
 	OperatorUserName string         `json:"operatorUserName"`
 }
 
 type DeletePersonParams struct {
-	ID               string `form:"id"`
-	OperatorUserName string `form:"operatorUserName"`
+	ID               string   `json:"id"`
+	BusinessType     []string `json:"businessType"`
+	DeleteWhole      bool     `json:"deleteWhole"`
+	DeleteUserID     string   `json:"deleteUserId"`
+	DeleteUserName   string   `json:"deleteUserName"`
+	OperatorUserName string   `json:"operatorUserName"`
 }
 
 type QueryPersonsParams struct {
-	Name                 string         `form:"name"`
-	UserID               string         `form:"userId"`
-	ExtendPropertyValues map[string]any `form:"extendPropertyValues"`
-	TenantID             string         `form:"tenantId"`
+	Name                 string                `form:"name"`
+	UserID               string                `form:"userId"`
+	ExtendPropertyValues map[string]any        `form:"extendPropertyValues"`
+	TenantID             string                `form:"tenantId"`
+	AdvancedQuery        *AdvancedQueryParams  `form:"advancedQuery"`
 	BaseQueryParams
 }