boweniac 1 week ago
parent
commit
d7a3fd4c84

+ 2 - 1
desc/all.api

@@ -43,4 +43,5 @@ import "./wechat/credit_usage.api"
 import "./wechat/pay_recharge.api"
 import "./wechat/whatsapp.api"
 import "./wechat/whatsapp_channel.api"
-import "./wechat/api_key.api"
+import "./wechat/api_key.api"
+import "./wechat/department.api"

+ 35 - 2
internal/handler/routes.go

@@ -32,6 +32,7 @@ import (
 	credit_balance "wechat-api/internal/handler/credit_balance"
 	credit_usage "wechat-api/internal/handler/credit_usage"
 	dashboard "wechat-api/internal/handler/dashboard"
+	department "wechat-api/internal/handler/department"
 	employee "wechat-api/internal/handler/employee"
 	employee_config "wechat-api/internal/handler/employee_config"
 	label "wechat-api/internal/handler/label"
@@ -52,7 +53,6 @@ import (
 	wxcarduser "wechat-api/internal/handler/wxcarduser"
 	wxcardvisit "wechat-api/internal/handler/wxcardvisit"
 	xiaoice "wechat-api/internal/handler/xiaoice"
-	
 	"wechat-api/internal/svc"
 
 	"github.com/zeromicro/go-zero/rest"
@@ -876,7 +876,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				},
 			}...,
 		),
-		//rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 		rest.WithPrefix("/v1"),
 	)
 
@@ -2097,4 +2096,38 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 	)
+
+	server.AddRoutes(
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Authority},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/department/create",
+					Handler: department.CreateDepartmentHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/department/update",
+					Handler: department.UpdateDepartmentHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/department/delete",
+					Handler: department.DeleteDepartmentHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/department/list",
+					Handler: department.GetDepartmentListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/department",
+					Handler: department.GetDepartmentByIdHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+	)
 }

+ 24 - 26
internal/service/MessageHandlers/friend_push_notice.go

@@ -36,33 +36,31 @@ func (f *FriendPushNoticeHandler) Handler(msg *wechat_ws.MsgJsonObject) error {
 			Only(context.TODO())
 		hookClient := hook.NewHook("", "", "")
 		for _, friend := range message.Friends {
-			if message.WeChatId == "wxid_ifzo7uu0cl3b22" {
-				friendType := 1
-				if friend.Type == 1 {
-					friendType = 2
-					_ = hookClient.RequestChatRoomInfo(friend.FriendId, message.WeChatId)
-				} else {
-					friendType = 1
-				}
-				_, err = f.svcCtx.DB.Contact.Create().
-					SetWxWxid(message.WeChatId).
-					SetType(friendType).
-					SetWxid(friend.FriendId).
-					SetAccount(friend.FriendNo).
-					SetNickname(friend.FriendNick).
-					SetMarkname(friend.Memo).
-					SetHeadimg(friend.Avatar).
-					//SetSex(cast.ToInt(friend.Gender)).
-					SetOrganizationID(wx_info.OrganizationID).
-					OnConflict().
-					UpdateNewValues().
-					SetOrganizationID(wx_info.OrganizationID).
-					ID(context.TODO())
+			friendType := 1
+			if friend.Type == 1 {
+				friendType = 2
+				_ = hookClient.RequestChatRoomInfo(friend.FriendId, message.WeChatId)
+			} else {
+				friendType = 1
+			}
+			_, err = f.svcCtx.DB.Contact.Create().
+				SetWxWxid(message.WeChatId).
+				SetType(friendType).
+				SetWxid(friend.FriendId).
+				SetAccount(friend.FriendNo).
+				SetNickname(friend.FriendNick).
+				SetMarkname(friend.Memo).
+				SetHeadimg(friend.Avatar).
+				//SetSex(cast.ToInt(friend.Gender)).
+				SetOrganizationID(wx_info.OrganizationID).
+				OnConflict().
+				UpdateNewValues().
+				SetOrganizationID(wx_info.OrganizationID).
+				ID(context.TODO())
 
-				if err != nil {
-					logx.Error("Contact.Create: ", wx_info.OrganizationID)
-					return err
-				}
+			if err != nil {
+				logx.Error("Contact.Create: ", wx_info.OrganizationID)
+				return err
 			}
 		}
 	}

+ 72 - 2
internal/types/types.go

@@ -1984,8 +1984,8 @@ type StdCompApiResp struct {
 
 // swagger:model FastgptSpecResp
 type FastgptSpecResp struct {
-	ResponseData []map[string]any `json:"responseData,omitempty"`
-	NewVariables map[string]any   `json:"newVariables,omitempty"`
+	ResponseData []map[string]string `json:"responseData,omitempty"`
+	NewVariables map[string]string   `json:"newVariables,omitempty"`
 }
 
 type ChatCompletionAudio struct {
@@ -4225,3 +4225,73 @@ type ApiKeyListReq struct {
 	OrganizationId *uint64 `json:"organization_id,optional"`
 }
 
+// The response data of department information | 部门信息
+// swagger:model DepartmentInfo
+type DepartmentInfo struct {
+	BaseIDInfo
+	// Translated Name | 展示名称
+	Trans string `json:"trans,optional"`
+	// Status | 状态
+	// max : 20
+	Status *uint32 `json:"status,optional" validate:"omitempty,lt=20"`
+	// Sort | 排序
+	// max : 10000
+	Sort *uint32 `json:"sort,optional" validate:"omitempty,lt=10000"`
+	// Name | 部门名称
+	// min length : 1
+	// max length : 50
+	Name *string `json:"name,optional" validate:"omitempty,min=1,max=50"`
+	// Ancestors | 父级部门列表
+	// max length : 200
+	Ancestors *string `json:"ancestors,optional" validate:"omitempty,max=200"`
+	// Leader | 部门负责人
+	// max length : 20
+	Leader *string `json:"leader,optional" validate:"omitempty,max=20"`
+	// Phone | 电话号码
+	// max length : 18
+	Phone *string `json:"phone,optional" validate:"omitempty,max=18"`
+	// Email | 邮箱
+	// max length : 70
+	Email *string `json:"email,optional" validate:"omitempty,max=70"`
+	// Remark | 备注
+	// max length : 200
+	Remark *string `json:"remark,optional" validate:"omitempty,max=200"`
+	// ParentId | 父级 ID
+	ParentId *uint64 `json:"parentId,optional"`
+}
+
+// The response data of department list | 部门列表数据
+// swagger:model DepartmentListResp
+type DepartmentListResp struct {
+	BaseDataInfo
+	// Department list data | 部门列表数据
+	Data DepartmentListInfo `json:"data"`
+}
+
+// Department list data | 部门列表数据
+// swagger:model DepartmentListInfo
+type DepartmentListInfo struct {
+	BaseListInfo
+	// The API list data | 部门列表数据
+	Data []DepartmentInfo `json:"data"`
+}
+
+// Get department list request params | 部门列表请求参数
+// swagger:model DepartmentListReq
+type DepartmentListReq struct {
+	PageInfo
+	// Name | 部门名称
+	// max length : 50
+	Name *string `json:"name,optional" validate:"omitempty,max=50"`
+	// Leader | 部门负责人
+	// max length : 20
+	Leader *string `json:"leader,optional" validate:"omitempty,max=20"`
+}
+
+// Department information response | 部门信息返回体
+// swagger:model DepartmentInfoResp
+type DepartmentInfoResp struct {
+	BaseDataInfo
+	// Department information | 部门数据
+	Data DepartmentInfo `json:"data"`
+}