|
|
@@ -10,6 +10,7 @@ const (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
+ ColumnScope = "scope"
|
|
|
ColumnGroup = "group"
|
|
|
ColumnValue = "value"
|
|
|
)
|
|
|
@@ -19,11 +20,13 @@ const (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
+ fieldScopeMaxLen = 256
|
|
|
fieldGroupMaxLen = 256
|
|
|
fieldValueMaxLen = 256
|
|
|
)
|
|
|
|
|
|
type Entity struct {
|
|
|
+ Scope string `sqlmapping:"column:scope;key;notUpdate;" sqlresult:"column:group;"`
|
|
|
Group string `sqlmapping:"column:group;key;notUpdate;" sqlresult:"column:group;"`
|
|
|
Value string `sqlmapping:"column:value;notUpdate;" sqlresult:"column:value;"`
|
|
|
}
|
|
|
@@ -33,11 +36,26 @@ func (e *Entity) DomainCNName() string {
|
|
|
}
|
|
|
|
|
|
func (e *Entity) CheckKeyFields() error {
|
|
|
- return e.checkFieldGroup()
|
|
|
+ err := e.checkFieldScope()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ err = e.checkFieldGroup()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
func (e *Entity) ForCreate() error {
|
|
|
- err := e.checkFieldGroup()
|
|
|
+ err := e.checkFieldScope()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ err = e.checkFieldGroup()
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -50,6 +68,18 @@ func (e *Entity) ForCreate() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+func (e *Entity) checkFieldScope() error {
|
|
|
+ if strutils.IsStringEmpty(e.Scope) {
|
|
|
+ return fserr.New(domainCNName + "范围为空")
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(e.Scope) > fieldScopeMaxLen {
|
|
|
+ return fserr.New(domainCNName + "范围超出限定长度")
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func (e *Entity) checkFieldGroup() error {
|
|
|
if strutils.IsStringEmpty(e.Group) {
|
|
|
return fserr.New(domainCNName + "组为空")
|
|
|
@@ -67,7 +97,7 @@ func (e *Entity) checkFieldValue() error {
|
|
|
return fserr.New(domainCNName + "值为空")
|
|
|
}
|
|
|
|
|
|
- if len([]byte(e.Value)) > fieldValueMaxLen {
|
|
|
+ if len(e.Value) > fieldValueMaxLen {
|
|
|
return fserr.New(domainCNName + "值超出限定长度")
|
|
|
}
|
|
|
|