初始化
This commit is contained in:
parent
d389b52b66
commit
fb0d22c655
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.c3gis</groupId>
|
||||
<artifactId>c3gis</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.3</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
30
src/main/java/com/gis3c/common/bean/BeanUtil.java
Normal file
30
src/main/java/com/gis3c/common/bean/BeanUtil.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/gis3c/common/exception/DataException.java
Normal file
25
src/main/java/com/gis3c/common/exception/DataException.java
Normal 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);
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/gis3c/common/exception/ViewException.java
Normal file
25
src/main/java/com/gis3c/common/exception/ViewException.java
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface LayerService {
|
||||
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 findeLayerByName(String layerName);
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface MapService {
|
||||
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 findMapByName(String mapName);
|
||||
|
||||
@ -8,7 +8,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface SourceService {
|
||||
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 findSourceByName(String sourceName);
|
||||
public Integer insertSource(Source source);
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
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.entity.Layer;
|
||||
import com.gis3c.ol.entity.Source;
|
||||
import com.gis3c.ol.service.LayerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -23,8 +27,17 @@ public class LayerServiceImpl implements LayerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Layer> findLayersByPage(Integer pageSize, Integer currentPage) {
|
||||
return layerDao.findLayersByPage(pageSize,(currentPage -1)*pageSize);
|
||||
public List<java.util.Map<String,Object>> findLayersByPage(Integer pageSize, Integer currentPage) {
|
||||
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
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
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.entity.Map;
|
||||
import com.gis3c.ol.service.MapService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -23,8 +27,17 @@ public class MapServiceImpl implements MapService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> findMapsByPage(Integer pageSize,Integer currentPage) {
|
||||
return mapDao.findMapsByPage(pageSize,(currentPage -1)*pageSize);
|
||||
public List<java.util.Map<String,Object>> findMapsByPage(Integer pageSize,Integer currentPage) {
|
||||
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
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
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.entity.Map;
|
||||
import com.gis3c.ol.entity.Source;
|
||||
import com.gis3c.ol.service.SourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -23,8 +27,17 @@ public class SourceServiceImpl implements SourceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Source> findSourcesByPage(Integer pageSize, Integer currentPage) {
|
||||
return sourceDao.findSourcesByPage(pageSize,(currentPage -1)*pageSize);
|
||||
public List<java.util.Map<String,Object>> findSourcesByPage(Integer pageSize, Integer currentPage) {
|
||||
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
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.gis3c.spatial;
|
||||
|
||||
import com.gis3c.common.bean.BeanUtil;
|
||||
import com.gis3c.ol.entity.Layer;
|
||||
import com.gis3c.ol.entity.Map;
|
||||
import com.gis3c.ol.entity.Source;
|
||||
import com.gis3c.ol.service.LayerService;
|
||||
import com.gis3c.ol.service.MapService;
|
||||
@ -61,8 +63,10 @@ public class App {
|
||||
// System.out.println(FeatureUtilities.JavaBeans2Json(result));
|
||||
|
||||
// //地图接口
|
||||
// Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9");
|
||||
// System.out.println(map.getLayers()[0][1]);
|
||||
// Map map = mapService.findMapById("83c734de-c010-4153-bf68-d291d715ac55");
|
||||
System.out.println(mapService.findMapsByPage(5,1));
|
||||
|
||||
|
||||
|
||||
// Map map = new Map();
|
||||
// map.setMapId(UUID.randomUUID().toString());
|
||||
@ -86,16 +90,16 @@ public class App {
|
||||
// System.out.println("插入成功");
|
||||
|
||||
//图层接口
|
||||
Layer layer = new Layer();
|
||||
layer.setLayerName("streetmap");
|
||||
layer.setAliasName("超图行政区图");
|
||||
layer.setSource("d7cb5f6f-ee31-4a6e-b8fd-72603a066c2b");
|
||||
layer.setType("ol.layer.Tile");
|
||||
java.util.Map<String,Object> options = new HashMap<>();
|
||||
options.put("projection","EPSG:4326");
|
||||
layer.setOptions(options);
|
||||
layerService.insertLayer(layer);
|
||||
System.out.println("插入成功");
|
||||
// Layer layer = new Layer();
|
||||
// layer.setLayerName("streetmap");
|
||||
// layer.setAliasName("超图行政区图");
|
||||
// layer.setSource("d7cb5f6f-ee31-4a6e-b8fd-72603a066c2b");
|
||||
// layer.setType("ol.layer.Tile");
|
||||
// java.util.Map<String,Object> options = new HashMap<>();
|
||||
// options.put("projection","EPSG:4326");
|
||||
// layer.setOptions(options);
|
||||
// layerService.insertLayer(layer);
|
||||
// System.out.println("插入成功");
|
||||
|
||||
|
||||
//资源接口
|
||||
|
||||
Loading…
Reference in New Issue
Block a user