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.
 
 

53 lines
1.8 KiB

package com.eco.plugin.xx.stsxit.controller;
import com.eco.plugin.xx.stsxit.config.PluginSimpleConfig;
import com.eco.plugin.xx.stsxit.utils.HttpUtils;
import com.eco.plugin.xx.stsxit.utils.ResponseUtils;
import com.eco.plugin.xx.stsxit.utils.Utils;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.json.JSONArray;
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.Mapping;
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;
@Controller
@LoginStatusChecker(required = false)
public class ControllerSelf {
@PostMapping(value = "/getDownloadUrl")
@ResponseBody
public void getDownloadUrl(HttpServletRequest req,HttpServletResponse res){
JSONObject json = Utils.getRequestBody(req);
String url = null;
try {
url = getUrl(json);
} catch (Exception e) {
ResponseUtils.failedResponse(res,"获取下载链接失败");
return ;
}
ResponseUtils.successResponse(res,url);
}
/**
* 获取下载url
* @param json
* @return
* @throws Exception
*/
private String getUrl(JSONObject json) throws Exception{
String url = PluginSimpleConfig.getInstance().getUrl();
String result = HttpUtils.HttpPostJson(url,new JSONArray().put(json).toString(),null);
return new JSONArray(result).getJSONObject(0).getJSONObject("returndata").getString("downloadurl");
}
}