jimmyyem пре 2 месеци
родитељ
комит
268e8a3d72

+ 2 - 2
ent/migrate/schema.go

@@ -1042,8 +1042,8 @@ var (
 		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
 		{Name: "ak", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "sk", Type: field.TypeString, Default: ""},
-		{Name: "callback", Type: field.TypeString, Default: ""},
-		{Name: "account", Type: field.TypeString, Default: ""},
+		{Name: "callback", Type: field.TypeString, Nullable: true, Default: ""},
+		{Name: "account", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "nickname", Type: field.TypeString, Default: ""},
 		{Name: "phone", Type: field.TypeString, Default: ""},
 		{Name: "organization_id", Type: field.TypeUint64, Nullable: true, Default: 0},

+ 38 - 0
ent/mutation.go

@@ -37375,9 +37375,22 @@ func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error
 	return oldValue.Callback, nil
 }
 
+// ClearCallback clears the value of the "callback" field.
+func (m *WhatsappMutation) ClearCallback() {
+	m.callback = nil
+	m.clearedFields[whatsapp.FieldCallback] = struct{}{}
+}
+
+// CallbackCleared returns if the "callback" field was cleared in this mutation.
+func (m *WhatsappMutation) CallbackCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldCallback]
+	return ok
+}
+
 // ResetCallback resets all changes to the "callback" field.
 func (m *WhatsappMutation) ResetCallback() {
 	m.callback = nil
+	delete(m.clearedFields, whatsapp.FieldCallback)
 }
 
 // SetAccount sets the "account" field.
@@ -37411,9 +37424,22 @@ func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error)
 	return oldValue.Account, nil
 }
 
+// ClearAccount clears the value of the "account" field.
+func (m *WhatsappMutation) ClearAccount() {
+	m.account = nil
+	m.clearedFields[whatsapp.FieldAccount] = struct{}{}
+}
+
+// AccountCleared returns if the "account" field was cleared in this mutation.
+func (m *WhatsappMutation) AccountCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldAccount]
+	return ok
+}
+
 // ResetAccount resets all changes to the "account" field.
 func (m *WhatsappMutation) ResetAccount() {
 	m.account = nil
+	delete(m.clearedFields, whatsapp.FieldAccount)
 }
 
 // SetNickname sets the "nickname" field.
@@ -38358,6 +38384,12 @@ func (m *WhatsappMutation) ClearedFields() []string {
 	if m.FieldCleared(whatsapp.FieldAk) {
 		fields = append(fields, whatsapp.FieldAk)
 	}
+	if m.FieldCleared(whatsapp.FieldCallback) {
+		fields = append(fields, whatsapp.FieldCallback)
+	}
+	if m.FieldCleared(whatsapp.FieldAccount) {
+		fields = append(fields, whatsapp.FieldAccount)
+	}
 	if m.FieldCleared(whatsapp.FieldOrganizationID) {
 		fields = append(fields, whatsapp.FieldOrganizationID)
 	}
@@ -38402,6 +38434,12 @@ func (m *WhatsappMutation) ClearField(name string) error {
 	case whatsapp.FieldAk:
 		m.ClearAk()
 		return nil
+	case whatsapp.FieldCallback:
+		m.ClearCallback()
+		return nil
+	case whatsapp.FieldAccount:
+		m.ClearAccount()
+		return nil
 	case whatsapp.FieldOrganizationID:
 		m.ClearOrganizationID()
 		return nil

+ 2 - 2
ent/schema/whatsapp.go

@@ -20,8 +20,8 @@ func (Whatsapp) Fields() []ent.Field {
 	return []ent.Field{
 		field.String("ak").Optional().Default("").Comment("ak"),
 		field.String("sk").Default("").Comment("端口号"),
-		field.String("callback").Default("").Comment("回调地址"),
-		field.String("account").Default("").Comment("微信账号"),
+		field.String("callback").Optional().Default("").Comment("回调地址"),
+		field.String("account").Optional().Default("").Comment("微信账号"),
 		field.String("nickname").Default("").Comment("昵称"),
 		field.String("phone").Default("").Comment("手机号"),
 		field.Uint64("organization_id").Optional().Default(0).Comment("机构 ID"),

+ 20 - 0
ent/whatsapp/where.go

@@ -500,6 +500,16 @@ func CallbackHasSuffix(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldHasSuffix(FieldCallback, v))
 }
 
+// CallbackIsNil applies the IsNil predicate on the "callback" field.
+func CallbackIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldCallback))
+}
+
+// CallbackNotNil applies the NotNil predicate on the "callback" field.
+func CallbackNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldCallback))
+}
+
 // CallbackEqualFold applies the EqualFold predicate on the "callback" field.
 func CallbackEqualFold(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEqualFold(FieldCallback, v))
@@ -565,6 +575,16 @@ func AccountHasSuffix(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldHasSuffix(FieldAccount, v))
 }
 
+// AccountIsNil applies the IsNil predicate on the "account" field.
+func AccountIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldAccount))
+}
+
+// AccountNotNil applies the NotNil predicate on the "account" field.
+func AccountNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldAccount))
+}
+
 // AccountEqualFold applies the EqualFold predicate on the "account" field.
 func AccountEqualFold(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEqualFold(FieldAccount, v))

+ 40 - 6
ent/whatsapp_create.go

@@ -363,12 +363,6 @@ func (wc *WhatsappCreate) check() error {
 	if _, ok := wc.mutation.Sk(); !ok {
 		return &ValidationError{Name: "sk", err: errors.New(`ent: missing required field "Whatsapp.sk"`)}
 	}
-	if _, ok := wc.mutation.Callback(); !ok {
-		return &ValidationError{Name: "callback", err: errors.New(`ent: missing required field "Whatsapp.callback"`)}
-	}
-	if _, ok := wc.mutation.Account(); !ok {
-		return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Whatsapp.account"`)}
-	}
 	if _, ok := wc.mutation.Nickname(); !ok {
 		return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Whatsapp.nickname"`)}
 	}
@@ -647,6 +641,12 @@ func (u *WhatsappUpsert) UpdateCallback() *WhatsappUpsert {
 	return u
 }
 
+// ClearCallback clears the value of the "callback" field.
+func (u *WhatsappUpsert) ClearCallback() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldCallback)
+	return u
+}
+
 // SetAccount sets the "account" field.
 func (u *WhatsappUpsert) SetAccount(v string) *WhatsappUpsert {
 	u.Set(whatsapp.FieldAccount, v)
@@ -659,6 +659,12 @@ func (u *WhatsappUpsert) UpdateAccount() *WhatsappUpsert {
 	return u
 }
 
+// ClearAccount clears the value of the "account" field.
+func (u *WhatsappUpsert) ClearAccount() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldAccount)
+	return u
+}
+
 // SetNickname sets the "nickname" field.
 func (u *WhatsappUpsert) SetNickname(v string) *WhatsappUpsert {
 	u.Set(whatsapp.FieldNickname, v)
@@ -990,6 +996,13 @@ func (u *WhatsappUpsertOne) UpdateCallback() *WhatsappUpsertOne {
 	})
 }
 
+// ClearCallback clears the value of the "callback" field.
+func (u *WhatsappUpsertOne) ClearCallback() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearCallback()
+	})
+}
+
 // SetAccount sets the "account" field.
 func (u *WhatsappUpsertOne) SetAccount(v string) *WhatsappUpsertOne {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1004,6 +1017,13 @@ func (u *WhatsappUpsertOne) UpdateAccount() *WhatsappUpsertOne {
 	})
 }
 
+// ClearAccount clears the value of the "account" field.
+func (u *WhatsappUpsertOne) ClearAccount() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAccount()
+	})
+}
+
 // SetNickname sets the "nickname" field.
 func (u *WhatsappUpsertOne) SetNickname(v string) *WhatsappUpsertOne {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1529,6 +1549,13 @@ func (u *WhatsappUpsertBulk) UpdateCallback() *WhatsappUpsertBulk {
 	})
 }
 
+// ClearCallback clears the value of the "callback" field.
+func (u *WhatsappUpsertBulk) ClearCallback() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearCallback()
+	})
+}
+
 // SetAccount sets the "account" field.
 func (u *WhatsappUpsertBulk) SetAccount(v string) *WhatsappUpsertBulk {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1543,6 +1570,13 @@ func (u *WhatsappUpsertBulk) UpdateAccount() *WhatsappUpsertBulk {
 	})
 }
 
+// ClearAccount clears the value of the "account" field.
+func (u *WhatsappUpsertBulk) ClearAccount() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAccount()
+	})
+}
+
 // SetNickname sets the "nickname" field.
 func (u *WhatsappUpsertBulk) SetNickname(v string) *WhatsappUpsertBulk {
 	return u.Update(func(s *WhatsappUpsert) {

+ 36 - 0
ent/whatsapp_update.go

@@ -131,6 +131,12 @@ func (wu *WhatsappUpdate) SetNillableCallback(s *string) *WhatsappUpdate {
 	return wu
 }
 
+// ClearCallback clears the value of the "callback" field.
+func (wu *WhatsappUpdate) ClearCallback() *WhatsappUpdate {
+	wu.mutation.ClearCallback()
+	return wu
+}
+
 // SetAccount sets the "account" field.
 func (wu *WhatsappUpdate) SetAccount(s string) *WhatsappUpdate {
 	wu.mutation.SetAccount(s)
@@ -145,6 +151,12 @@ func (wu *WhatsappUpdate) SetNillableAccount(s *string) *WhatsappUpdate {
 	return wu
 }
 
+// ClearAccount clears the value of the "account" field.
+func (wu *WhatsappUpdate) ClearAccount() *WhatsappUpdate {
+	wu.mutation.ClearAccount()
+	return wu
+}
+
 // SetNickname sets the "nickname" field.
 func (wu *WhatsappUpdate) SetNickname(s string) *WhatsappUpdate {
 	wu.mutation.SetNickname(s)
@@ -434,9 +446,15 @@ func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if value, ok := wu.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
 	}
+	if wu.mutation.CallbackCleared() {
+		_spec.ClearField(whatsapp.FieldCallback, field.TypeString)
+	}
 	if value, ok := wu.mutation.Account(); ok {
 		_spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
 	}
+	if wu.mutation.AccountCleared() {
+		_spec.ClearField(whatsapp.FieldAccount, field.TypeString)
+	}
 	if value, ok := wu.mutation.Nickname(); ok {
 		_spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
 	}
@@ -658,6 +676,12 @@ func (wuo *WhatsappUpdateOne) SetNillableCallback(s *string) *WhatsappUpdateOne
 	return wuo
 }
 
+// ClearCallback clears the value of the "callback" field.
+func (wuo *WhatsappUpdateOne) ClearCallback() *WhatsappUpdateOne {
+	wuo.mutation.ClearCallback()
+	return wuo
+}
+
 // SetAccount sets the "account" field.
 func (wuo *WhatsappUpdateOne) SetAccount(s string) *WhatsappUpdateOne {
 	wuo.mutation.SetAccount(s)
@@ -672,6 +696,12 @@ func (wuo *WhatsappUpdateOne) SetNillableAccount(s *string) *WhatsappUpdateOne {
 	return wuo
 }
 
+// ClearAccount clears the value of the "account" field.
+func (wuo *WhatsappUpdateOne) ClearAccount() *WhatsappUpdateOne {
+	wuo.mutation.ClearAccount()
+	return wuo
+}
+
 // SetNickname sets the "nickname" field.
 func (wuo *WhatsappUpdateOne) SetNickname(s string) *WhatsappUpdateOne {
 	wuo.mutation.SetNickname(s)
@@ -991,9 +1021,15 @@ func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err
 	if value, ok := wuo.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
 	}
+	if wuo.mutation.CallbackCleared() {
+		_spec.ClearField(whatsapp.FieldCallback, field.TypeString)
+	}
 	if value, ok := wuo.mutation.Account(); ok {
 		_spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
 	}
+	if wuo.mutation.AccountCleared() {
+		_spec.ClearField(whatsapp.FieldAccount, field.TypeString)
+	}
 	if value, ok := wuo.mutation.Nickname(); ok {
 		_spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
 	}

+ 0 - 1
internal/logic/whatsapp/create_whatsapp_logic.go

@@ -30,7 +30,6 @@ func (l *CreateWhatsappLogic) CreateWhatsapp(req *types.WhatsappInfo) (*types.Ba
 	var stringSlice []string
 
 	_, err := l.svcCtx.DB.Whatsapp.Create().
-		SetNotNilStatus(req.Status).
 		SetNotNilAk(req.Ak).
 		SetNotNilSk(req.Sk).
 		SetNotNilCallback(req.Callback).

+ 0 - 1
internal/logic/whatsapp/get_whatsapp_by_id_logic.go

@@ -66,7 +66,6 @@ func (l *GetWhatsappByIdLogic) GetWhatsappById(req *types.IDReq) (*types.Whatsap
 				CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
 				UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
 			},
-			Status:           &data.Status,
 			Ak:               &data.Ak,
 			Sk:               &data.Sk,
 			Callback:         &data.Callback,

+ 0 - 1
internal/logic/whatsapp/get_whatsapp_list_logic.go

@@ -79,7 +79,6 @@ func (l *GetWhatsappListLogic) GetWhatsappList(req *types.WhatsappListReq) (*typ
 					CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
 					UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
 				},
-				Status:           &v.Status,
 				Ak:               &v.Ak,
 				Sk:               &v.Sk,
 				Callback:         &v.Callback,

+ 0 - 1
internal/logic/whatsapp/update_whatsapp_logic.go

@@ -27,7 +27,6 @@ func NewUpdateWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Up
 
 func (l *UpdateWhatsappLogic) UpdateWhatsapp(req *types.WhatsappInfo) (*types.BaseMsgResp, error) {
 	err := l.svcCtx.DB.Whatsapp.UpdateOneID(*req.Id).
-		SetNotNilStatus(req.Status).
 		SetNotNilAk(req.Ak).
 		SetNotNilSk(req.Sk).
 		SetNotNilCallback(req.Callback).