1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package com.yihu.platform.apiservice;
- import com.coreframework.db.DB;
- import com.coreframework.db.Sql;
- import com.coreframework.ioc.Ioc;
- import com.coreframework.util.AppConfig;
- import com.yihu.platform.service.IUserMappingService;
- import com.yihu.platform.utils.HttpUtil;
- import net.sf.json.JSONObject;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * 厦门i健康api
- */
- public class IHealthService {
- private static final String URL = AppConfig.getValue("HealthServiceURL");
- private static final IUserMappingService userMappingService = Ioc.get(IUserMappingService.class);
- private String token;
- public IHealthService() {
- super();
- try {
- token = getToken();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 获取token
- *
- * @return
- * @throws Exception
- */
- public String getToken() throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "gc/accesstoken");
- Map map = new HashMap();
- map.put("appid", AppConfig.getValue("Token.appid"));
- map.put("appSecret", AppConfig.getValue("Token.appSecret"));
- String resp = httpUtil.post(map);
- JSONObject json = JSONObject.fromObject(resp);
- if (json.getInt("status") != 10000) throw new Exception("获取token失败:" + json);
- return json.getJSONObject("result").getString("accesstoken");
- }
- public String queryPatient(String userId) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/patient/user/patient");
- httpUtil.setHeader("userAgent", userMappingService.getUserAgent(userId));
- Map map = new HashMap();
- map.put("code", userId);
- map.put("accesstoken", token);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String queryHospital(String hospitalId, String provinceId, String cityId, Integer page, Integer pageSize) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/hospital/");
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("hospitalId", hospitalId);
- map.put("provinceId", provinceId);
- map.put("cityId", cityId);
- map.put("page", page);
- map.put("pageSize", pageSize);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String queryDoctor( String hospitalId,String userId, Integer pageIndex, Integer pageSize) throws Exception {
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/doctor/user/doctors");
- httpUtil.setHeader("userAgent", userMappingService.getUserAgent(userId));
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("hospitalId", hospitalId);
- map.put("page", pageIndex);
- map.put("pageSize", pageSize);
- String resp = httpUtil.get(map);
- return resp;
- }
- public String queryDoctorByUserId(String userId) throws Exception{
- HttpUtil httpUtil = new HttpUtil(URL + "wlyygc/doctor/user/doctor");
- Map map = new HashMap();
- map.put("accesstoken", token);
- map.put("code", userId);
- String resp = httpUtil.get(map);
- return resp;
- }
- }
|