初始化

This commit is contained in:
hukekuan@163.com 2018-01-29 18:20:33 +08:00
parent d389b52b66
commit fb0d22c655
12 changed files with 169 additions and 22 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.c3gis</groupId> <groupId>com.c3gis</groupId>
<artifactId>c3gis</artifactId> <artifactId>c3gis</artifactId>
<version>1.0.2</version> <version>1.0.3</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

View File

@ -0,0 +1,30 @@
package com.gis3c.common.bean;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
* Created by hukekuan on 2018/1/29.
*/
public class BeanUtil {
public static Map<String,Object> Bean2Map(Object instance,Class cls) throws IllegalAccessException {
Map<String,Object> result = new HashMap<>();
Field[] fields = cls.getDeclaredFields();
Object value;
Map<String,Object> mapValue;
for(Field field:fields){
field.setAccessible(true);
value = field.get(instance);
if(value instanceof HashMap){
mapValue = (HashMap<String, Object>) value;
for(Map.Entry<String,Object> entry:mapValue.entrySet()){
result.put(entry.getKey(),entry.getValue());
}
}else{
result.put(field.getName(),value);
}
}
return result;
}
}

View File

@ -0,0 +1,24 @@
package com.gis3c.common.exception;
/**
* Created by hukekuan on 2018/1/29.
*/
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 1L;
public BusinessException(){
super();
}
public BusinessException(String message) {
super(message);
}
public BusinessException(Throwable cause) {
super(cause);
}
public BusinessException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -0,0 +1,25 @@
package com.gis3c.common.exception;
/**
* Created by hukekuan on 2018/1/29.
*/
public class DataException extends RuntimeException {
private static final long serialVersionUID = 1L;
public DataException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace){
super(message,cause,enableSuppression,writableStackTrace);
}
public DataException(String message,Throwable cause){
super(message,cause);
}
public DataException(String message){
super(message);
}
public DataException(Throwable cause){
super(cause);
}
}

View File

@ -0,0 +1,25 @@
package com.gis3c.common.exception;
/**
* Created by hukekuan on 2018/1/29.
*/
public class ViewException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ViewException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace){
super(message,cause,enableSuppression,writableStackTrace);
}
public ViewException(String message,Throwable cause){
super(message,cause);
}
public ViewException(String message){
super(message);
}
public ViewException(Throwable cause){
super(cause);
}
}

View File

@ -10,7 +10,7 @@ import java.util.List;
*/ */
public interface LayerService { public interface LayerService {
public List<Layer> findAllList(); public List<Layer> findAllList();
public List<Layer> findLayersByPage(Integer pageSize,Integer currentPage); public List<java.util.Map<String,Object>> findLayersByPage(Integer pageSize,Integer currentPage);
public Layer findeLayerById(String layerId); public Layer findeLayerById(String layerId);
public Layer findeLayerByName(String layerName); public Layer findeLayerByName(String layerName);

View File

@ -9,7 +9,7 @@ import java.util.List;
*/ */
public interface MapService { public interface MapService {
public List<Map> findAllList(); public List<Map> findAllList();
public List<Map> findMapsByPage(Integer pageSize,Integer currentPage); public List<java.util.Map<String,Object>> findMapsByPage(Integer pageSize,Integer currentPage);
public Map findMapById(String mapId); public Map findMapById(String mapId);
public Map findMapByName(String mapName); public Map findMapByName(String mapName);

View File

@ -8,7 +8,7 @@ import java.util.List;
*/ */
public interface SourceService { public interface SourceService {
public List<Source> findAllList(); public List<Source> findAllList();
public List<Source> findSourcesByPage(Integer pageSize,Integer currentPage); public List<java.util.Map<String,Object>> findSourcesByPage(Integer pageSize,Integer currentPage);
public Source findSourceById(String sourceId); public Source findSourceById(String sourceId);
public Source findSourceByName(String sourceName); public Source findSourceByName(String sourceName);
public Integer insertSource(Source source); public Integer insertSource(Source source);

View File

@ -1,11 +1,15 @@
package com.gis3c.ol.service.impl; package com.gis3c.ol.service.impl;
import com.gis3c.common.bean.BeanUtil;
import com.gis3c.common.exception.BusinessException;
import com.gis3c.ol.dao.LayerDao; import com.gis3c.ol.dao.LayerDao;
import com.gis3c.ol.entity.Layer; import com.gis3c.ol.entity.Layer;
import com.gis3c.ol.entity.Source;
import com.gis3c.ol.service.LayerService; import com.gis3c.ol.service.LayerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -23,8 +27,17 @@ public class LayerServiceImpl implements LayerService {
} }
@Override @Override
public List<Layer> findLayersByPage(Integer pageSize, Integer currentPage) { public List<java.util.Map<String,Object>> findLayersByPage(Integer pageSize, Integer currentPage) {
return layerDao.findLayersByPage(pageSize,(currentPage -1)*pageSize); List<java.util.Map<String,Object>> result = new ArrayList<>();
List<Layer> queryList = layerDao.findLayersByPage(pageSize,(currentPage -1)*pageSize);
queryList.forEach(layer -> {
try {
result.add(BeanUtil.Bean2Map(layer, Layer.class));
} catch (IllegalAccessException e) {
throw new BusinessException(e);
}
});
return result;
} }
@Override @Override

View File

@ -1,11 +1,15 @@
package com.gis3c.ol.service.impl; package com.gis3c.ol.service.impl;
import com.gis3c.common.bean.BeanUtil;
import com.gis3c.common.exception.BusinessException;
import com.gis3c.ol.dao.MapDao; import com.gis3c.ol.dao.MapDao;
import com.gis3c.ol.entity.Map; import com.gis3c.ol.entity.Map;
import com.gis3c.ol.service.MapService; import com.gis3c.ol.service.MapService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -23,8 +27,17 @@ public class MapServiceImpl implements MapService {
} }
@Override @Override
public List<Map> findMapsByPage(Integer pageSize,Integer currentPage) { public List<java.util.Map<String,Object>> findMapsByPage(Integer pageSize,Integer currentPage) {
return mapDao.findMapsByPage(pageSize,(currentPage -1)*pageSize); List<java.util.Map<String,Object>> result = new ArrayList<>();
List<Map> queryList = mapDao.findMapsByPage(pageSize,(currentPage -1)*pageSize);
queryList.forEach(map -> {
try {
result.add(BeanUtil.Bean2Map(map, Map.class));
} catch (IllegalAccessException e) {
throw new BusinessException(e);
}
});
return result;
} }
@Override @Override

View File

@ -1,11 +1,15 @@
package com.gis3c.ol.service.impl; package com.gis3c.ol.service.impl;
import com.gis3c.common.bean.BeanUtil;
import com.gis3c.common.exception.BusinessException;
import com.gis3c.ol.dao.SourceDao; import com.gis3c.ol.dao.SourceDao;
import com.gis3c.ol.entity.Map;
import com.gis3c.ol.entity.Source; import com.gis3c.ol.entity.Source;
import com.gis3c.ol.service.SourceService; import com.gis3c.ol.service.SourceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -23,8 +27,17 @@ public class SourceServiceImpl implements SourceService {
} }
@Override @Override
public List<Source> findSourcesByPage(Integer pageSize, Integer currentPage) { public List<java.util.Map<String,Object>> findSourcesByPage(Integer pageSize, Integer currentPage) {
return sourceDao.findSourcesByPage(pageSize,(currentPage -1)*pageSize); List<java.util.Map<String,Object>> result = new ArrayList<>();
List<Source> queryList = sourceDao.findSourcesByPage(pageSize,(currentPage -1)*pageSize);
queryList.forEach(source -> {
try {
result.add(BeanUtil.Bean2Map(source, Source.class));
} catch (IllegalAccessException e) {
throw new BusinessException(e);
}
});
return result;
} }
@Override @Override

View File

@ -1,6 +1,8 @@
package com.gis3c.spatial; package com.gis3c.spatial;
import com.gis3c.common.bean.BeanUtil;
import com.gis3c.ol.entity.Layer; import com.gis3c.ol.entity.Layer;
import com.gis3c.ol.entity.Map;
import com.gis3c.ol.entity.Source; import com.gis3c.ol.entity.Source;
import com.gis3c.ol.service.LayerService; import com.gis3c.ol.service.LayerService;
import com.gis3c.ol.service.MapService; import com.gis3c.ol.service.MapService;
@ -61,8 +63,10 @@ public class App {
// System.out.println(FeatureUtilities.JavaBeans2Json(result)); // System.out.println(FeatureUtilities.JavaBeans2Json(result));
// //地图接口 // //地图接口
// Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9"); // Map map = mapService.findMapById("83c734de-c010-4153-bf68-d291d715ac55");
// System.out.println(map.getLayers()[0][1]); System.out.println(mapService.findMapsByPage(5,1));
// Map map = new Map(); // Map map = new Map();
// map.setMapId(UUID.randomUUID().toString()); // map.setMapId(UUID.randomUUID().toString());
@ -86,16 +90,16 @@ public class App {
// System.out.println("插入成功"); // System.out.println("插入成功");
//图层接口 //图层接口
Layer layer = new Layer(); // Layer layer = new Layer();
layer.setLayerName("streetmap"); // layer.setLayerName("streetmap");
layer.setAliasName("超图行政区图"); // layer.setAliasName("超图行政区图");
layer.setSource("d7cb5f6f-ee31-4a6e-b8fd-72603a066c2b"); // layer.setSource("d7cb5f6f-ee31-4a6e-b8fd-72603a066c2b");
layer.setType("ol.layer.Tile"); // layer.setType("ol.layer.Tile");
java.util.Map<String,Object> options = new HashMap<>(); // java.util.Map<String,Object> options = new HashMap<>();
options.put("projection","EPSG:4326"); // options.put("projection","EPSG:4326");
layer.setOptions(options); // layer.setOptions(options);
layerService.insertLayer(layer); // layerService.insertLayer(layer);
System.out.println("插入成功"); // System.out.println("插入成功");
//资源接口 //资源接口