亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
2. Member update operation" >2. Member update operation
2)成員的獲取定義如下:" >2)成員的獲取定義如下:
3)部門(mén)成員的獲取定義如下:
7、綜合例子調(diào)用代碼" >7、綜合例子調(diào)用代碼
Home WeChat Applet WeChat Development C# development of WeChat portal and application of WeChat enterprise account address book management development and member management

C# development of WeChat portal and application of WeChat enterprise account address book management development and member management

Mar 02, 2017 am 09:41 AM

1. Member creation operation

For convenience, we can create a departmental organizational structure, which is a prerequisite for development, because our address book management is also based on an organizational structure, as above The level of organizational structure introduced in this article is the same. Here I create a root structure of Guangzhou Aiqidi, and then create some organizational structures in it, as shown in the figure below.

C# development of WeChat portal and application of WeChat enterprise account address book management development and member management

You can add people through functional operations in the background. This article mainly introduces how to call the WeChat Enterprise Account API for personnel management operations.

The API definition of the creator is as follows.

  • Request instructions

Https request method: POST

https://qyapi.weixin.qq. com/cgi-bin/user/create?access_token=ACCESS_TOKEN

The request package structure is:

{
???"userid":?"zhangsan",
???"name":?"張三",
???"department":?[1,?2],
???"position":?"產(chǎn)品經(jīng)理",
???"mobile":?"15913215421",
???"gender":?1,
???"tel":?"62394",
???"email":?"zhangsan@gzdev.com",
???"weixinid":?"zhangsan4dev"
}
  • Parameter description

Parameters must Description
access_token is Call interface credentials
userid is the employee UserID. The account number corresponding to the management end must be unique within the enterprise. The length is 1~64 characters
name is the name of the member. The length is 1~64 characters
department No List of department IDs to which members belong. Note that the upper limit for direct employees in each department is 1,000
position No position information. The length is 0~64 characters
mobile No Mobile phone number. It must be unique within the enterprise, mobile/weixinid/email cannot be empty at the same time
gender No Gender. gender=0 means male, =1 means female. Default gender=0
tel No Office phone number. The length is 0~64 characters
email No email. The length is 0~64 characters. The company must have a unique
weixinid No WeChat ID. Must be the only one in the enterprise
  • Permission description

The administrator must have the interface of "operating address book" permissions, as well as the management permissions of designated departments.

  • Return result

{
???"errcode":?0,
???"errmsg":?"created"
}

In C#, we need to define the corresponding interface, and then construct the corresponding transfer entity information as needed.

Here I have defined all the interfaces for personnel management. The interface definitions are as follows.

????????#region?部門(mén)成員管理????????///?<summary>
????????///?創(chuàng)建成員????????///?</summary>
????????CommonResult?CreateUser(string?accessToken,?CorpUserJson?user);????????///?<summary>
????????///?更新成員????????///?</summary>
????????CommonResult?UpdateUser(string?accessToken,?CorpUserUpdateJson?user);????????///?<summary>
????????///?刪除成員????????///?</summary>
????????CommonResult?DeleteUser(string?accessToken,?string?userid);????????///?<summary>
????????///?根據(jù)成員id獲取成員信息????????///?</summary>
????????CorpUserGetJson?GetUser(string?accessToken,?string?userid);????????///?<summary>
????????///?獲取部門(mén)成員????????///?</summary>
????????CorpUserListJson?GetDeptUser(string?accessToken,?int?department_id,?int?fetch_child?=?0,?int?status?=?0);????????#endregion

Then create a CorpUserJson entity object that carries personnel information based on the information definition. The implementation operation code for creating personnel is as follows.

????????///?<summary>
????????///?創(chuàng)建成員????????///?</summary>
????????public?CommonResult?CreateUser(string?accessToken,?CorpUserJson?user)
????????{????????????string?urlFormat?=?"http://ipnx.cn/{0}";????????????var?data?=?new
????????????{
????????????????userid?=?user.userid,
????????????????name?=?user.name,
????????????????department?=?user.department,
????????????????position?=?user.position,
????????????????mobile?=?user.mobile,
????????????????gender?=?user.gender,
????????????????tel?=?user.tel,
????????????????email?=?user.email,
????????????????weixinid?=?user.weixinid
????????????};????????????var?url?=?string.Format(urlFormat,?accessToken);????????????var?postData?=?data.ToJson();????????????return?Helper.GetCorpExecuteResult(url,?postData);
????????}

2. Member update operation

Member data update Similar to the creation operation, its enterprise number is defined as follows.

  • Request instructions

Https request method: POST

https://qyapi.weixin.qq. com/cgi-bin/user/update?access_token=ACCESS_TOKEN

The request package example is as follows (if a non-required field is not specified, the previous setting value of the field will not be updated):

{
???"userid":?"zhangsan",
???"name":?"李四",
???"department":?[1],
???"position":?"后臺(tái)工程師",
???"mobile":?"15913215421",
???"gender":?1,
???"tel":?"62394",
???"email":?"zhangsan@gzdev.com",
???"weixinid":?"lisifordev",
???"enable":?1
}

Since its operation data is similar, its implementation code is also similar, as shown below.

????????///?<summary>
????????///?更新成員????????///?</summary>
????????public?CommonResult?UpdateUser(string?accessToken,?CorpUserUpdateJson?user)
????????{????????????string?urlFormat?=?"http://ipnx.cn/{0}";????????????//string?postData?=?user.ToJson();
????????????var?data?=?new
????????????{
????????????????userid?=?user.userid,
????????????????name?=?user.name,
????????????????department?=?user.department,
????????????????position?=?user.position,
????????????????mobile?=?user.mobile,
????????????????gender?=?user.gender,
????????????????tel?=?user.tel,
????????????????email?=?user.email,
????????????????weixinid?=?user.weixinid,
????????????????enable?=?user.enable
????????????};????????????var?url?=?string.Format(urlFormat,?accessToken);????????????var?postData?=?data.ToJson();????????????return?Helper.GetCorpExecuteResult(url,?postData);
????????}

3. Deletion of members, acquisition of members, Acquisition operations of department members

These operations are similar to the above and will not be described in detail. The main thing is to define their corresponding return data information as needed, and then parse the Json data and convert it into corresponding entity.

1) The definition of deletion personnel is as follows:

    Request instructions
  • Https Request method: GET

https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token=ACCESS_TOKEN&userid=lisi

    Parameter Description
Parametersaccess_tokenuserid
  • 返回結(jié)果

{
???"errcode":?0,
???"errmsg":?"deleted"
}

2)成員的獲取定義如下:

  • 請(qǐng)求說(shuō)明

Https請(qǐng)求方式: GET

https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&userid=lisi

  • 參數(shù)說(shuō)明

Required Description
is the calling interface credential
is the employee UserID. Corresponding account number on the management side
參數(shù) 必須 說(shuō)明
access_token 調(diào)用接口憑證
userid 員工UserID
  • 返回結(jié)果

{
???"errcode":?0,
???"errmsg":?"ok",
???"userid":?"zhangsan",
???"name":?"李四",
???"department":?[1,?2],
???"position":?"后臺(tái)工程師",
???"mobile":?"15913215421",
???"gender":?1,
???"tel":?"62394",
???"email":?"zhangsan@gzdev.com",
???"weixinid":?"lisifordev",??
???"avatar":?"http://wx.qlogo.cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0",
???"status":?1
}

3)部門(mén)成員的獲取定義如下:

  • 請(qǐng)求說(shuō)明

Https請(qǐng)求方式: GET

https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=ACCESS_TOKEN&department_id=1&fetch_child=0&status=0

  • 參數(shù)說(shuō)明

參數(shù) 必須 說(shuō)明
access_token 調(diào)用接口憑證
department_id 獲取的部門(mén)id
fetch_child 1/0:是否遞歸獲取子部門(mén)下面的成員
status 0獲取全部員工,1獲取已關(guān)注成員列表,2獲取禁用成員列表,4獲取未關(guān)注成員列表。status可疊加
  • 權(quán)限說(shuō)明

管理員須擁有’獲取部門(mén)成員’的接口權(quán)限,以及指定部門(mén)的查看權(quán)限。

  • 返回結(jié)果

{
???"errcode":?0,
???"errmsg":?"ok",
???"userlist":?[
???????????{
??????????????????"userid":?"zhangsan",
??????????????????"name":?"李四"
???????????}
?????]
}

這個(gè)返回值我們定義一個(gè)實(shí)體對(duì)象用來(lái)存儲(chǔ)數(shù)據(jù)即可。

????///?<summary>
????///?獲取部門(mén)成員返回的數(shù)據(jù)????///?</summary>
????public?class?CorpUserListJson?:?BaseJsonResult
????{????????public?CorpUserListJson()
????????{????????????this.userlist?=?new?List<corpusersimplejson>();
????????}????????///?<summary>
????????///?返回的錯(cuò)誤消息????????///?</summary>
????????public?CorpReturnCode?errcode?{?get;?set;?}????????///?<summary>
????????///?對(duì)返回碼的文本描述內(nèi)容????????///?</summary>
????????public?string?errmsg?{?get;?set;?}????????///?<summary>
????????///?成員列表????????///?</summary>
????????public?List<corpusersimplejson>?userlist?{?get;?set;?}
????}</corpusersimplejson></corpusersimplejson>

?

7、綜合例子調(diào)用代碼

上面介紹了一些企業(yè)號(hào)的接口定義和我對(duì)API的C#封裝接口和部分實(shí)現(xiàn)代碼,實(shí)現(xiàn)了功能后,我們就可以在代碼中對(duì)它進(jìn)行測(cè)試,確信是否正常使用。

????????///?<summary>
????????///?人員管理綜合性操作(創(chuàng)建、修改、獲取信息、刪除)????????///?</summary>
????????///?<param>
????????///?<param>
????????private?void?btnCorpUser_Click(object?sender,?EventArgs?e)
????????{
????????????CorpUserJson?user?=?new?CorpUserJson();
????????????user.userid?=?"test";
????????????user.name?="測(cè)試用戶(hù)";
????????????user.department?=?new?List<int>(){2};
????????????user.email?=?"test@163.com";

????????????ICorpAddressBookApi?bll?=?new?CorpAddressBookApi();
????????????CommonResult?result?=?bll.CreateUser(token,?user);????????????if?(result?!=?null)
????????????{
????????????????Console.WriteLine("創(chuàng)建成員:{0}?{1}?{2}",?user.name,?(result.Success???"成功"?:?"失敗"),?result.ErrorMessage);????????????????string?name?=?"修改測(cè)試";
????????????????user.name?=?name;
????????????????CorpUserUpdateJson?userUpdate?=?new?CorpUserUpdateJson(user);
????????????????result?=?bll.UpdateUser(token,?userUpdate);????????????????if?(result?!=?null)
????????????????{
????????????????????Console.WriteLine("修改名稱(chēng):{0}?{1}?{2}",?name,?(result.Success???"成功"?:?"失敗"),?result.ErrorMessage);
????????????????}

????????????????CorpUserGetJson?userGet?=?bll.GetUser(token,?user.userid);????????????????if?(userGet?!=?null)
????????????????{
????????????????????Console.WriteLine("成員名稱(chēng):{0}?({1}?{2})",?userGet.name,?user.userid,?user.email);
????????????????}

????????????????result?=?bll.DeleteUser(token,?user.userid);????????????????if?(result?!=?null)
????????????????{
????????????????????Console.WriteLine("刪除成員:{0}?{1}?{2}",?name,?(result.Success???"成功"?:?"失敗"),?result.ErrorMessage);
????????????????}
????????????}
????????}</int>

C# development of WeChat portal and application of WeChat enterprise account address book management development and member management

獲取部門(mén)人員的操作代碼如下所示。

????????///?<summary>
????????///?獲取部門(mén)人員????????///?</summary>
????????private?void?btnCorpUserList_Click(object?sender,?EventArgs?e)
????????{????????????int?deptId?=?1;
????????????ICorpAddressBookApi?bll?=?new?CorpAddressBookApi();
????????????CorpUserListJson?result?=?bll.GetDeptUser(token,?deptId);????????????if?(result?!=?null)
????????????{????????????????foreach(CorpUserSimpleJson?item?in?result.userlist)
????????????????{
????????????????????Console.WriteLine("成員名稱(chēng):{0}?{1}",?item.name,?item.userid);
????????????????}
????????????}
????????}

?

人員的管理,相對(duì)來(lái)說(shuō)比較簡(jiǎn)單,主要是在一定的部門(mén)下創(chuàng)建人員,然后也可以給標(biāo)簽增加相應(yīng)的人員,基本上就是這些了,不過(guò)一定需要確保有相應(yīng)的權(quán)限進(jìn)行操作。

更多C# development of WeChat portal and application of WeChat enterprise account address book management development and member management相關(guān)文章請(qǐng)關(guān)注PHP中文網(wǎng)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72