Commit 17f3d1af by mingyuan

defautl sass appid

parent 8e7c74b2
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/work-design/rails_com.git remote: https://github.com/work-design/rails_com.git
revision: 0fa82f6df70ac2222a9a5fdeb8f0d209ba01eeb7 revision: 953ef46899c750d41ea6e09aba71c9376363e1ce
specs: specs:
rails_com (1.2.9) rails_com (1.2.9)
acme-client acme-client
......
...@@ -13,12 +13,13 @@ module Dingtalk::Api ...@@ -13,12 +13,13 @@ module Dingtalk::Api
end end
end end
def get_employee_code(mobile, tenant_id) def get_employee_code(mobile)
payload = { payload = {
areaCode: '86', areaCode: '86',
namespace: 'local' namespace: 'local',
tenantId: app.tenant_id,
mobile: mobile
} }
payload.merge! mobile: mobile, tenantId: tenant_id
r = post '/mozi/employee/get_by_mobile', payload, base: BASE r = post '/mozi/employee/get_by_mobile', payload, base: BASE
......
...@@ -12,6 +12,7 @@ module Dingtalk ...@@ -12,6 +12,7 @@ module Dingtalk
:name, :name,
:corp_id, :corp_id,
:agent_id, :agent_id,
:tenant_id,
:app_key, :app_key,
:app_secret :app_secret
] ]
......
...@@ -6,9 +6,9 @@ module Dingtalk ...@@ -6,9 +6,9 @@ module Dingtalk
attribute :employee_code, :string attribute :employee_code, :string
end end
def sync_employee_code(mobile, tenant_id, app_key) def sync_employee_code(mobile, app_key = nil)
app = SaasApp.find_by(app_key: app_key) app = SaasApp.find_by(app_key: app_key) || SaasApp.first
info = app.api.get_employee_code(mobile, tenant_id) info = app.api.get_employee_code(mobile)
self.employee_code = info['employeeCode'] self.employee_code = info['employeeCode']
self self
end end
......
...@@ -14,6 +14,7 @@ module Dingtalk ...@@ -14,6 +14,7 @@ module Dingtalk
attribute :jsapi_ticket, :string attribute :jsapi_ticket, :string
attribute :oauth2_state, :string attribute :oauth2_state, :string
attribute :jsapi_ticket_expires_at, :datetime attribute :jsapi_ticket_expires_at, :datetime
attribute :tenant_id, :string, comment: '专有钉钉,租户ID'
has_many :dingtalk_users, foreign_key: :appid, primary_key: :app_key has_many :dingtalk_users, foreign_key: :appid, primary_key: :app_key
end end
......
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
<p><%= model.app_key %></p> <p><%= model.app_key %></p>
<p><%= model.app_secret %></p> <p><%= model.app_secret %></p>
</td> </td>
<td><%= model.tenant_id %></td>
...@@ -7,4 +7,5 @@ ...@@ -7,4 +7,5 @@
<p><%= Dingtalk::App.human_attribute_name(:app_key) %></p> <p><%= Dingtalk::App.human_attribute_name(:app_key) %></p>
<p><%= Dingtalk::App.human_attribute_name(:app_secret) %></p> <p><%= Dingtalk::App.human_attribute_name(:app_secret) %></p>
</th> </th>
<th><%= Dingtalk::App.human_attribute_name(:tenant_id) %></th>
<th></th> <th></th>
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