Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -15,7 +15,7 @@ var (
|
|||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
api := New(appKey, appSecret, appCode)
|
api := New(appKey, appSecret, appCode)
|
||||||
result, err := api.GetLogisticsInfo("JD0088184529553")
|
result, err := api.GetLogisticsInfo("78652277511810")
|
||||||
globals.SugarLogger.Debugf("result======== %s", utils.Format4Output(result, false))
|
globals.SugarLogger.Debugf("result======== %s", utils.Format4Output(result, false))
|
||||||
globals.SugarLogger.Debugf("err======== %s", utils.Format4Output(err, false))
|
globals.SugarLogger.Debugf("err======== %s", utils.Format4Output(err, false))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ func (a *API) CreateAppChat(param *CreateAppChatParamReq) error {
|
|||||||
// 获取所有的部门列表
|
// 获取所有的部门列表
|
||||||
func (a *API) GetAllDepartmentList() ([]*Department, error) {
|
func (a *API) GetAllDepartmentList() ([]*Department, error) {
|
||||||
a.CheckAccessTokenExpiresIn()
|
a.CheckAccessTokenExpiresIn()
|
||||||
data, err := a.AccessAPI(WeChatBaseApi, GetAllDepartmentListById, http.MethodGet, map[string]interface{}{"access_token": a.accessToken})
|
param := map[string]interface{}{"access_token": a.accessToken}
|
||||||
|
data, err := a.AccessAPI(WeChatBaseApi, GetAllDepartmentListById, http.MethodGet, param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -62,25 +63,6 @@ func (a *API) GetAllDepartmentList() ([]*Department, error) {
|
|||||||
return result.Department, nil
|
return result.Department, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取企业部门用户详细情况
|
|
||||||
func (a *API) GetEnterpriseStaffInfo(department int) ([]*UserList, error) {
|
|
||||||
a.CheckAccessTokenExpiresIn()
|
|
||||||
departmentUserDetail, err := a.AccessAPI(WeChatBaseApi, GetDepartmentUserDetail, http.MethodGet, map[string]interface{}{"department_id": department, "fetch_child": 0})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
result := &GetEnterpriseStaffInfoRes{}
|
|
||||||
if err := utils.Map2StructByJson(departmentUserDetail, result, false); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if result.ErrCode != 0 {
|
|
||||||
return nil, errors.New(result.ErrMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.UserList, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 通过手机号获取用户消息
|
// 通过手机号获取用户消息
|
||||||
func (a *API) GetUserIdByMobile(mobile string) (string, error) {
|
func (a *API) GetUserIdByMobile(mobile string) (string, error) {
|
||||||
a.CheckAccessTokenExpiresIn()
|
a.CheckAccessTokenExpiresIn()
|
||||||
|
|||||||
37
platformapi/enterprise_wechat/department_list.go
Normal file
37
platformapi/enterprise_wechat/department_list.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package enterprise_wechat
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetDepartmentList 获取部门id列表
|
||||||
|
func (a *API) GetDepartmentList() {
|
||||||
|
a.CheckAccessTokenExpiresIn()
|
||||||
|
param := map[string]interface{}{"access_token": a.accessToken}
|
||||||
|
departmentList, err := a.AccessAPI(WeChatBaseApi, GetDepartmentList, http.MethodGet, param)
|
||||||
|
fmt.Println(departmentList)
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEnterpriseStaffInfo 获取企业部门用户详细情况
|
||||||
|
func (a *API) GetEnterpriseStaffInfo(department int) ([]*UserList, error) {
|
||||||
|
a.CheckAccessTokenExpiresIn()
|
||||||
|
departmentUserDetail, err := a.AccessAPI(WeChatBaseApi, GetDepartmentUserDetail, http.MethodGet, map[string]interface{}{"fetch_child": 1, "department_id": department, "access_token": a.accessToken})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetEnterpriseStaffInfoRes{}
|
||||||
|
if err := utils.Map2StructByJson(departmentUserDetail, result, false); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.ErrCode != 0 {
|
||||||
|
return nil, errors.New(result.ErrMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.UserList, nil
|
||||||
|
}
|
||||||
@@ -129,3 +129,11 @@ func TestGetUserId(t *testing.T) {
|
|||||||
phone, err := api.GetUserIdByMobile("18981810340")
|
phone, err := api.GetUserIdByMobile("18981810340")
|
||||||
globals.SugarLogger.Debugf("phone := %s,err :=%s", phone, err)
|
globals.SugarLogger.Debugf("phone := %s,err :=%s", phone, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDepartmentList(t *testing.T) {
|
||||||
|
api.GetDepartmentList()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetEnterpriseStaffInfo(t *testing.T) {
|
||||||
|
api.GetEnterpriseStaffInfo(7)
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]
|
|||||||
fullURL := utils.GenerateGetURL(baseUrl, actionApi, map[string]interface{}{"access_token": a.accessToken})
|
fullURL := utils.GenerateGetURL(baseUrl, actionApi, map[string]interface{}{"access_token": a.accessToken})
|
||||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data)))
|
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data)))
|
||||||
} else {
|
} else {
|
||||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(baseUrl, actionApi, bizParams), nil)
|
getUrl := utils.GenerateGetURL(baseUrl, actionApi, bizParams)
|
||||||
|
request, _ = http.NewRequest(http.MethodGet, getUrl, nil)
|
||||||
}
|
}
|
||||||
request.Header.Set("Content-Type", "application/json")
|
request.Header.Set("Content-Type", "application/json")
|
||||||
return request
|
return request
|
||||||
|
|||||||
@@ -7,18 +7,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
WeChatBaseApi = "https://qyapi.weixin.qq.com" // 企业微信基础访问链接
|
WeChatBaseApi = "https://qyapi.weixin.qq.com" // 企业微信基础访问链接
|
||||||
|
ParentDepartmentId = 7 // 企业微信全职人员文件夹id
|
||||||
|
|
||||||
// api接口
|
// api接口
|
||||||
GetToken = "cgi-bin/gettoken" // 获取token
|
GetToken = "cgi-bin/gettoken" // 获取token
|
||||||
CreateAppChat = "cgi-bin/appchat/create" // 创建会话群聊
|
CreateAppChat = "cgi-bin/appchat/create" // 创建会话群聊
|
||||||
GetAllDepartmentListById = "cgi-bin/department/list" // 获取所有的部门
|
GetAllDepartmentListById = "cgi-bin/department/list" // 获取所有的部门
|
||||||
CreateBoosToJxStaff = "cgi-bin/user/create" // 将京西老板创建为企业员工
|
CreateBoosToJxStaff = "cgi-bin/user/create" // 将京西老板创建为企业员工
|
||||||
GetDepartmentUserDetail = "cgi-bin/user/list" // 获取部门用户详细情况
|
GetDepartmentUserDetail = "cgi-bin/user/list" // 获取部门用户详细情况
|
||||||
GetUserByMobileUrl = "cgi-bin/user/getuserid" // 通过手机号获取用户id
|
GetUserByMobileUrl = "cgi-bin/user/getuserid" // 通过手机号获取用户id
|
||||||
SendMsgToUser = "cgi-bin/message/send" // 给用户发送消息
|
SendMsgToUser = "cgi-bin/message/send" // 给用户发送消息
|
||||||
|
GetDepartmentList = "cgi-bin/department/simplelist" // 获取部门子id列表
|
||||||
|
|
||||||
EnterpriseTicketInfo = "/suite/receive" // 企业微信服务器会定时(每十分钟)推送ticket
|
EnterpriseTicketInfo = "/suite/receive" // 企业微信服务器会定时(每十分钟)推送ticket
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 注册请求api
|
// 注册请求api
|
||||||
|
|||||||
22
platformapi/tiktok_shop/222/dd_test.go
Normal file
22
platformapi/tiktok_shop/222/dd_test.go
Normal file
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ import (
|
|||||||
// "authority_id": ""
|
// "authority_id": ""
|
||||||
//}`
|
//}`
|
||||||
|
|
||||||
var token = `{"access_token":"067cd47f-fa07-464f-a474-066a2351f9f0","expires_in":1675644618,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"99575e32-6c75-41ec-8df0-98470e8c0402","authority_id":""}`
|
var token = `{"access_token":"7bb849c5-4270-44c5-a5dc-a02d78532d46","expires_in":1676246698,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"b0e98248-89bd-4cf2-9968-bb6e61d7845d","authority_id":""}`
|
||||||
|
|
||||||
//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`
|
//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateSubProduct(t *testing.T) {
|
|
||||||
//params := `[1,2]`
|
|
||||||
//var obj []int
|
|
||||||
//err := Strings2Objs(params, &obj)
|
|
||||||
//fmt.Println(err)
|
|
||||||
//fmt.Println(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除已经创建商品,重新同步
|
// 删除已经创建商品,重新同步
|
||||||
func TestDeleteSkuAndUploadSku2(t *testing.T) {
|
func TestDeleteSkuAndUploadSku2(t *testing.T) {
|
||||||
var errList = make([]error, 0, 0)
|
var errList = make([]error, 0, 0)
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ func init() {
|
|||||||
sugarLogger = logger.Sugar()
|
sugarLogger = logger.Sugar()
|
||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
|
|
||||||
// sandbox
|
}
|
||||||
// api = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
|
||||||
// prod
|
func TestCreateSubProduct(t *testing.T) {
|
||||||
|
a.CreateSubProduct(3592508194611683124, 64251631)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCategory(t *testing.T) {
|
func TestCategory(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user