Ver Fonte

修改bug

yjp há 1 ano atrás
pai
commit
284dc16124
1 ficheiros alterados com 25 adições e 0 exclusões
  1. 25 0
      framework/core/domain/entity/field.go

+ 25 - 0
framework/core/domain/entity/field.go

@@ -55,6 +55,22 @@ func CheckFieldLastUpdateUserID(entity Entity) error {
 	return checkIDTypeField(entity, FieldLastUpdateUserID, "最近更新用户ID")
 }
 
+func CheckFieldIDResult(checkResult check.Result) error {
+	return checkIDTypeResult(checkResult, FieldID, "ID")
+}
+
+func CheckFieldTenantIDResult(checkResult check.Result) error {
+	return checkIDTypeResult(checkResult, FieldTenantID, "租户ID")
+}
+
+func CheckFieldCreateUserIDResult(checkResult check.Result) error {
+	return checkIDTypeResult(checkResult, FieldCreateUserID, "创建用户ID")
+}
+
+func CheckFieldLastUpdateUserIDResult(checkResult check.Result) error {
+	return checkIDTypeResult(checkResult, FieldLastUpdateUserID, "最近更新用户ID")
+}
+
 func checkIDTypeField(entity Entity, fieldName string, fieldCNName string) error {
 	checkResult := check.Struct(entity, map[string]string{
 		fieldName: entity.DomainCNName() + fieldCNName,
@@ -68,6 +84,15 @@ func checkIDTypeField(entity Entity, fieldName string, fieldCNName string) error
 	return nil
 }
 
+func checkIDTypeResult(checkResult check.Result, domainCNName string, fieldName string) error {
+	err := checkResult.CheckFields(fieldName)
+	if err != nil {
+		return errors.New(domainCNName + ": " + err.Error())
+	}
+
+	return nil
+}
+
 const (
 	idLen = 32
 )