光大银行涉农接口
This commit is contained in:
+71
@@ -0,0 +1,71 @@
|
|||||||
|
package com.fangjia.open.controllers;
|
||||||
|
|
||||||
|
import com.fangjia.core.util.HttpRequest;
|
||||||
|
import com.fangjia.open.interceptors.Authority;
|
||||||
|
import com.fangjia.open.interceptors.Role;
|
||||||
|
import com.fangjia.open.model.AddressModel;
|
||||||
|
import com.fangjia.open.model.BasicModel;
|
||||||
|
import com.fangjia.open.model.RestfulModelAndView;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 光大接口
|
||||||
|
*/
|
||||||
|
@Authority(role = Role.USER)
|
||||||
|
public class GdBankController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 涉农识别-新规
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object villageIdentifyAction(AddressModel model) {
|
||||||
|
|
||||||
|
RestfulModelAndView mav = new RestfulModelAndView();
|
||||||
|
if (StringUtils.isBlank(model.getAddress())) {
|
||||||
|
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest();
|
||||||
|
JSONObject json = null;
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null);
|
||||||
|
params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null);
|
||||||
|
params.put("redis", (model.getRadius() != null && model.getRadius() != 0) ? model.getRadius().toString() : null);
|
||||||
|
params.put("address", model.getAddress());
|
||||||
|
params.put("showFullValue", "2");
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (json != null) {
|
||||||
|
int code = json.getInt("msgCode");
|
||||||
|
String msg = json.getString("msg");
|
||||||
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
|
if (json.containsKey("result")) {
|
||||||
|
JSONObject result = json.getJSONObject("result");
|
||||||
|
if (("是").equals(result.get("countyLevelCity"))){
|
||||||
|
result.put("prefectureLevelCity", "否");
|
||||||
|
} else if(("否").equals(result.get("countyLevelCity"))){
|
||||||
|
result.put("prefectureLevelCity", "是");
|
||||||
|
}
|
||||||
|
basicModel.setResult(result);
|
||||||
|
}
|
||||||
|
mav.setModel(basicModel);
|
||||||
|
} else {
|
||||||
|
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||||
|
}
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user