|
|
@@ -1,101 +0,0 @@
|
|
|
-package configuration
|
|
|
-
|
|
|
-import (
|
|
|
- "git.sxidc.com/go-tools/utils/strutils"
|
|
|
- "git.sxidc.com/service-supports/fserr"
|
|
|
-)
|
|
|
-
|
|
|
-const (
|
|
|
- ColumnScope = "scope"
|
|
|
- ColumnGroup = "group"
|
|
|
- ColumnValue = "value"
|
|
|
-)
|
|
|
-
|
|
|
-const (
|
|
|
- fieldScopeMaxLen = 256
|
|
|
- fieldGroupMaxLen = 256
|
|
|
- fieldValueMaxLen = 256
|
|
|
-)
|
|
|
-
|
|
|
-type ValueObject 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;"`
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) DomainCNName() string {
|
|
|
- return "配置"
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) DomainCamelName() string {
|
|
|
- return "Configuration"
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) CheckKeyFields() error {
|
|
|
- err := valueObject.checkFieldScope()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- err = valueObject.checkFieldGroup()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) ForCreate() error {
|
|
|
- err := valueObject.checkFieldScope()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- err = valueObject.checkFieldGroup()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- err = valueObject.checkFieldValue()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) checkFieldScope() error {
|
|
|
- if strutils.IsStringEmpty(valueObject.Scope) {
|
|
|
- return fserr.New(valueObject.DomainCNName() + "范围为空")
|
|
|
- }
|
|
|
-
|
|
|
- if len(valueObject.Scope) > fieldScopeMaxLen {
|
|
|
- return fserr.New(valueObject.DomainCNName() + "范围超出限定长度")
|
|
|
- }
|
|
|
-
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) checkFieldGroup() error {
|
|
|
- if strutils.IsStringEmpty(valueObject.Group) {
|
|
|
- return fserr.New(valueObject.DomainCNName() + "组为空")
|
|
|
- }
|
|
|
-
|
|
|
- if len(valueObject.Group) > fieldGroupMaxLen {
|
|
|
- return fserr.New(valueObject.DomainCNName() + "组超出限定长度")
|
|
|
- }
|
|
|
-
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (valueObject *ValueObject) checkFieldValue() error {
|
|
|
- if strutils.IsStringEmpty(valueObject.Value) {
|
|
|
- return fserr.New(valueObject.DomainCNName() + "值为空")
|
|
|
- }
|
|
|
-
|
|
|
- if len(valueObject.Value) > fieldValueMaxLen {
|
|
|
- return fserr.New(valueObject.DomainCNName() + "值超出限定长度")
|
|
|
- }
|
|
|
-
|
|
|
- return nil
|
|
|
-}
|