Kaynağa Gözat

删除ForDelete接口

yjp 1 yıl önce
ebeveyn
işleme
45a0189c2d

+ 7 - 11
convenient/domain/configuration/entity.go

@@ -11,10 +11,6 @@ const (
 	ColumnValue = "value"
 )
 
-const (
-	domainCNName = "配置"
-)
-
 const (
 	tableName = "configurations"
 )
@@ -32,7 +28,7 @@ type Entity struct {
 }
 
 func (e *Entity) DomainCNName() string {
-	return domainCNName
+	return "配置"
 }
 
 func (e *Entity) CheckKeyFields() error {
@@ -70,11 +66,11 @@ func (e *Entity) ForCreate() error {
 
 func (e *Entity) checkFieldScope() error {
 	if strutils.IsStringEmpty(e.Scope) {
-		return fserr.New(domainCNName + "范围为空")
+		return fserr.New(e.DomainCNName() + "范围为空")
 	}
 
 	if len(e.Scope) > fieldScopeMaxLen {
-		return fserr.New(domainCNName + "范围超出限定长度")
+		return fserr.New(e.DomainCNName() + "范围超出限定长度")
 	}
 
 	return nil
@@ -82,11 +78,11 @@ func (e *Entity) checkFieldScope() error {
 
 func (e *Entity) checkFieldGroup() error {
 	if strutils.IsStringEmpty(e.Group) {
-		return fserr.New(domainCNName + "组为空")
+		return fserr.New(e.DomainCNName() + "组为空")
 	}
 
 	if len(e.Group) > fieldGroupMaxLen {
-		return fserr.New(domainCNName + "组超出限定长度")
+		return fserr.New(e.DomainCNName() + "组超出限定长度")
 	}
 
 	return nil
@@ -94,11 +90,11 @@ func (e *Entity) checkFieldGroup() error {
 
 func (e *Entity) checkFieldValue() error {
 	if strutils.IsStringEmpty(e.Value) {
-		return fserr.New(domainCNName + "值为空")
+		return fserr.New(e.DomainCNName() + "值为空")
 	}
 
 	if len(e.Value) > fieldValueMaxLen {
-		return fserr.New(domainCNName + "值超出限定长度")
+		return fserr.New(e.DomainCNName() + "值超出限定长度")
 	}
 
 	return nil

+ 5 - 9
examples/example_domain/class/entity.go

@@ -15,10 +15,6 @@ const (
 	ColumnStudentNum = "student_num"
 )
 
-const (
-	domainCNName = "班级"
-)
-
 const (
 	fieldNameMaxLen = 128
 )
@@ -31,7 +27,7 @@ type Entity struct {
 }
 
 func (e *Entity) DomainCNName() string {
-	return domainCNName
+	return "班级"
 }
 
 func (e *Entity) ForCreate() error {
@@ -64,11 +60,11 @@ func (e *Entity) ForUpdate() error {
 
 func (e *Entity) checkFieldName() error {
 	if strutils.IsStringEmpty(e.Name) {
-		return fserr.New(domainCNName + "名称为空")
+		return fserr.New(e.DomainCNName() + "名称为空")
 	}
 
 	if len(e.Name) > fieldNameMaxLen {
-		return fserr.New(domainCNName + "名称超出限定长度")
+		return fserr.New(e.DomainCNName() + "名称超出限定长度")
 	}
 
 	return nil
@@ -76,11 +72,11 @@ func (e *Entity) checkFieldName() error {
 
 func (e *Entity) checkUpdateFields() error {
 	if strutils.AllBlank(e.Name) {
-		return fserr.New(domainCNName + "没有传递需要更新的字段")
+		return fserr.New(e.DomainCNName() + "没有传递需要更新的字段")
 	}
 
 	if strutils.IsStringNotEmpty(e.Name) && len(e.Name) > fieldNameMaxLen {
-		return fserr.New(domainCNName + "名称超出限定长度")
+		return fserr.New(e.DomainCNName() + "名称超出限定长度")
 	}
 
 	return nil

+ 7 - 11
examples/example_domain/configuration/entity.go

@@ -15,10 +15,6 @@ const (
 	ColumnValue = "value"
 )
 
-const (
-	domainCNName = "配置"
-)
-
 const (
 	fieldScopeMaxLen = 256
 	fieldGroupMaxLen = 256
@@ -32,7 +28,7 @@ type Entity struct {
 }
 
 func (e *Entity) DomainCNName() string {
-	return domainCNName
+	return "配置"
 }
 
 func (e *Entity) CheckKeyFields() error {
@@ -70,11 +66,11 @@ func (e *Entity) ForCreate() error {
 
 func (e *Entity) checkFieldScope() error {
 	if strutils.IsStringEmpty(e.Scope) {
-		return fserr.New(domainCNName + "范围为空")
+		return fserr.New(e.DomainCNName() + "范围为空")
 	}
 
 	if len(e.Scope) > fieldScopeMaxLen {
-		return fserr.New(domainCNName + "范围超出限定长度")
+		return fserr.New(e.DomainCNName() + "范围超出限定长度")
 	}
 
 	return nil
@@ -82,11 +78,11 @@ func (e *Entity) checkFieldScope() error {
 
 func (e *Entity) checkFieldGroup() error {
 	if strutils.IsStringEmpty(e.Group) {
-		return fserr.New(domainCNName + "组为空")
+		return fserr.New(e.DomainCNName() + "组为空")
 	}
 
 	if len(e.Group) > fieldGroupMaxLen {
-		return fserr.New(domainCNName + "组超出限定长度")
+		return fserr.New(e.DomainCNName() + "组超出限定长度")
 	}
 
 	return nil
@@ -94,11 +90,11 @@ func (e *Entity) checkFieldGroup() error {
 
 func (e *Entity) checkFieldValue() error {
 	if strutils.IsStringEmpty(e.Value) {
-		return fserr.New(domainCNName + "值为空")
+		return fserr.New(e.DomainCNName() + "值为空")
 	}
 
 	if len(e.Value) > fieldValueMaxLen {
-		return fserr.New(domainCNName + "值超出限定长度")
+		return fserr.New(e.DomainCNName() + "值超出限定长度")
 	}
 
 	return nil