Browse Source

完成查询规则

yjp 9 months ago
parent
commit
7ea7c8c450

+ 1 - 1
convenient/data_containers/configuration/configuration.yaml

@@ -6,7 +6,7 @@ spec:
   spec:
     table_name: # 替换.configurations
     columns:
-      - name: group
+      - name: scope
         type: varchar(256)
         comment: 范围
         not_null: true

+ 27 - 0
convenient/data_containers/query_rule/query_rule.yaml

@@ -0,0 +1,27 @@
+kind: DataContainer
+spec:
+  namespace: # 替换
+  data_source: # 替换
+  name: # 替换.query_rules
+  spec:
+    table_name: # 替换.query_rules
+    columns:
+      - name: scope
+        type: varchar(256)
+        comment: 范围
+        not_null: true
+        primary_key: true
+      - name: domain_name
+        type: varchar(256)
+        comment: 领域名
+        not_null: true
+        primary_key: true
+      - name: domain_cn_name
+        type: varchar(256)
+        comment: 领域中文名
+        not_null: true
+      - name: rule
+        type: text
+        comment: 规则
+        not_null: true
+

+ 1 - 1
convenient/domain/configuration/api.go

@@ -29,7 +29,7 @@ func (simple *Simple) bind(binder *binding.Binder) {
 		Schema:         simple.Schema,
 		CreateJsonBody: &AddConfigurationJsonBody{},
 		DeleteJsonBody: &RemoveConfigurationJsonBody{},
-	})
+	}, value_object_crud.WithDisableQuery[any]())
 
 	binding.GetBind(binder, &binding.SimpleBindItem[map[string]any]{
 		Path:             "/configuration/values",

+ 90 - 0
convenient/domain/query_rule/api.go

@@ -0,0 +1,90 @@
+package query_rule
+
+import (
+	"git.sxidc.com/go-framework/baize/convenient/value_object_crud"
+	"git.sxidc.com/go-framework/baize/framework/binding"
+	"git.sxidc.com/go-framework/baize/framework/core/api"
+	"git.sxidc.com/go-framework/baize/framework/core/api/request"
+	"git.sxidc.com/go-framework/baize/framework/core/api/response"
+	"git.sxidc.com/go-framework/baize/framework/core/application"
+	"git.sxidc.com/go-framework/baize/framework/core/domain"
+	"git.sxidc.com/go-framework/baize/framework/core/infrastructure"
+	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database"
+	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/sql"
+)
+
+// Simple Bind参数
+type Simple struct {
+	// schema
+	Schema string
+}
+
+func (simple *Simple) bind(binder *binding.Binder) {
+	queryRuleTableName := domain.TableName(simple.Schema, &ValueObject{})
+
+	value_object_crud.BindSimple(binder, &value_object_crud.Simple[any]{
+		ValueObject:    &ValueObject{},
+		Schema:         simple.Schema,
+		CreateJsonBody: &AddQueryRuleJsonBody{},
+		DeleteJsonBody: &RemoveQueryRuleJsonBody{},
+	}, value_object_crud.WithDisableQuery[any]())
+
+	binding.PostBind(binder, &binding.SimpleBindItem[map[string]any]{
+		Path:             "/queryRuleDefinition/get",
+		SendResponseFunc: response.SendMapResponse,
+		RequestParams:    &GetQueryRuleQueryParams{},
+		Objects:          []domain.Object{&ValueObject{}},
+		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
+			errResponse := map[string]any{
+				"definition": make([]QueryRuleDefinitionItem, 0),
+			}
+
+			valueObject, err := domain.ToConcrete[*ValueObject](objects[0])
+			if err != nil {
+				return errResponse, err
+			}
+
+			return map[string]any{
+				"definition": GetQueryRuleDefinition(valueObject.RuleDomainName),
+			}, nil
+		},
+	})
+
+	binding.PostBind(binder, &binding.SimpleBindItem[Info]{
+		Path:             "/queryRule/get",
+		SendResponseFunc: response.SendInfoResponse[Info],
+		RequestParams:    &GetQueryRuleQueryParams{},
+		Objects:          []domain.Object{&ValueObject{}},
+		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (Info, error) {
+			dbExecutor := i.DBExecutor()
+
+			valueObject, err := domain.ToConcrete[*ValueObject](objects[0])
+			if err != nil {
+				return Info{}, err
+			}
+
+			result, err := database.QueryOne(dbExecutor, &sql.QueryOneExecuteParams{
+				TableName: queryRuleTableName,
+				Conditions: sql.NewConditions().
+					Equal(ColumnScope, valueObject.Scope).
+					Equal(ColumnDomainName, valueObject.RuleDomainName),
+			})
+			if err != nil {
+				return Info{}, err
+			}
+
+			info := new(Info)
+			err = sql.ParseSqlResult(result, info)
+			if err != nil {
+				return Info{}, err
+			}
+
+			return *info, nil
+		},
+	})
+}
+
+func Bind(app *application.App, simple *Simple) {
+	binder := binding.NewBinder(app.Api().ChooseRouter(api.RouterPrefix, ""), app.Infrastructure())
+	simple.bind(binder)
+}

+ 8 - 0
convenient/domain/query_rule/info.go

@@ -0,0 +1,8 @@
+package query_rule
+
+type Info struct {
+	Scope            string `json:"scope" sqlresult:"column:scope"`
+	RuleDomainName   string `json:"domainName" sqlresult:"column:domain_name"`
+	RuleDomainCNName string `json:"domainCNName" sqlresult:"column:domain_cn_name"`
+	Rule             string `json:"rule" sqlresult:"column:rule"`
+}

+ 170 - 0
convenient/domain/query_rule/query_rule_definition.go

@@ -0,0 +1,170 @@
+package query_rule
+
+import (
+	"git.sxidc.com/go-framework/baize/framework/core/domain/entity"
+	"git.sxidc.com/go-framework/baize/framework/core/tag/rule"
+	"sync"
+)
+
+const (
+	opEqual              = "eq"
+	opNotEqual           = "ne"
+	opLessThan           = "lt"
+	opLessThanOrEqual    = "lte"
+	opGreaterThan        = "gt"
+	opGreaterThanOrEqual = "gte"
+	opIn                 = "in"
+	opNotIn              = "not-in"
+	opPrefix             = "prefix"
+	opSuffix             = "suffix"
+	opContains           = "contains"
+)
+
+func IsSupportedOperator(op string) bool {
+	return op == opEqual || op == opNotEqual ||
+		op == opLessThan || op == opLessThanOrEqual ||
+		op == opGreaterThan || op == opGreaterThanOrEqual ||
+		op == opIn || op == opNotIn ||
+		op == opPrefix || op == opSuffix || op == opContains
+}
+
+var opTranslationMap = map[string]string{
+	opEqual:              "等于",
+	opNotEqual:           "不等于",
+	opLessThan:           "小于",
+	opLessThanOrEqual:    "小于等于",
+	opGreaterThan:        "大于",
+	opGreaterThanOrEqual: "大于等于",
+	opIn:                 "包含在列表",
+	opNotIn:              "不包含在列表",
+	opPrefix:             "包含前缀",
+	opSuffix:             "包含后缀",
+	opContains:           "包含",
+}
+
+var (
+	operatorEqual = Operator{
+		Name:   opEqual,
+		CNName: opTranslationMap[opEqual],
+	}
+
+	operatorNotEqual = Operator{
+		Name:   opNotEqual,
+		CNName: opTranslationMap[opNotEqual],
+	}
+
+	operatorLessThan = Operator{
+		Name:   opLessThan,
+		CNName: opTranslationMap[opLessThan],
+	}
+
+	operatorLessThanOrEqual = Operator{
+		Name:   opLessThanOrEqual,
+		CNName: opTranslationMap[opLessThanOrEqual],
+	}
+
+	operatorGreaterThan = Operator{
+		Name:   opGreaterThan,
+		CNName: opTranslationMap[opGreaterThan],
+	}
+
+	operatorGreaterThanOrEqual = Operator{
+		Name:   opGreaterThanOrEqual,
+		CNName: opTranslationMap[opGreaterThanOrEqual],
+	}
+
+	operatorIn = Operator{
+		Name:   opIn,
+		CNName: opTranslationMap[opIn],
+	}
+
+	operatorNotIn = Operator{
+		Name:   opNotIn,
+		CNName: opTranslationMap[opNotIn],
+	}
+
+	operatorPrefix = Operator{
+		Name:   opPrefix,
+		CNName: opTranslationMap[opPrefix],
+	}
+
+	operatorSuffix = Operator{
+		Name:   opSuffix,
+		CNName: opTranslationMap[opSuffix],
+	}
+
+	operatorContains = Operator{
+		Name:   opContains,
+		CNName: opTranslationMap[opContains],
+	}
+)
+
+var operatorOfTypeMap = map[string][]Operator{
+	rule.TypeString: {
+		operatorEqual, operatorNotEqual, operatorIn, operatorNotIn, operatorPrefix, operatorSuffix, operatorContains,
+	},
+	rule.TypeTime: {
+		operatorEqual, operatorNotEqual, operatorLessThan, operatorLessThanOrEqual, operatorGreaterThan, operatorGreaterThanOrEqual, operatorIn, operatorNotIn,
+	},
+	rule.TypeNumber: {
+		operatorEqual, operatorNotEqual, operatorLessThan, operatorLessThanOrEqual, operatorGreaterThan, operatorGreaterThanOrEqual, operatorIn, operatorNotIn,
+	},
+	rule.TypeBool: {
+		operatorEqual, operatorNotEqual,
+	},
+}
+
+var registeredDomainMap = &sync.Map{}
+
+type Operator struct {
+	Name   string `json:"name"`
+	CNName string `json:"cnName"`
+}
+
+type QueryRuleDefinitionItem struct {
+	FieldType   string     `json:"fieldType"`
+	FieldName   string     `json:"fieldName"`
+	FieldCNName string     `json:"fieldCNName"`
+	ColumnName  string     `json:"columnName"`
+	Operators   []Operator `json:"operators"`
+}
+
+type RegisterQueryRuleDefinitionsByEntityItem struct {
+	Entity   entity.Entity
+	FieldMap map[string]string
+}
+
+func RegisterQueryRuleDefinitionByEntity(items ...RegisterQueryRuleDefinitionsByEntityItem) error {
+	for _, item := range items {
+		e := item.Entity
+
+		fields, err := rule.DefaultUsage(e)
+		if err != nil {
+			return err
+		}
+
+		definitions := make([]QueryRuleDefinitionItem, 0)
+		for _, field := range fields {
+			definitions = append(definitions, QueryRuleDefinitionItem{
+				FieldType:   field.Type,
+				FieldName:   field.FieldName,
+				ColumnName:  field.ColumnName,
+				FieldCNName: item.FieldMap[field.FieldName],
+				Operators:   operatorOfTypeMap[field.Type],
+			})
+		}
+
+		registeredDomainMap.Store(e.DomainCamelName(), definitions)
+	}
+
+	return nil
+}
+
+func GetQueryRuleDefinition(domainName string) []QueryRuleDefinitionItem {
+	result, ok := registeredDomainMap.Load(domainName)
+	if !ok {
+		return make([]QueryRuleDefinitionItem, 0)
+	}
+
+	return result.([]QueryRuleDefinitionItem)
+}

+ 141 - 0
convenient/domain/query_rule/query_rule_parser.go

@@ -0,0 +1,141 @@
+package query_rule
+
+import (
+	"encoding/json"
+	"git.sxidc.com/go-framework/baize/framework/core/domain"
+	"git.sxidc.com/go-framework/baize/framework/core/infrastructure"
+	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database"
+	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/sql"
+	"git.sxidc.com/go-framework/baize/framework/core/tag/rule"
+	"git.sxidc.com/go-tools/utils/reflectutils"
+	"git.sxidc.com/go-tools/utils/strutils"
+	"github.com/pkg/errors"
+	"reflect"
+)
+
+type Rule struct {
+	FieldName  string `json:"fieldName"`
+	FieldType  string `json:"fieldType"`
+	ColumnName string `json:"columnName"`
+	Operator   string `json:"operator"`
+	Value      any    `json:"value"`
+}
+
+func (r Rule) Check() error {
+	if strutils.IsStringEmpty(r.FieldName) {
+		return errors.New("字段名为空")
+	}
+
+	if !rule.IsSupportedType(r.FieldType) {
+		return errors.New("字段类型不支持")
+	}
+
+	if strutils.IsStringEmpty(r.ColumnName) {
+		return errors.New("列名为空")
+	}
+
+	if !IsSupportedOperator(r.Operator) {
+		return errors.New("操作符不支持")
+	}
+
+	if r.Value == nil {
+		return errors.New("没有传递值")
+	}
+
+	return nil
+}
+
+func Lint(ruleStr string) error {
+	rules := make([]Rule, 0)
+	err := json.Unmarshal([]byte(ruleStr), &rules)
+	if err != nil {
+		return err
+	}
+
+	for _, r := range rules {
+		err := r.Check()
+		if err != nil {
+			return err
+		}
+	}
+
+	return nil
+}
+
+func FormConditions(dbSchema string, scope string, domainName string, i *infrastructure.Infrastructure) (*sql.Conditions, error) {
+	dbExecutor := i.DBExecutor()
+
+	result, err := database.QueryOne(dbExecutor, &sql.QueryOneExecuteParams{
+		TableName:  domain.TableName(dbSchema, &ValueObject{}),
+		Conditions: sql.NewConditions().Equal(ColumnScope, scope).Equal(ColumnDomainName, domainName),
+	})
+	if err != nil {
+		return nil, err
+	}
+
+	rules := make([]Rule, 0)
+	err = json.Unmarshal([]byte(result.ColumnValueString(ColumnRule)), &rules)
+	if err != nil {
+		return nil, err
+	}
+
+	conditions := sql.NewConditions()
+	for _, r := range rules {
+		err := r.Check()
+		if err != nil {
+			return nil, err
+		}
+
+		switch r.Operator {
+		case opEqual:
+			conditions.Equal(r.ColumnName, r.Value)
+		case opNotEqual:
+			conditions.Not(r.ColumnName, r.Value)
+		case opLessThan:
+			conditions.LessThan(r.ColumnName, r.Value)
+		case opLessThanOrEqual:
+			conditions.LessThanAndEqual(r.ColumnName, r.Value)
+		case opGreaterThan:
+			conditions.GreaterThan(r.ColumnName, r.Value)
+		case opGreaterThanOrEqual:
+			conditions.GreaterThanAndEqual(r.ColumnName, r.Value)
+		case opIn:
+			if reflect.TypeOf(r.Value).Kind() != reflect.Slice {
+				return nil, errors.New("使用\"包含在列表\"操作符必须使用列表")
+			}
+
+			conditions.In(r.FieldName, r.Value)
+		case opNotIn:
+			if reflect.TypeOf(r.Value).Kind() != reflect.Slice {
+				return nil, errors.New("使用\"不包含在列表\"操作符必须使用列表")
+			}
+
+			conditions.NotIn(r.FieldName, r.Value)
+		case opPrefix:
+			strValue, err := reflectutils.ToString(r.Value)
+			if err != nil {
+				return nil, err
+			}
+
+			conditions.Like(r.FieldName, strValue+"%")
+		case opSuffix:
+			strValue, err := reflectutils.ToString(r.Value)
+			if err != nil {
+				return nil, err
+			}
+
+			conditions.Like(r.FieldName, "%"+strValue)
+		case opContains:
+			strValue, err := reflectutils.ToString(r.Value)
+			if err != nil {
+				return nil, err
+			}
+
+			conditions.Like(r.FieldName, "%"+strValue+"%")
+		default:
+			return nil, errors.Errorf("不支持的操作符%v", r.Operator)
+		}
+	}
+
+	return conditions, nil
+}

+ 24 - 0
convenient/domain/query_rule/request_params.go

@@ -0,0 +1,24 @@
+package query_rule
+
+type (
+	AddQueryRuleJsonBody struct {
+		Scope        string `json:"scope" binding:"required" assign:"toField:Scope"`
+		DomainName   string `json:"domainName" binding:"required" assign:"toField:RuleDomainName"`
+		DomainCNName string `json:"domainCNName" binding:"required" assign:"toField:RuleDomainCNName"`
+		Rule         string `json:"rule" binding:"required" assign:"toField:Rule"`
+	}
+
+	RemoveQueryRuleJsonBody struct {
+		Scope      string `json:"scope" binding:"required" assign:"toField:Scope"`
+		DomainName string `json:"domainName" binding:"required" assign:"toField:RuleDomainName"`
+	}
+
+	GetQueryRuleQueryParams struct {
+		Scope      string `json:"scope" binding:"required" assign:"toField:Scope"`
+		DomainName string `json:"domainName" binding:"required" assign:"toField:RuleDomainName"`
+	}
+
+	GetQueryRuleDefinitionQueryParams struct {
+		DomainName string `json:"domainName" binding:"required" assign:"toField:RuleDomainName"`
+	}
+)

+ 91 - 0
convenient/domain/query_rule/value_object.go

@@ -0,0 +1,91 @@
+package query_rule
+
+import (
+	"git.sxidc.com/go-framework/baize/framework/core/domain"
+	"git.sxidc.com/go-framework/baize/framework/core/domain/value_object"
+	"git.sxidc.com/go-framework/baize/framework/core/tag/check"
+)
+
+const (
+	FieldScope        = "Scope"
+	FieldDomainName   = "DomainName"
+	FieldDomainCNName = "DomainCNName"
+	FieldRule         = "Rule"
+)
+
+var (
+	ColumnScope        = domain.ColumnName(FieldScope)
+	ColumnDomainName   = "domain_name"
+	ColumnDomainCNName = "domain_cn_name"
+	ColumnRule         = domain.ColumnName(FieldRule)
+)
+
+var fieldMap = map[string]string{
+	FieldScope:        "范围",
+	FieldDomainName:   "领域名",
+	FieldDomainCNName: "领域中文名",
+	FieldRule:         "规则",
+}
+
+type ValueObject struct {
+	value_object.Base
+	Scope            string `sqlmapping:"column:scope;key;notUpdate;" sqlresult:"column:scope;" check:"required,lte=256"`
+	RuleDomainName   string `sqlmapping:"column:domain_name;key;notUpdate;" sqlresult:"column:domain_name;" check:"required,lte=256"`
+	RuleDomainCNName string `sqlmapping:"column:domain_cn_name;key;notUpdate;" sqlresult:"column:domain_cn_name;" check:"required,lte=256"`
+	Rule             string `sqlmapping:"column:rule;notUpdate;" sqlresult:"column:rule;" check:"required"`
+}
+
+func (valueObject *ValueObject) DomainCNName() string {
+	return "查询规则"
+}
+
+func (valueObject *ValueObject) DomainCamelName() string {
+	return "QueryRule"
+}
+
+func (valueObject *ValueObject) CheckKeyFields() error {
+	checkResult := check.Struct(valueObject, fieldMap)
+
+	err := domain.CheckField(checkResult, valueObject.DomainCNName(), FieldScope)
+	if err != nil {
+		return err
+	}
+
+	err = domain.CheckField(checkResult, valueObject.DomainCNName(), FieldDomainName)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+func (valueObject *ValueObject) ForCreate() error {
+	checkResult := check.Struct(valueObject, fieldMap)
+
+	err := domain.CheckField(checkResult, valueObject.DomainCNName(), FieldScope)
+	if err != nil {
+		return err
+	}
+
+	err = domain.CheckField(checkResult, valueObject.DomainCNName(), FieldDomainName)
+	if err != nil {
+		return err
+	}
+
+	err = domain.CheckField(checkResult, valueObject.DomainCNName(), FieldDomainCNName)
+	if err != nil {
+		return err
+	}
+
+	err = domain.CheckField(checkResult, valueObject.DomainCNName(), FieldRule)
+	if err != nil {
+		return err
+	}
+
+	err = Lint(valueObject.Rule)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}

+ 22 - 20
framework/core/tag/rule/tag.go

@@ -4,24 +4,21 @@ import (
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/logger"
 	"git.sxidc.com/go-tools/utils/reflectutils"
 	"git.sxidc.com/go-tools/utils/strutils"
+	"git.sxidc.com/go-tools/utils/template"
+	"github.com/iancoleman/strcase"
 	"github.com/pkg/errors"
 	"reflect"
 	"strings"
 )
 
 const (
-	TypeDefault = "default"
-	TypeString  = "string"
-	TypeTime    = "time"
-	TypeNumber  = "number"
-	TypeBool    = "bool"
+	TypeString = "string"
+	TypeTime   = "time"
+	TypeNumber = "number"
+	TypeBool   = "bool"
 )
 
-func isDefaultType(typeStr string) bool {
-	return typeStr == TypeDefault
-}
-
-func isSupportedType(typeStr string) bool {
+func IsSupportedType(typeStr string) bool {
 	return typeStr == TypeString || typeStr == TypeTime || typeStr == TypeNumber || typeStr == TypeBool
 }
 
@@ -31,12 +28,14 @@ const (
 )
 
 const (
-	tagKey  = "rule"
-	tagType = "type"
+	tagKey        = "rule"
+	tagPartColumn = "column"
+	tagPartType   = "type"
 )
 
 type Tag struct {
-	Type string
+	ColumnName string
+	Type       string
 }
 
 func parseTag(entityElemValue reflect.Value, onParsedFieldTagFunc OnParsedFieldTagFunc) error {
@@ -104,7 +103,8 @@ func parseFieldTag(field reflect.StructField, tagStr string) (*Tag, error) {
 	}
 
 	tag := &Tag{
-		Type: fieldTypeStr,
+		ColumnName: strcase.ToSnake(template.Id(field.Name)),
+		Type:       fieldTypeStr,
 	}
 
 	if strutils.IsStringEmpty(tagStr) {
@@ -124,17 +124,19 @@ func parseFieldTag(field reflect.StructField, tagStr string) (*Tag, error) {
 			}
 
 			switch tagPartKeyValue[0] {
-			case tagType:
+			case tagPartColumn:
 				if strutils.IsStringEmpty(tagPartKeyValue[1]) {
-					return nil, errors.New("type没有赋值字段类型")
+					return nil, errors.New("column没有赋值列名")
 				}
 
-				if isDefaultType(tagPartKeyValue[1]) {
-					continue
+				tag.ColumnName = tagPartKeyValue[1]
+			case tagPartType:
+				if strutils.IsStringEmpty(tagPartKeyValue[1]) {
+					return nil, errors.New("type没有赋值字段类型")
 				}
 
-				if !isSupportedType(tagPartKeyValue[1]) {
-					return nil, errors.New("type支持的类型包括: string, number, time")
+				if !IsSupportedType(tagPartKeyValue[1]) {
+					return nil, errors.Errorf("类型为%v, type支持的类型包括: string, number, time", tagPartKeyValue[1])
 				}
 
 				tag.Type = tagPartKeyValue[1]

+ 6 - 4
framework/core/tag/rule/usage.go

@@ -5,8 +5,9 @@ import (
 )
 
 type Field struct {
-	FieldName string
-	Type      string
+	FieldName  string
+	ColumnName string
+	Type       string
 }
 
 func DefaultUsage(e any) ([]Field, error) {
@@ -23,8 +24,9 @@ func DefaultUsage(e any) ([]Field, error) {
 func defaultCallback(fields *[]Field) OnParsedFieldTagFunc {
 	return func(fieldName string, entityFieldElemValue reflect.Value, tag *Tag) error {
 		field := Field{
-			FieldName: fieldName,
-			Type:      tag.Type,
+			FieldName:  fieldName,
+			ColumnName: tag.ColumnName,
+			Type:       tag.Type,
 		}
 
 		*fields = append(*fields, field)

+ 2 - 1
framework/core/tag/sql/sql_mapping/tag.go

@@ -4,6 +4,7 @@ import (
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/logger"
 	"git.sxidc.com/go-tools/utils/reflectutils"
 	"git.sxidc.com/go-tools/utils/strutils"
+	"git.sxidc.com/go-tools/utils/template"
 	"github.com/iancoleman/strcase"
 	"github.com/pkg/errors"
 	"reflect"
@@ -100,7 +101,7 @@ func parseFieldTag(field reflect.StructField, tagStr string) (*Tag, error) {
 	}
 
 	tag := &Tag{
-		Name:           strcase.ToSnake(field.Name),
+		Name:           strcase.ToSnake(template.Id(field.Name)),
 		IsKey:          false,
 		CanUpdate:      true,
 		CanUpdateClear: false,

+ 2 - 1
framework/core/tag/sql/sql_result/tag.go

@@ -4,6 +4,7 @@ import (
 	"git.sxidc.com/go-framework/baize/framework/core/infrastructure/logger"
 	"git.sxidc.com/go-tools/utils/reflectutils"
 	"git.sxidc.com/go-tools/utils/strutils"
+	"git.sxidc.com/go-tools/utils/template"
 	"github.com/iancoleman/strcase"
 	"github.com/pkg/errors"
 	"reflect"
@@ -92,7 +93,7 @@ func parseFieldTag(field reflect.StructField, tagStr string) (*Tag, error) {
 	}
 
 	tag := &Tag{
-		Name:       strcase.ToSnake(field.Name),
+		Name:       strcase.ToSnake(template.Id(field.Name)),
 		TimeLayout: time.DateTime,
 		AESKey:     "",
 		SplitWith:  defaultSplitWith,

+ 420 - 120
test/rule_tag_test.go

@@ -10,36 +10,36 @@ import (
 
 type RuleTagStruct struct {
 	Ignore          string
-	StringValue     string    `rule:"type:default"`
-	IntValue        int       `rule:"type:default"`
-	Int8Value       int8      `rule:"type:default"`
-	Int16Value      int16     `rule:"type:default"`
-	Int32Value      int32     `rule:"type:default"`
-	Int64Value      int64     `rule:"type:default"`
-	UintValue       uint      `rule:"type:default"`
-	Uint8Value      uint8     `rule:"type:default"`
-	Uint16Value     uint16    `rule:"type:default"`
-	Uint32Value     uint32    `rule:"type:default"`
-	Uint64Value     uint64    `rule:"type:default"`
-	Float32Value    float32   `rule:"type:default"`
-	Float64Value    float64   `rule:"type:default"`
-	TimeValue       time.Time `rule:"type:default"`
-	BoolValue       bool      `rule:"type:default"`
-	TagStringValue  bool      `rule:"type:string"`
-	TagIntValue     string    `rule:"type:number"`
-	TagInt8Value    string    `rule:"type:number"`
-	TagInt16Value   string    `rule:"type:number"`
-	TagInt32Value   string    `rule:"type:number"`
-	TagInt64Value   string    `rule:"type:number"`
-	TagUintValue    string    `rule:"type:number"`
-	TagUint8Value   string    `rule:"type:number"`
-	TagUint16Value  string    `rule:"type:number"`
-	TagUint32Value  string    `rule:"type:number"`
-	TagUint64Value  string    `rule:"type:number"`
-	TagFloat32Value string    `rule:"type:number"`
-	TagFloat64Value string    `rule:"type:number"`
-	TagTimeValue    string    `rule:"type:time"`
-	TagBoolValue    string    `rule:"type:bool"`
+	StringValue     string    `rule:"column:string_value"`
+	IntValue        int       `rule:"column:int_value"`
+	Int8Value       int8      `rule:"column:int8_value"`
+	Int16Value      int16     `rule:"column:int16_value"`
+	Int32Value      int32     `rule:"column:int32_value"`
+	Int64Value      int64     `rule:"column:int64_value"`
+	UintValue       uint      `rule:"column:uint_value"`
+	Uint8Value      uint8     `rule:"column:uint8_value"`
+	Uint16Value     uint16    `rule:"column:uint16_value"`
+	Uint32Value     uint32    `rule:"column:uint32_value"`
+	Uint64Value     uint64    `rule:"column:uint64_value"`
+	Float32Value    float32   `rule:"column:float32_value"`
+	Float64Value    float64   `rule:"column:float64_value"`
+	TimeValue       time.Time `rule:"column:time_value"`
+	BoolValue       bool      `rule:"column:bool_value"`
+	TagStringValue  bool      `rule:"column:string_value;type:string"`
+	TagIntValue     string    `rule:"column:int_value;type:number"`
+	TagInt8Value    string    `rule:"column:int8_value;type:number"`
+	TagInt16Value   string    `rule:"column:int16_value;type:number"`
+	TagInt32Value   string    `rule:"column:int32_value;type:number"`
+	TagInt64Value   string    `rule:"column:int64_value;type:number"`
+	TagUintValue    string    `rule:"column:uint_value;type:number"`
+	TagUint8Value   string    `rule:"column:uint8_value;type:number"`
+	TagUint16Value  string    `rule:"column:uint16_value;type:number"`
+	TagUint32Value  string    `rule:"column:uint32_value;type:number"`
+	TagUint64Value  string    `rule:"column:uint64_value;type:number"`
+	TagFloat32Value string    `rule:"column:float32_value;type:number"`
+	TagFloat64Value string    `rule:"column:float64_value;type:number"`
+	TagTimeValue    string    `rule:"column:time_value;type:time"`
+	TagBoolValue    string    `rule:"column:bool_value;type:bool"`
 }
 
 func (s RuleTagStruct) checkFields(t *testing.T, fields []rule.Field) {
@@ -54,153 +54,303 @@ func (s RuleTagStruct) checkFields(t *testing.T, fields []rule.Field) {
 
 		switch field.FieldName {
 		case "StringValue":
+			if field.ColumnName != "string_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "string_value"))
+			}
+
 			if field.Type != "string" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "IntValue":
+			if field.ColumnName != "int_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int8Value":
+			if field.ColumnName != "int8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int16Value":
+			if field.ColumnName != "int16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int32Value":
+			if field.ColumnName != "int32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int64Value":
+			if field.ColumnName != "int64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "UintValue":
+			if field.ColumnName != "uint_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint8Value":
+			if field.ColumnName != "uint8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint16Value":
+			if field.ColumnName != "uint16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint32Value":
+			if field.ColumnName != "uint32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint64Value":
+			if field.ColumnName != "uint64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Float32Value":
+			if field.ColumnName != "float32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Float64Value":
+			if field.ColumnName != "float64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TimeValue":
+			if field.ColumnName != "time_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "time" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "BoolValue":
+			if field.ColumnName != "bool_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "bool" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagStringValue":
+			if field.ColumnName != "string_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "string_value"))
+			}
+
 			if field.Type != "string" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagIntValue":
+			if field.ColumnName != "int_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt8Value":
+			if field.ColumnName != "int8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt16Value":
+			if field.ColumnName != "int16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt32Value":
+			if field.ColumnName != "int32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt64Value":
+			if field.ColumnName != "int64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUintValue":
+			if field.ColumnName != "uint_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint8Value":
+			if field.ColumnName != "uint8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint16Value":
+			if field.ColumnName != "uint16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint32Value":
+			if field.ColumnName != "uint32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint64Value":
+			if field.ColumnName != "uint64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagFloat32Value":
+			if field.ColumnName != "float32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagFloat64Value":
+			if field.ColumnName != "float64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagTimeValue":
+			if field.ColumnName != "time_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "time" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagBoolValue":
+			if field.ColumnName != "bool_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "bool" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		default:
@@ -211,36 +361,36 @@ func (s RuleTagStruct) checkFields(t *testing.T, fields []rule.Field) {
 
 type RuleTagPointerFieldsStruct struct {
 	Ignore          *string
-	StringValue     *string    `rule:"type:default"`
-	IntValue        *int       `rule:"type:default"`
-	Int8Value       *int8      `rule:"type:default"`
-	Int16Value      *int16     `rule:"type:default"`
-	Int32Value      *int32     `rule:"type:default"`
-	Int64Value      *int64     `rule:"type:default"`
-	UintValue       *uint      `rule:"type:default"`
-	Uint8Value      *uint8     `rule:"type:default"`
-	Uint16Value     *uint16    `rule:"type:default"`
-	Uint32Value     *uint32    `rule:"type:default"`
-	Uint64Value     *uint64    `rule:"type:default"`
-	Float32Value    *float32   `rule:"type:default"`
-	Float64Value    *float64   `rule:"type:default"`
-	TimeValue       *time.Time `rule:"type:default"`
-	BoolValue       *bool      `rule:"type:default"`
-	TagStringValue  *bool      `rule:"type:string"`
-	TagIntValue     *string    `rule:"type:number"`
-	TagInt8Value    *string    `rule:"type:number"`
-	TagInt16Value   *string    `rule:"type:number"`
-	TagInt32Value   *string    `rule:"type:number"`
-	TagInt64Value   *string    `rule:"type:number"`
-	TagUintValue    *string    `rule:"type:number"`
-	TagUint8Value   *string    `rule:"type:number"`
-	TagUint16Value  *string    `rule:"type:number"`
-	TagUint32Value  *string    `rule:"type:number"`
-	TagUint64Value  *string    `rule:"type:number"`
-	TagFloat32Value *string    `rule:"type:number"`
-	TagFloat64Value *string    `rule:"type:number"`
-	TagTimeValue    *string    `rule:"type:time"`
-	TagBoolValue    *string    `rule:"type:bool"`
+	StringValue     *string    `rule:"column:string_value"`
+	IntValue        *int       `rule:"column:int_value"`
+	Int8Value       *int8      `rule:"column:int8_value"`
+	Int16Value      *int16     `rule:"column:int16_value"`
+	Int32Value      *int32     `rule:"column:int32_value"`
+	Int64Value      *int64     `rule:"column:int64_value"`
+	UintValue       *uint      `rule:"column:uint_value"`
+	Uint8Value      *uint8     `rule:"column:uint8_value"`
+	Uint16Value     *uint16    `rule:"column:uint16_value"`
+	Uint32Value     *uint32    `rule:"column:uint32_value"`
+	Uint64Value     *uint64    `rule:"column:uint64_value"`
+	Float32Value    *float32   `rule:"column:float32_value"`
+	Float64Value    *float64   `rule:"column:float64_value"`
+	TimeValue       *time.Time `rule:"column:time_value"`
+	BoolValue       *bool      `rule:"column:bool_value"`
+	TagStringValue  *bool      `rule:"column:string_value;type:string"`
+	TagIntValue     *string    `rule:"column:int_value;type:number"`
+	TagInt8Value    *string    `rule:"column:int8_value;type:number"`
+	TagInt16Value   *string    `rule:"column:int16_value;type:number"`
+	TagInt32Value   *string    `rule:"column:int32_value;type:number"`
+	TagInt64Value   *string    `rule:"column:int64_value;type:number"`
+	TagUintValue    *string    `rule:"column:uint_value;type:number"`
+	TagUint8Value   *string    `rule:"column:uint8_value;type:number"`
+	TagUint16Value  *string    `rule:"column:uint16_value;type:number"`
+	TagUint32Value  *string    `rule:"column:uint32_value;type:number"`
+	TagUint64Value  *string    `rule:"column:uint64_value;type:number"`
+	TagFloat32Value *string    `rule:"column:float32_value;type:number"`
+	TagFloat64Value *string    `rule:"column:float64_value;type:number"`
+	TagTimeValue    *string    `rule:"column:time_value;type:time"`
+	TagBoolValue    *string    `rule:"column:bool_value;type:bool"`
 }
 
 func (s RuleTagPointerFieldsStruct) checkFields(t *testing.T, fields []rule.Field) {
@@ -255,153 +405,303 @@ func (s RuleTagPointerFieldsStruct) checkFields(t *testing.T, fields []rule.Fiel
 
 		switch field.FieldName {
 		case "StringValue":
+			if field.ColumnName != "string_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "string_value"))
+			}
+
 			if field.Type != "string" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "IntValue":
+			if field.ColumnName != "int_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int8Value":
+			if field.ColumnName != "int8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int16Value":
+			if field.ColumnName != "int16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int32Value":
+			if field.ColumnName != "int32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Int64Value":
+			if field.ColumnName != "int64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "UintValue":
+			if field.ColumnName != "uint_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint8Value":
+			if field.ColumnName != "uint8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint16Value":
+			if field.ColumnName != "uint16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint32Value":
+			if field.ColumnName != "uint32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Uint64Value":
+			if field.ColumnName != "uint64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Float32Value":
+			if field.ColumnName != "float32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "Float64Value":
+			if field.ColumnName != "float64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TimeValue":
+			if field.ColumnName != "time_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "time" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "BoolValue":
+			if field.ColumnName != "bool_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "bool" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagStringValue":
+			if field.ColumnName != "string_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "string_value"))
+			}
+
 			if field.Type != "string" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagIntValue":
+			if field.ColumnName != "int_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt8Value":
+			if field.ColumnName != "int8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt16Value":
+			if field.ColumnName != "int16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt32Value":
+			if field.ColumnName != "int32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagInt64Value":
+			if field.ColumnName != "int64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "int64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUintValue":
+			if field.ColumnName != "uint_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint8Value":
+			if field.ColumnName != "uint8_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint8_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint16Value":
+			if field.ColumnName != "uint16_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint16_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint32Value":
+			if field.ColumnName != "uint32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagUint64Value":
+			if field.ColumnName != "uint64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "uint64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagFloat32Value":
+			if field.ColumnName != "float32_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float32_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagFloat64Value":
+			if field.ColumnName != "float64_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "number" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagTimeValue":
+			if field.ColumnName != "time_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "time" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		case "TagBoolValue":
+			if field.ColumnName != "bool_value" {
+				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual column: %v",
+					field.ColumnName, "float64_value"))
+			}
+
 			if field.Type != "bool" {
-				t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual type: %v",
+				t.Fatalf("%+v\n", errors.Errorf("类型解析测试错误: fieldName: %v, actual type: %v",
 					field.FieldName, field.Type))
 			}
 		default: