Commit 8e7c74b2 by mingyuan

get employee by mobile

parent 9d238680
......@@ -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: 074ee48cd8cd754977c8946f73479fe4a7e9b3f5
revision: 092a58af67ee302612df8cb5416149f6b9c7890a
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)
......
......@@ -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
......@@ -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')
......
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
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment