Browse Source

取消数字员工个字段内容长度限制

boweniac 3 months ago
parent
commit
50f05cf768
7 changed files with 18 additions and 132 deletions
  1. 0 12
      ent/employee/employee.go
  2. 0 30
      ent/employee_create.go
  3. 0 60
      ent/employee_update.go
  4. 7 7
      ent/migrate/schema.go
  5. 0 16
      ent/runtime/runtime.go
  6. 7 7
      ent/schema/employee.go
  7. 4 0
      go.sum

+ 0 - 12
ent/employee/employee.go

@@ -137,10 +137,6 @@ var (
 	UpdateDefaultUpdatedAt func() time.Time
 	// TitleValidator is a validator for the "title" field. It is called by the builders before save.
 	TitleValidator func(string) error
-	// AvatarValidator is a validator for the "avatar" field. It is called by the builders before save.
-	AvatarValidator func(string) error
-	// TagsValidator is a validator for the "tags" field. It is called by the builders before save.
-	TagsValidator func(string) error
 	// DefaultHireCount holds the default value on creation for the "hire_count" field.
 	DefaultHireCount int
 	// HireCountValidator is a validator for the "hire_count" field. It is called by the builders before save.
@@ -155,16 +151,10 @@ var (
 	AchievementCountValidator func(int) error
 	// DefaultIntro holds the default value on creation for the "intro" field.
 	DefaultIntro string
-	// IntroValidator is a validator for the "intro" field. It is called by the builders before save.
-	IntroValidator func(string) error
 	// DefaultEstimate holds the default value on creation for the "estimate" field.
 	DefaultEstimate string
-	// EstimateValidator is a validator for the "estimate" field. It is called by the builders before save.
-	EstimateValidator func(string) error
 	// DefaultSkill holds the default value on creation for the "skill" field.
 	DefaultSkill string
-	// SkillValidator is a validator for the "skill" field. It is called by the builders before save.
-	SkillValidator func(string) error
 	// DefaultAbilityType holds the default value on creation for the "ability_type" field.
 	DefaultAbilityType string
 	// DefaultScene holds the default value on creation for the "scene" field.
@@ -173,8 +163,6 @@ var (
 	DefaultSwitchIn string
 	// DefaultVideoURL holds the default value on creation for the "video_url" field.
 	DefaultVideoURL string
-	// VideoURLValidator is a validator for the "video_url" field. It is called by the builders before save.
-	VideoURLValidator func(string) error
 	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	OrganizationIDValidator func(uint64) error
 	// CategoryIDValidator is a validator for the "category_id" field. It is called by the builders before save.

+ 0 - 30
ent/employee_create.go

@@ -459,19 +459,9 @@ func (ec *EmployeeCreate) check() error {
 	if _, ok := ec.mutation.Avatar(); !ok {
 		return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "Employee.avatar"`)}
 	}
-	if v, ok := ec.mutation.Avatar(); ok {
-		if err := employee.AvatarValidator(v); err != nil {
-			return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
-		}
-	}
 	if _, ok := ec.mutation.Tags(); !ok {
 		return &ValidationError{Name: "tags", err: errors.New(`ent: missing required field "Employee.tags"`)}
 	}
-	if v, ok := ec.mutation.Tags(); ok {
-		if err := employee.TagsValidator(v); err != nil {
-			return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
-		}
-	}
 	if _, ok := ec.mutation.HireCount(); !ok {
 		return &ValidationError{Name: "hire_count", err: errors.New(`ent: missing required field "Employee.hire_count"`)}
 	}
@@ -499,27 +489,12 @@ func (ec *EmployeeCreate) check() error {
 	if _, ok := ec.mutation.Intro(); !ok {
 		return &ValidationError{Name: "intro", err: errors.New(`ent: missing required field "Employee.intro"`)}
 	}
-	if v, ok := ec.mutation.Intro(); ok {
-		if err := employee.IntroValidator(v); err != nil {
-			return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
-		}
-	}
 	if _, ok := ec.mutation.Estimate(); !ok {
 		return &ValidationError{Name: "estimate", err: errors.New(`ent: missing required field "Employee.estimate"`)}
 	}
-	if v, ok := ec.mutation.Estimate(); ok {
-		if err := employee.EstimateValidator(v); err != nil {
-			return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
-		}
-	}
 	if _, ok := ec.mutation.Skill(); !ok {
 		return &ValidationError{Name: "skill", err: errors.New(`ent: missing required field "Employee.skill"`)}
 	}
-	if v, ok := ec.mutation.Skill(); ok {
-		if err := employee.SkillValidator(v); err != nil {
-			return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
-		}
-	}
 	if _, ok := ec.mutation.AbilityType(); !ok {
 		return &ValidationError{Name: "ability_type", err: errors.New(`ent: missing required field "Employee.ability_type"`)}
 	}
@@ -532,11 +507,6 @@ func (ec *EmployeeCreate) check() error {
 	if _, ok := ec.mutation.VideoURL(); !ok {
 		return &ValidationError{Name: "video_url", err: errors.New(`ent: missing required field "Employee.video_url"`)}
 	}
-	if v, ok := ec.mutation.VideoURL(); ok {
-		if err := employee.VideoURLValidator(v); err != nil {
-			return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
-		}
-	}
 	if _, ok := ec.mutation.OrganizationID(); !ok {
 		return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Employee.organization_id"`)}
 	}

+ 0 - 60
ent/employee_update.go

@@ -510,16 +510,6 @@ func (eu *EmployeeUpdate) check() error {
 			return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Employee.title": %w`, err)}
 		}
 	}
-	if v, ok := eu.mutation.Avatar(); ok {
-		if err := employee.AvatarValidator(v); err != nil {
-			return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
-		}
-	}
-	if v, ok := eu.mutation.Tags(); ok {
-		if err := employee.TagsValidator(v); err != nil {
-			return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
-		}
-	}
 	if v, ok := eu.mutation.HireCount(); ok {
 		if err := employee.HireCountValidator(v); err != nil {
 			return &ValidationError{Name: "hire_count", err: fmt.Errorf(`ent: validator failed for field "Employee.hire_count": %w`, err)}
@@ -535,26 +525,6 @@ func (eu *EmployeeUpdate) check() error {
 			return &ValidationError{Name: "achievement_count", err: fmt.Errorf(`ent: validator failed for field "Employee.achievement_count": %w`, err)}
 		}
 	}
-	if v, ok := eu.mutation.Intro(); ok {
-		if err := employee.IntroValidator(v); err != nil {
-			return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
-		}
-	}
-	if v, ok := eu.mutation.Estimate(); ok {
-		if err := employee.EstimateValidator(v); err != nil {
-			return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
-		}
-	}
-	if v, ok := eu.mutation.Skill(); ok {
-		if err := employee.SkillValidator(v); err != nil {
-			return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
-		}
-	}
-	if v, ok := eu.mutation.VideoURL(); ok {
-		if err := employee.VideoURLValidator(v); err != nil {
-			return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
-		}
-	}
 	if v, ok := eu.mutation.OrganizationID(); ok {
 		if err := employee.OrganizationIDValidator(v); err != nil {
 			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Employee.organization_id": %w`, err)}
@@ -1273,16 +1243,6 @@ func (euo *EmployeeUpdateOne) check() error {
 			return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Employee.title": %w`, err)}
 		}
 	}
-	if v, ok := euo.mutation.Avatar(); ok {
-		if err := employee.AvatarValidator(v); err != nil {
-			return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
-		}
-	}
-	if v, ok := euo.mutation.Tags(); ok {
-		if err := employee.TagsValidator(v); err != nil {
-			return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
-		}
-	}
 	if v, ok := euo.mutation.HireCount(); ok {
 		if err := employee.HireCountValidator(v); err != nil {
 			return &ValidationError{Name: "hire_count", err: fmt.Errorf(`ent: validator failed for field "Employee.hire_count": %w`, err)}
@@ -1298,26 +1258,6 @@ func (euo *EmployeeUpdateOne) check() error {
 			return &ValidationError{Name: "achievement_count", err: fmt.Errorf(`ent: validator failed for field "Employee.achievement_count": %w`, err)}
 		}
 	}
-	if v, ok := euo.mutation.Intro(); ok {
-		if err := employee.IntroValidator(v); err != nil {
-			return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
-		}
-	}
-	if v, ok := euo.mutation.Estimate(); ok {
-		if err := employee.EstimateValidator(v); err != nil {
-			return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
-		}
-	}
-	if v, ok := euo.mutation.Skill(); ok {
-		if err := employee.SkillValidator(v); err != nil {
-			return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
-		}
-	}
-	if v, ok := euo.mutation.VideoURL(); ok {
-		if err := employee.VideoURLValidator(v); err != nil {
-			return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
-		}
-	}
 	if v, ok := euo.mutation.OrganizationID(); ok {
 		if err := employee.OrganizationIDValidator(v); err != nil {
 			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Employee.organization_id": %w`, err)}

+ 7 - 7
ent/migrate/schema.go

@@ -260,19 +260,19 @@ var (
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
 		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
-		{Name: "title", Type: field.TypeString, Size: 255, Comment: "title | 标题"},
-		{Name: "avatar", Type: field.TypeString, Size: 1000, Comment: "avatar | 头像"},
-		{Name: "tags", Type: field.TypeString, Size: 255, Comment: "tags | 个人标签"},
+		{Name: "title", Type: field.TypeString, Size: 1000, Comment: "title | 标题"},
+		{Name: "avatar", Type: field.TypeString, Comment: "avatar | 头像"},
+		{Name: "tags", Type: field.TypeString, Comment: "tags | 个人标签"},
 		{Name: "hire_count", Type: field.TypeInt, Comment: "hire_count | 被雇佣次数", Default: 0},
 		{Name: "service_count", Type: field.TypeInt, Comment: "service_count | 已服务次数", Default: 0},
 		{Name: "achievement_count", Type: field.TypeInt, Comment: "achievement_count | 业绩单数", Default: 0},
-		{Name: "intro", Type: field.TypeString, Size: 1000, Comment: "intro | 个人介绍", Default: ""},
-		{Name: "estimate", Type: field.TypeString, Size: 1000, Comment: "estimate | 自我评价", Default: ""},
-		{Name: "skill", Type: field.TypeString, Size: 1000, Comment: "skill | 技能卡", Default: ""},
+		{Name: "intro", Type: field.TypeString, Comment: "intro | 个人介绍", Default: ""},
+		{Name: "estimate", Type: field.TypeString, Comment: "estimate | 自我评价", Default: ""},
+		{Name: "skill", Type: field.TypeString, Comment: "skill | 技能卡", Default: ""},
 		{Name: "ability_type", Type: field.TypeString, Comment: "ability_type | 能力类型", Default: ""},
 		{Name: "scene", Type: field.TypeString, Comment: "scene | 使用场景", Default: ""},
 		{Name: "switch_in", Type: field.TypeString, Comment: "switch_in | 支持介入", Default: ""},
-		{Name: "video_url", Type: field.TypeString, Size: 1000, Comment: "video_url | 视频地址", Default: ""},
+		{Name: "video_url", Type: field.TypeString, Comment: "video_url | 视频地址", Default: ""},
 		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
 		{Name: "category_id", Type: field.TypeUint64, Comment: "category_id | 分类ID"},
 		{Name: "api_base", Type: field.TypeString, Comment: "api_base", Default: ""},

+ 0 - 16
ent/runtime/runtime.go

@@ -391,14 +391,6 @@ func init() {
 	employeeDescTitle := employeeFields[0].Descriptor()
 	// employee.TitleValidator is a validator for the "title" field. It is called by the builders before save.
 	employee.TitleValidator = employeeDescTitle.Validators[0].(func(string) error)
-	// employeeDescAvatar is the schema descriptor for avatar field.
-	employeeDescAvatar := employeeFields[1].Descriptor()
-	// employee.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save.
-	employee.AvatarValidator = employeeDescAvatar.Validators[0].(func(string) error)
-	// employeeDescTags is the schema descriptor for tags field.
-	employeeDescTags := employeeFields[2].Descriptor()
-	// employee.TagsValidator is a validator for the "tags" field. It is called by the builders before save.
-	employee.TagsValidator = employeeDescTags.Validators[0].(func(string) error)
 	// employeeDescHireCount is the schema descriptor for hire_count field.
 	employeeDescHireCount := employeeFields[3].Descriptor()
 	// employee.DefaultHireCount holds the default value on creation for the hire_count field.
@@ -421,20 +413,14 @@ func init() {
 	employeeDescIntro := employeeFields[6].Descriptor()
 	// employee.DefaultIntro holds the default value on creation for the intro field.
 	employee.DefaultIntro = employeeDescIntro.Default.(string)
-	// employee.IntroValidator is a validator for the "intro" field. It is called by the builders before save.
-	employee.IntroValidator = employeeDescIntro.Validators[0].(func(string) error)
 	// employeeDescEstimate is the schema descriptor for estimate field.
 	employeeDescEstimate := employeeFields[7].Descriptor()
 	// employee.DefaultEstimate holds the default value on creation for the estimate field.
 	employee.DefaultEstimate = employeeDescEstimate.Default.(string)
-	// employee.EstimateValidator is a validator for the "estimate" field. It is called by the builders before save.
-	employee.EstimateValidator = employeeDescEstimate.Validators[0].(func(string) error)
 	// employeeDescSkill is the schema descriptor for skill field.
 	employeeDescSkill := employeeFields[8].Descriptor()
 	// employee.DefaultSkill holds the default value on creation for the skill field.
 	employee.DefaultSkill = employeeDescSkill.Default.(string)
-	// employee.SkillValidator is a validator for the "skill" field. It is called by the builders before save.
-	employee.SkillValidator = employeeDescSkill.Validators[0].(func(string) error)
 	// employeeDescAbilityType is the schema descriptor for ability_type field.
 	employeeDescAbilityType := employeeFields[9].Descriptor()
 	// employee.DefaultAbilityType holds the default value on creation for the ability_type field.
@@ -451,8 +437,6 @@ func init() {
 	employeeDescVideoURL := employeeFields[12].Descriptor()
 	// employee.DefaultVideoURL holds the default value on creation for the video_url field.
 	employee.DefaultVideoURL = employeeDescVideoURL.Default.(string)
-	// employee.VideoURLValidator is a validator for the "video_url" field. It is called by the builders before save.
-	employee.VideoURLValidator = employeeDescVideoURL.Validators[0].(func(string) error)
 	// employeeDescOrganizationID is the schema descriptor for organization_id field.
 	employeeDescOrganizationID := employeeFields[13].Descriptor()
 	// employee.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.

+ 7 - 7
ent/schema/employee.go

@@ -18,19 +18,19 @@ type Employee struct {
 
 func (Employee) Fields() []ent.Field {
 	return []ent.Field{
-		field.String("title").MaxLen(255).Comment("title | 标题"),
-		field.String("avatar").MaxLen(1000).Comment("avatar | 头像"),
-		field.String("tags").MaxLen(255).Comment("tags | 个人标签"),
+		field.String("title").MaxLen(1000).Comment("title | 标题"),
+		field.String("avatar").Comment("avatar | 头像"),
+		field.String("tags").Comment("tags | 个人标签"),
 		field.Int("hire_count").Positive().Default(0).Comment("hire_count | 被雇佣次数"),
 		field.Int("service_count").Positive().Default(0).Comment("service_count | 已服务次数"),
 		field.Int("achievement_count").Positive().Default(0).Comment("achievement_count | 业绩单数"),
-		field.String("intro").MaxLen(1000).Default("").Comment("intro | 个人介绍"),
-		field.String("estimate").MaxLen(1000).Default("").Comment("estimate | 自我评价"),
-		field.String("skill").MaxLen(1000).Default("").Comment("skill | 技能卡"),
+		field.String("intro").Default("").Comment("intro | 个人介绍"),
+		field.String("estimate").Default("").Comment("estimate | 自我评价"),
+		field.String("skill").Default("").Comment("skill | 技能卡"),
 		field.String("ability_type").Default("").Comment("ability_type | 能力类型"),
 		field.String("scene").Default("").Comment("scene | 使用场景"),
 		field.String("switch_in").Default("").Comment("switch_in | 支持介入"),
-		field.String("video_url").MaxLen(1000).Default("").Comment("video_url | 视频地址"),
+		field.String("video_url").Default("").Comment("video_url | 视频地址"),
 		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
 		field.Uint64("category_id").Positive().Comment("category_id | 分类ID"),
 		field.String("api_base").Default("").Comment("api_base"),

+ 4 - 0
go.sum

@@ -445,6 +445,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
 github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
@@ -478,6 +479,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
 github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
 github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
@@ -576,6 +578,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
 github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
+github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
+github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=