Jelajahi Sumber

增加控制频率的字段

lichangdong 1 Minggu lalu
induk
melakukan
5e816d07be

+ 13 - 2
ent/addwechatfriendlog.go

@@ -30,8 +30,10 @@ type AddWechatFriendLog struct {
 	FindRequest map[string]interface{} `json:"find_request,omitempty"`
 	// 查询返回结果
 	FindResult map[string]interface{} `json:"find_result,omitempty"`
-	// 是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以)
+	// 任务执行次数
 	IsCanAdd int `json:"is_can_add,omitempty"`
+	// 是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以 2成功添加申请)
+	TaskCount int `json:"task_count,omitempty"`
 	// 添加时候的请求体
 	TaskID int64 `json:"task_id,omitempty"`
 	// 添加时候的请求体
@@ -52,7 +54,7 @@ func (*AddWechatFriendLog) scanValues(columns []string) ([]any, error) {
 		switch columns[i] {
 		case addwechatfriendlog.FieldFindRequest, addwechatfriendlog.FieldFindResult, addwechatfriendlog.FieldAddRequest, addwechatfriendlog.FieldAddResult:
 			values[i] = new([]byte)
-		case addwechatfriendlog.FieldID, addwechatfriendlog.FieldOwnerWxType, addwechatfriendlog.FieldIsCanAdd, addwechatfriendlog.FieldTaskID, addwechatfriendlog.FieldCreatedAt, addwechatfriendlog.FieldUpdatedAt:
+		case addwechatfriendlog.FieldID, addwechatfriendlog.FieldOwnerWxType, addwechatfriendlog.FieldIsCanAdd, addwechatfriendlog.FieldTaskCount, addwechatfriendlog.FieldTaskID, addwechatfriendlog.FieldCreatedAt, addwechatfriendlog.FieldUpdatedAt:
 			values[i] = new(sql.NullInt64)
 		case addwechatfriendlog.FieldOwnerWxID, addwechatfriendlog.FieldFindContent, addwechatfriendlog.FieldMessage:
 			values[i] = new(sql.NullString)
@@ -123,6 +125,12 @@ func (awfl *AddWechatFriendLog) assignValues(columns []string, values []any) err
 			} else if value.Valid {
 				awfl.IsCanAdd = int(value.Int64)
 			}
+		case addwechatfriendlog.FieldTaskCount:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field task_count", values[i])
+			} else if value.Valid {
+				awfl.TaskCount = int(value.Int64)
+			}
 		case addwechatfriendlog.FieldTaskID:
 			if value, ok := values[i].(*sql.NullInt64); !ok {
 				return fmt.Errorf("unexpected type %T for field task_id", values[i])
@@ -214,6 +222,9 @@ func (awfl *AddWechatFriendLog) String() string {
 	builder.WriteString("is_can_add=")
 	builder.WriteString(fmt.Sprintf("%v", awfl.IsCanAdd))
 	builder.WriteString(", ")
+	builder.WriteString("task_count=")
+	builder.WriteString(fmt.Sprintf("%v", awfl.TaskCount))
+	builder.WriteString(", ")
 	builder.WriteString("task_id=")
 	builder.WriteString(fmt.Sprintf("%v", awfl.TaskID))
 	builder.WriteString(", ")

+ 10 - 0
ent/addwechatfriendlog/addwechatfriendlog.go

@@ -25,6 +25,8 @@ const (
 	FieldFindResult = "find_result"
 	// FieldIsCanAdd holds the string denoting the is_can_add field in the database.
 	FieldIsCanAdd = "is_can_add"
+	// FieldTaskCount holds the string denoting the task_count field in the database.
+	FieldTaskCount = "task_count"
 	// FieldTaskID holds the string denoting the task_id field in the database.
 	FieldTaskID = "task_id"
 	// FieldAddRequest holds the string denoting the add_request field in the database.
@@ -49,6 +51,7 @@ var Columns = []string{
 	FieldFindRequest,
 	FieldFindResult,
 	FieldIsCanAdd,
+	FieldTaskCount,
 	FieldTaskID,
 	FieldAddRequest,
 	FieldAddResult,
@@ -83,6 +86,8 @@ var (
 	MessageValidator func(string) error
 	// DefaultIsCanAdd holds the default value on creation for the "is_can_add" field.
 	DefaultIsCanAdd int
+	// DefaultTaskCount holds the default value on creation for the "task_count" field.
+	DefaultTaskCount int
 	// DefaultTaskID holds the default value on creation for the "task_id" field.
 	DefaultTaskID int64
 	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
@@ -126,6 +131,11 @@ func ByIsCanAdd(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldIsCanAdd, opts...).ToFunc()
 }
 
+// ByTaskCount orders the results by the task_count field.
+func ByTaskCount(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldTaskCount, opts...).ToFunc()
+}
+
 // ByTaskID orders the results by the task_id field.
 func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldTaskID, opts...).ToFunc()

+ 45 - 0
ent/addwechatfriendlog/where.go

@@ -78,6 +78,11 @@ func IsCanAdd(v int) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldIsCanAdd, v))
 }
 
+// TaskCount applies equality check predicate on the "task_count" field. It's identical to TaskCountEQ.
+func TaskCount(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldTaskCount, v))
+}
+
 // TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ.
 func TaskID(v int64) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldTaskID, v))
@@ -388,6 +393,46 @@ func IsCanAddLTE(v int) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldIsCanAdd, v))
 }
 
+// TaskCountEQ applies the EQ predicate on the "task_count" field.
+func TaskCountEQ(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldTaskCount, v))
+}
+
+// TaskCountNEQ applies the NEQ predicate on the "task_count" field.
+func TaskCountNEQ(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNEQ(FieldTaskCount, v))
+}
+
+// TaskCountIn applies the In predicate on the "task_count" field.
+func TaskCountIn(vs ...int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIn(FieldTaskCount, vs...))
+}
+
+// TaskCountNotIn applies the NotIn predicate on the "task_count" field.
+func TaskCountNotIn(vs ...int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotIn(FieldTaskCount, vs...))
+}
+
+// TaskCountGT applies the GT predicate on the "task_count" field.
+func TaskCountGT(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGT(FieldTaskCount, v))
+}
+
+// TaskCountGTE applies the GTE predicate on the "task_count" field.
+func TaskCountGTE(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGTE(FieldTaskCount, v))
+}
+
+// TaskCountLT applies the LT predicate on the "task_count" field.
+func TaskCountLT(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLT(FieldTaskCount, v))
+}
+
+// TaskCountLTE applies the LTE predicate on the "task_count" field.
+func TaskCountLTE(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldTaskCount, v))
+}
+
 // TaskIDEQ applies the EQ predicate on the "task_id" field.
 func TaskIDEQ(v int64) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldTaskID, v))

+ 85 - 0
ent/addwechatfriendlog_create.go

@@ -103,6 +103,20 @@ func (awflc *AddWechatFriendLogCreate) SetNillableIsCanAdd(i *int) *AddWechatFri
 	return awflc
 }
 
+// SetTaskCount sets the "task_count" field.
+func (awflc *AddWechatFriendLogCreate) SetTaskCount(i int) *AddWechatFriendLogCreate {
+	awflc.mutation.SetTaskCount(i)
+	return awflc
+}
+
+// SetNillableTaskCount sets the "task_count" field if the given value is not nil.
+func (awflc *AddWechatFriendLogCreate) SetNillableTaskCount(i *int) *AddWechatFriendLogCreate {
+	if i != nil {
+		awflc.SetTaskCount(*i)
+	}
+	return awflc
+}
+
 // SetTaskID sets the "task_id" field.
 func (awflc *AddWechatFriendLogCreate) SetTaskID(i int64) *AddWechatFriendLogCreate {
 	awflc.mutation.SetTaskID(i)
@@ -218,6 +232,10 @@ func (awflc *AddWechatFriendLogCreate) defaults() {
 		v := addwechatfriendlog.DefaultIsCanAdd
 		awflc.mutation.SetIsCanAdd(v)
 	}
+	if _, ok := awflc.mutation.TaskCount(); !ok {
+		v := addwechatfriendlog.DefaultTaskCount
+		awflc.mutation.SetTaskCount(v)
+	}
 	if _, ok := awflc.mutation.TaskID(); !ok {
 		v := addwechatfriendlog.DefaultTaskID
 		awflc.mutation.SetTaskID(v)
@@ -264,6 +282,9 @@ func (awflc *AddWechatFriendLogCreate) check() error {
 	if _, ok := awflc.mutation.IsCanAdd(); !ok {
 		return &ValidationError{Name: "is_can_add", err: errors.New(`ent: missing required field "AddWechatFriendLog.is_can_add"`)}
 	}
+	if _, ok := awflc.mutation.TaskCount(); !ok {
+		return &ValidationError{Name: "task_count", err: errors.New(`ent: missing required field "AddWechatFriendLog.task_count"`)}
+	}
 	if _, ok := awflc.mutation.TaskID(); !ok {
 		return &ValidationError{Name: "task_id", err: errors.New(`ent: missing required field "AddWechatFriendLog.task_id"`)}
 	}
@@ -334,6 +355,10 @@ func (awflc *AddWechatFriendLogCreate) createSpec() (*AddWechatFriendLog, *sqlgr
 		_spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
 		_node.IsCanAdd = value
 	}
+	if value, ok := awflc.mutation.TaskCount(); ok {
+		_spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
+		_node.TaskCount = value
+	}
 	if value, ok := awflc.mutation.TaskID(); ok {
 		_spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
 		_node.TaskID = value
@@ -514,6 +539,24 @@ func (u *AddWechatFriendLogUpsert) AddIsCanAdd(v int) *AddWechatFriendLogUpsert
 	return u
 }
 
+// SetTaskCount sets the "task_count" field.
+func (u *AddWechatFriendLogUpsert) SetTaskCount(v int) *AddWechatFriendLogUpsert {
+	u.Set(addwechatfriendlog.FieldTaskCount, v)
+	return u
+}
+
+// UpdateTaskCount sets the "task_count" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsert) UpdateTaskCount() *AddWechatFriendLogUpsert {
+	u.SetExcluded(addwechatfriendlog.FieldTaskCount)
+	return u
+}
+
+// AddTaskCount adds v to the "task_count" field.
+func (u *AddWechatFriendLogUpsert) AddTaskCount(v int) *AddWechatFriendLogUpsert {
+	u.Add(addwechatfriendlog.FieldTaskCount, v)
+	return u
+}
+
 // SetTaskID sets the "task_id" field.
 func (u *AddWechatFriendLogUpsert) SetTaskID(v int64) *AddWechatFriendLogUpsert {
 	u.Set(addwechatfriendlog.FieldTaskID, v)
@@ -778,6 +821,27 @@ func (u *AddWechatFriendLogUpsertOne) UpdateIsCanAdd() *AddWechatFriendLogUpsert
 	})
 }
 
+// SetTaskCount sets the "task_count" field.
+func (u *AddWechatFriendLogUpsertOne) SetTaskCount(v int) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetTaskCount(v)
+	})
+}
+
+// AddTaskCount adds v to the "task_count" field.
+func (u *AddWechatFriendLogUpsertOne) AddTaskCount(v int) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.AddTaskCount(v)
+	})
+}
+
+// UpdateTaskCount sets the "task_count" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertOne) UpdateTaskCount() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateTaskCount()
+	})
+}
+
 // SetTaskID sets the "task_id" field.
 func (u *AddWechatFriendLogUpsertOne) SetTaskID(v int64) *AddWechatFriendLogUpsertOne {
 	return u.Update(func(s *AddWechatFriendLogUpsert) {
@@ -1223,6 +1287,27 @@ func (u *AddWechatFriendLogUpsertBulk) UpdateIsCanAdd() *AddWechatFriendLogUpser
 	})
 }
 
+// SetTaskCount sets the "task_count" field.
+func (u *AddWechatFriendLogUpsertBulk) SetTaskCount(v int) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetTaskCount(v)
+	})
+}
+
+// AddTaskCount adds v to the "task_count" field.
+func (u *AddWechatFriendLogUpsertBulk) AddTaskCount(v int) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.AddTaskCount(v)
+	})
+}
+
+// UpdateTaskCount sets the "task_count" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertBulk) UpdateTaskCount() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateTaskCount()
+	})
+}
+
 // SetTaskID sets the "task_id" field.
 func (u *AddWechatFriendLogUpsertBulk) SetTaskID(v int64) *AddWechatFriendLogUpsertBulk {
 	return u.Update(func(s *AddWechatFriendLogUpsert) {

+ 54 - 0
ent/addwechatfriendlog_update.go

@@ -135,6 +135,27 @@ func (awflu *AddWechatFriendLogUpdate) AddIsCanAdd(i int) *AddWechatFriendLogUpd
 	return awflu
 }
 
+// SetTaskCount sets the "task_count" field.
+func (awflu *AddWechatFriendLogUpdate) SetTaskCount(i int) *AddWechatFriendLogUpdate {
+	awflu.mutation.ResetTaskCount()
+	awflu.mutation.SetTaskCount(i)
+	return awflu
+}
+
+// SetNillableTaskCount sets the "task_count" field if the given value is not nil.
+func (awflu *AddWechatFriendLogUpdate) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdate {
+	if i != nil {
+		awflu.SetTaskCount(*i)
+	}
+	return awflu
+}
+
+// AddTaskCount adds i to the "task_count" field.
+func (awflu *AddWechatFriendLogUpdate) AddTaskCount(i int) *AddWechatFriendLogUpdate {
+	awflu.mutation.AddTaskCount(i)
+	return awflu
+}
+
 // SetTaskID sets the "task_id" field.
 func (awflu *AddWechatFriendLogUpdate) SetTaskID(i int64) *AddWechatFriendLogUpdate {
 	awflu.mutation.ResetTaskID()
@@ -320,6 +341,12 @@ func (awflu *AddWechatFriendLogUpdate) sqlSave(ctx context.Context) (n int, err
 	if value, ok := awflu.mutation.AddedIsCanAdd(); ok {
 		_spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
 	}
+	if value, ok := awflu.mutation.TaskCount(); ok {
+		_spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
+	}
+	if value, ok := awflu.mutation.AddedTaskCount(); ok {
+		_spec.AddField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
+	}
 	if value, ok := awflu.mutation.TaskID(); ok {
 		_spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
 	}
@@ -478,6 +505,27 @@ func (awfluo *AddWechatFriendLogUpdateOne) AddIsCanAdd(i int) *AddWechatFriendLo
 	return awfluo
 }
 
+// SetTaskCount sets the "task_count" field.
+func (awfluo *AddWechatFriendLogUpdateOne) SetTaskCount(i int) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ResetTaskCount()
+	awfluo.mutation.SetTaskCount(i)
+	return awfluo
+}
+
+// SetNillableTaskCount sets the "task_count" field if the given value is not nil.
+func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdateOne {
+	if i != nil {
+		awfluo.SetTaskCount(*i)
+	}
+	return awfluo
+}
+
+// AddTaskCount adds i to the "task_count" field.
+func (awfluo *AddWechatFriendLogUpdateOne) AddTaskCount(i int) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.AddTaskCount(i)
+	return awfluo
+}
+
 // SetTaskID sets the "task_id" field.
 func (awfluo *AddWechatFriendLogUpdateOne) SetTaskID(i int64) *AddWechatFriendLogUpdateOne {
 	awfluo.mutation.ResetTaskID()
@@ -693,6 +741,12 @@ func (awfluo *AddWechatFriendLogUpdateOne) sqlSave(ctx context.Context) (_node *
 	if value, ok := awfluo.mutation.AddedIsCanAdd(); ok {
 		_spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
 	}
+	if value, ok := awfluo.mutation.TaskCount(); ok {
+		_spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
+	}
+	if value, ok := awfluo.mutation.AddedTaskCount(); ok {
+		_spec.AddField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
+	}
 	if value, ok := awfluo.mutation.TaskID(); ok {
 		_spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
 	}

+ 1 - 0
ent/migrate/schema.go

@@ -19,6 +19,7 @@ var (
 		{Name: "find_request", Type: field.TypeJSON, Nullable: true},
 		{Name: "find_result", Type: field.TypeJSON, Nullable: true},
 		{Name: "is_can_add", Type: field.TypeInt, Default: 0},
+		{Name: "task_count", Type: field.TypeInt, Default: 0},
 		{Name: "task_id", Type: field.TypeInt64, Default: 0},
 		{Name: "add_request", Type: field.TypeJSON, Nullable: true},
 		{Name: "add_result", Type: field.TypeJSON, Nullable: true},

+ 88 - 1
ent/mutation.go

@@ -137,6 +137,8 @@ type AddWechatFriendLogMutation struct {
 	find_result      *map[string]interface{}
 	is_can_add       *int
 	addis_can_add    *int
+	task_count       *int
+	addtask_count    *int
 	task_id          *int64
 	addtask_id       *int64
 	add_request      *map[string]interface{}
@@ -573,6 +575,62 @@ func (m *AddWechatFriendLogMutation) ResetIsCanAdd() {
 	m.addis_can_add = nil
 }
 
+// SetTaskCount sets the "task_count" field.
+func (m *AddWechatFriendLogMutation) SetTaskCount(i int) {
+	m.task_count = &i
+	m.addtask_count = nil
+}
+
+// TaskCount returns the value of the "task_count" field in the mutation.
+func (m *AddWechatFriendLogMutation) TaskCount() (r int, exists bool) {
+	v := m.task_count
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldTaskCount returns the old "task_count" field's value of the AddWechatFriendLog entity.
+// If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *AddWechatFriendLogMutation) OldTaskCount(ctx context.Context) (v int, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldTaskCount is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldTaskCount requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldTaskCount: %w", err)
+	}
+	return oldValue.TaskCount, nil
+}
+
+// AddTaskCount adds i to the "task_count" field.
+func (m *AddWechatFriendLogMutation) AddTaskCount(i int) {
+	if m.addtask_count != nil {
+		*m.addtask_count += i
+	} else {
+		m.addtask_count = &i
+	}
+}
+
+// AddedTaskCount returns the value that was added to the "task_count" field in this mutation.
+func (m *AddWechatFriendLogMutation) AddedTaskCount() (r int, exists bool) {
+	v := m.addtask_count
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ResetTaskCount resets all changes to the "task_count" field.
+func (m *AddWechatFriendLogMutation) ResetTaskCount() {
+	m.task_count = nil
+	m.addtask_count = nil
+}
+
 // SetTaskID sets the "task_id" field.
 func (m *AddWechatFriendLogMutation) SetTaskID(i int64) {
 	m.task_id = &i
@@ -873,7 +931,7 @@ func (m *AddWechatFriendLogMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *AddWechatFriendLogMutation) Fields() []string {
-	fields := make([]string, 0, 12)
+	fields := make([]string, 0, 13)
 	if m.owner_wx_id != nil {
 		fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
 	}
@@ -895,6 +953,9 @@ func (m *AddWechatFriendLogMutation) Fields() []string {
 	if m.is_can_add != nil {
 		fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
 	}
+	if m.task_count != nil {
+		fields = append(fields, addwechatfriendlog.FieldTaskCount)
+	}
 	if m.task_id != nil {
 		fields = append(fields, addwechatfriendlog.FieldTaskID)
 	}
@@ -932,6 +993,8 @@ func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
 		return m.FindResult()
 	case addwechatfriendlog.FieldIsCanAdd:
 		return m.IsCanAdd()
+	case addwechatfriendlog.FieldTaskCount:
+		return m.TaskCount()
 	case addwechatfriendlog.FieldTaskID:
 		return m.TaskID()
 	case addwechatfriendlog.FieldAddRequest:
@@ -965,6 +1028,8 @@ func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string)
 		return m.OldFindResult(ctx)
 	case addwechatfriendlog.FieldIsCanAdd:
 		return m.OldIsCanAdd(ctx)
+	case addwechatfriendlog.FieldTaskCount:
+		return m.OldTaskCount(ctx)
 	case addwechatfriendlog.FieldTaskID:
 		return m.OldTaskID(ctx)
 	case addwechatfriendlog.FieldAddRequest:
@@ -1033,6 +1098,13 @@ func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) erro
 		}
 		m.SetIsCanAdd(v)
 		return nil
+	case addwechatfriendlog.FieldTaskCount:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetTaskCount(v)
+		return nil
 	case addwechatfriendlog.FieldTaskID:
 		v, ok := value.(int64)
 		if !ok {
@@ -1082,6 +1154,9 @@ func (m *AddWechatFriendLogMutation) AddedFields() []string {
 	if m.addis_can_add != nil {
 		fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
 	}
+	if m.addtask_count != nil {
+		fields = append(fields, addwechatfriendlog.FieldTaskCount)
+	}
 	if m.addtask_id != nil {
 		fields = append(fields, addwechatfriendlog.FieldTaskID)
 	}
@@ -1103,6 +1178,8 @@ func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedOwnerWxType()
 	case addwechatfriendlog.FieldIsCanAdd:
 		return m.AddedIsCanAdd()
+	case addwechatfriendlog.FieldTaskCount:
+		return m.AddedTaskCount()
 	case addwechatfriendlog.FieldTaskID:
 		return m.AddedTaskID()
 	case addwechatfriendlog.FieldCreatedAt:
@@ -1132,6 +1209,13 @@ func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) erro
 		}
 		m.AddIsCanAdd(v)
 		return nil
+	case addwechatfriendlog.FieldTaskCount:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddTaskCount(v)
+		return nil
 	case addwechatfriendlog.FieldTaskID:
 		v, ok := value.(int64)
 		if !ok {
@@ -1228,6 +1312,9 @@ func (m *AddWechatFriendLogMutation) ResetField(name string) error {
 	case addwechatfriendlog.FieldIsCanAdd:
 		m.ResetIsCanAdd()
 		return nil
+	case addwechatfriendlog.FieldTaskCount:
+		m.ResetTaskCount()
+		return nil
 	case addwechatfriendlog.FieldTaskID:
 		m.ResetTaskID()
 		return nil

+ 7 - 3
ent/runtime/runtime.go

@@ -129,16 +129,20 @@ func init() {
 	addwechatfriendlogDescIsCanAdd := addwechatfriendlogFields[7].Descriptor()
 	// addwechatfriendlog.DefaultIsCanAdd holds the default value on creation for the is_can_add field.
 	addwechatfriendlog.DefaultIsCanAdd = addwechatfriendlogDescIsCanAdd.Default.(int)
+	// addwechatfriendlogDescTaskCount is the schema descriptor for task_count field.
+	addwechatfriendlogDescTaskCount := addwechatfriendlogFields[8].Descriptor()
+	// addwechatfriendlog.DefaultTaskCount holds the default value on creation for the task_count field.
+	addwechatfriendlog.DefaultTaskCount = addwechatfriendlogDescTaskCount.Default.(int)
 	// addwechatfriendlogDescTaskID is the schema descriptor for task_id field.
-	addwechatfriendlogDescTaskID := addwechatfriendlogFields[8].Descriptor()
+	addwechatfriendlogDescTaskID := addwechatfriendlogFields[9].Descriptor()
 	// addwechatfriendlog.DefaultTaskID holds the default value on creation for the task_id field.
 	addwechatfriendlog.DefaultTaskID = addwechatfriendlogDescTaskID.Default.(int64)
 	// addwechatfriendlogDescCreatedAt is the schema descriptor for created_at field.
-	addwechatfriendlogDescCreatedAt := addwechatfriendlogFields[11].Descriptor()
+	addwechatfriendlogDescCreatedAt := addwechatfriendlogFields[12].Descriptor()
 	// addwechatfriendlog.DefaultCreatedAt holds the default value on creation for the created_at field.
 	addwechatfriendlog.DefaultCreatedAt = addwechatfriendlogDescCreatedAt.Default.(func() int64)
 	// addwechatfriendlogDescUpdatedAt is the schema descriptor for updated_at field.
-	addwechatfriendlogDescUpdatedAt := addwechatfriendlogFields[12].Descriptor()
+	addwechatfriendlogDescUpdatedAt := addwechatfriendlogFields[13].Descriptor()
 	// addwechatfriendlog.DefaultUpdatedAt holds the default value on creation for the updated_at field.
 	addwechatfriendlog.DefaultUpdatedAt = addwechatfriendlogDescUpdatedAt.Default.(func() int64)
 	// addwechatfriendlog.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.

+ 4 - 1
ent/schema/add_wechat_friend_log.go

@@ -52,7 +52,10 @@ func (AddWechatFriendLog) Fields() []ent.Field {
 
 		field.Int("is_can_add").
 			Default(0).
-			Comment("是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以)"),
+			Comment("任务执行次数"),
+		field.Int("task_count").
+			Default(0).
+			Comment("是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以 2成功添加申请)"),
 		field.Int64("task_id").Default(0).Comment("添加时候的请求体"),
 		field.JSON("add_request", map[string]interface{}{}).
 			Optional().Comment("添加时候的请求体"),

+ 24 - 0
ent/set_not_nil.go

@@ -176,6 +176,30 @@ func (awfl *AddWechatFriendLogCreate) SetNotNilIsCanAdd(value *int) *AddWechatFr
 }
 
 // set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdate) SetNotNilTaskCount(value *int) *AddWechatFriendLogUpdate {
+	if value != nil {
+		return awfl.SetTaskCount(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdateOne) SetNotNilTaskCount(value *int) *AddWechatFriendLogUpdateOne {
+	if value != nil {
+		return awfl.SetTaskCount(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogCreate) SetNotNilTaskCount(value *int) *AddWechatFriendLogCreate {
+	if value != nil {
+		return awfl.SetTaskCount(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
 func (awfl *AddWechatFriendLogUpdate) SetNotNilTaskID(value *int64) *AddWechatFriendLogUpdate {
 	if value != nil {
 		return awfl.SetTaskID(*value)

+ 1 - 0
internal/service/addfriend/add_wechat_friend_log.go

@@ -76,6 +76,7 @@ func (l *AddWechatFriendService) AddNewFriend(wechatId, content, message string)
 		Where(addwechatfriendlog.OwnerWxIDEQ(wechatId)).
 		Where(addwechatfriendlog.FindContentEQ(content)).
 		SetAddResult(result).
+		AddTaskCount(1).
 		SetUpdatedAt(time.Now().Unix())
 	_, err = update.Save(l.ctx)
 	if err != nil || result["sendResult"] != "success" {