| | |
| | | */ |
| | | <T extends Serializable> int selectCount(Class<?> mapperClass, SqlSentence sqlSentence); |
| | | |
| | | /**查询条数 |
| | | * @param mapperClass mapper类 |
| | | * @param sqlSentence 查询参数类 |
| | | * @return 返回条数 |
| | | */ |
| | | <T extends Serializable> int selectCountSql(Class<?> mapperClass, SqlSentence sqlSentence); |
| | | |
| | | /**查询列表,返回实体类的List |
| | | * @param mapperClass mapper类 |
| | | * @param sqlSentence 查询参数类 |
| | |
| | | */ |
| | | <T extends Serializable> int selectCount(Class<?> mapperClass, SqlSentence sqlSentence); |
| | | |
| | | /**查询条数 |
| | | * @param mapperClass mapper类 |
| | | * @param sqlSentence 查询参数类 |
| | | * @return 返回条数 |
| | | */ |
| | | <T extends Serializable> int selectCountSql(Class<?> mapperClass, SqlSentence sqlSentence); |
| | | |
| | | |
| | | /**查询列表,返回实体类的List |
| | | * @param mapperClass mapper类 |
| | | * @param sqlSentence 查询参数类 |
| | |
| | | return sqlSessionFactory.openSession().insert(getStatement(mapperClass,"insert"),entity); |
| | | } |
| | | |
| | | /**获取条数*/ |
| | | /**获取条数 |
| | | * @return*/ |
| | | @Override |
| | | public <T extends Serializable> int selectCount(Class<?> mapperClass,SqlSentence sqlSentence) { |
| | | public <T extends Serializable> int selectCount(Class<?> mapperClass, SqlSentence sqlSentence) { |
| | | return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCount"),sqlSentence); |
| | | } |
| | | |
| | | /**获取条数 |
| | | * @return*/ |
| | | @Override |
| | | public <T extends Serializable> int selectCountSql(Class<?> mapperClass, SqlSentence sqlSentence) { |
| | | return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCountSql"),sqlSentence); |
| | | } |
| | | |
| | | /**获取列表*/ |
| | | @Override |
| | | public <T extends Serializable> List<T> selectList(Class<?> mapperClass, SqlSentence sqlSentence) { |
| | |
| | | return commonDao.selectCount(mapperClass,sqlSentence); |
| | | } |
| | | |
| | | /**获取条数*/ |
| | | @Override |
| | | public <T extends Serializable> int selectCountSql(Class<?> mapperClass,SqlSentence sqlSentence) { |
| | | return commonDao.selectCountSql(mapperClass,sqlSentence); |
| | | } |
| | | |
| | | /**获取列表*/ |
| | | @Override |
| | | public <T extends Serializable> List<T> selectList(Class<?> mapperClass, SqlSentence sqlSentence) { |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.activation.MimetypesFileTypeMap; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | |
| | | /**回车换行,用于一行的结尾*/ |
| | | private static final String LINE_END = "\r\n"; |
| | | |
| | | public static String getInputStream(HttpServletRequest request) throws Exception { |
| | | ServletInputStream stream = null; |
| | | BufferedReader reader = null; |
| | | StringBuffer sb = new StringBuffer(); |
| | | try { |
| | | stream = request.getInputStream(); |
| | | // 获取响应 |
| | | reader = new BufferedReader(new InputStreamReader(stream)); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | sb.append(line); |
| | | } |
| | | } catch (IOException e) { |
| | | //logger.error(e); |
| | | throw new RuntimeException("读取返回支付接口数据流出现异常!"); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | //logger.info("输入流返回的内容:" + sb.toString()); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static String post(String requestUrl, String accessToken, String params) |
| | | throws Exception { |
| | |
| | | // //System.out.println("HttpURLUtil:"+wxMsgXml); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | obj = new JSONObject(); |
| | | try { |
| | | obj.put("status", 1); |
| | | obj.put("errMsg", e.getMessage()); |
| | | } catch (JSONException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } finally { |
| | | if (con != null) { |
| | | con.disconnect(); |
| | |
| | | return null == str || str.trim().length() == 0 || "undefined".equals(str); |
| | | } |
| | | |
| | | /**判断空*/ |
| | | public static boolean isNull(String str) { |
| | | return null == str || str.trim().length() == 0 || "undefined".equals(str); |
| | | } |
| | | |
| | | /**判断非空*/ |
| | | public static boolean noNull(String str) { |
| | | return null != str && str.trim().length() != 0 && !"undefined".equals(str); |
| | | } |
| | | |
| | | /** |
| | | * 判断字符内容中是否存在一个为空的字符�? |
| | | * <p> |
New file |
| | |
| | | package com.hx.util.gaode; |
| | | |
| | | /** |
| | | * 获取地址经纬度 |
| | | * 响应实体化 |
| | | */ |
| | | public class AddressCode { |
| | | |
| | | /**经度*/ |
| | | private String lng; |
| | | /**维度*/ |
| | | private String lat; |
| | | /**城市编码*/ |
| | | private String cityCode; |
| | | |
| | | public AddressCode() { |
| | | } |
| | | |
| | | public String getLng() { |
| | | return lng; |
| | | } |
| | | |
| | | public void setLng(String lng) { |
| | | this.lng = lng; |
| | | } |
| | | |
| | | public String getLat() { |
| | | return lat; |
| | | } |
| | | |
| | | public void setLat(String lat) { |
| | | this.lat = lat; |
| | | } |
| | | |
| | | public String getCityCode() { |
| | | return cityCode; |
| | | } |
| | | |
| | | public void setCityCode(String cityCode) { |
| | | this.cityCode = cityCode; |
| | | } |
| | | } |
New file |
| | |
| | | package com.hx.util.gaode; |
| | | |
| | | import com.hx.util.HttpUtil; |
| | | import com.hx.util.StringUtils; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | |
| | | /** |
| | | * 高德地图工具 |
| | | * @author mgchen |
| | | * |
| | | */ |
| | | public class GaoDeMapUtil { |
| | | |
| | | /**获取经纬度*/ |
| | | public static String URL_CODE = "https://restapi.amap.com/v3/geocode/geo"; |
| | | |
| | | /** |
| | | * 获取地址的经纬度 |
| | | * @param address |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public static AddressCode addressCode(String address,String key) { |
| | | AddressCode addressCode = null; |
| | | //URL_CODE = URL_CODE+"?key="+key+"&address="+URLEncoder.encode(address,"UTF-8");//地址编译 |
| | | URL_CODE = URL_CODE+"?key="+key+"&address="+address; |
| | | JSONObject data = HttpUtil.HttpURLUtil(URL_CODE,null); |
| | | if(data.optInt("status",0) == 1){ |
| | | JSONArray geocodes = data.getJSONArray("geocodes"); |
| | | if(geocodes.size()==1){ |
| | | JSONObject locationObj = geocodes.getJSONObject(0); |
| | | String location = locationObj.optString("location"); |
| | | if(StringUtils.noNull(location)){ |
| | | String[] locations = location.split(","); |
| | | if(locations.length != 2){ |
| | | return null; |
| | | } |
| | | addressCode = new AddressCode(); |
| | | addressCode.setLng(locations[0]); |
| | | addressCode.setLat(locations[1]); |
| | | addressCode.setCityCode(locationObj.optString("citycode")); |
| | | } |
| | | } |
| | | } |
| | | return addressCode; |
| | | } |
| | | |
| | | |
| | | } |