Browse Source

fix:edit sop_task/update

jimmyyem 3 months ago
parent
commit
957143c93a

+ 1 - 1
desc/wechat/sop_stage.api

@@ -77,7 +77,7 @@ type (
         OrganizationId *uint64 `json:"organizationId,optional"`
 
 		// Token
-		Token *string `json:"token,optional"`
+		Token []string `json:"token,optional"`
     }
 
     // The response data of sop node information | SopNode信息

+ 1 - 1
ent/migrate/schema.go

@@ -616,7 +616,7 @@ var (
 		{Name: "plan_end_time", Type: field.TypeTime, Nullable: true, Comment: "任务计划结束时间"},
 		{Name: "creator_id", Type: field.TypeString, Nullable: true, Comment: "创建者 id"},
 		{Name: "organization_id", Type: field.TypeUint64, Nullable: true, Comment: "机构 ID", Default: 1},
-		{Name: "token", Type: field.TypeString, Nullable: true, Comment: "Token", Default: ""},
+		{Name: "token", Type: field.TypeJSON, Nullable: true, Comment: "Token"},
 	}
 	// SopTaskTable holds the schema information for the "sop_task" table.
 	SopTaskTable = &schema.Table{

+ 22 - 5
ent/mutation.go

@@ -21080,7 +21080,8 @@ type SopTaskMutation struct {
 	creator_id          *string
 	organization_id     *uint64
 	addorganization_id  *int64
-	token               *string
+	token               *[]string
+	appendtoken         []string
 	clearedFields       map[string]struct{}
 	task_stages         map[uint64]struct{}
 	removedtask_stages  map[uint64]struct{}
@@ -21760,12 +21761,13 @@ func (m *SopTaskMutation) ResetOrganizationID() {
 }
 
 // SetToken sets the "token" field.
-func (m *SopTaskMutation) SetToken(s string) {
+func (m *SopTaskMutation) SetToken(s []string) {
 	m.token = &s
+	m.appendtoken = nil
 }
 
 // Token returns the value of the "token" field in the mutation.
-func (m *SopTaskMutation) Token() (r string, exists bool) {
+func (m *SopTaskMutation) Token() (r []string, exists bool) {
 	v := m.token
 	if v == nil {
 		return
@@ -21776,7 +21778,7 @@ func (m *SopTaskMutation) Token() (r string, exists bool) {
 // OldToken returns the old "token" field's value of the SopTask entity.
 // If the SopTask 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 *SopTaskMutation) OldToken(ctx context.Context) (v string, err error) {
+func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
 	if !m.op.Is(OpUpdateOne) {
 		return v, errors.New("OldToken is only allowed on UpdateOne operations")
 	}
@@ -21790,9 +21792,23 @@ func (m *SopTaskMutation) OldToken(ctx context.Context) (v string, err error) {
 	return oldValue.Token, nil
 }
 
+// AppendToken adds s to the "token" field.
+func (m *SopTaskMutation) AppendToken(s []string) {
+	m.appendtoken = append(m.appendtoken, s...)
+}
+
+// AppendedToken returns the list of values that were appended to the "token" field in this mutation.
+func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
+	if len(m.appendtoken) == 0 {
+		return nil, false
+	}
+	return m.appendtoken, true
+}
+
 // ClearToken clears the value of the "token" field.
 func (m *SopTaskMutation) ClearToken() {
 	m.token = nil
+	m.appendtoken = nil
 	m.clearedFields[soptask.FieldToken] = struct{}{}
 }
 
@@ -21805,6 +21821,7 @@ func (m *SopTaskMutation) TokenCleared() bool {
 // ResetToken resets all changes to the "token" field.
 func (m *SopTaskMutation) ResetToken() {
 	m.token = nil
+	m.appendtoken = nil
 	delete(m.clearedFields, soptask.FieldToken)
 }
 
@@ -22085,7 +22102,7 @@ func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
 		m.SetOrganizationID(v)
 		return nil
 	case soptask.FieldToken:
-		v, ok := value.(string)
+		v, ok := value.([]string)
 		if !ok {
 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 		}

+ 0 - 4
ent/runtime/runtime.go

@@ -820,10 +820,6 @@ func init() {
 	soptaskDescOrganizationID := soptaskFields[6].Descriptor()
 	// soptask.DefaultOrganizationID holds the default value on creation for the organization_id field.
 	soptask.DefaultOrganizationID = soptaskDescOrganizationID.Default.(uint64)
-	// soptaskDescToken is the schema descriptor for token field.
-	soptaskDescToken := soptaskFields[7].Descriptor()
-	// soptask.DefaultToken holds the default value on creation for the token field.
-	soptask.DefaultToken = soptaskDescToken.Default.(string)
 	tokenMixin := schema.Token{}.Mixin()
 	tokenMixinHooks1 := tokenMixin[1].Hooks()
 	token.Hooks[0] = tokenMixinHooks1[0]

+ 1 - 1
ent/schema/sop_task.go

@@ -39,7 +39,7 @@ func (SopTask) Fields() []ent.Field {
 		field.Uint64("organization_id").Optional().Default(1).
 			Comment("机构 ID").
 			Annotations(entsql.WithComments(true)),
-		field.String("token").Optional().Default("").
+		field.JSON("token", []string{}).Optional().
 			Comment("Token").
 			Annotations(entsql.WithComments(true)),
 	}

+ 6 - 6
ent/set_not_nil.go

@@ -4688,25 +4688,25 @@ func (st *SopTaskCreate) SetNotNilOrganizationID(value *uint64) *SopTaskCreate {
 }
 
 // set field if value's pointer is not nil.
-func (st *SopTaskUpdate) SetNotNilToken(value *string) *SopTaskUpdate {
+func (st *SopTaskUpdate) SetNotNilToken(value []string) *SopTaskUpdate {
 	if value != nil {
-		return st.SetToken(*value)
+		return st.SetToken(value)
 	}
 	return st
 }
 
 // set field if value's pointer is not nil.
-func (st *SopTaskUpdateOne) SetNotNilToken(value *string) *SopTaskUpdateOne {
+func (st *SopTaskUpdateOne) SetNotNilToken(value []string) *SopTaskUpdateOne {
 	if value != nil {
-		return st.SetToken(*value)
+		return st.SetToken(value)
 	}
 	return st
 }
 
 // set field if value's pointer is not nil.
-func (st *SopTaskCreate) SetNotNilToken(value *string) *SopTaskCreate {
+func (st *SopTaskCreate) SetNotNilToken(value []string) *SopTaskCreate {
 	if value != nil {
-		return st.SetToken(*value)
+		return st.SetToken(value)
 	}
 	return st
 }

+ 9 - 7
ent/soptask.go

@@ -41,7 +41,7 @@ type SopTask struct {
 	// 机构 ID
 	OrganizationID uint64 `json:"organization_id,omitempty"`
 	// Token
-	Token string `json:"token,omitempty"`
+	Token []string `json:"token,omitempty"`
 	// Edges holds the relations/edges for other nodes in the graph.
 	// The values are being populated by the SopTaskQuery when eager-loading is set.
 	Edges        SopTaskEdges `json:"edges"`
@@ -71,11 +71,11 @@ func (*SopTask) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case soptask.FieldBotWxidList:
+		case soptask.FieldBotWxidList, soptask.FieldToken:
 			values[i] = new([]byte)
 		case soptask.FieldID, soptask.FieldStatus, soptask.FieldType, soptask.FieldOrganizationID:
 			values[i] = new(sql.NullInt64)
-		case soptask.FieldName, soptask.FieldCreatorID, soptask.FieldToken:
+		case soptask.FieldName, soptask.FieldCreatorID:
 			values[i] = new(sql.NullString)
 		case soptask.FieldCreatedAt, soptask.FieldUpdatedAt, soptask.FieldDeletedAt, soptask.FieldPlanStartTime, soptask.FieldPlanEndTime:
 			values[i] = new(sql.NullTime)
@@ -169,10 +169,12 @@ func (st *SopTask) assignValues(columns []string, values []any) error {
 				st.OrganizationID = uint64(value.Int64)
 			}
 		case soptask.FieldToken:
-			if value, ok := values[i].(*sql.NullString); !ok {
+			if value, ok := values[i].(*[]byte); !ok {
 				return fmt.Errorf("unexpected type %T for field token", values[i])
-			} else if value.Valid {
-				st.Token = value.String
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &st.Token); err != nil {
+					return fmt.Errorf("unmarshal field token: %w", err)
+				}
 			}
 		default:
 			st.selectValues.Set(columns[i], values[i])
@@ -249,7 +251,7 @@ func (st *SopTask) String() string {
 	builder.WriteString(fmt.Sprintf("%v", st.OrganizationID))
 	builder.WriteString(", ")
 	builder.WriteString("token=")
-	builder.WriteString(st.Token)
+	builder.WriteString(fmt.Sprintf("%v", st.Token))
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 0 - 7
ent/soptask/soptask.go

@@ -101,8 +101,6 @@ var (
 	DefaultType int
 	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
 	DefaultOrganizationID uint64
-	// DefaultToken holds the default value on creation for the "token" field.
-	DefaultToken string
 )
 
 // OrderOption defines the ordering options for the SopTask queries.
@@ -163,11 +161,6 @@ func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
 }
 
-// ByToken orders the results by the token field.
-func ByToken(opts ...sql.OrderTermOption) OrderOption {
-	return sql.OrderByField(FieldToken, opts...).ToFunc()
-}
-
 // ByTaskStagesCount orders the results by task_stages count.
 func ByTaskStagesCount(opts ...sql.OrderTermOption) OrderOption {
 	return func(s *sql.Selector) {

+ 0 - 70
ent/soptask/where.go

@@ -105,11 +105,6 @@ func OrganizationID(v uint64) predicate.SopTask {
 	return predicate.SopTask(sql.FieldEQ(FieldOrganizationID, v))
 }
 
-// Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
-func Token(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldEQ(FieldToken, v))
-}
-
 // CreatedAtEQ applies the EQ predicate on the "created_at" field.
 func CreatedAtEQ(v time.Time) predicate.SopTask {
 	return predicate.SopTask(sql.FieldEQ(FieldCreatedAt, v))
@@ -630,61 +625,6 @@ func OrganizationIDNotNil() predicate.SopTask {
 	return predicate.SopTask(sql.FieldNotNull(FieldOrganizationID))
 }
 
-// TokenEQ applies the EQ predicate on the "token" field.
-func TokenEQ(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldEQ(FieldToken, v))
-}
-
-// TokenNEQ applies the NEQ predicate on the "token" field.
-func TokenNEQ(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldNEQ(FieldToken, v))
-}
-
-// TokenIn applies the In predicate on the "token" field.
-func TokenIn(vs ...string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldIn(FieldToken, vs...))
-}
-
-// TokenNotIn applies the NotIn predicate on the "token" field.
-func TokenNotIn(vs ...string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldNotIn(FieldToken, vs...))
-}
-
-// TokenGT applies the GT predicate on the "token" field.
-func TokenGT(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldGT(FieldToken, v))
-}
-
-// TokenGTE applies the GTE predicate on the "token" field.
-func TokenGTE(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldGTE(FieldToken, v))
-}
-
-// TokenLT applies the LT predicate on the "token" field.
-func TokenLT(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldLT(FieldToken, v))
-}
-
-// TokenLTE applies the LTE predicate on the "token" field.
-func TokenLTE(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldLTE(FieldToken, v))
-}
-
-// TokenContains applies the Contains predicate on the "token" field.
-func TokenContains(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldContains(FieldToken, v))
-}
-
-// TokenHasPrefix applies the HasPrefix predicate on the "token" field.
-func TokenHasPrefix(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldHasPrefix(FieldToken, v))
-}
-
-// TokenHasSuffix applies the HasSuffix predicate on the "token" field.
-func TokenHasSuffix(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldHasSuffix(FieldToken, v))
-}
-
 // TokenIsNil applies the IsNil predicate on the "token" field.
 func TokenIsNil() predicate.SopTask {
 	return predicate.SopTask(sql.FieldIsNull(FieldToken))
@@ -695,16 +635,6 @@ func TokenNotNil() predicate.SopTask {
 	return predicate.SopTask(sql.FieldNotNull(FieldToken))
 }
 
-// TokenEqualFold applies the EqualFold predicate on the "token" field.
-func TokenEqualFold(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldEqualFold(FieldToken, v))
-}
-
-// TokenContainsFold applies the ContainsFold predicate on the "token" field.
-func TokenContainsFold(v string) predicate.SopTask {
-	return predicate.SopTask(sql.FieldContainsFold(FieldToken, v))
-}
-
 // HasTaskStages applies the HasEdge predicate on the "task_stages" edge.
 func HasTaskStages() predicate.SopTask {
 	return predicate.SopTask(func(s *sql.Selector) {

+ 5 - 17
ent/soptask_create.go

@@ -162,19 +162,11 @@ func (stc *SopTaskCreate) SetNillableOrganizationID(u *uint64) *SopTaskCreate {
 }
 
 // SetToken sets the "token" field.
-func (stc *SopTaskCreate) SetToken(s string) *SopTaskCreate {
+func (stc *SopTaskCreate) SetToken(s []string) *SopTaskCreate {
 	stc.mutation.SetToken(s)
 	return stc
 }
 
-// SetNillableToken sets the "token" field if the given value is not nil.
-func (stc *SopTaskCreate) SetNillableToken(s *string) *SopTaskCreate {
-	if s != nil {
-		stc.SetToken(*s)
-	}
-	return stc
-}
-
 // SetID sets the "id" field.
 func (stc *SopTaskCreate) SetID(u uint64) *SopTaskCreate {
 	stc.mutation.SetID(u)
@@ -259,10 +251,6 @@ func (stc *SopTaskCreate) defaults() error {
 		v := soptask.DefaultOrganizationID
 		stc.mutation.SetOrganizationID(v)
 	}
-	if _, ok := stc.mutation.Token(); !ok {
-		v := soptask.DefaultToken
-		stc.mutation.SetToken(v)
-	}
 	return nil
 }
 
@@ -363,7 +351,7 @@ func (stc *SopTaskCreate) createSpec() (*SopTask, *sqlgraph.CreateSpec) {
 		_node.OrganizationID = value
 	}
 	if value, ok := stc.mutation.Token(); ok {
-		_spec.SetField(soptask.FieldToken, field.TypeString, value)
+		_spec.SetField(soptask.FieldToken, field.TypeJSON, value)
 		_node.Token = value
 	}
 	if nodes := stc.mutation.TaskStagesIDs(); len(nodes) > 0 {
@@ -615,7 +603,7 @@ func (u *SopTaskUpsert) ClearOrganizationID() *SopTaskUpsert {
 }
 
 // SetToken sets the "token" field.
-func (u *SopTaskUpsert) SetToken(v string) *SopTaskUpsert {
+func (u *SopTaskUpsert) SetToken(v []string) *SopTaskUpsert {
 	u.Set(soptask.FieldToken, v)
 	return u
 }
@@ -894,7 +882,7 @@ func (u *SopTaskUpsertOne) ClearOrganizationID() *SopTaskUpsertOne {
 }
 
 // SetToken sets the "token" field.
-func (u *SopTaskUpsertOne) SetToken(v string) *SopTaskUpsertOne {
+func (u *SopTaskUpsertOne) SetToken(v []string) *SopTaskUpsertOne {
 	return u.Update(func(s *SopTaskUpsert) {
 		s.SetToken(v)
 	})
@@ -1342,7 +1330,7 @@ func (u *SopTaskUpsertBulk) ClearOrganizationID() *SopTaskUpsertBulk {
 }
 
 // SetToken sets the "token" field.
-func (u *SopTaskUpsertBulk) SetToken(v string) *SopTaskUpsertBulk {
+func (u *SopTaskUpsertBulk) SetToken(v []string) *SopTaskUpsertBulk {
 	return u.Update(func(s *SopTaskUpsert) {
 		s.SetToken(v)
 	})

+ 22 - 16
ent/soptask_update.go

@@ -224,16 +224,14 @@ func (stu *SopTaskUpdate) ClearOrganizationID() *SopTaskUpdate {
 }
 
 // SetToken sets the "token" field.
-func (stu *SopTaskUpdate) SetToken(s string) *SopTaskUpdate {
+func (stu *SopTaskUpdate) SetToken(s []string) *SopTaskUpdate {
 	stu.mutation.SetToken(s)
 	return stu
 }
 
-// SetNillableToken sets the "token" field if the given value is not nil.
-func (stu *SopTaskUpdate) SetNillableToken(s *string) *SopTaskUpdate {
-	if s != nil {
-		stu.SetToken(*s)
-	}
+// AppendToken appends s to the "token" field.
+func (stu *SopTaskUpdate) AppendToken(s []string) *SopTaskUpdate {
+	stu.mutation.AppendToken(s)
 	return stu
 }
 
@@ -414,10 +412,15 @@ func (stu *SopTaskUpdate) sqlSave(ctx context.Context) (n int, err error) {
 		_spec.ClearField(soptask.FieldOrganizationID, field.TypeUint64)
 	}
 	if value, ok := stu.mutation.Token(); ok {
-		_spec.SetField(soptask.FieldToken, field.TypeString, value)
+		_spec.SetField(soptask.FieldToken, field.TypeJSON, value)
+	}
+	if value, ok := stu.mutation.AppendedToken(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, soptask.FieldToken, value)
+		})
 	}
 	if stu.mutation.TokenCleared() {
-		_spec.ClearField(soptask.FieldToken, field.TypeString)
+		_spec.ClearField(soptask.FieldToken, field.TypeJSON)
 	}
 	if stu.mutation.TaskStagesCleared() {
 		edge := &sqlgraph.EdgeSpec{
@@ -678,16 +681,14 @@ func (stuo *SopTaskUpdateOne) ClearOrganizationID() *SopTaskUpdateOne {
 }
 
 // SetToken sets the "token" field.
-func (stuo *SopTaskUpdateOne) SetToken(s string) *SopTaskUpdateOne {
+func (stuo *SopTaskUpdateOne) SetToken(s []string) *SopTaskUpdateOne {
 	stuo.mutation.SetToken(s)
 	return stuo
 }
 
-// SetNillableToken sets the "token" field if the given value is not nil.
-func (stuo *SopTaskUpdateOne) SetNillableToken(s *string) *SopTaskUpdateOne {
-	if s != nil {
-		stuo.SetToken(*s)
-	}
+// AppendToken appends s to the "token" field.
+func (stuo *SopTaskUpdateOne) AppendToken(s []string) *SopTaskUpdateOne {
+	stuo.mutation.AppendToken(s)
 	return stuo
 }
 
@@ -898,10 +899,15 @@ func (stuo *SopTaskUpdateOne) sqlSave(ctx context.Context) (_node *SopTask, err
 		_spec.ClearField(soptask.FieldOrganizationID, field.TypeUint64)
 	}
 	if value, ok := stuo.mutation.Token(); ok {
-		_spec.SetField(soptask.FieldToken, field.TypeString, value)
+		_spec.SetField(soptask.FieldToken, field.TypeJSON, value)
+	}
+	if value, ok := stuo.mutation.AppendedToken(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, soptask.FieldToken, value)
+		})
 	}
 	if stuo.mutation.TokenCleared() {
-		_spec.ClearField(soptask.FieldToken, field.TypeString)
+		_spec.ClearField(soptask.FieldToken, field.TypeJSON)
 	}
 	if stuo.mutation.TaskStagesCleared() {
 		edge := &sqlgraph.EdgeSpec{

+ 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=
@@ -574,6 +576,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=

+ 6 - 5
internal/logic/sop_task/get_api_sop_task_list_logic.go

@@ -2,11 +2,12 @@ package sop_task
 
 import (
 	"context"
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqljson"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
 	"github.com/zeromicro/go-zero/core/errorx"
 	"net/http"
-	"wechat-api/ent/predicate"
 	"wechat-api/ent/soptask"
 	"wechat-api/ent/wx"
 	"wechat-api/hook"
@@ -38,10 +39,9 @@ func (l *GetApiSopTaskListLogic) GetApiSopTaskList(req *types.SopApiListReq, r *
 		return nil, errorx.NewCodeInvalidArgumentError("check auth failed")
 	}
 
-	var predicates []predicate.SopTask
-	predicates = append(predicates, soptask.Token(tokenStr))
-	predicates = append(predicates, soptask.StatusEQ(uint8(3)))
-	data, err := l.svcCtx.DB.SopTask.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
+	data, err := l.svcCtx.DB.SopTask.Query().Where(soptask.StatusEQ(uint8(3))).Where(func(s *sql.Selector) {
+		s.Where(sqljson.ValueContains("token", tokenStr))
+	}).Page(l.ctx, req.Page, req.PageSize)
 
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
@@ -70,6 +70,7 @@ func (l *GetApiSopTaskListLogic) GetApiSopTaskList(req *types.SopApiListReq, r *
 			PlanStartTime: pointy.GetUnixMilliPointer(v.PlanStartTime.UnixMilli()),
 			PlanEndTime:   pointy.GetUnixMilliPointer(v.PlanEndTime.UnixMilli()),
 			CreatorId:     &v.CreatorID,
+			Token:         v.Token,
 		})
 	}
 

+ 1 - 7
internal/logic/sop_task/update_sop_task_logic.go

@@ -36,12 +36,6 @@ func (l *UpdateSopTaskLogic) UpdateSopTask(req *types.SopTaskInfo) (*types.BaseM
 		return nil, dberrorhandler.DefaultEntError(l.Logger, fmt.Errorf("planEndTime must be greater than planStartTime"), req)
 	}
 
-	var token *string
-	if req.Token != nil {
-		token = req.Token
-		req.BotWxidList = nil
-	}
-
 	err := l.svcCtx.DB.SopTask.UpdateOneID(*req.Id).
 		Where(soptask.StatusEQ(1), soptask.OrganizationID(organizationId)).
 		SetNotNilStatus(req.Status).
@@ -51,7 +45,7 @@ func (l *UpdateSopTaskLogic) UpdateSopTask(req *types.SopTaskInfo) (*types.BaseM
 		SetNotNilPlanStartTime(pointy.GetTimeMilliPointer(req.PlanStartTime)).
 		SetNotNilPlanEndTime(pointy.GetTimeMilliPointer(req.PlanEndTime)).
 		SetNotNilCreatorID(req.CreatorId).
-		SetNotNilToken(token).
+		SetNotNilToken(req.Token).
 		Exec(l.ctx)
 
 	if err != nil {

+ 1 - 1
internal/types/types.go

@@ -1284,7 +1284,7 @@ type SopTaskInfo struct {
 	// 组织ID
 	OrganizationId *uint64 `json:"organizationId,optional"`
 	// Token
-	Token *string `json:"token,optional"`
+	Token []string `json:"token,optional"`
 }
 
 // The response data of sop node information | SopNode信息