Commit f0b70fd4 by mingyuan

support info api

parent 30039ba0
......@@ -3,7 +3,8 @@ module Dingtalk::Api
BASE = 'https://oapi.dingtalk.com/'
def getuserinfo(code)
post 'topapi/v2/user/getuserinfo', code: code
r = post 'topapi/v2/user/getuserinfo', code: code
r['result']
end
end
......
module Dingtalk
class AppsController < BaseController
before_action :set_app, only: [:login]
def info
result = @app.getuserinfo(params[:code])
render json: result
end
def create
end
private
def set_app
@app = App.find_by corp_id: params[:corp_id]
end
end
end
......@@ -8,6 +8,16 @@ dd.ready(() => {
div.innerText = info.code
console.log(info)
alert(info.code)
fetch(ele.href, {
method: method,
headers: {
Accept: 'text/vnd.turbo-stream.html'
}
}).then(response => {
return response.text()
}).then(body => {
Turbo.renderStreamMessage(body)
})
},
onFail(res) {
alert('dd error: ' + JSON.stringify(res))
......
......@@ -8,6 +8,11 @@ Rails.application.routes.draw do
controller :home do
get :index
end
resources :apps do
collection do
get :info
end
end
end
end
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