update readme.md
This commit is contained in:
parent
36903b64e2
commit
d4ebe7f217
|
@ -70,6 +70,8 @@ chmod +x auto-install.sh
|
|||
#### 脚本安装完成之后,按自己实际的配置修改项目配置文件:
|
||||
修改pwdselfservice/local_settings.py中的参数,按自己的实际参数修改
|
||||
```` python
|
||||
修改pwdselfservice/local_settings.py中的参数,按自己的实际参数修改
|
||||
```` python
|
||||
# AD配置
|
||||
# AD主机,可以是IP或主机域名,例如可以是:abc.com或172.16.122.1
|
||||
AD_HOST = '修改为自己的'
|
||||
|
@ -108,7 +110,6 @@ TMPID_COOKIE_AGE = 300
|
|||
|
||||
# 主页域名,index.html中的钉钉跳转等需要指定域名,如果是脚本自动部署,以下域名会自动替换。
|
||||
HOME_URL = 'PWD_SELF_SERVICE_DOMAIN'
|
||||
|
||||
````
|
||||
### 以上配置修改完成之后,则可以通过配置的域名直接访问。
|
||||
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
from dingtalk.client import *
|
||||
import requests
|
||||
from pwdselfservice.local_settings import *
|
||||
|
||||
|
||||
def ding_get_access_token():
|
||||
"""
|
||||
获取钉钉access token
|
||||
:return:
|
||||
"""
|
||||
resp = requests.get(
|
||||
url=DING_URL + "/gettoken",
|
||||
params=dict(appid=DING_SELF_APP_ID, appsecret=DING_SELF_APP_SECRET)
|
||||
)
|
||||
resp = resp.json()
|
||||
if resp['access_token']:
|
||||
return resp['access_token']
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def ding_get_persistent_code(code, token):
|
||||
"""
|
||||
获取钉钉当前用户的unionid
|
||||
:return:
|
||||
"""
|
||||
resp = requests.post(
|
||||
url="%s/get_persistent_code?access_token=%s" % (DING_URL, token),
|
||||
json=dict(tmp_auth_code=code),
|
||||
)
|
||||
resp = resp.json()
|
||||
if resp['unionid']:
|
||||
return resp['unionid']
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def ding_client_connect():
|
||||
"""
|
||||
钉钉连接器
|
||||
:return:
|
||||
"""
|
||||
client = AppKeyClient(corp_id=DING_CORP_ID, app_key=DING_APP_KEY, app_secret=DING_APP_SECRET)
|
||||
return client
|
||||
|
||||
|
||||
def ding_get_dept_user_list_detail(dept_id, offset, size):
|
||||
"""
|
||||
获取部门中的用户列表详细清单
|
||||
:param code:
|
||||
:return:
|
||||
"""
|
||||
client = ding_client_connect()
|
||||
result = client.user.list(department_id=dept_id, offset=offset, size=size)
|
||||
return result
|
||||
|
||||
|
||||
def ding_get_userinfo_by_code(code):
|
||||
"""
|
||||
:param code: requestAuthCode接口中获取的CODE
|
||||
:return:
|
||||
"""
|
||||
client = ding_client_connect()
|
||||
resutl = client.user.getuserinfo(code)
|
||||
return resutl
|
||||
|
||||
|
||||
def ding_get_userid_by_unionid(unionid):
|
||||
"""
|
||||
:param unionid: 用户在当前钉钉开放平台账号范围内的唯一标识
|
||||
:return:
|
||||
"""
|
||||
client = ding_client_connect()
|
||||
resutl = client.user.get_userid_by_unionid(unionid)
|
||||
if resutl['userid']:
|
||||
return resutl['userid']
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def ding_get_org_user_count():
|
||||
"""
|
||||
企业员工数量
|
||||
only_active – 是否包含未激活钉钉的人员数量
|
||||
:return:
|
||||
"""
|
||||
client = ding_client_connect()
|
||||
resutl = client.user.get_org_user_count('only_active')
|
||||
return resutl
|
||||
|
||||
|
||||
def ding_get_userinfo_detail(user_id):
|
||||
"""
|
||||
user_id – 用户ID
|
||||
:return:
|
||||
"""
|
||||
client = ding_client_connect()
|
||||
resutl = client.user.get(user_id)
|
||||
return resutl
|
Loading…
Reference in New Issue