Przeglądaj źródła

fix:edit batch_msg/create,get_list

jimmyyem 7 miesięcy temu
rodzic
commit
5ece8496b6

+ 6 - 0
desc/wechat/batch_msg.api

@@ -46,6 +46,9 @@ type (
 
         // 标签列表
         Labels  []string `json:"labels,optional"`
+
+		// 标签列表
+		Type  *int32 `json:"type,optional"`
     }
 
     // The response data of batch msg list | BatchMsg列表数据
@@ -79,6 +82,9 @@ type (
 
 		// 任务名称
 		TaskName  *string `json:"taskName,optional"`
+
+		// 群发类型
+		Type *int32 `json:"type"`
     }
 
     // BatchMsg information response | BatchMsg信息返回体

+ 13 - 2
ent/batchmsg.go

@@ -46,7 +46,9 @@ type BatchMsg struct {
 	// 结束时间
 	StopTime time.Time `json:"stop_time,omitempty"`
 	// 发送时间
-	SendTime     time.Time `json:"send_time,omitempty"`
+	SendTime time.Time `json:"send_time,omitempty"`
+	// 发送类型 1-群发消息 2-群发朋友圈
+	Type         int32 `json:"type,omitempty"`
 	selectValues sql.SelectValues
 }
 
@@ -55,7 +57,7 @@ func (*BatchMsg) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case batchmsg.FieldID, batchmsg.FieldStatus, batchmsg.FieldTotal, batchmsg.FieldSuccess, batchmsg.FieldFail:
+		case batchmsg.FieldID, batchmsg.FieldStatus, batchmsg.FieldTotal, batchmsg.FieldSuccess, batchmsg.FieldFail, batchmsg.FieldType:
 			values[i] = new(sql.NullInt64)
 		case batchmsg.FieldBatchNo, batchmsg.FieldTaskName, batchmsg.FieldFromwxid, batchmsg.FieldMsg, batchmsg.FieldTag:
 			values[i] = new(sql.NullString)
@@ -172,6 +174,12 @@ func (bm *BatchMsg) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				bm.SendTime = value.Time
 			}
+		case batchmsg.FieldType:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field type", values[i])
+			} else if value.Valid {
+				bm.Type = int32(value.Int64)
+			}
 		default:
 			bm.selectValues.Set(columns[i], values[i])
 		}
@@ -252,6 +260,9 @@ func (bm *BatchMsg) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("send_time=")
 	builder.WriteString(bm.SendTime.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("type=")
+	builder.WriteString(fmt.Sprintf("%v", bm.Type))
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 8 - 0
ent/batchmsg/batchmsg.go

@@ -44,6 +44,8 @@ const (
 	FieldStopTime = "stop_time"
 	// FieldSendTime holds the string denoting the send_time field in the database.
 	FieldSendTime = "send_time"
+	// FieldType holds the string denoting the type field in the database.
+	FieldType = "type"
 	// Table holds the table name of the batchmsg in the database.
 	Table = "batch_msg"
 )
@@ -66,6 +68,7 @@ var Columns = []string{
 	FieldStartTime,
 	FieldStopTime,
 	FieldSendTime,
+	FieldType,
 }
 
 // ValidColumn reports if the column name is valid (part of the table columns).
@@ -178,3 +181,8 @@ func ByStopTime(opts ...sql.OrderTermOption) OrderOption {
 func BySendTime(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldSendTime, opts...).ToFunc()
 }
+
+// ByType orders the results by the type field.
+func ByType(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldType, opts...).ToFunc()
+}

+ 55 - 0
ent/batchmsg/where.go

@@ -129,6 +129,11 @@ func SendTime(v time.Time) predicate.BatchMsg {
 	return predicate.BatchMsg(sql.FieldEQ(FieldSendTime, v))
 }
 
+// Type applies equality check predicate on the "type" field. It's identical to TypeEQ.
+func Type(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldEQ(FieldType, v))
+}
+
 // CreatedAtEQ applies the EQ predicate on the "created_at" field.
 func CreatedAtEQ(v time.Time) predicate.BatchMsg {
 	return predicate.BatchMsg(sql.FieldEQ(FieldCreatedAt, v))
@@ -984,6 +989,56 @@ func SendTimeNotNil() predicate.BatchMsg {
 	return predicate.BatchMsg(sql.FieldNotNull(FieldSendTime))
 }
 
+// TypeEQ applies the EQ predicate on the "type" field.
+func TypeEQ(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldEQ(FieldType, v))
+}
+
+// TypeNEQ applies the NEQ predicate on the "type" field.
+func TypeNEQ(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldNEQ(FieldType, v))
+}
+
+// TypeIn applies the In predicate on the "type" field.
+func TypeIn(vs ...int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldIn(FieldType, vs...))
+}
+
+// TypeNotIn applies the NotIn predicate on the "type" field.
+func TypeNotIn(vs ...int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldNotIn(FieldType, vs...))
+}
+
+// TypeGT applies the GT predicate on the "type" field.
+func TypeGT(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldGT(FieldType, v))
+}
+
+// TypeGTE applies the GTE predicate on the "type" field.
+func TypeGTE(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldGTE(FieldType, v))
+}
+
+// TypeLT applies the LT predicate on the "type" field.
+func TypeLT(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldLT(FieldType, v))
+}
+
+// TypeLTE applies the LTE predicate on the "type" field.
+func TypeLTE(v int32) predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldLTE(FieldType, v))
+}
+
+// TypeIsNil applies the IsNil predicate on the "type" field.
+func TypeIsNil() predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldIsNull(FieldType))
+}
+
+// TypeNotNil applies the NotNil predicate on the "type" field.
+func TypeNotNil() predicate.BatchMsg {
+	return predicate.BatchMsg(sql.FieldNotNull(FieldType))
+}
+
 // And groups predicates with the AND operator between them.
 func And(predicates ...predicate.BatchMsg) predicate.BatchMsg {
 	return predicate.BatchMsg(sql.AndPredicates(predicates...))

+ 98 - 0
ent/batchmsg_create.go

@@ -232,6 +232,20 @@ func (bmc *BatchMsgCreate) SetNillableSendTime(t *time.Time) *BatchMsgCreate {
 	return bmc
 }
 
+// SetType sets the "type" field.
+func (bmc *BatchMsgCreate) SetType(i int32) *BatchMsgCreate {
+	bmc.mutation.SetType(i)
+	return bmc
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (bmc *BatchMsgCreate) SetNillableType(i *int32) *BatchMsgCreate {
+	if i != nil {
+		bmc.SetType(*i)
+	}
+	return bmc
+}
+
 // SetID sets the "id" field.
 func (bmc *BatchMsgCreate) SetID(u uint64) *BatchMsgCreate {
 	bmc.mutation.SetID(u)
@@ -397,6 +411,10 @@ func (bmc *BatchMsgCreate) createSpec() (*BatchMsg, *sqlgraph.CreateSpec) {
 		_spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
 		_node.SendTime = value
 	}
+	if value, ok := bmc.mutation.GetType(); ok {
+		_spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
+		_node.Type = value
+	}
 	return _node, _spec
 }
 
@@ -719,6 +737,30 @@ func (u *BatchMsgUpsert) ClearSendTime() *BatchMsgUpsert {
 	return u
 }
 
+// SetType sets the "type" field.
+func (u *BatchMsgUpsert) SetType(v int32) *BatchMsgUpsert {
+	u.Set(batchmsg.FieldType, v)
+	return u
+}
+
+// UpdateType sets the "type" field to the value that was provided on create.
+func (u *BatchMsgUpsert) UpdateType() *BatchMsgUpsert {
+	u.SetExcluded(batchmsg.FieldType)
+	return u
+}
+
+// AddType adds v to the "type" field.
+func (u *BatchMsgUpsert) AddType(v int32) *BatchMsgUpsert {
+	u.Add(batchmsg.FieldType, v)
+	return u
+}
+
+// ClearType clears the value of the "type" field.
+func (u *BatchMsgUpsert) ClearType() *BatchMsgUpsert {
+	u.SetNull(batchmsg.FieldType)
+	return u
+}
+
 // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
 // Using this option is equivalent to using:
 //
@@ -1085,6 +1127,34 @@ func (u *BatchMsgUpsertOne) ClearSendTime() *BatchMsgUpsertOne {
 	})
 }
 
+// SetType sets the "type" field.
+func (u *BatchMsgUpsertOne) SetType(v int32) *BatchMsgUpsertOne {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.SetType(v)
+	})
+}
+
+// AddType adds v to the "type" field.
+func (u *BatchMsgUpsertOne) AddType(v int32) *BatchMsgUpsertOne {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.AddType(v)
+	})
+}
+
+// UpdateType sets the "type" field to the value that was provided on create.
+func (u *BatchMsgUpsertOne) UpdateType() *BatchMsgUpsertOne {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.UpdateType()
+	})
+}
+
+// ClearType clears the value of the "type" field.
+func (u *BatchMsgUpsertOne) ClearType() *BatchMsgUpsertOne {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.ClearType()
+	})
+}
+
 // Exec executes the query.
 func (u *BatchMsgUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -1617,6 +1687,34 @@ func (u *BatchMsgUpsertBulk) ClearSendTime() *BatchMsgUpsertBulk {
 	})
 }
 
+// SetType sets the "type" field.
+func (u *BatchMsgUpsertBulk) SetType(v int32) *BatchMsgUpsertBulk {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.SetType(v)
+	})
+}
+
+// AddType adds v to the "type" field.
+func (u *BatchMsgUpsertBulk) AddType(v int32) *BatchMsgUpsertBulk {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.AddType(v)
+	})
+}
+
+// UpdateType sets the "type" field to the value that was provided on create.
+func (u *BatchMsgUpsertBulk) UpdateType() *BatchMsgUpsertBulk {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.UpdateType()
+	})
+}
+
+// ClearType clears the value of the "type" field.
+func (u *BatchMsgUpsertBulk) ClearType() *BatchMsgUpsertBulk {
+	return u.Update(func(s *BatchMsgUpsert) {
+		s.ClearType()
+	})
+}
+
 // Exec executes the query.
 func (u *BatchMsgUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 72 - 0
ent/batchmsg_update.go

@@ -322,6 +322,33 @@ func (bmu *BatchMsgUpdate) ClearSendTime() *BatchMsgUpdate {
 	return bmu
 }
 
+// SetType sets the "type" field.
+func (bmu *BatchMsgUpdate) SetType(i int32) *BatchMsgUpdate {
+	bmu.mutation.ResetType()
+	bmu.mutation.SetType(i)
+	return bmu
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (bmu *BatchMsgUpdate) SetNillableType(i *int32) *BatchMsgUpdate {
+	if i != nil {
+		bmu.SetType(*i)
+	}
+	return bmu
+}
+
+// AddType adds i to the "type" field.
+func (bmu *BatchMsgUpdate) AddType(i int32) *BatchMsgUpdate {
+	bmu.mutation.AddType(i)
+	return bmu
+}
+
+// ClearType clears the value of the "type" field.
+func (bmu *BatchMsgUpdate) ClearType() *BatchMsgUpdate {
+	bmu.mutation.ClearType()
+	return bmu
+}
+
 // Mutation returns the BatchMsgMutation object of the builder.
 func (bmu *BatchMsgUpdate) Mutation() *BatchMsgMutation {
 	return bmu.mutation
@@ -471,6 +498,15 @@ func (bmu *BatchMsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if bmu.mutation.SendTimeCleared() {
 		_spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
 	}
+	if value, ok := bmu.mutation.GetType(); ok {
+		_spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
+	}
+	if value, ok := bmu.mutation.AddedType(); ok {
+		_spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
+	}
+	if bmu.mutation.TypeCleared() {
+		_spec.ClearField(batchmsg.FieldType, field.TypeInt32)
+	}
 	if n, err = sqlgraph.UpdateNodes(ctx, bmu.driver, _spec); err != nil {
 		if _, ok := err.(*sqlgraph.NotFoundError); ok {
 			err = &NotFoundError{batchmsg.Label}
@@ -785,6 +821,33 @@ func (bmuo *BatchMsgUpdateOne) ClearSendTime() *BatchMsgUpdateOne {
 	return bmuo
 }
 
+// SetType sets the "type" field.
+func (bmuo *BatchMsgUpdateOne) SetType(i int32) *BatchMsgUpdateOne {
+	bmuo.mutation.ResetType()
+	bmuo.mutation.SetType(i)
+	return bmuo
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (bmuo *BatchMsgUpdateOne) SetNillableType(i *int32) *BatchMsgUpdateOne {
+	if i != nil {
+		bmuo.SetType(*i)
+	}
+	return bmuo
+}
+
+// AddType adds i to the "type" field.
+func (bmuo *BatchMsgUpdateOne) AddType(i int32) *BatchMsgUpdateOne {
+	bmuo.mutation.AddType(i)
+	return bmuo
+}
+
+// ClearType clears the value of the "type" field.
+func (bmuo *BatchMsgUpdateOne) ClearType() *BatchMsgUpdateOne {
+	bmuo.mutation.ClearType()
+	return bmuo
+}
+
 // Mutation returns the BatchMsgMutation object of the builder.
 func (bmuo *BatchMsgUpdateOne) Mutation() *BatchMsgMutation {
 	return bmuo.mutation
@@ -964,6 +1027,15 @@ func (bmuo *BatchMsgUpdateOne) sqlSave(ctx context.Context) (_node *BatchMsg, er
 	if bmuo.mutation.SendTimeCleared() {
 		_spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
 	}
+	if value, ok := bmuo.mutation.GetType(); ok {
+		_spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
+	}
+	if value, ok := bmuo.mutation.AddedType(); ok {
+		_spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
+	}
+	if bmuo.mutation.TypeCleared() {
+		_spec.ClearField(batchmsg.FieldType, field.TypeInt32)
+	}
 	_node = &BatchMsg{config: bmuo.config}
 	_spec.Assign = _node.assignValues
 	_spec.ScanValues = _node.scanValues

+ 6 - 0
ent/migrate/schema.go

@@ -53,6 +53,7 @@ var (
 		{Name: "start_time", Type: field.TypeTime, Nullable: true, Comment: "开始时间"},
 		{Name: "stop_time", Type: field.TypeTime, Nullable: true, Comment: "结束时间"},
 		{Name: "send_time", Type: field.TypeTime, Nullable: true, Comment: "发送时间"},
+		{Name: "type", Type: field.TypeInt32, Nullable: true, Comment: "发送类型 1-群发消息 2-群发朋友圈"},
 	}
 	// BatchMsgTable holds the schema information for the "batch_msg" table.
 	BatchMsgTable = &schema.Table{
@@ -65,6 +66,11 @@ var (
 				Unique:  true,
 				Columns: []*schema.Column{BatchMsgColumns[5]},
 			},
+			{
+				Name:    "batchmsg_type",
+				Unique:  false,
+				Columns: []*schema.Column{BatchMsgColumns[16]},
+			},
 		},
 	}
 	// ContactColumns holds the columns for the "contact" table.

+ 108 - 1
ent/mutation.go

@@ -1083,6 +1083,8 @@ type BatchMsgMutation struct {
 	start_time    *time.Time
 	stop_time     *time.Time
 	send_time     *time.Time
+	_type         *int32
+	add_type      *int32
 	clearedFields map[string]struct{}
 	done          bool
 	oldValue      func(context.Context) (*BatchMsg, error)
@@ -1986,6 +1988,76 @@ func (m *BatchMsgMutation) ResetSendTime() {
 	delete(m.clearedFields, batchmsg.FieldSendTime)
 }
 
+// SetType sets the "type" field.
+func (m *BatchMsgMutation) SetType(i int32) {
+	m._type = &i
+	m.add_type = nil
+}
+
+// GetType returns the value of the "type" field in the mutation.
+func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
+	v := m._type
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldType returns the old "type" field's value of the BatchMsg entity.
+// If the BatchMsg 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 *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldType is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldType requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldType: %w", err)
+	}
+	return oldValue.Type, nil
+}
+
+// AddType adds i to the "type" field.
+func (m *BatchMsgMutation) AddType(i int32) {
+	if m.add_type != nil {
+		*m.add_type += i
+	} else {
+		m.add_type = &i
+	}
+}
+
+// AddedType returns the value that was added to the "type" field in this mutation.
+func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
+	v := m.add_type
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearType clears the value of the "type" field.
+func (m *BatchMsgMutation) ClearType() {
+	m._type = nil
+	m.add_type = nil
+	m.clearedFields[batchmsg.FieldType] = struct{}{}
+}
+
+// TypeCleared returns if the "type" field was cleared in this mutation.
+func (m *BatchMsgMutation) TypeCleared() bool {
+	_, ok := m.clearedFields[batchmsg.FieldType]
+	return ok
+}
+
+// ResetType resets all changes to the "type" field.
+func (m *BatchMsgMutation) ResetType() {
+	m._type = nil
+	m.add_type = nil
+	delete(m.clearedFields, batchmsg.FieldType)
+}
+
 // Where appends a list predicates to the BatchMsgMutation builder.
 func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
 	m.predicates = append(m.predicates, ps...)
@@ -2020,7 +2092,7 @@ func (m *BatchMsgMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *BatchMsgMutation) Fields() []string {
-	fields := make([]string, 0, 15)
+	fields := make([]string, 0, 16)
 	if m.created_at != nil {
 		fields = append(fields, batchmsg.FieldCreatedAt)
 	}
@@ -2066,6 +2138,9 @@ func (m *BatchMsgMutation) Fields() []string {
 	if m.send_time != nil {
 		fields = append(fields, batchmsg.FieldSendTime)
 	}
+	if m._type != nil {
+		fields = append(fields, batchmsg.FieldType)
+	}
 	return fields
 }
 
@@ -2104,6 +2179,8 @@ func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
 		return m.StopTime()
 	case batchmsg.FieldSendTime:
 		return m.SendTime()
+	case batchmsg.FieldType:
+		return m.GetType()
 	}
 	return nil, false
 }
@@ -2143,6 +2220,8 @@ func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value
 		return m.OldStopTime(ctx)
 	case batchmsg.FieldSendTime:
 		return m.OldSendTime(ctx)
+	case batchmsg.FieldType:
+		return m.OldType(ctx)
 	}
 	return nil, fmt.Errorf("unknown BatchMsg field %s", name)
 }
@@ -2257,6 +2336,13 @@ func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetSendTime(v)
 		return nil
+	case batchmsg.FieldType:
+		v, ok := value.(int32)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetType(v)
+		return nil
 	}
 	return fmt.Errorf("unknown BatchMsg field %s", name)
 }
@@ -2277,6 +2363,9 @@ func (m *BatchMsgMutation) AddedFields() []string {
 	if m.addfail != nil {
 		fields = append(fields, batchmsg.FieldFail)
 	}
+	if m.add_type != nil {
+		fields = append(fields, batchmsg.FieldType)
+	}
 	return fields
 }
 
@@ -2293,6 +2382,8 @@ func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedSuccess()
 	case batchmsg.FieldFail:
 		return m.AddedFail()
+	case batchmsg.FieldType:
+		return m.AddedType()
 	}
 	return nil, false
 }
@@ -2330,6 +2421,13 @@ func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddFail(v)
 		return nil
+	case batchmsg.FieldType:
+		v, ok := value.(int32)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddType(v)
+		return nil
 	}
 	return fmt.Errorf("unknown BatchMsg numeric field %s", name)
 }
@@ -2377,6 +2475,9 @@ func (m *BatchMsgMutation) ClearedFields() []string {
 	if m.FieldCleared(batchmsg.FieldSendTime) {
 		fields = append(fields, batchmsg.FieldSendTime)
 	}
+	if m.FieldCleared(batchmsg.FieldType) {
+		fields = append(fields, batchmsg.FieldType)
+	}
 	return fields
 }
 
@@ -2430,6 +2531,9 @@ func (m *BatchMsgMutation) ClearField(name string) error {
 	case batchmsg.FieldSendTime:
 		m.ClearSendTime()
 		return nil
+	case batchmsg.FieldType:
+		m.ClearType()
+		return nil
 	}
 	return fmt.Errorf("unknown BatchMsg nullable field %s", name)
 }
@@ -2483,6 +2587,9 @@ func (m *BatchMsgMutation) ResetField(name string) error {
 	case batchmsg.FieldSendTime:
 		m.ResetSendTime()
 		return nil
+	case batchmsg.FieldType:
+		m.ResetType()
+		return nil
 	}
 	return fmt.Errorf("unknown BatchMsg field %s", name)
 }

+ 6 - 2
ent/schema/batch_msg.go

@@ -28,7 +28,9 @@ func (BatchMsg) Fields() []ent.Field {
 		field.Int32("fail").Optional().Comment("失败数量"),
 		field.Time("start_time").Optional().Comment("开始时间"),
 		field.Time("stop_time").Optional().Comment("结束时间"),
-		field.Time("send_time").Optional().Comment("发送时间")}
+		field.Time("send_time").Optional().Comment("发送时间"),
+		field.Int32("type").Optional().Comment("发送类型 1-群发消息 2-群发朋友圈"),
+	}
 }
 func (BatchMsg) Mixin() []ent.Mixin {
 	return []ent.Mixin{
@@ -42,7 +44,9 @@ func (BatchMsg) Edges() []ent.Edge {
 
 func (BatchMsg) Indexes() []ent.Index {
 	return []ent.Index{
-		index.Fields("batch_no").Unique()}
+		index.Fields("batch_no").Unique(),
+		index.Fields("type"),
+	}
 }
 
 func (BatchMsg) Annotations() []schema.Annotation {

+ 24 - 0
ent/set_not_nil.go

@@ -536,6 +536,30 @@ func (bm *BatchMsgCreate) SetNotNilSendTime(value *time.Time) *BatchMsgCreate {
 }
 
 // set field if value's pointer is not nil.
+func (bm *BatchMsgUpdate) SetNotNilType(value *int32) *BatchMsgUpdate {
+	if value != nil {
+		return bm.SetType(*value)
+	}
+	return bm
+}
+
+// set field if value's pointer is not nil.
+func (bm *BatchMsgUpdateOne) SetNotNilType(value *int32) *BatchMsgUpdateOne {
+	if value != nil {
+		return bm.SetType(*value)
+	}
+	return bm
+}
+
+// set field if value's pointer is not nil.
+func (bm *BatchMsgCreate) SetNotNilType(value *int32) *BatchMsgCreate {
+	if value != nil {
+		return bm.SetType(*value)
+	}
+	return bm
+}
+
+// set field if value's pointer is not nil.
 func (c *ContactUpdate) SetNotNilUpdatedAt(value *time.Time) *ContactUpdate {
 	if value != nil {
 		return c.SetUpdatedAt(*value)

+ 1 - 0
internal/logic/batch_msg/create_batch_msg_logic.go

@@ -169,6 +169,7 @@ func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.Ba
 		SetNotNilTaskName(req.TaskName).
 		SetNotNilStartTime(&startTime).
 		SetNotNilSendTime(&sendTime).
+		SetNotNilType(req.Type).
 		Save(l.ctx)
 
 	if err != nil {

+ 1 - 0
internal/logic/batch_msg/get_batch_msg_list_logic.go

@@ -31,6 +31,7 @@ func NewGetBatchMsgListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
 
 func (l *GetBatchMsgListLogic) GetBatchMsgList(req *types.BatchMsgListReq) (*types.BatchMsgListResp, error) {
 	var predicates []predicate.BatchMsg
+	predicates = append(predicates, batchmsg.Type(*req.Type))
 	if req.BatchNo != nil {
 		predicates = append(predicates, batchmsg.BatchNoContains(*req.BatchNo))
 	}

+ 4 - 0
internal/types/types.go

@@ -1238,6 +1238,8 @@ type BatchMsgInfo struct {
 	SendTimeStr *string `json:"sendTimeStr,optional"`
 	// 标签列表
 	Labels []string `json:"labels,optional"`
+	// 标签列表
+	Type *int32 `json:"type,optional"`
 }
 
 // The response data of batch msg list | BatchMsg列表数据
@@ -1268,6 +1270,8 @@ type BatchMsgListReq struct {
 	Msg *string `json:"msg,optional"`
 	// 任务名称
 	TaskName *string `json:"taskName,optional"`
+	// 群发类型
+	Type *int32 `json:"type"`
 }
 
 // BatchMsg information response | BatchMsg信息返回体