Browse Source

Merge branch 'task_526_lichangdong_250424'

lichangdong 1 day ago
parent
commit
fa419cb534
33 changed files with 2257 additions and 108 deletions
  1. 1 0
      crontask/init.go
  2. 8 1
      crontask/wx_add_friend.go
  3. 10 4
      desc/openapi/chat.api
  4. 53 4
      desc/wechat/add_wechat_friend_log.api
  5. 50 6
      ent/addwechatfriendlog.go
  6. 44 0
      ent/addwechatfriendlog/addwechatfriendlog.go
  7. 270 0
      ent/addwechatfriendlog/where.go
  8. 378 0
      ent/addwechatfriendlog_create.go
  9. 268 0
      ent/addwechatfriendlog_update.go
  10. 14 0
      ent/migrate/schema.go
  11. 387 27
      ent/mutation.go
  12. 20 0
      ent/runtime/runtime.go
  13. 14 14
      ent/schema/add_wechat_friend_log.go
  14. 96 0
      ent/set_not_nil.go
  15. 32 0
      hook/contact.go
  16. 0 2
      internal/handler/add_friend/add_friend_by_phone_handler.go
  17. 42 0
      internal/handler/add_friend/add_friend_list_handler.go
  18. 44 0
      internal/handler/add_friend/cancel_by_ids_handler.go
  19. 10 0
      internal/handler/routes.go
  20. 3 2
      internal/logic/Wxhook/get_friends_and_groups_logic.go
  21. 8 1
      internal/logic/add_friend/add_friend_by_phone_logic.go
  22. 122 0
      internal/logic/add_friend/add_friend_list_logic.go
  23. 48 0
      internal/logic/add_friend/cancel_by_ids_logic.go
  24. 201 23
      internal/logic/chat/add_friend_by_phone_logic.go
  25. 4 3
      internal/middleware/authority_middleware.go
  26. 1 0
      internal/middleware/openauthority_middleware.go
  27. 0 6
      internal/pkg/util/strings.go
  28. 10 2
      internal/service/MessageHandlers/find_contact_task_result_notice.go
  29. 9 3
      internal/service/MessageHandlers/task_result_notice.go
  30. 3 2
      internal/service/addfriend/add_wechat_friend_log.go
  31. 59 8
      internal/types/types.go
  32. 32 0
      internal/utils/strings.go
  33. 16 0
      internal/utils/typekit/list.go

+ 1 - 0
crontask/init.go

@@ -24,6 +24,7 @@ func NewCronTask(ctx context.Context, svcCtx *svc.ServiceContext) *CronTask {
 
 func ScheduleRun(c *cron.Cron, serverCtx *svc.ServiceContext) {
 
+	//除了fe环境任务关闭 其他环境任务要正常打开
 	l := NewCronTask(context.Background(), serverCtx)
 	c.AddFunc("* * * * *", func() {
 		l.sendMsg()

+ 8 - 1
crontask/wx_add_friend.go

@@ -121,8 +121,15 @@ func (me *CronTask) getTaskList() ([]*ent.AddWechatFriendLog, error) {
 		WITH RandRanked AS (
     		SELECT %s,ROW_NUMBER() OVER(PARTITION BY owner_wx_id ORDER BY id DESC) as rn
     		FROM add_wechat_friend_log
-		    WHERE is_can_add = 1 AND task_count < 3)
+		    WHERE is_can_add = 1 )
 		SELECT %s FROM RandRanked WHERE rn = 1;`, fieldListStr, fieldListStr)
+	/*
+				rawQuery := fmt.Sprintf(`
+				WITH RandRanked AS (
+		    		SELECT %s,ROW_NUMBER() OVER(PARTITION BY owner_wx_id ORDER BY id DESC) as rn
+		    		FROM add_wechat_friend_log
+				    WHERE is_can_add = 1 AND task_count < 3)
+				SELECT %s FROM RandRanked WHERE rn = 1;`, fieldListStr, fieldListStr)*/
 
 	//fmt.Println(rawQuery)
 	// 执行原始查询

+ 10 - 4
desc/openapi/chat.api

@@ -1,14 +1,20 @@
 import "../base.api"
+import "../wechat/wxhook.api"
 
 type (
     
     
 	//add_friend_by_phone api接口请求值
 	AddFriendByPhoneReq {
-		Type int `json:"type"`
-		WeChatId string `json:"WeChatId"`
-		Phone string `json:"phone"`
+		Type int `json:"type,options=1|3,default=1"`
+		WeChatIds []string `json:"wechat_ids,optional,omitempty"`
+		Phones []string `json:"phones"`
 		Message string `json:"message"`
+		CallbackURL string `json:"callback_url,optional"`
+	}
+
+	NullReq {
+
 	}
 
 	//以下是API请求类型
@@ -202,7 +208,7 @@ type (
 service Wechat {
     
     @handler getAuth
-    get /chat/getauth () returns (BaseMsgResp)
+    get /chat/getauth (NullReq) returns (BaseMsgResp)
 }
 
 @server(

+ 53 - 4
desc/wechat/add_wechat_friend_log.api

@@ -4,10 +4,50 @@ type (
     
     //add_friend_by_phone api接口请求值
     AddWechatFriendLogInfo {
-        Type int `json:"type"`
-        WeChatIds []string `json:"WeChatId,optional,omitempty"`
-        Phone string `json:"phone"`
-        Message string `json:"message"`
+        Type int `json:"type,options=1|3,default=1"`
+		WeChatIds []string `json:"wechat_ids,optional,omitempty"`
+		Phones []string `json:"phones"`
+		Message string `json:"message"`
+		CallbackURL string `json:"callback_url,optional"`
+    }
+
+    AddFriendListReq {
+        PageInfo
+        OwnerWxId *string `json:"wxId,optional"`
+        OwnerWxType *int `json:"type,optional"`
+        FindContent *string `json:"phone,optional"`
+        status *int `json:"status,optional"`
+    }
+
+     AddFriendListResp {
+        BaseDataInfo
+        Data FriendListInfo `json:"data"`
+     }
+
+    FriendListInfo {
+        BaseListInfo
+        Data []FriendList `json:"data"`
+    }
+
+    FriendList{
+        Id int64 `json:"id,optional"`
+        // 微信id 公众号微信ID
+        OwnerWxId  *string `json:"wxId,optional"`
+        OwnerWxType  *string `json:"wxType,optional"`
+        FindContent  *string `json:"phone,optional"`
+        Status *string `json:"status,optional"`
+        StatusInt *int `json:"statusInt,optional"`
+        ErrMessage  *string `json:"errMessage,optional"`
+        TaskCount  *int `json:"taskCount,optional"`
+        isShow  *int `json:"isShow,optional"`
+        // 微信昵称 群备注名称
+        Message  *string `json:"message,optional"`
+        CreateTime  *string `json:"createTime,optional"`
+        UpdateTime  *string `json:"updateTime,optional"`
+    }
+
+    CancelByIdsReq {
+        Ids []int64 `json:"ids" validate:"required,min=1"`
     }
 )
 
@@ -21,4 +61,13 @@ service Wechat {
     // 手机号加好友接口
     @handler AddFriendByPhone
     post /add_friend/add_friend_by_phone (AddWechatFriendLogInfo) returns (BaseMsgResp)
+
+    // 添加好友的列表接口
+    @handler AddFriendList
+    post /add_friend/add_friend_list (AddFriendListReq) returns (AddFriendListResp)
+
+    // cancel task add friend
+    @handler CancelByIds
+    post /add_friend/cancel_by_ids (CancelByIdsReq) returns (BaseMsgResp)
+
 } 

+ 50 - 6
ent/addwechatfriendlog.go

@@ -20,7 +20,7 @@ type AddWechatFriendLog struct {
 	ID int64 `json:"id,omitempty"`
 	// 属主的wxid
 	OwnerWxID string `json:"owner_wx_id,omitempty"`
-	// 属主的微信类型(1个微,2企微)
+	// 属主的微信类型(1个微,3企微)
 	OwnerWxType int `json:"owner_wx_type,omitempty"`
 	// 手机号
 	FindContent string `json:"find_content,omitempty"`
@@ -32,7 +32,7 @@ type AddWechatFriendLog struct {
 	FindResult map[string]interface{} `json:"find_result,omitempty"`
 	// 任务执行次数
 	IsCanAdd int `json:"is_can_add,omitempty"`
-	// 是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以 2成功添加申请
+	// 是否可以添加好友(与属主账号非好友且其数据查询正常时 0数据准备中,1 待执行 2成功添加申请 3timeout及其他错误 4用户不存在 5手动取消 6已经是好友
 	TaskCount int `json:"task_count,omitempty"`
 	// 添加时候的请求体
 	TaskID int64 `json:"task_id,omitempty"`
@@ -43,8 +43,16 @@ type AddWechatFriendLog struct {
 	// 创建时间戳
 	CreatedAt int64 `json:"created_at,omitempty"`
 	// 修改时间戳
-	UpdatedAt    int64 `json:"updated_at,omitempty"`
-	selectValues sql.SelectValues
+	UpdatedAt int64 `json:"updated_at,omitempty"`
+	// 1.api录入 2.人工导入
+	Source int `json:"source,omitempty"`
+	// 用户名称
+	NickName string `json:"nick_name,omitempty"`
+	// 用户头像
+	Avatar string `json:"avatar,omitempty"`
+	// 组织架构id
+	OrganizationID int64 `json:"organization_id,omitempty"`
+	selectValues   sql.SelectValues
 }
 
 // scanValues returns the types for scanning values from sql.Rows.
@@ -54,9 +62,9 @@ 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.FieldTaskCount, addwechatfriendlog.FieldTaskID, addwechatfriendlog.FieldCreatedAt, addwechatfriendlog.FieldUpdatedAt:
+		case addwechatfriendlog.FieldID, addwechatfriendlog.FieldOwnerWxType, addwechatfriendlog.FieldIsCanAdd, addwechatfriendlog.FieldTaskCount, addwechatfriendlog.FieldTaskID, addwechatfriendlog.FieldCreatedAt, addwechatfriendlog.FieldUpdatedAt, addwechatfriendlog.FieldSource, addwechatfriendlog.FieldOrganizationID:
 			values[i] = new(sql.NullInt64)
-		case addwechatfriendlog.FieldOwnerWxID, addwechatfriendlog.FieldFindContent, addwechatfriendlog.FieldMessage:
+		case addwechatfriendlog.FieldOwnerWxID, addwechatfriendlog.FieldFindContent, addwechatfriendlog.FieldMessage, addwechatfriendlog.FieldNickName, addwechatfriendlog.FieldAvatar:
 			values[i] = new(sql.NullString)
 		default:
 			values[i] = new(sql.UnknownType)
@@ -165,6 +173,30 @@ func (awfl *AddWechatFriendLog) assignValues(columns []string, values []any) err
 			} else if value.Valid {
 				awfl.UpdatedAt = value.Int64
 			}
+		case addwechatfriendlog.FieldSource:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field source", values[i])
+			} else if value.Valid {
+				awfl.Source = int(value.Int64)
+			}
+		case addwechatfriendlog.FieldNickName:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field nick_name", values[i])
+			} else if value.Valid {
+				awfl.NickName = value.String
+			}
+		case addwechatfriendlog.FieldAvatar:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field avatar", values[i])
+			} else if value.Valid {
+				awfl.Avatar = value.String
+			}
+		case addwechatfriendlog.FieldOrganizationID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field organization_id", values[i])
+			} else if value.Valid {
+				awfl.OrganizationID = value.Int64
+			}
 		default:
 			awfl.selectValues.Set(columns[i], values[i])
 		}
@@ -239,6 +271,18 @@ func (awfl *AddWechatFriendLog) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("updated_at=")
 	builder.WriteString(fmt.Sprintf("%v", awfl.UpdatedAt))
+	builder.WriteString(", ")
+	builder.WriteString("source=")
+	builder.WriteString(fmt.Sprintf("%v", awfl.Source))
+	builder.WriteString(", ")
+	builder.WriteString("nick_name=")
+	builder.WriteString(awfl.NickName)
+	builder.WriteString(", ")
+	builder.WriteString("avatar=")
+	builder.WriteString(awfl.Avatar)
+	builder.WriteString(", ")
+	builder.WriteString("organization_id=")
+	builder.WriteString(fmt.Sprintf("%v", awfl.OrganizationID))
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 44 - 0
ent/addwechatfriendlog/addwechatfriendlog.go

@@ -37,6 +37,14 @@ const (
 	FieldCreatedAt = "created_at"
 	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
 	FieldUpdatedAt = "updated_at"
+	// FieldSource holds the string denoting the source field in the database.
+	FieldSource = "source"
+	// FieldNickName holds the string denoting the nick_name field in the database.
+	FieldNickName = "nick_name"
+	// FieldAvatar holds the string denoting the avatar field in the database.
+	FieldAvatar = "avatar"
+	// FieldOrganizationID holds the string denoting the organization_id field in the database.
+	FieldOrganizationID = "organization_id"
 	// Table holds the table name of the addwechatfriendlog in the database.
 	Table = "add_wechat_friend_log"
 )
@@ -57,6 +65,10 @@ var Columns = []string{
 	FieldAddResult,
 	FieldCreatedAt,
 	FieldUpdatedAt,
+	FieldSource,
+	FieldNickName,
+	FieldAvatar,
+	FieldOrganizationID,
 }
 
 // ValidColumn reports if the column name is valid (part of the table columns).
@@ -96,6 +108,18 @@ var (
 	DefaultUpdatedAt func() int64
 	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
 	UpdateDefaultUpdatedAt func() int64
+	// DefaultSource holds the default value on creation for the "source" field.
+	DefaultSource int
+	// DefaultNickName holds the default value on creation for the "nick_name" field.
+	DefaultNickName string
+	// NickNameValidator is a validator for the "nick_name" field. It is called by the builders before save.
+	NickNameValidator func(string) error
+	// DefaultAvatar holds the default value on creation for the "avatar" field.
+	DefaultAvatar string
+	// AvatarValidator is a validator for the "avatar" field. It is called by the builders before save.
+	AvatarValidator func(string) error
+	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
+	DefaultOrganizationID int64
 )
 
 // OrderOption defines the ordering options for the AddWechatFriendLog queries.
@@ -150,3 +174,23 @@ func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
 func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
 }
+
+// BySource orders the results by the source field.
+func BySource(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldSource, opts...).ToFunc()
+}
+
+// ByNickName orders the results by the nick_name field.
+func ByNickName(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldNickName, opts...).ToFunc()
+}
+
+// ByAvatar orders the results by the avatar field.
+func ByAvatar(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAvatar, opts...).ToFunc()
+}
+
+// ByOrganizationID orders the results by the organization_id field.
+func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
+}

+ 270 - 0
ent/addwechatfriendlog/where.go

@@ -98,6 +98,26 @@ func UpdatedAt(v int64) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldUpdatedAt, v))
 }
 
+// Source applies equality check predicate on the "source" field. It's identical to SourceEQ.
+func Source(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldSource, v))
+}
+
+// NickName applies equality check predicate on the "nick_name" field. It's identical to NickNameEQ.
+func NickName(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldNickName, v))
+}
+
+// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ.
+func Avatar(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldAvatar, v))
+}
+
+// OrganizationID applies equality check predicate on the "organization_id" field. It's identical to OrganizationIDEQ.
+func OrganizationID(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldOrganizationID, v))
+}
+
 // OwnerWxIDEQ applies the EQ predicate on the "owner_wx_id" field.
 func OwnerWxIDEQ(v string) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldOwnerWxID, v))
@@ -573,6 +593,256 @@ func UpdatedAtLTE(v int64) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldUpdatedAt, v))
 }
 
+// SourceEQ applies the EQ predicate on the "source" field.
+func SourceEQ(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldSource, v))
+}
+
+// SourceNEQ applies the NEQ predicate on the "source" field.
+func SourceNEQ(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNEQ(FieldSource, v))
+}
+
+// SourceIn applies the In predicate on the "source" field.
+func SourceIn(vs ...int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIn(FieldSource, vs...))
+}
+
+// SourceNotIn applies the NotIn predicate on the "source" field.
+func SourceNotIn(vs ...int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotIn(FieldSource, vs...))
+}
+
+// SourceGT applies the GT predicate on the "source" field.
+func SourceGT(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGT(FieldSource, v))
+}
+
+// SourceGTE applies the GTE predicate on the "source" field.
+func SourceGTE(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGTE(FieldSource, v))
+}
+
+// SourceLT applies the LT predicate on the "source" field.
+func SourceLT(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLT(FieldSource, v))
+}
+
+// SourceLTE applies the LTE predicate on the "source" field.
+func SourceLTE(v int) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldSource, v))
+}
+
+// SourceIsNil applies the IsNil predicate on the "source" field.
+func SourceIsNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIsNull(FieldSource))
+}
+
+// SourceNotNil applies the NotNil predicate on the "source" field.
+func SourceNotNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotNull(FieldSource))
+}
+
+// NickNameEQ applies the EQ predicate on the "nick_name" field.
+func NickNameEQ(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldNickName, v))
+}
+
+// NickNameNEQ applies the NEQ predicate on the "nick_name" field.
+func NickNameNEQ(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNEQ(FieldNickName, v))
+}
+
+// NickNameIn applies the In predicate on the "nick_name" field.
+func NickNameIn(vs ...string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIn(FieldNickName, vs...))
+}
+
+// NickNameNotIn applies the NotIn predicate on the "nick_name" field.
+func NickNameNotIn(vs ...string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotIn(FieldNickName, vs...))
+}
+
+// NickNameGT applies the GT predicate on the "nick_name" field.
+func NickNameGT(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGT(FieldNickName, v))
+}
+
+// NickNameGTE applies the GTE predicate on the "nick_name" field.
+func NickNameGTE(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGTE(FieldNickName, v))
+}
+
+// NickNameLT applies the LT predicate on the "nick_name" field.
+func NickNameLT(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLT(FieldNickName, v))
+}
+
+// NickNameLTE applies the LTE predicate on the "nick_name" field.
+func NickNameLTE(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldNickName, v))
+}
+
+// NickNameContains applies the Contains predicate on the "nick_name" field.
+func NickNameContains(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldContains(FieldNickName, v))
+}
+
+// NickNameHasPrefix applies the HasPrefix predicate on the "nick_name" field.
+func NickNameHasPrefix(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldHasPrefix(FieldNickName, v))
+}
+
+// NickNameHasSuffix applies the HasSuffix predicate on the "nick_name" field.
+func NickNameHasSuffix(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldHasSuffix(FieldNickName, v))
+}
+
+// NickNameIsNil applies the IsNil predicate on the "nick_name" field.
+func NickNameIsNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIsNull(FieldNickName))
+}
+
+// NickNameNotNil applies the NotNil predicate on the "nick_name" field.
+func NickNameNotNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotNull(FieldNickName))
+}
+
+// NickNameEqualFold applies the EqualFold predicate on the "nick_name" field.
+func NickNameEqualFold(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEqualFold(FieldNickName, v))
+}
+
+// NickNameContainsFold applies the ContainsFold predicate on the "nick_name" field.
+func NickNameContainsFold(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldContainsFold(FieldNickName, v))
+}
+
+// AvatarEQ applies the EQ predicate on the "avatar" field.
+func AvatarEQ(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldAvatar, v))
+}
+
+// AvatarNEQ applies the NEQ predicate on the "avatar" field.
+func AvatarNEQ(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNEQ(FieldAvatar, v))
+}
+
+// AvatarIn applies the In predicate on the "avatar" field.
+func AvatarIn(vs ...string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIn(FieldAvatar, vs...))
+}
+
+// AvatarNotIn applies the NotIn predicate on the "avatar" field.
+func AvatarNotIn(vs ...string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotIn(FieldAvatar, vs...))
+}
+
+// AvatarGT applies the GT predicate on the "avatar" field.
+func AvatarGT(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGT(FieldAvatar, v))
+}
+
+// AvatarGTE applies the GTE predicate on the "avatar" field.
+func AvatarGTE(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGTE(FieldAvatar, v))
+}
+
+// AvatarLT applies the LT predicate on the "avatar" field.
+func AvatarLT(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLT(FieldAvatar, v))
+}
+
+// AvatarLTE applies the LTE predicate on the "avatar" field.
+func AvatarLTE(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldAvatar, v))
+}
+
+// AvatarContains applies the Contains predicate on the "avatar" field.
+func AvatarContains(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldContains(FieldAvatar, v))
+}
+
+// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field.
+func AvatarHasPrefix(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldHasPrefix(FieldAvatar, v))
+}
+
+// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field.
+func AvatarHasSuffix(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldHasSuffix(FieldAvatar, v))
+}
+
+// AvatarIsNil applies the IsNil predicate on the "avatar" field.
+func AvatarIsNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIsNull(FieldAvatar))
+}
+
+// AvatarNotNil applies the NotNil predicate on the "avatar" field.
+func AvatarNotNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotNull(FieldAvatar))
+}
+
+// AvatarEqualFold applies the EqualFold predicate on the "avatar" field.
+func AvatarEqualFold(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEqualFold(FieldAvatar, v))
+}
+
+// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field.
+func AvatarContainsFold(v string) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldContainsFold(FieldAvatar, v))
+}
+
+// OrganizationIDEQ applies the EQ predicate on the "organization_id" field.
+func OrganizationIDEQ(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDNEQ applies the NEQ predicate on the "organization_id" field.
+func OrganizationIDNEQ(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDIn applies the In predicate on the "organization_id" field.
+func OrganizationIDIn(vs ...int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDNotIn applies the NotIn predicate on the "organization_id" field.
+func OrganizationIDNotIn(vs ...int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDGT applies the GT predicate on the "organization_id" field.
+func OrganizationIDGT(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGT(FieldOrganizationID, v))
+}
+
+// OrganizationIDGTE applies the GTE predicate on the "organization_id" field.
+func OrganizationIDGTE(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldGTE(FieldOrganizationID, v))
+}
+
+// OrganizationIDLT applies the LT predicate on the "organization_id" field.
+func OrganizationIDLT(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLT(FieldOrganizationID, v))
+}
+
+// OrganizationIDLTE applies the LTE predicate on the "organization_id" field.
+func OrganizationIDLTE(v int64) predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldLTE(FieldOrganizationID, v))
+}
+
+// OrganizationIDIsNil applies the IsNil predicate on the "organization_id" field.
+func OrganizationIDIsNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldIsNull(FieldOrganizationID))
+}
+
+// OrganizationIDNotNil applies the NotNil predicate on the "organization_id" field.
+func OrganizationIDNotNil() predicate.AddWechatFriendLog {
+	return predicate.AddWechatFriendLog(sql.FieldNotNull(FieldOrganizationID))
+}
+
 // And groups predicates with the AND operator between them.
 func And(predicates ...predicate.AddWechatFriendLog) predicate.AddWechatFriendLog {
 	return predicate.AddWechatFriendLog(sql.AndPredicates(predicates...))

+ 378 - 0
ent/addwechatfriendlog_create.go

@@ -171,6 +171,62 @@ func (awflc *AddWechatFriendLogCreate) SetNillableUpdatedAt(i *int64) *AddWechat
 	return awflc
 }
 
+// SetSource sets the "source" field.
+func (awflc *AddWechatFriendLogCreate) SetSource(i int) *AddWechatFriendLogCreate {
+	awflc.mutation.SetSource(i)
+	return awflc
+}
+
+// SetNillableSource sets the "source" field if the given value is not nil.
+func (awflc *AddWechatFriendLogCreate) SetNillableSource(i *int) *AddWechatFriendLogCreate {
+	if i != nil {
+		awflc.SetSource(*i)
+	}
+	return awflc
+}
+
+// SetNickName sets the "nick_name" field.
+func (awflc *AddWechatFriendLogCreate) SetNickName(s string) *AddWechatFriendLogCreate {
+	awflc.mutation.SetNickName(s)
+	return awflc
+}
+
+// SetNillableNickName sets the "nick_name" field if the given value is not nil.
+func (awflc *AddWechatFriendLogCreate) SetNillableNickName(s *string) *AddWechatFriendLogCreate {
+	if s != nil {
+		awflc.SetNickName(*s)
+	}
+	return awflc
+}
+
+// SetAvatar sets the "avatar" field.
+func (awflc *AddWechatFriendLogCreate) SetAvatar(s string) *AddWechatFriendLogCreate {
+	awflc.mutation.SetAvatar(s)
+	return awflc
+}
+
+// SetNillableAvatar sets the "avatar" field if the given value is not nil.
+func (awflc *AddWechatFriendLogCreate) SetNillableAvatar(s *string) *AddWechatFriendLogCreate {
+	if s != nil {
+		awflc.SetAvatar(*s)
+	}
+	return awflc
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (awflc *AddWechatFriendLogCreate) SetOrganizationID(i int64) *AddWechatFriendLogCreate {
+	awflc.mutation.SetOrganizationID(i)
+	return awflc
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (awflc *AddWechatFriendLogCreate) SetNillableOrganizationID(i *int64) *AddWechatFriendLogCreate {
+	if i != nil {
+		awflc.SetOrganizationID(*i)
+	}
+	return awflc
+}
+
 // SetID sets the "id" field.
 func (awflc *AddWechatFriendLogCreate) SetID(i int64) *AddWechatFriendLogCreate {
 	awflc.mutation.SetID(i)
@@ -248,6 +304,22 @@ func (awflc *AddWechatFriendLogCreate) defaults() {
 		v := addwechatfriendlog.DefaultUpdatedAt()
 		awflc.mutation.SetUpdatedAt(v)
 	}
+	if _, ok := awflc.mutation.Source(); !ok {
+		v := addwechatfriendlog.DefaultSource
+		awflc.mutation.SetSource(v)
+	}
+	if _, ok := awflc.mutation.NickName(); !ok {
+		v := addwechatfriendlog.DefaultNickName
+		awflc.mutation.SetNickName(v)
+	}
+	if _, ok := awflc.mutation.Avatar(); !ok {
+		v := addwechatfriendlog.DefaultAvatar
+		awflc.mutation.SetAvatar(v)
+	}
+	if _, ok := awflc.mutation.OrganizationID(); !ok {
+		v := addwechatfriendlog.DefaultOrganizationID
+		awflc.mutation.SetOrganizationID(v)
+	}
 }
 
 // check runs all checks and user-defined validators on the builder.
@@ -294,6 +366,16 @@ func (awflc *AddWechatFriendLogCreate) check() error {
 	if _, ok := awflc.mutation.UpdatedAt(); !ok {
 		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AddWechatFriendLog.updated_at"`)}
 	}
+	if v, ok := awflc.mutation.NickName(); ok {
+		if err := addwechatfriendlog.NickNameValidator(v); err != nil {
+			return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.nick_name": %w`, err)}
+		}
+	}
+	if v, ok := awflc.mutation.Avatar(); ok {
+		if err := addwechatfriendlog.AvatarValidator(v); err != nil {
+			return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %w`, err)}
+		}
+	}
 	return nil
 }
 
@@ -379,6 +461,22 @@ func (awflc *AddWechatFriendLogCreate) createSpec() (*AddWechatFriendLog, *sqlgr
 		_spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
 		_node.UpdatedAt = value
 	}
+	if value, ok := awflc.mutation.Source(); ok {
+		_spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
+		_node.Source = value
+	}
+	if value, ok := awflc.mutation.NickName(); ok {
+		_spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
+		_node.NickName = value
+	}
+	if value, ok := awflc.mutation.Avatar(); ok {
+		_spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
+		_node.Avatar = value
+	}
+	if value, ok := awflc.mutation.OrganizationID(); ok {
+		_spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
+		_node.OrganizationID = value
+	}
 	return _node, _spec
 }
 
@@ -647,6 +745,90 @@ func (u *AddWechatFriendLogUpsert) AddUpdatedAt(v int64) *AddWechatFriendLogUpse
 	return u
 }
 
+// SetSource sets the "source" field.
+func (u *AddWechatFriendLogUpsert) SetSource(v int) *AddWechatFriendLogUpsert {
+	u.Set(addwechatfriendlog.FieldSource, v)
+	return u
+}
+
+// UpdateSource sets the "source" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsert) UpdateSource() *AddWechatFriendLogUpsert {
+	u.SetExcluded(addwechatfriendlog.FieldSource)
+	return u
+}
+
+// AddSource adds v to the "source" field.
+func (u *AddWechatFriendLogUpsert) AddSource(v int) *AddWechatFriendLogUpsert {
+	u.Add(addwechatfriendlog.FieldSource, v)
+	return u
+}
+
+// ClearSource clears the value of the "source" field.
+func (u *AddWechatFriendLogUpsert) ClearSource() *AddWechatFriendLogUpsert {
+	u.SetNull(addwechatfriendlog.FieldSource)
+	return u
+}
+
+// SetNickName sets the "nick_name" field.
+func (u *AddWechatFriendLogUpsert) SetNickName(v string) *AddWechatFriendLogUpsert {
+	u.Set(addwechatfriendlog.FieldNickName, v)
+	return u
+}
+
+// UpdateNickName sets the "nick_name" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsert) UpdateNickName() *AddWechatFriendLogUpsert {
+	u.SetExcluded(addwechatfriendlog.FieldNickName)
+	return u
+}
+
+// ClearNickName clears the value of the "nick_name" field.
+func (u *AddWechatFriendLogUpsert) ClearNickName() *AddWechatFriendLogUpsert {
+	u.SetNull(addwechatfriendlog.FieldNickName)
+	return u
+}
+
+// SetAvatar sets the "avatar" field.
+func (u *AddWechatFriendLogUpsert) SetAvatar(v string) *AddWechatFriendLogUpsert {
+	u.Set(addwechatfriendlog.FieldAvatar, v)
+	return u
+}
+
+// UpdateAvatar sets the "avatar" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsert) UpdateAvatar() *AddWechatFriendLogUpsert {
+	u.SetExcluded(addwechatfriendlog.FieldAvatar)
+	return u
+}
+
+// ClearAvatar clears the value of the "avatar" field.
+func (u *AddWechatFriendLogUpsert) ClearAvatar() *AddWechatFriendLogUpsert {
+	u.SetNull(addwechatfriendlog.FieldAvatar)
+	return u
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *AddWechatFriendLogUpsert) SetOrganizationID(v int64) *AddWechatFriendLogUpsert {
+	u.Set(addwechatfriendlog.FieldOrganizationID, v)
+	return u
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsert) UpdateOrganizationID() *AddWechatFriendLogUpsert {
+	u.SetExcluded(addwechatfriendlog.FieldOrganizationID)
+	return u
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *AddWechatFriendLogUpsert) AddOrganizationID(v int64) *AddWechatFriendLogUpsert {
+	u.Add(addwechatfriendlog.FieldOrganizationID, v)
+	return u
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (u *AddWechatFriendLogUpsert) ClearOrganizationID() *AddWechatFriendLogUpsert {
+	u.SetNull(addwechatfriendlog.FieldOrganizationID)
+	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:
 //
@@ -947,6 +1129,104 @@ func (u *AddWechatFriendLogUpsertOne) UpdateUpdatedAt() *AddWechatFriendLogUpser
 	})
 }
 
+// SetSource sets the "source" field.
+func (u *AddWechatFriendLogUpsertOne) SetSource(v int) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetSource(v)
+	})
+}
+
+// AddSource adds v to the "source" field.
+func (u *AddWechatFriendLogUpsertOne) AddSource(v int) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.AddSource(v)
+	})
+}
+
+// UpdateSource sets the "source" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertOne) UpdateSource() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateSource()
+	})
+}
+
+// ClearSource clears the value of the "source" field.
+func (u *AddWechatFriendLogUpsertOne) ClearSource() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearSource()
+	})
+}
+
+// SetNickName sets the "nick_name" field.
+func (u *AddWechatFriendLogUpsertOne) SetNickName(v string) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetNickName(v)
+	})
+}
+
+// UpdateNickName sets the "nick_name" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertOne) UpdateNickName() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateNickName()
+	})
+}
+
+// ClearNickName clears the value of the "nick_name" field.
+func (u *AddWechatFriendLogUpsertOne) ClearNickName() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearNickName()
+	})
+}
+
+// SetAvatar sets the "avatar" field.
+func (u *AddWechatFriendLogUpsertOne) SetAvatar(v string) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetAvatar(v)
+	})
+}
+
+// UpdateAvatar sets the "avatar" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertOne) UpdateAvatar() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateAvatar()
+	})
+}
+
+// ClearAvatar clears the value of the "avatar" field.
+func (u *AddWechatFriendLogUpsertOne) ClearAvatar() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearAvatar()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *AddWechatFriendLogUpsertOne) SetOrganizationID(v int64) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *AddWechatFriendLogUpsertOne) AddOrganizationID(v int64) *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertOne) UpdateOrganizationID() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (u *AddWechatFriendLogUpsertOne) ClearOrganizationID() *AddWechatFriendLogUpsertOne {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearOrganizationID()
+	})
+}
+
 // Exec executes the query.
 func (u *AddWechatFriendLogUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -1413,6 +1693,104 @@ func (u *AddWechatFriendLogUpsertBulk) UpdateUpdatedAt() *AddWechatFriendLogUpse
 	})
 }
 
+// SetSource sets the "source" field.
+func (u *AddWechatFriendLogUpsertBulk) SetSource(v int) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetSource(v)
+	})
+}
+
+// AddSource adds v to the "source" field.
+func (u *AddWechatFriendLogUpsertBulk) AddSource(v int) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.AddSource(v)
+	})
+}
+
+// UpdateSource sets the "source" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertBulk) UpdateSource() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateSource()
+	})
+}
+
+// ClearSource clears the value of the "source" field.
+func (u *AddWechatFriendLogUpsertBulk) ClearSource() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearSource()
+	})
+}
+
+// SetNickName sets the "nick_name" field.
+func (u *AddWechatFriendLogUpsertBulk) SetNickName(v string) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetNickName(v)
+	})
+}
+
+// UpdateNickName sets the "nick_name" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertBulk) UpdateNickName() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateNickName()
+	})
+}
+
+// ClearNickName clears the value of the "nick_name" field.
+func (u *AddWechatFriendLogUpsertBulk) ClearNickName() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearNickName()
+	})
+}
+
+// SetAvatar sets the "avatar" field.
+func (u *AddWechatFriendLogUpsertBulk) SetAvatar(v string) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetAvatar(v)
+	})
+}
+
+// UpdateAvatar sets the "avatar" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertBulk) UpdateAvatar() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateAvatar()
+	})
+}
+
+// ClearAvatar clears the value of the "avatar" field.
+func (u *AddWechatFriendLogUpsertBulk) ClearAvatar() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearAvatar()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *AddWechatFriendLogUpsertBulk) SetOrganizationID(v int64) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *AddWechatFriendLogUpsertBulk) AddOrganizationID(v int64) *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *AddWechatFriendLogUpsertBulk) UpdateOrganizationID() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (u *AddWechatFriendLogUpsertBulk) ClearOrganizationID() *AddWechatFriendLogUpsertBulk {
+	return u.Update(func(s *AddWechatFriendLogUpsert) {
+		s.ClearOrganizationID()
+	})
+}
+
 // Exec executes the query.
 func (u *AddWechatFriendLogUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 268 - 0
ent/addwechatfriendlog_update.go

@@ -235,6 +235,100 @@ func (awflu *AddWechatFriendLogUpdate) AddUpdatedAt(i int64) *AddWechatFriendLog
 	return awflu
 }
 
+// SetSource sets the "source" field.
+func (awflu *AddWechatFriendLogUpdate) SetSource(i int) *AddWechatFriendLogUpdate {
+	awflu.mutation.ResetSource()
+	awflu.mutation.SetSource(i)
+	return awflu
+}
+
+// SetNillableSource sets the "source" field if the given value is not nil.
+func (awflu *AddWechatFriendLogUpdate) SetNillableSource(i *int) *AddWechatFriendLogUpdate {
+	if i != nil {
+		awflu.SetSource(*i)
+	}
+	return awflu
+}
+
+// AddSource adds i to the "source" field.
+func (awflu *AddWechatFriendLogUpdate) AddSource(i int) *AddWechatFriendLogUpdate {
+	awflu.mutation.AddSource(i)
+	return awflu
+}
+
+// ClearSource clears the value of the "source" field.
+func (awflu *AddWechatFriendLogUpdate) ClearSource() *AddWechatFriendLogUpdate {
+	awflu.mutation.ClearSource()
+	return awflu
+}
+
+// SetNickName sets the "nick_name" field.
+func (awflu *AddWechatFriendLogUpdate) SetNickName(s string) *AddWechatFriendLogUpdate {
+	awflu.mutation.SetNickName(s)
+	return awflu
+}
+
+// SetNillableNickName sets the "nick_name" field if the given value is not nil.
+func (awflu *AddWechatFriendLogUpdate) SetNillableNickName(s *string) *AddWechatFriendLogUpdate {
+	if s != nil {
+		awflu.SetNickName(*s)
+	}
+	return awflu
+}
+
+// ClearNickName clears the value of the "nick_name" field.
+func (awflu *AddWechatFriendLogUpdate) ClearNickName() *AddWechatFriendLogUpdate {
+	awflu.mutation.ClearNickName()
+	return awflu
+}
+
+// SetAvatar sets the "avatar" field.
+func (awflu *AddWechatFriendLogUpdate) SetAvatar(s string) *AddWechatFriendLogUpdate {
+	awflu.mutation.SetAvatar(s)
+	return awflu
+}
+
+// SetNillableAvatar sets the "avatar" field if the given value is not nil.
+func (awflu *AddWechatFriendLogUpdate) SetNillableAvatar(s *string) *AddWechatFriendLogUpdate {
+	if s != nil {
+		awflu.SetAvatar(*s)
+	}
+	return awflu
+}
+
+// ClearAvatar clears the value of the "avatar" field.
+func (awflu *AddWechatFriendLogUpdate) ClearAvatar() *AddWechatFriendLogUpdate {
+	awflu.mutation.ClearAvatar()
+	return awflu
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (awflu *AddWechatFriendLogUpdate) SetOrganizationID(i int64) *AddWechatFriendLogUpdate {
+	awflu.mutation.ResetOrganizationID()
+	awflu.mutation.SetOrganizationID(i)
+	return awflu
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (awflu *AddWechatFriendLogUpdate) SetNillableOrganizationID(i *int64) *AddWechatFriendLogUpdate {
+	if i != nil {
+		awflu.SetOrganizationID(*i)
+	}
+	return awflu
+}
+
+// AddOrganizationID adds i to the "organization_id" field.
+func (awflu *AddWechatFriendLogUpdate) AddOrganizationID(i int64) *AddWechatFriendLogUpdate {
+	awflu.mutation.AddOrganizationID(i)
+	return awflu
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (awflu *AddWechatFriendLogUpdate) ClearOrganizationID() *AddWechatFriendLogUpdate {
+	awflu.mutation.ClearOrganizationID()
+	return awflu
+}
+
 // Mutation returns the AddWechatFriendLogMutation object of the builder.
 func (awflu *AddWechatFriendLogUpdate) Mutation() *AddWechatFriendLogMutation {
 	return awflu.mutation
@@ -293,6 +387,16 @@ func (awflu *AddWechatFriendLogUpdate) check() error {
 			return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
 		}
 	}
+	if v, ok := awflu.mutation.NickName(); ok {
+		if err := addwechatfriendlog.NickNameValidator(v); err != nil {
+			return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.nick_name": %w`, err)}
+		}
+	}
+	if v, ok := awflu.mutation.Avatar(); ok {
+		if err := addwechatfriendlog.AvatarValidator(v); err != nil {
+			return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %w`, err)}
+		}
+	}
 	return nil
 }
 
@@ -377,6 +481,36 @@ func (awflu *AddWechatFriendLogUpdate) sqlSave(ctx context.Context) (n int, err
 	if value, ok := awflu.mutation.AddedUpdatedAt(); ok {
 		_spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
 	}
+	if value, ok := awflu.mutation.Source(); ok {
+		_spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
+	}
+	if value, ok := awflu.mutation.AddedSource(); ok {
+		_spec.AddField(addwechatfriendlog.FieldSource, field.TypeInt, value)
+	}
+	if awflu.mutation.SourceCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldSource, field.TypeInt)
+	}
+	if value, ok := awflu.mutation.NickName(); ok {
+		_spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
+	}
+	if awflu.mutation.NickNameCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldNickName, field.TypeString)
+	}
+	if value, ok := awflu.mutation.Avatar(); ok {
+		_spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
+	}
+	if awflu.mutation.AvatarCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldAvatar, field.TypeString)
+	}
+	if value, ok := awflu.mutation.OrganizationID(); ok {
+		_spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
+	}
+	if value, ok := awflu.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
+	}
+	if awflu.mutation.OrganizationIDCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64)
+	}
 	if n, err = sqlgraph.UpdateNodes(ctx, awflu.driver, _spec); err != nil {
 		if _, ok := err.(*sqlgraph.NotFoundError); ok {
 			err = &NotFoundError{addwechatfriendlog.Label}
@@ -605,6 +739,100 @@ func (awfluo *AddWechatFriendLogUpdateOne) AddUpdatedAt(i int64) *AddWechatFrien
 	return awfluo
 }
 
+// SetSource sets the "source" field.
+func (awfluo *AddWechatFriendLogUpdateOne) SetSource(i int) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ResetSource()
+	awfluo.mutation.SetSource(i)
+	return awfluo
+}
+
+// SetNillableSource sets the "source" field if the given value is not nil.
+func (awfluo *AddWechatFriendLogUpdateOne) SetNillableSource(i *int) *AddWechatFriendLogUpdateOne {
+	if i != nil {
+		awfluo.SetSource(*i)
+	}
+	return awfluo
+}
+
+// AddSource adds i to the "source" field.
+func (awfluo *AddWechatFriendLogUpdateOne) AddSource(i int) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.AddSource(i)
+	return awfluo
+}
+
+// ClearSource clears the value of the "source" field.
+func (awfluo *AddWechatFriendLogUpdateOne) ClearSource() *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ClearSource()
+	return awfluo
+}
+
+// SetNickName sets the "nick_name" field.
+func (awfluo *AddWechatFriendLogUpdateOne) SetNickName(s string) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.SetNickName(s)
+	return awfluo
+}
+
+// SetNillableNickName sets the "nick_name" field if the given value is not nil.
+func (awfluo *AddWechatFriendLogUpdateOne) SetNillableNickName(s *string) *AddWechatFriendLogUpdateOne {
+	if s != nil {
+		awfluo.SetNickName(*s)
+	}
+	return awfluo
+}
+
+// ClearNickName clears the value of the "nick_name" field.
+func (awfluo *AddWechatFriendLogUpdateOne) ClearNickName() *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ClearNickName()
+	return awfluo
+}
+
+// SetAvatar sets the "avatar" field.
+func (awfluo *AddWechatFriendLogUpdateOne) SetAvatar(s string) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.SetAvatar(s)
+	return awfluo
+}
+
+// SetNillableAvatar sets the "avatar" field if the given value is not nil.
+func (awfluo *AddWechatFriendLogUpdateOne) SetNillableAvatar(s *string) *AddWechatFriendLogUpdateOne {
+	if s != nil {
+		awfluo.SetAvatar(*s)
+	}
+	return awfluo
+}
+
+// ClearAvatar clears the value of the "avatar" field.
+func (awfluo *AddWechatFriendLogUpdateOne) ClearAvatar() *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ClearAvatar()
+	return awfluo
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (awfluo *AddWechatFriendLogUpdateOne) SetOrganizationID(i int64) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ResetOrganizationID()
+	awfluo.mutation.SetOrganizationID(i)
+	return awfluo
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOrganizationID(i *int64) *AddWechatFriendLogUpdateOne {
+	if i != nil {
+		awfluo.SetOrganizationID(*i)
+	}
+	return awfluo
+}
+
+// AddOrganizationID adds i to the "organization_id" field.
+func (awfluo *AddWechatFriendLogUpdateOne) AddOrganizationID(i int64) *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.AddOrganizationID(i)
+	return awfluo
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (awfluo *AddWechatFriendLogUpdateOne) ClearOrganizationID() *AddWechatFriendLogUpdateOne {
+	awfluo.mutation.ClearOrganizationID()
+	return awfluo
+}
+
 // Mutation returns the AddWechatFriendLogMutation object of the builder.
 func (awfluo *AddWechatFriendLogUpdateOne) Mutation() *AddWechatFriendLogMutation {
 	return awfluo.mutation
@@ -676,6 +904,16 @@ func (awfluo *AddWechatFriendLogUpdateOne) check() error {
 			return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
 		}
 	}
+	if v, ok := awfluo.mutation.NickName(); ok {
+		if err := addwechatfriendlog.NickNameValidator(v); err != nil {
+			return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.nick_name": %w`, err)}
+		}
+	}
+	if v, ok := awfluo.mutation.Avatar(); ok {
+		if err := addwechatfriendlog.AvatarValidator(v); err != nil {
+			return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %w`, err)}
+		}
+	}
 	return nil
 }
 
@@ -777,6 +1015,36 @@ func (awfluo *AddWechatFriendLogUpdateOne) sqlSave(ctx context.Context) (_node *
 	if value, ok := awfluo.mutation.AddedUpdatedAt(); ok {
 		_spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
 	}
+	if value, ok := awfluo.mutation.Source(); ok {
+		_spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
+	}
+	if value, ok := awfluo.mutation.AddedSource(); ok {
+		_spec.AddField(addwechatfriendlog.FieldSource, field.TypeInt, value)
+	}
+	if awfluo.mutation.SourceCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldSource, field.TypeInt)
+	}
+	if value, ok := awfluo.mutation.NickName(); ok {
+		_spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
+	}
+	if awfluo.mutation.NickNameCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldNickName, field.TypeString)
+	}
+	if value, ok := awfluo.mutation.Avatar(); ok {
+		_spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
+	}
+	if awfluo.mutation.AvatarCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldAvatar, field.TypeString)
+	}
+	if value, ok := awfluo.mutation.OrganizationID(); ok {
+		_spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
+	}
+	if value, ok := awfluo.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
+	}
+	if awfluo.mutation.OrganizationIDCleared() {
+		_spec.ClearField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64)
+	}
 	_node = &AddWechatFriendLog{config: awfluo.config}
 	_spec.Assign = _node.assignValues
 	_spec.ScanValues = _node.scanValues

+ 14 - 0
ent/migrate/schema.go

@@ -25,6 +25,10 @@ var (
 		{Name: "add_result", Type: field.TypeJSON, Nullable: true},
 		{Name: "created_at", Type: field.TypeInt64},
 		{Name: "updated_at", Type: field.TypeInt64},
+		{Name: "source", Type: field.TypeInt, Nullable: true, Default: 1},
+		{Name: "nick_name", Type: field.TypeString, Nullable: true, Size: 255, Default: ""},
+		{Name: "avatar", Type: field.TypeString, Nullable: true, Size: 255, Default: ""},
+		{Name: "organization_id", Type: field.TypeInt64, Nullable: true, Default: 0},
 	}
 	// AddWechatFriendLogTable holds the schema information for the "add_wechat_friend_log" table.
 	AddWechatFriendLogTable = &schema.Table{
@@ -37,6 +41,16 @@ var (
 				Unique:  false,
 				Columns: []*schema.Column{AddWechatFriendLogColumns[1], AddWechatFriendLogColumns[7]},
 			},
+			{
+				Name:    "addwechatfriendlog_owner_wx_id_find_content",
+				Unique:  true,
+				Columns: []*schema.Column{AddWechatFriendLogColumns[1], AddWechatFriendLogColumns[3]},
+			},
+			{
+				Name:    "addwechatfriendlog_organization_id_find_content",
+				Unique:  true,
+				Columns: []*schema.Column{AddWechatFriendLogColumns[17], AddWechatFriendLogColumns[3]},
+			},
 		},
 	}
 	// AgentColumns holds the columns for the "agent" table.

+ 387 - 27
ent/mutation.go

@@ -125,32 +125,38 @@ const (
 // AddWechatFriendLogMutation represents an operation that mutates the AddWechatFriendLog nodes in the graph.
 type AddWechatFriendLogMutation struct {
 	config
-	op               Op
-	typ              string
-	id               *int64
-	owner_wx_id      *string
-	owner_wx_type    *int
-	addowner_wx_type *int
-	find_content     *string
-	message          *string
-	find_request     *map[string]interface{}
-	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{}
-	add_result       *map[string]interface{}
-	created_at       *int64
-	addcreated_at    *int64
-	updated_at       *int64
-	addupdated_at    *int64
-	clearedFields    map[string]struct{}
-	done             bool
-	oldValue         func(context.Context) (*AddWechatFriendLog, error)
-	predicates       []predicate.AddWechatFriendLog
+	op                 Op
+	typ                string
+	id                 *int64
+	owner_wx_id        *string
+	owner_wx_type      *int
+	addowner_wx_type   *int
+	find_content       *string
+	message            *string
+	find_request       *map[string]interface{}
+	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{}
+	add_result         *map[string]interface{}
+	created_at         *int64
+	addcreated_at      *int64
+	updated_at         *int64
+	addupdated_at      *int64
+	source             *int
+	addsource          *int
+	nick_name          *string
+	avatar             *string
+	organization_id    *int64
+	addorganization_id *int64
+	clearedFields      map[string]struct{}
+	done               bool
+	oldValue           func(context.Context) (*AddWechatFriendLog, error)
+	predicates         []predicate.AddWechatFriendLog
 }
 
 var _ ent.Mutation = (*AddWechatFriendLogMutation)(nil)
@@ -897,6 +903,244 @@ func (m *AddWechatFriendLogMutation) ResetUpdatedAt() {
 	m.addupdated_at = nil
 }
 
+// SetSource sets the "source" field.
+func (m *AddWechatFriendLogMutation) SetSource(i int) {
+	m.source = &i
+	m.addsource = nil
+}
+
+// Source returns the value of the "source" field in the mutation.
+func (m *AddWechatFriendLogMutation) Source() (r int, exists bool) {
+	v := m.source
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldSource returns the old "source" 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) OldSource(ctx context.Context) (v int, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldSource is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldSource requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldSource: %w", err)
+	}
+	return oldValue.Source, nil
+}
+
+// AddSource adds i to the "source" field.
+func (m *AddWechatFriendLogMutation) AddSource(i int) {
+	if m.addsource != nil {
+		*m.addsource += i
+	} else {
+		m.addsource = &i
+	}
+}
+
+// AddedSource returns the value that was added to the "source" field in this mutation.
+func (m *AddWechatFriendLogMutation) AddedSource() (r int, exists bool) {
+	v := m.addsource
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearSource clears the value of the "source" field.
+func (m *AddWechatFriendLogMutation) ClearSource() {
+	m.source = nil
+	m.addsource = nil
+	m.clearedFields[addwechatfriendlog.FieldSource] = struct{}{}
+}
+
+// SourceCleared returns if the "source" field was cleared in this mutation.
+func (m *AddWechatFriendLogMutation) SourceCleared() bool {
+	_, ok := m.clearedFields[addwechatfriendlog.FieldSource]
+	return ok
+}
+
+// ResetSource resets all changes to the "source" field.
+func (m *AddWechatFriendLogMutation) ResetSource() {
+	m.source = nil
+	m.addsource = nil
+	delete(m.clearedFields, addwechatfriendlog.FieldSource)
+}
+
+// SetNickName sets the "nick_name" field.
+func (m *AddWechatFriendLogMutation) SetNickName(s string) {
+	m.nick_name = &s
+}
+
+// NickName returns the value of the "nick_name" field in the mutation.
+func (m *AddWechatFriendLogMutation) NickName() (r string, exists bool) {
+	v := m.nick_name
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldNickName returns the old "nick_name" 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) OldNickName(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldNickName is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldNickName requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldNickName: %w", err)
+	}
+	return oldValue.NickName, nil
+}
+
+// ClearNickName clears the value of the "nick_name" field.
+func (m *AddWechatFriendLogMutation) ClearNickName() {
+	m.nick_name = nil
+	m.clearedFields[addwechatfriendlog.FieldNickName] = struct{}{}
+}
+
+// NickNameCleared returns if the "nick_name" field was cleared in this mutation.
+func (m *AddWechatFriendLogMutation) NickNameCleared() bool {
+	_, ok := m.clearedFields[addwechatfriendlog.FieldNickName]
+	return ok
+}
+
+// ResetNickName resets all changes to the "nick_name" field.
+func (m *AddWechatFriendLogMutation) ResetNickName() {
+	m.nick_name = nil
+	delete(m.clearedFields, addwechatfriendlog.FieldNickName)
+}
+
+// SetAvatar sets the "avatar" field.
+func (m *AddWechatFriendLogMutation) SetAvatar(s string) {
+	m.avatar = &s
+}
+
+// Avatar returns the value of the "avatar" field in the mutation.
+func (m *AddWechatFriendLogMutation) Avatar() (r string, exists bool) {
+	v := m.avatar
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAvatar returns the old "avatar" 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) OldAvatar(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAvatar requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
+	}
+	return oldValue.Avatar, nil
+}
+
+// ClearAvatar clears the value of the "avatar" field.
+func (m *AddWechatFriendLogMutation) ClearAvatar() {
+	m.avatar = nil
+	m.clearedFields[addwechatfriendlog.FieldAvatar] = struct{}{}
+}
+
+// AvatarCleared returns if the "avatar" field was cleared in this mutation.
+func (m *AddWechatFriendLogMutation) AvatarCleared() bool {
+	_, ok := m.clearedFields[addwechatfriendlog.FieldAvatar]
+	return ok
+}
+
+// ResetAvatar resets all changes to the "avatar" field.
+func (m *AddWechatFriendLogMutation) ResetAvatar() {
+	m.avatar = nil
+	delete(m.clearedFields, addwechatfriendlog.FieldAvatar)
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (m *AddWechatFriendLogMutation) SetOrganizationID(i int64) {
+	m.organization_id = &i
+	m.addorganization_id = nil
+}
+
+// OrganizationID returns the value of the "organization_id" field in the mutation.
+func (m *AddWechatFriendLogMutation) OrganizationID() (r int64, exists bool) {
+	v := m.organization_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v int64, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldOrganizationID requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
+	}
+	return oldValue.OrganizationID, nil
+}
+
+// AddOrganizationID adds i to the "organization_id" field.
+func (m *AddWechatFriendLogMutation) AddOrganizationID(i int64) {
+	if m.addorganization_id != nil {
+		*m.addorganization_id += i
+	} else {
+		m.addorganization_id = &i
+	}
+}
+
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
+func (m *AddWechatFriendLogMutation) AddedOrganizationID() (r int64, exists bool) {
+	v := m.addorganization_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (m *AddWechatFriendLogMutation) ClearOrganizationID() {
+	m.organization_id = nil
+	m.addorganization_id = nil
+	m.clearedFields[addwechatfriendlog.FieldOrganizationID] = struct{}{}
+}
+
+// OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
+func (m *AddWechatFriendLogMutation) OrganizationIDCleared() bool {
+	_, ok := m.clearedFields[addwechatfriendlog.FieldOrganizationID]
+	return ok
+}
+
+// ResetOrganizationID resets all changes to the "organization_id" field.
+func (m *AddWechatFriendLogMutation) ResetOrganizationID() {
+	m.organization_id = nil
+	m.addorganization_id = nil
+	delete(m.clearedFields, addwechatfriendlog.FieldOrganizationID)
+}
+
 // Where appends a list predicates to the AddWechatFriendLogMutation builder.
 func (m *AddWechatFriendLogMutation) Where(ps ...predicate.AddWechatFriendLog) {
 	m.predicates = append(m.predicates, ps...)
@@ -931,7 +1175,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, 13)
+	fields := make([]string, 0, 17)
 	if m.owner_wx_id != nil {
 		fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
 	}
@@ -971,6 +1215,18 @@ func (m *AddWechatFriendLogMutation) Fields() []string {
 	if m.updated_at != nil {
 		fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
 	}
+	if m.source != nil {
+		fields = append(fields, addwechatfriendlog.FieldSource)
+	}
+	if m.nick_name != nil {
+		fields = append(fields, addwechatfriendlog.FieldNickName)
+	}
+	if m.avatar != nil {
+		fields = append(fields, addwechatfriendlog.FieldAvatar)
+	}
+	if m.organization_id != nil {
+		fields = append(fields, addwechatfriendlog.FieldOrganizationID)
+	}
 	return fields
 }
 
@@ -1005,6 +1261,14 @@ func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
 		return m.CreatedAt()
 	case addwechatfriendlog.FieldUpdatedAt:
 		return m.UpdatedAt()
+	case addwechatfriendlog.FieldSource:
+		return m.Source()
+	case addwechatfriendlog.FieldNickName:
+		return m.NickName()
+	case addwechatfriendlog.FieldAvatar:
+		return m.Avatar()
+	case addwechatfriendlog.FieldOrganizationID:
+		return m.OrganizationID()
 	}
 	return nil, false
 }
@@ -1040,6 +1304,14 @@ func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string)
 		return m.OldCreatedAt(ctx)
 	case addwechatfriendlog.FieldUpdatedAt:
 		return m.OldUpdatedAt(ctx)
+	case addwechatfriendlog.FieldSource:
+		return m.OldSource(ctx)
+	case addwechatfriendlog.FieldNickName:
+		return m.OldNickName(ctx)
+	case addwechatfriendlog.FieldAvatar:
+		return m.OldAvatar(ctx)
+	case addwechatfriendlog.FieldOrganizationID:
+		return m.OldOrganizationID(ctx)
 	}
 	return nil, fmt.Errorf("unknown AddWechatFriendLog field %s", name)
 }
@@ -1140,6 +1412,34 @@ func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) erro
 		}
 		m.SetUpdatedAt(v)
 		return nil
+	case addwechatfriendlog.FieldSource:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetSource(v)
+		return nil
+	case addwechatfriendlog.FieldNickName:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetNickName(v)
+		return nil
+	case addwechatfriendlog.FieldAvatar:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAvatar(v)
+		return nil
+	case addwechatfriendlog.FieldOrganizationID:
+		v, ok := value.(int64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetOrganizationID(v)
+		return nil
 	}
 	return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
 }
@@ -1166,6 +1466,12 @@ func (m *AddWechatFriendLogMutation) AddedFields() []string {
 	if m.addupdated_at != nil {
 		fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
 	}
+	if m.addsource != nil {
+		fields = append(fields, addwechatfriendlog.FieldSource)
+	}
+	if m.addorganization_id != nil {
+		fields = append(fields, addwechatfriendlog.FieldOrganizationID)
+	}
 	return fields
 }
 
@@ -1186,6 +1492,10 @@ func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedCreatedAt()
 	case addwechatfriendlog.FieldUpdatedAt:
 		return m.AddedUpdatedAt()
+	case addwechatfriendlog.FieldSource:
+		return m.AddedSource()
+	case addwechatfriendlog.FieldOrganizationID:
+		return m.AddedOrganizationID()
 	}
 	return nil, false
 }
@@ -1237,6 +1547,20 @@ func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) erro
 		}
 		m.AddUpdatedAt(v)
 		return nil
+	case addwechatfriendlog.FieldSource:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddSource(v)
+		return nil
+	case addwechatfriendlog.FieldOrganizationID:
+		v, ok := value.(int64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddOrganizationID(v)
+		return nil
 	}
 	return fmt.Errorf("unknown AddWechatFriendLog numeric field %s", name)
 }
@@ -1257,6 +1581,18 @@ func (m *AddWechatFriendLogMutation) ClearedFields() []string {
 	if m.FieldCleared(addwechatfriendlog.FieldAddResult) {
 		fields = append(fields, addwechatfriendlog.FieldAddResult)
 	}
+	if m.FieldCleared(addwechatfriendlog.FieldSource) {
+		fields = append(fields, addwechatfriendlog.FieldSource)
+	}
+	if m.FieldCleared(addwechatfriendlog.FieldNickName) {
+		fields = append(fields, addwechatfriendlog.FieldNickName)
+	}
+	if m.FieldCleared(addwechatfriendlog.FieldAvatar) {
+		fields = append(fields, addwechatfriendlog.FieldAvatar)
+	}
+	if m.FieldCleared(addwechatfriendlog.FieldOrganizationID) {
+		fields = append(fields, addwechatfriendlog.FieldOrganizationID)
+	}
 	return fields
 }
 
@@ -1283,6 +1619,18 @@ func (m *AddWechatFriendLogMutation) ClearField(name string) error {
 	case addwechatfriendlog.FieldAddResult:
 		m.ClearAddResult()
 		return nil
+	case addwechatfriendlog.FieldSource:
+		m.ClearSource()
+		return nil
+	case addwechatfriendlog.FieldNickName:
+		m.ClearNickName()
+		return nil
+	case addwechatfriendlog.FieldAvatar:
+		m.ClearAvatar()
+		return nil
+	case addwechatfriendlog.FieldOrganizationID:
+		m.ClearOrganizationID()
+		return nil
 	}
 	return fmt.Errorf("unknown AddWechatFriendLog nullable field %s", name)
 }
@@ -1330,6 +1678,18 @@ func (m *AddWechatFriendLogMutation) ResetField(name string) error {
 	case addwechatfriendlog.FieldUpdatedAt:
 		m.ResetUpdatedAt()
 		return nil
+	case addwechatfriendlog.FieldSource:
+		m.ResetSource()
+		return nil
+	case addwechatfriendlog.FieldNickName:
+		m.ResetNickName()
+		return nil
+	case addwechatfriendlog.FieldAvatar:
+		m.ResetAvatar()
+		return nil
+	case addwechatfriendlog.FieldOrganizationID:
+		m.ResetOrganizationID()
+		return nil
 	}
 	return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
 }

+ 20 - 0
ent/runtime/runtime.go

@@ -147,6 +147,26 @@ func init() {
 	addwechatfriendlog.DefaultUpdatedAt = addwechatfriendlogDescUpdatedAt.Default.(func() int64)
 	// addwechatfriendlog.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
 	addwechatfriendlog.UpdateDefaultUpdatedAt = addwechatfriendlogDescUpdatedAt.UpdateDefault.(func() int64)
+	// addwechatfriendlogDescSource is the schema descriptor for source field.
+	addwechatfriendlogDescSource := addwechatfriendlogFields[14].Descriptor()
+	// addwechatfriendlog.DefaultSource holds the default value on creation for the source field.
+	addwechatfriendlog.DefaultSource = addwechatfriendlogDescSource.Default.(int)
+	// addwechatfriendlogDescNickName is the schema descriptor for nick_name field.
+	addwechatfriendlogDescNickName := addwechatfriendlogFields[15].Descriptor()
+	// addwechatfriendlog.DefaultNickName holds the default value on creation for the nick_name field.
+	addwechatfriendlog.DefaultNickName = addwechatfriendlogDescNickName.Default.(string)
+	// addwechatfriendlog.NickNameValidator is a validator for the "nick_name" field. It is called by the builders before save.
+	addwechatfriendlog.NickNameValidator = addwechatfriendlogDescNickName.Validators[0].(func(string) error)
+	// addwechatfriendlogDescAvatar is the schema descriptor for avatar field.
+	addwechatfriendlogDescAvatar := addwechatfriendlogFields[16].Descriptor()
+	// addwechatfriendlog.DefaultAvatar holds the default value on creation for the avatar field.
+	addwechatfriendlog.DefaultAvatar = addwechatfriendlogDescAvatar.Default.(string)
+	// addwechatfriendlog.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save.
+	addwechatfriendlog.AvatarValidator = addwechatfriendlogDescAvatar.Validators[0].(func(string) error)
+	// addwechatfriendlogDescOrganizationID is the schema descriptor for organization_id field.
+	addwechatfriendlogDescOrganizationID := addwechatfriendlogFields[17].Descriptor()
+	// addwechatfriendlog.DefaultOrganizationID holds the default value on creation for the organization_id field.
+	addwechatfriendlog.DefaultOrganizationID = addwechatfriendlogDescOrganizationID.Default.(int64)
 	agentMixin := schema.Agent{}.Mixin()
 	agentMixinHooks1 := agentMixin[1].Hooks()
 	agent.Hooks[0] = agentMixinHooks1[0]

+ 14 - 14
ent/schema/add_wechat_friend_log.go

@@ -30,7 +30,7 @@ func (AddWechatFriendLog) Fields() []ent.Field {
 
 		field.Int("owner_wx_type").
 			Default(1).
-			Comment("属主的微信类型(1个微,2企微)"),
+			Comment("属主的微信类型(1个微,3企微)"),
 
 		field.String("find_content").
 			Default("").
@@ -45,35 +45,33 @@ func (AddWechatFriendLog) Fields() []ent.Field {
 		field.JSON("find_request", map[string]interface{}{}).
 			Optional().
 			Comment("发起查询数据的时候json"),
-
 		field.JSON("find_result", map[string]interface{}{}).
 			Optional().
 			Comment("查询返回结果"),
-
 		field.Int("is_can_add").
 			Default(0).
 			Comment("任务执行次数"),
 		field.Int("task_count").
 			Default(0).
-			Comment("是否可以添加好友(与属主账号非好友且其数据查询正常时 0 不可以,1 可以 2成功添加申请)"),
+			Comment("1: 待执行, 2: 成功申请, 3: 执行错误, 4: 用户不存在, 5: 后台取消, 6: 已是好友, 7: 成功邀请"),
 		field.Int64("task_id").Default(0).Comment("添加时候的请求体"),
 		field.JSON("add_request", map[string]interface{}{}).
 			Optional().Comment("添加时候的请求体"),
 		field.JSON("add_result", map[string]interface{}{}).
 			Optional().Comment("添加请求的结果"),
-
-		field.Int64("created_at").
-			DefaultFunc(func() int64 {
-				return time.Now().Unix()
-			}).Comment("创建时间戳"),
-
+		field.Int64("created_at").DefaultFunc(func() int64 {
+			return time.Now().Unix()
+		}).Comment("创建时间戳"),
 		field.Int64("updated_at").
 			DefaultFunc(func() int64 {
 				return time.Now().Unix()
-			}).
-			UpdateDefault(func() int64 {
-				return time.Now().Unix()
-			}).Comment("修改时间戳"),
+			}).UpdateDefault(func() int64 {
+			return time.Now().Unix()
+		}).Comment("修改时间戳"),
+		field.Int("source").Default(1).Optional().Comment("1.api录入 2.人工导入"),
+		field.String("nick_name").Default("").Optional().MaxLen(255).Comment("用户名称"),
+		field.String("avatar").Default("").MaxLen(255).Optional().Comment("用户头像"),
+		field.Int64("organization_id").Default(0).Optional().Comment("组织架构id"),
 	}
 }
 
@@ -81,6 +79,8 @@ func (AddWechatFriendLog) Fields() []ent.Field {
 func (AddWechatFriendLog) Indexes() []ent.Index {
 	return []ent.Index{
 		index.Fields("owner_wx_id", "is_can_add"),
+		index.Fields("owner_wx_id", "find_content").Unique(),
+		index.Fields("organization_id", "find_content").Unique(),
 	}
 }
 

+ 96 - 0
ent/set_not_nil.go

@@ -320,6 +320,102 @@ func (awfl *AddWechatFriendLogCreate) SetNotNilUpdatedAt(value *int64) *AddWecha
 }
 
 // set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdate) SetNotNilSource(value *int) *AddWechatFriendLogUpdate {
+	if value != nil {
+		return awfl.SetSource(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdateOne) SetNotNilSource(value *int) *AddWechatFriendLogUpdateOne {
+	if value != nil {
+		return awfl.SetSource(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogCreate) SetNotNilSource(value *int) *AddWechatFriendLogCreate {
+	if value != nil {
+		return awfl.SetSource(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdate) SetNotNilNickName(value *string) *AddWechatFriendLogUpdate {
+	if value != nil {
+		return awfl.SetNickName(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdateOne) SetNotNilNickName(value *string) *AddWechatFriendLogUpdateOne {
+	if value != nil {
+		return awfl.SetNickName(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogCreate) SetNotNilNickName(value *string) *AddWechatFriendLogCreate {
+	if value != nil {
+		return awfl.SetNickName(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdate) SetNotNilAvatar(value *string) *AddWechatFriendLogUpdate {
+	if value != nil {
+		return awfl.SetAvatar(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdateOne) SetNotNilAvatar(value *string) *AddWechatFriendLogUpdateOne {
+	if value != nil {
+		return awfl.SetAvatar(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogCreate) SetNotNilAvatar(value *string) *AddWechatFriendLogCreate {
+	if value != nil {
+		return awfl.SetAvatar(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdate) SetNotNilOrganizationID(value *int64) *AddWechatFriendLogUpdate {
+	if value != nil {
+		return awfl.SetOrganizationID(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogUpdateOne) SetNotNilOrganizationID(value *int64) *AddWechatFriendLogUpdateOne {
+	if value != nil {
+		return awfl.SetOrganizationID(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
+func (awfl *AddWechatFriendLogCreate) SetNotNilOrganizationID(value *int64) *AddWechatFriendLogCreate {
+	if value != nil {
+		return awfl.SetOrganizationID(*value)
+	}
+	return awfl
+}
+
+// set field if value's pointer is not nil.
 func (a *AgentUpdate) SetNotNilUpdatedAt(value *time.Time) *AgentUpdate {
 	if value != nil {
 		return a.SetUpdatedAt(*value)

+ 32 - 0
hook/contact.go

@@ -240,6 +240,38 @@ func (h *Hook) TriggerUserLabelTask(wxWxid string) error {
 	return nil
 }
 
+func (h *Hook) TriggerContactPushTask(wxWxid string) error {
+	conn, err := h.connWorkPhone()
+	if err != nil {
+		err = fmt.Errorf("TriggerContactPushTask failed")
+		return err
+	}
+	defer func(conn *websocket.Conn) {
+		err = conn.Close()
+		if err != nil {
+			err = fmt.Errorf("TriggerContactPushTask failed")
+		}
+	}(conn)
+
+	message := map[string]interface{}{
+		"MsgType": "TriggerContactPushTask",
+		"Content": map[string]interface{}{
+			"WxId": wxWxid,
+		},
+	}
+	transportMessageJSON, err := json.Marshal(message)
+	if err != nil {
+		return err
+	}
+	// 发送 JSON 消息
+	err = conn.WriteMessage(websocket.TextMessage, transportMessageJSON)
+	if err != nil {
+		return fmt.Errorf("failed to send message: %v", err)
+	}
+
+	return nil
+}
+
 func (h *Hook) AddFriendInChatRoom(ChatRoomId, wxWxid, friendId, desc string) error {
 	conn, err := h.connWorkPhone()
 	if err != nil {

+ 0 - 2
internal/handler/add_friend/add_friend_by_phone_handler.go

@@ -14,8 +14,6 @@ import (
 //
 // 手机号加好友接口
 //
-// 手机号加好友接口
-//
 // Parameters:
 //  + name: body
 //    require: true

+ 42 - 0
internal/handler/add_friend/add_friend_list_handler.go

@@ -0,0 +1,42 @@
+package add_friend
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/add_friend"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /add_friend/add_friend_list add_friend AddFriendList
+//
+// 添加好友的列表接口
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: AddFriendListReq
+//
+// Responses:
+//  200: AddFriendListResp
+
+func AddFriendListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.AddFriendListReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := add_friend.NewAddFriendListLogic(r.Context(), svcCtx)
+		resp, err := l.AddFriendList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/add_friend/cancel_by_ids_handler.go

@@ -0,0 +1,44 @@
+package add_friend
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/add_friend"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /add_friend/cancel_by_ids add_friend CancelByIds
+//
+// cancel task add friend
+//
+// cancel task add friend
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: CancelByIdsReq
+//
+// Responses:
+//  200: BaseMsgResp
+
+func CancelByIdsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CancelByIdsReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := add_friend.NewCancelByIdsLogic(r.Context(), svcCtx)
+		resp, err := l.CancelByIds(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 10 - 0
internal/handler/routes.go

@@ -2366,6 +2366,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/add_friend/add_friend_by_phone",
 					Handler: add_friend.AddFriendByPhoneHandler(serverCtx),
 				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/add_friend/add_friend_list",
+					Handler: add_friend.AddFriendListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/add_friend/cancel_by_ids",
+					Handler: add_friend.CancelByIdsHandler(serverCtx),
+				},
 			}...,
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),

+ 3 - 2
internal/logic/Wxhook/get_friends_and_groups_logic.go

@@ -208,9 +208,10 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
 
 		if wxInfo.Ctype == uint64(3) {
 			hookClient = hook.NewWecomHook("", "", "")
-			_ = hookClient.TriggerCustomerPushTask(wxInfo.Wxid)
+			_ = hookClient.TriggerCustomerPushTask(wxInfo.Wxid) //获取客户
 			_ = hookClient.TriggerConversationPushTask(wxInfo.Wxid)
-			_ = hookClient.TriggerUserLabelTask(wxInfo.Wxid)
+			_ = hookClient.TriggerUserLabelTask(wxInfo.Wxid)   //获取客户标签
+			_ = hookClient.TriggerContactPushTask(wxInfo.Wxid) //获取同事
 		} else {
 
 			data := map[string]interface{}{

+ 8 - 1
internal/logic/add_friend/add_friend_by_phone_logic.go

@@ -3,6 +3,7 @@ package add_friend
 import (
 	"context"
 
+	"wechat-api/internal/logic/chat"
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 
@@ -25,5 +26,11 @@ func NewAddFriendByPhoneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 func (l *AddFriendByPhoneLogic) AddFriendByPhone(req *types.AddWechatFriendLogInfo) (resp *types.BaseMsgResp, err error) {
 	// todo: add your logic here and delete this line
 
-	return
+	chatLogic := chat.NewAddFriendByPhoneLogic(l.ctx, l.svcCtx)
+	nreq := &types.AddFriendByPhoneReq{Type: req.Type,
+		WeChatIds:   req.WeChatIds,
+		Phones:      req.Phones,
+		Message:     req.Message,
+		CallbackURL: req.CallbackURL}
+	return chatLogic.AddFriendByPhone(nreq)
 }

+ 122 - 0
internal/logic/add_friend/add_friend_list_logic.go

@@ -0,0 +1,122 @@
+package add_friend
+
+import (
+	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"github.com/zeromicro/go-zero/core/logx"
+	"wechat-api/ent/addwechatfriendlog"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/wx"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils"
+)
+
+type AddFriendListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAddFriendListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddFriendListLogic {
+	return &AddFriendListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *AddFriendListLogic) AddFriendList(req *types.AddFriendListReq) (resp *types.AddFriendListResp, err error) {
+	//获取上下文的组织id
+	organizationId := l.ctx.Value("organizationId").(uint64)
+	//通过organizationId去wx表拿微信机器人的数
+
+	query := l.svcCtx.DB.Wx.Query().Where(wx.OrganizationIDEQ(organizationId), wx.DeletedAtIsNil())
+	// 动态添加条件示例:假设 req.OwnerWxId 存在时添加额外的 Where 条件
+	if utils.IsNonEmptyString(req.OwnerWxId) {
+		query = query.Where(wx.WxidEQ(*req.OwnerWxId))
+	}
+	wxIds, err := query.Select(wx.FieldWxid).Strings(l.ctx)
+	if err != nil {
+		//数据库错误,不直接返回错误,防止暴露数据库错误
+		return nil, errorx.NewInvalidArgumentError("请联系管理员")
+	}
+	//机器人列表为空,直接返回
+	if len(wxIds) == 0 {
+		return nil, errorx.NewInvalidArgumentError("当前组织架构下,没有wx机器人")
+	}
+	var predicates []predicate.AddWechatFriendLog
+
+	predicates = append(predicates, addwechatfriendlog.OwnerWxIDIn(wxIds...))
+	ownerWxType := req.OwnerWxType
+	//查询企业微信机器人加的好友
+	if ownerWxType != nil && *ownerWxType > 0 {
+		predicates = append(predicates, addwechatfriendlog.OwnerWxTypeEQ(*ownerWxType))
+	}
+	//查找添加好友
+	if utils.IsNonEmptyString(req.FindContent) {
+		predicates = append(predicates, addwechatfriendlog.FindContent(*req.FindContent))
+	}
+
+	//var IsCanAdd []int
+	if req.Status != nil {
+		predicates = append(predicates, addwechatfriendlog.IsCanAddEQ(*req.Status))
+	}
+	data, err := l.svcCtx.DB.AddWechatFriendLog.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("请联系管理员")
+	}
+	resp = &types.AddFriendListResp{}
+	resp.Msg = errormsg.Success
+	resp.Data.Total = data.PageDetails.Total
+	for _, v := range data.List {
+		var wxString string
+		if v.OwnerWxType == 1 {
+			wxString = "个微"
+		} else {
+			wxString = "企微"
+		}
+		resp.Data.Data = append(resp.Data.Data,
+			types.FriendList{
+				Id:          v.ID,
+				OwnerWxId:   &v.OwnerWxID,
+				OwnerWxType: &wxString,
+				FindContent: &v.FindContent,
+				StatusInt:   &v.IsCanAdd,
+				Status: func() *string {
+					statusMap := map[int]string{
+						1: "待执行",
+						2: "已执行",
+						3: "成功申请",
+						4: "执行错误",
+						5: "用户不存在",
+						6: "后台取消",
+						7: "已是好友",
+						8: "成功邀请",
+					}
+					statusStr := statusMap[v.IsCanAdd]
+					return &statusStr
+				}(),
+				IsShow: func() *int {
+					statusMap := map[int]int{
+						0: 1,
+						1: 1,
+						2: 0,
+						3: 0,
+						4: 0,
+						5: 0,
+						6: 0,
+						7: 0,
+					}
+					isShow := statusMap[v.IsCanAdd]
+					return &isShow
+				}(),
+				TaskCount:  &v.TaskCount,
+				Message:    &v.Message,
+				CreateTime: utils.UnixTimeToBeijing(v.CreatedAt),
+				UpdateTime: utils.UnixTimeToBeijing(v.UpdatedAt),
+			},
+		)
+	}
+	return resp, nil
+}

+ 48 - 0
internal/logic/add_friend/cancel_by_ids_logic.go

@@ -0,0 +1,48 @@
+package add_friend
+
+import (
+	"context"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"time"
+	"wechat-api/ent/addwechatfriendlog"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CancelByIdsLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCancelByIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelByIdsLogic {
+	return &CancelByIdsLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *CancelByIdsLogic) CancelByIds(req *types.CancelByIdsReq) (resp *types.BaseMsgResp, err error) {
+	if req.Ids == nil {
+		return nil, errorx.NewInvalidArgumentError("参数ids不能为空")
+	}
+	if len(req.Ids) == 0 {
+		return nil, errorx.NewInvalidArgumentError("参数ids不能为空")
+	}
+	var isCanAdd []int
+	isCanAdd = append(isCanAdd, 0, 1)
+	err = l.svcCtx.DB.AddWechatFriendLog.Update().
+		SetIsCanAdd(6).                  // 假设要将IsCanAdd字段设置为5
+		SetUpdatedAt(time.Now().Unix()). // 设置修改时间
+		Where(addwechatfriendlog.IDIn(req.Ids...), addwechatfriendlog.IsCanAddIn(isCanAdd...)).
+		Exec(l.ctx)
+	if err != nil {
+		return nil, errorx.NewInvalidArgumentError("取消失败")
+	}
+	return &types.BaseMsgResp{
+		Code: 0,
+		Msg:  "取消成功",
+	}, nil
+}

+ 201 - 23
internal/logic/chat/add_friend_by_phone_logic.go

@@ -3,15 +3,20 @@ package chat
 import (
 	"context"
 	"errors"
+	"fmt"
 
 	"wechat-api/ent"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/wx"
 	"wechat-api/internal/service/addfriend"
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
-	"wechat-api/internal/utils/contextkey"
+	"wechat-api/internal/utils/typekit"
 
+	"github.com/go-sql-driver/mysql"
 	"github.com/suyuan32/simple-admin-common/enum/errorcode"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/errorx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -28,45 +33,218 @@ func NewAddFriendByPhoneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 		svcCtx: svcCtx}
 }
 
+func GetListRandOne(strList []string) string {
+	one := ""
+	if len(strList) > 0 {
+		typekit.ShuffleList(strList)
+		one = strList[0]
+	}
+	return one
+}
+
+func (l *AddFriendByPhoneLogic) getWxInfoList(preds ...predicate.Wx) ([]*ent.Wx, error) {
+	preds = append(preds, wx.StatusEQ(1))
+	return l.svcCtx.DB.Wx.Query().Where(preds...).All(l.ctx)
+}
+
+func (l *AddFriendByPhoneLogic) getWxIdListByOid(Oid uint64, Type uint64) ([]string, error) {
+	preds := []predicate.Wx{}
+	preds = append(preds, wx.OrganizationIDEQ(Oid))
+	if Type == 1 || Type == 3 {
+		preds = append(preds, wx.CtypeEQ(Type))
+	}
+	wxIdList := []string{}
+	wxInfoList, err := l.getWxInfoList(preds...)
+	if err == nil {
+		for _, wxInfo := range wxInfoList {
+			wxIdList = append(wxIdList, wxInfo.Wxid)
+		}
+	}
+	return wxIdList, err
+}
+
+type AddFriendByPhoneInfo struct {
+	Type        int    `json:"type"`
+	WeChatId    string `json:"wechat_id"`
+	Oid         int64  `json:"oid"`
+	Phone       string `json:"phone"`
+	Message     string `json:"message"`
+	CallbackURL string `json:"callback_url"`
+}
+
+func (l *AddFriendByPhoneLogic) rebuildAddFriendByPhoneInfos(req *types.AddFriendByPhoneReq,
+	Oid uint64) ([]AddFriendByPhoneInfo, error) {
+
+	var err error
+	_, req.WeChatIds, req.Phones, err = l.alignWxidsAndPhones(Oid,
+		uint64(req.Type), req.WeChatIds, req.Phones)
+	if err != nil {
+		return nil, err
+	}
+	infos := []AddFriendByPhoneInfo{}
+	for idx, phone := range req.Phones { //以phones为主,逐一绑定wxid,多余的wxid忽略
+		info := AddFriendByPhoneInfo{Type: req.Type, WeChatId: req.WeChatIds[idx],
+			Phone: phone, Message: req.Message, CallbackURL: req.CallbackURL, Oid: int64(Oid)}
+		infos = append(infos, info)
+	}
+	return infos, nil
+}
+
+/*
+1.手机号是必传的,至少有1个
+2.微信号可以不传为空,这种情况拿当前登录者同租户OID的微信ID随机绑定传入的每个手机号
+3.微信号数量等于或者大于手机号数量,则按输入前后顺序逐一绑定,多出来的微信号忽略
+4.当微信号数量小于手机号数量,多出来的手机号则从输入的微信号中随机找1个绑定
+*/
+
+func (l *AddFriendByPhoneLogic) alignWxidsAndPhones(Oid uint64, CType uint64,
+	weChatIds []string, phones []string) (bool, []string, []string, error) {
+
+	lenWechatIds := len(weChatIds)
+	lenPhones := len(phones)
+
+	if lenPhones == 0 {
+		return false, nil, nil, errors.New("phones empty")
+	}
+
+	if lenWechatIds == 0 { //输入wxids为空,从当前库中同Oid的Wxid里随机选1个
+		allWxIds, err := l.getWxIdListByOid(Oid, CType)
+		if err != nil {
+			return false, weChatIds, phones, err
+		}
+		if len(allWxIds) == 0 {
+			return false, weChatIds, phones, fmt.Errorf("wxids empty(%d)", Oid)
+		}
+		for range lenPhones {
+			weChatIds = append(weChatIds, GetListRandOne(allWxIds))
+		}
+	} else if lenWechatIds < lenPhones { //当wxids数量小于phones数量,从已输入wxids随机选1个对齐phones
+		for range lenPhones - lenWechatIds {
+			weChatIds = append(weChatIds, GetListRandOne(weChatIds))
+		}
+	}
+	//剩下的case就是wxids数量等于或大于phones
+	return true, weChatIds, phones, nil
+}
+
+/*
+func (l *AddFriendByPhoneLogic) alignWxidsAndPhones(Oid uint64, CType uint64,
+	weChatIds []string, phones []string) (bool, []string, []string, error) {
+
+	lenWechatIds := len(weChatIds)
+	lenPhones := len(phones)
+	//case1: 输入的wxids和phones大小一样,不需要对齐
+	if lenWechatIds == lenPhones {
+		return true, weChatIds, phones, nil
+	}
+	//case2: 输入的wxids比phones小或者空
+	if lenWechatIds < lenPhones {
+		allWxIds, err := l.getWxIdListByOid(Oid, CType)
+		if err != nil {
+			return false, weChatIds, phones, err
+		}
+		if len(allWxIds) == 0 {
+			if len(weChatIds) == 0 {
+				err = errors.New("db wxIds empty")
+			}
+			return false, weChatIds, phones, err
+		}
+		for i := 0; i < lenPhones-lenWechatIds; i++ {
+			weChatIds = append(weChatIds, GetRandWxid(allWxIds))
+		}
+	} else { //case 3: 输入的wxids比phones大
+
+		//	for i := 0; i < lenWechatIds-lenPhones; i++ {
+		//		phones = append(phones, GetRandWxid(phones))
+		//	}
+
+	}
+	return true, weChatIds, phones, nil
+}
+*/
+
 func (l *AddFriendByPhoneLogic) AddFriendByPhone(req *types.AddFriendByPhoneReq) (resp *types.BaseMsgResp, err error) {
 	// todo: add your logic here and delete this line
 
-	var (
-		apiKeyObj *ent.ApiKey
-		ok        bool
-	)
+	if len(req.Phones) == 0 {
+		return nil, errors.New("miss phone")
+	}
+
+	orgID, ok := l.ctx.Value("organizationId").(uint64)
+	if !ok || orgID == 0 {
+		return nil, errors.New("content get oid info err")
+	}
+
+	//fmt.Println("before weChatIds:", req.WeChatIds)
+	//fmt.Println("before phones:", req.Phones)
+	//apiKeyObj.OrganizationID = 1
 
-	//从上下文中获取鉴权中间件埋下的apiAuthInfo
-	apiKeyObj, ok = contextkey.AuthTokenInfoKey.GetValue(l.ctx)
-	if !ok {
-		return nil, errors.New("content get auth info err")
+	if req.Type != 3 {
+		req.Type = 1
 	}
-	err = l.AppendWechaFriendAddReq(apiKeyObj, req)
+	infos, err := l.rebuildAddFriendByPhoneInfos(req, orgID)
 	if err != nil {
 		return nil, err
 	}
-	//addfriend.NewAddWechatFriendService(l.ctx, l.svcCtx).AddNewFriend(req.WeChatId, req.Phone, req.Message)
-	addfriend.NewAddWechatFriendService(l.ctx, l.svcCtx).FindFriendByContent(req.WeChatId, req.Phone)
+	//fmt.Println("after weChatIds:", req.WeChatIds)
+	//fmt.Println("after phones:", req.Phones)
+	//fmt.Println(typekit.PrettyPrint(infos))
+
+	var id int64
+	for _, info := range infos {
+		id, err = l.AppendWechaFriendAddInfo(&info)
+		if err != nil {
+			logx.Errorf("chat.AppendWechaFriendAddLog err : %s", err)
+			return nil, err
+		}
+		logx.Infof("chat.AppendWechaFriendAddLog succ,get id:%d", id)
 
-	resp = &types.BaseMsgResp{
-		Msg:  errormsg.Success,
-		Code: errorcode.OK,
+		continue
+		if req.Type != 1 {
+			continue //企微忽略后面
+		}
+		ret := addfriend.NewAddWechatFriendService(l.ctx, l.svcCtx).
+			FindFriendByContent(info.WeChatId, info.Phone)
+		retStr := "fail"
+		if ret {
+			retStr = "succ"
+		}
+		logx.Infof("call addfriend.NewAddWechatFriendService.FindFriendByContent('%s','%s') maybe %s", info.WeChatId, info.Phone, retStr)
 	}
+	return &types.BaseMsgResp{Msg: errormsg.Success, Code: errorcode.OK}, nil
+}
 
-	return resp, nil
+func isDuplicateEntry(err error) bool {
+	var mysqlErr *mysql.MySQLError
+	if errors.As(err, &mysqlErr) {
+		return mysqlErr.Number == 1062
+	}
+	return false
 }
 
-func (l *AddFriendByPhoneLogic) AppendWechaFriendAddReq(apiKeyObj *ent.ApiKey, req *types.AddFriendByPhoneReq) error {
+func (l *AddFriendByPhoneLogic) AppendWechaFriendAddInfo(addInfo *AddFriendByPhoneInfo) (int64, error) {
 
+	isCanAdd := 0
+	if addInfo.Type != 1 {
+		isCanAdd = 1
+	}
+	isCanAdd = 1
 	res, err := l.svcCtx.DB.AddWechatFriendLog.Create().
-		SetNotNilOwnerWxID(&req.WeChatId).
-		SetNotNilOwnerWxType(&req.Type).
-		SetNotNilFindContent(&req.Phone).
-		SetNotNilMessage(&req.Message).
+		SetNotNilOwnerWxID(&addInfo.WeChatId).
+		SetNotNilOwnerWxType(&addInfo.Type).
+		SetNotNilFindContent(&addInfo.Phone).
+		SetNotNilMessage(&addInfo.Message).
+		SetIsCanAdd(isCanAdd).
+		SetNotNilOrganizationID(&addInfo.Oid).
 		Save(l.ctx)
 
+	id := int64(0)
 	if err == nil {
-		logx.Infof("AppendWechaFriendAddReq succ,get id:%d", res.ID)
+		id = res.ID
+	} else {
+		if isDuplicateEntry(err) {
+			err = errorx.NewDefaultError("手机号不能重复绑定")
+		}
 	}
-	return err
+	return id, err
 }

+ 4 - 3
internal/middleware/authority_middleware.go

@@ -3,11 +3,12 @@ package middleware
 import (
 	"context"
 	"errors"
-	"github.com/suyuan32/simple-admin-core/rpc/coreclient"
-	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"net/http"
 	"strings"
 
+	"github.com/suyuan32/simple-admin-core/rpc/coreclient"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
+
 	"github.com/casbin/casbin/v2"
 	"github.com/redis/go-redis/v9"
 	"github.com/suyuan32/simple-admin-common/config"
@@ -39,7 +40,7 @@ func (m *AuthorityMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
 		// get the method
 		act := r.Method
 		// get the role id
-		roleIds := r.Context().Value("roleId").(string)
+		roleIds, _ := r.Context().Value("roleId").(string)
 
 		// check jwt blacklist
 		jwtResult, err := m.Rds.Get(context.Background(), config.RedisTokenPrefix+jwt.StripBearerPrefixFromToken(r.Header.Get("Authorization"))).Result()

+ 1 - 0
internal/middleware/openauthority_middleware.go

@@ -153,6 +153,7 @@ func (m *OpenAuthorityMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc
 		}
 
 		ctx = contextkey.AuthTokenInfoKey.WithValue(ctx, apiKeyObj)
+		ctx = context.WithValue(ctx, "organizationId", apiKeyObj.OrganizationID) //兼容awt中间件的方式
 
 		newReq := r.WithContext(ctx)
 		// Passthrough to next handler if need

+ 0 - 6
internal/pkg/util/strings.go

@@ -1,6 +0,0 @@
-package util
-
-// IsNonEmptyString 判断字符串指针不为 nil 且不为空
-func IsNonEmptyString(s *string) bool {
-	return s != nil && *s != ""
-}

+ 10 - 2
internal/service/MessageHandlers/find_contact_task_result_notice.go

@@ -88,11 +88,19 @@ func (f *FindContactTaskResultNoticeHandler) Handle(ctx context.Context, msg *we
 		Where(addwechatfriendlog.FindContentEQ(message.SearchText)).
 		SetFindResult(m).
 		SetUpdatedAt(time.Now().Unix())
+
+	if message.ErrMsg != nil {
+		if *message.ErrMsg == "用户不存在" {
+			update = update.SetIsCanAdd(5)
+		} else {
+			update = update.SetIsCanAdd(4)
+		}
+	}
 	if message.Success {
 		if message.IsFriend {
-			update = update.SetIsCanAdd(0)
+			update = update.SetIsCanAdd(7)
 		} else {
-			update = update.SetIsCanAdd(1)
+			update = update.SetIsCanAdd(1) //todo 后续这里会发送 添加请求
 		}
 	}
 	if _, err := update.Save(ctx); err != nil {

+ 9 - 3
internal/service/MessageHandlers/task_result_notice.go

@@ -61,12 +61,18 @@ func (f *TaskResultNoticeHandler) Handle(ctx context.Context, msg *wechat_ws.Msg
 		SetAddResult(m).
 		SetUpdatedAt(time.Now().Unix())
 
-	if common.ErrMsg == "该用户不存在" {
-		update.SetIsCanAdd(0) // 重置添加为不能添加好友
+	if common.Code == "InternalError" {
+		if common.ErrMsg == "timeout" {
+			update.SetIsCanAdd(4) // 重置添加为不能添加好友
+		} else if common.ErrMsg == "该用户不存在" || common.ErrMsg == "用户不存在" {
+			update.SetIsCanAdd(5) // 重置添加为不能添加好友
+		} else {
+			update.SetIsCanAdd(4)
+		} // 重置添加为不能添加好友
 	}
 
 	if common.Success {
-		update.SetIsCanAdd(2) // 表示任务成功
+		update.SetIsCanAdd(3) // 表示任务成功
 	}
 
 	if _, err := update.Save(ctx); err != nil {

+ 3 - 2
internal/service/addfriend/add_wechat_friend_log.go

@@ -60,7 +60,7 @@ func (l *AddWechatFriendService) FindFriendByContent(wechatId, content string) b
 
 func (l *AddWechatFriendService) AddNewFriend(wechatId, content, message string, wechatType int) bool {
 	//先记录请求
-	if wechatType != 1 && wechatType != 2 {
+	if wechatType != 1 && wechatType != 3 {
 		return false
 	}
 	node, err := snowflake.NewNode(1) // 1 是节点 ID,根据需要设置
@@ -77,7 +77,7 @@ func (l *AddWechatFriendService) AddNewFriend(wechatId, content, message string,
 	case 1:
 		hookClient = hook.NewHook("", "", "")
 		result, err = hookClient.AddFriendTask(wechatId, content, message, taskId.Int64())
-	case 2:
+	case 3:
 		hookClient = hook.NewWecomHook("", "", "")
 		result, err = hookClient.AddWecomCustomerFromSearchTask(wechatId, content, message, taskId.Int64())
 	default:
@@ -94,6 +94,7 @@ func (l *AddWechatFriendService) AddNewFriend(wechatId, content, message string,
 		SetAddRequest(result).
 		SetTaskID(taskId.Int64()).
 		AddTaskCount(1).
+		SetIsCanAdd(2).
 		SetUpdatedAt(time.Now().Unix())
 	_, err = update.Save(l.ctx)
 	logx.Infof("更新 AddWechatFriendLog-field-add-result成功: %v", result)

+ 59 - 8
internal/types/types.go

@@ -2038,10 +2038,15 @@ type WxidReq struct {
 // add_friend_by_phone api接口请求值
 // swagger:model AddFriendByPhoneReq
 type AddFriendByPhoneReq struct {
-	Type     int    `json:"type"`
-	WeChatId string `json:"WeChatId"`
-	Phone    string `json:"phone"`
-	Message  string `json:"message"`
+	Type        int      `json:"type,options=1|3,default=1"`
+	WeChatIds   []string `json:"wechat_ids,optional,omitempty"`
+	Phones      []string `json:"phones"`
+	Message     string   `json:"message"`
+	CallbackURL string   `json:"callback_url,optional"`
+}
+
+// swagger:model NullReq
+type NullReq struct {
 }
 
 // 以下是API请求类型
@@ -4767,8 +4772,54 @@ type LoginResp struct {
 // add_friend_by_phone api接口请求值
 // swagger:model AddWechatFriendLogInfo
 type AddWechatFriendLogInfo struct {
-	Type      int      `json:"type"`
-	WeChatIds []string `json:"WeChatId,optional,omitempty"`
-	Phone     string   `json:"phone"`
-	Message   string   `json:"message"`
+	Type        int      `json:"type,options=1|3,default=1"`
+	WeChatIds   []string `json:"wechat_ids,optional,omitempty"`
+	Phones      []string `json:"phones"`
+	Message     string   `json:"message"`
+	CallbackURL string   `json:"callback_url,optional"`
+}
+
+// swagger:model AddFriendListReq
+type AddFriendListReq struct {
+	PageInfo
+	OwnerWxId   *string `json:"wxId,optional"`
+	OwnerWxType *int    `json:"type,optional"`
+	FindContent *string `json:"phone,optional"`
+	Status      *int    `json:"status,optional"`
+}
+
+// swagger:model AddFriendListResp
+type AddFriendListResp struct {
+	BaseDataInfo
+	Data FriendListInfo `json:"data"`
+}
+
+// swagger:model FriendListInfo
+type FriendListInfo struct {
+	BaseListInfo
+	Data []FriendList `json:"data"`
+}
+
+type FriendList struct {
+	Id int64 `json:"id,optional"`
+	// 微信id 公众号微信ID
+	OwnerWxId   *string `json:"wxId,optional"`
+	OwnerWxType *string `json:"wxType,optional"`
+	FindContent *string `json:"phone,optional"`
+	Status      *string `json:"status,optional"`
+	StatusInt   *int    `json:"statusInt,optional"`
+	ErrMessage  *string `json:"errMessage,optional"`
+	TaskCount   *int    `json:"taskCount,optional"`
+	IsShow      *int    `json:"isShow,optional"`
+	// 微信昵称 群备注名称
+	Message    *string `json:"message,optional"`
+	CreateTime *string `json:"createTime,optional"`
+	UpdateTime *string `json:"updateTime,optional"`
+}
+
+// swagger:model CancelByIdsReq
+type CancelByIdsReq struct {
+	// required : true
+	// min length : 1
+	Ids []int64 `json:"ids" validate:"required,min=1"`
 }

+ 32 - 0
internal/utils/strings.go

@@ -0,0 +1,32 @@
+package utils
+
+import "time"
+
+// IsNonEmptyString 判断字符串指针不为 nil 且不为空
+func IsNonEmptyString(s *string) bool {
+	return s != nil && *s != ""
+}
+
+// UnixTimeToBeijing 将 Unix 时间戳转换为北京时间字符串
+func UnixTimeToBeijing(i any) *string {
+	// 断言输入为 int64 类型
+	unixTime, ok := i.(int64)
+	if !ok {
+		return nil
+	}
+
+	// 当传入的时间为0值时,返回固定字符串"---"
+	if unixTime == 0 {
+		defaultTime := "--"
+		return &defaultTime
+	}
+
+	// 转换为北京时间(UTC+8)
+	beijingTime := time.Unix(unixTime, 0).In(time.FixedZone("CST", 8*3600))
+
+	// 格式化时间字符串
+	formattedTime := beijingTime.Format("2006-01-02 15:04:05")
+
+	// 返回字符串指针
+	return &formattedTime
+}

+ 16 - 0
internal/utils/typekit/list.go

@@ -0,0 +1,16 @@
+package typekit
+
+import "math/rand/v2"
+
+/*
+* 随机打乱一个泛型列表
+*
+*  tl1 := []string{"a", "b", "c"}
+*  tl1 := []int{1,2,3}
+*  ShuffleList(tl1)
+ */
+func ShuffleList[T any](list []T) {
+	rand.Shuffle(len(list), func(i, j int) {
+		list[i], list[j] = list[j], list[i]
+	})
+}