Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails_dingtalk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
other
rails_dingtalk
Commits
8e7c74b2
Commit
8e7c74b2
authored
Sep 14, 2021
by
mingyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get employee by mobile
parent
9d238680
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
6 deletions
+42
-6
Gemfile.lock
Gemfile.lock
+4
-4
saas.rb
app/apis/dingtalk/api/inner/saas.rb
+16
-0
http_client.rb
app/apis/dingtalk/http_client.rb
+1
-1
user.rb
app/models/dingtalk/ext/user.rb
+18
-0
saas_app.rb
app/models/dingtalk/model/app/saas_app.rb
+2
-1
dingtalk_user.rb
app/models/dingtalk/model/dingtalk_user.rb
+1
-0
No files found.
Gemfile.lock
View file @
8e7c74b2
...
...
@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/work-design/rails_com.git
revision:
45c5d36f3b00416bb719b73bde82cee16338a380
revision:
0fa82f6df70ac2222a9a5fdeb8f0d209ba01eeb7
specs:
rails_com (1.2.9)
acme-client
...
...
@@ -23,14 +23,14 @@ GIT
GIT
remote: https://github.com/work-design/rails_design.git
revision: 0
74ee48cd8cd754977c8946f73479fe4a7e9b3f5
revision: 0
92a58af67ee302612df8cb5416149f6b9c7890a
specs:
rails_design (0.0.1)
rails
GIT
remote: https://github.com/work-design/rails_extend.git
revision:
0c2ef4ef6c5538dfeb7df0692012177431d2f59e
revision:
40067af089497d0abe0ebf2fba77e813902bc868
specs:
rails_extend (1.0.0)
rails (>= 6.0)
...
...
@@ -123,7 +123,7 @@ GEM
default_where (2.3.0)
activerecord (>= 4.0, <= 7.0)
erubi (1.10.0)
faraday (1.7.
1
)
faraday (1.7.
2
)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
...
...
app/apis/dingtalk/api/inner/saas.rb
View file @
8e7c74b2
...
...
@@ -13,5 +13,21 @@ module Dingtalk::Api
end
end
def
get_employee_code
(
mobile
,
tenant_id
)
payload
=
{
areaCode:
'86'
,
namespace:
'local'
}
payload
.
merge!
mobile:
mobile
,
tenantId:
tenant_id
r
=
post
'/mozi/employee/get_by_mobile'
,
payload
,
base:
BASE
if
r
.
is_a?
Hash
r
.
dig
(
'content'
,
'data'
)
else
r
end
end
end
end
app/apis/dingtalk/http_client.rb
View file @
8e7c74b2
...
...
@@ -54,7 +54,7 @@ module Dingtalk
content_type
=
response
.
content_type
.
mime_type
body
=
response
.
body
.
to_s
Rails
.
logger
.
debug
"
body:
#{
body
}
"
Rails
.
logger
.
debug
"
#{
body
}
"
if
content_type
=~
/image|audio|video/
data
=
Tempfile
.
new
(
'tmp'
)
...
...
app/models/dingtalk/ext/user.rb
0 → 100644
View file @
8e7c74b2
module
Dingtalk
module
Ext::User
extend
ActiveSupport
::
Concern
included
do
attribute
:employee_code
,
:string
end
def
sync_employee_code
(
mobile
,
tenant_id
,
app_key
)
app
=
SaasApp
.
find_by
(
app_key:
app_key
)
info
=
app
.
api
.
get_employee_code
(
mobile
,
tenant_id
)
self
.
employee_code
=
info
[
'employeeCode'
]
self
end
end
end
app/models/dingtalk/model/app/saas_app.rb
View file @
8e7c74b2
...
...
@@ -16,7 +16,8 @@ module Dingtalk
dingtalk_user
=
dingtalk_users
.
find_or_initialize_by
(
uid:
info
[
'openid'
])
dingtalk_user
.
name
=
info
[
'nickNameCn'
]
dingtalk_user
.
identity
=
info
[
'account'
]
dingtalk_user
.
extra
=
info
.
slice
(
'clientId'
,
'lastName'
,
'realmId'
,
'realmName'
,
'tenantUserId'
,
'employeeCode'
,
'accountId'
,
'tenantId'
,
'tenantName'
,
'referId'
,
'namespace'
)
dingtalk_user
.
employee_code
=
info
[
'employeeCode'
]
dingtalk_user
.
extra
=
info
.
slice
(
'clientId'
,
'lastName'
,
'realmId'
,
'realmName'
,
'tenantUserId'
,
'accountId'
,
'tenantId'
,
'tenantName'
,
'referId'
,
'namespace'
)
dingtalk_user
end
...
...
app/models/dingtalk/model/dingtalk_user.rb
View file @
8e7c74b2
...
...
@@ -14,6 +14,7 @@ module Dingtalk
attribute
:refresh_token
,
:string
attribute
:extra
,
:json
,
default:
{}
attribute
:identity
,
:string
,
index:
true
attribute
:employee_code
,
:string
belongs_to
:new_app
,
foreign_key: :appid
,
primary_key: :app_key
,
optional:
true
belongs_to
:saas_app
,
foreign_key: :appid
,
primary_key: :app_key
,
optional:
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment