You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.1 KiB
87 lines
3.1 KiB
package com.eco.plugin.xx.bjftdfsso.controller; |
|
|
|
import com.eco.plugin.xx.bjftdfsso.config.PluginSimpleConfig; |
|
import com.eco.plugin.xx.bjftdfsso.utils.FRUtils; |
|
import com.eco.plugin.xx.bjftdfsso.utils.JDBCUtil; |
|
import com.eco.plugin.xx.bjftdfsso.utils.Utils; |
|
import com.fr.decision.privilege.TransmissionTool; |
|
import com.fr.decision.webservice.annotation.LoginStatusChecker; |
|
import com.fr.json.JSONObject; |
|
import com.fr.plugin.transform.FunctionRecorder; |
|
import com.fr.third.springframework.stereotype.Controller; |
|
import com.fr.third.springframework.web.bind.annotation.GetMapping; |
|
import com.fr.third.springframework.web.bind.annotation.PostMapping; |
|
import com.fr.third.springframework.web.bind.annotation.ResponseBody; |
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.util.HashMap; |
|
import java.util.Map; |
|
|
|
@Controller |
|
@LoginStatusChecker(required = false) |
|
@FunctionRecorder |
|
public class UtilsController { |
|
|
|
@GetMapping(value = "/isAdmin") |
|
@ResponseBody |
|
public Map<String,Object> isAdmin(HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
Map<String,Object> result = new HashMap<String,Object>(); |
|
String username = request.getParameter("username"); |
|
|
|
result.put("isadmin", Utils.isAdmin(username)); |
|
|
|
return result; |
|
} |
|
|
|
@GetMapping(value = "/userIsExist") |
|
@ResponseBody |
|
public Map<String,Object> userIsExist(HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
Map<String,Object> result = new HashMap<String,Object>(); |
|
String username = request.getParameter("username"); |
|
|
|
result.put("isExist", FRUtils.isUserExist(username)); |
|
|
|
return result; |
|
} |
|
|
|
@PostMapping(value = "/testDBConnect") |
|
@ResponseBody |
|
public Map<String,Object> testDBConnect(HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
JSONObject jsonObject = Utils.getRequestBody(request); |
|
String username = jsonObject.getString("username"); |
|
String psd = TransmissionTool.decrypt(jsonObject.getString("psd")); |
|
String url = PluginSimpleConfig.getInstance().getUrl(); |
|
boolean testConnect = JDBCUtil.testConnection(url,username,psd); |
|
|
|
Map<String,Object> result = new HashMap<String,Object>(); |
|
|
|
if(!testConnect){ |
|
return result; |
|
} |
|
|
|
String token = FRUtils.getToken(request,response,username); |
|
|
|
if(Utils.isNullStr(token)){ |
|
return result; |
|
} |
|
|
|
Map<String,Object> originUrlResponse = new HashMap<String,Object>(); |
|
originUrlResponse.put("originUrl","/webroot/decision"); |
|
originUrlResponse.put("method","GET"); |
|
originUrlResponse.put("parameters",new HashMap<String,String>()); |
|
|
|
Map<String,Object> data = new HashMap<String,Object>(); |
|
data.put("username",username); |
|
data.put("validity",-1); |
|
data.put("callback",null); |
|
data.put("accessToken",token); |
|
data.put("originUrlResponse",originUrlResponse); |
|
data.put("url","/webroot/decision"); |
|
|
|
|
|
result.put("data", data); |
|
|
|
return result; |
|
} |
|
|
|
}
|
|
|