Commit cd67ab98 by Jbb

图层代码 完结

parent 9eda25cd
package com.founder.commonutils.viewEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
......@@ -13,10 +13,11 @@ import java.util.Date;
@Accessors(chain = true)
@TableName("tb_st_layer_data")
@ApiModel(value="图层数据对象", description="图层数据")
public class TbStLayerData implements Serializable {
public class TbStLayerData extends PageInfo implements Serializable {
@TableId(value = "xxzjbh")
private String xxzjbh;
private String gl_xxzjbh;
//@TableField(value = "gl_xxzjbh")
private String glXxzjbh;
private double x; //经度
private double y; //纬度
private String xStr; //保存错误的经度
......@@ -32,12 +33,12 @@ public class TbStLayerData implements Serializable {
this.xxzjbh = xxzjbh;
}
public String getGl_xxzjbh() {
return gl_xxzjbh;
public String getGlXxzjbh() {
return glXxzjbh;
}
public void setGl_xxzjbh(String gl_xxzjbh) {
this.gl_xxzjbh = gl_xxzjbh;
public void setGlXxzjbh(String glXxzjbh) {
this.glXxzjbh = glXxzjbh;
}
public double getX() {
......
......@@ -3,10 +3,13 @@ package com.founder.view.config;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.github.pagehelper.PageHelper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
@Configuration
@MapperScan("com.founder.view.mapper")
public class EduConfig {
......@@ -27,5 +30,15 @@ public class EduConfig {
return new PaginationInterceptor();
}
@Bean
public PageHelper getPageHelper(){
PageHelper pageHelper=new PageHelper();
Properties properties=new Properties();
properties.setProperty("helperDialect","mysql");
properties.setProperty("reasonable","true");
properties.setProperty("supportMethodsArguments","true");
properties.setProperty("params","count=countSql");
pageHelper.setProperties(properties);
return pageHelper;
}
}
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.viewEntity.TbStLayer;
import com.founder.view.service.TbStLayerDataService;
import com.founder.view.service.TbStLayerService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -19,10 +20,19 @@ import javax.annotation.Resource;
public class TbStLayerController {
@Resource
TbStLayerService tbStLayerService;
@Resource
TbStLayerDataService tbStLayerDataService;
@RequestMapping("/getLayers")
public MapRestResult getLayers(@RequestBody TbStLayer tbStLayer) {
return tbStLayerService.getLayers(tbStLayer,tbStLayer.getPageNo(),tbStLayer.getSize());
}
@RequestMapping("/getLayerData")
public MapRestResult getLayerData(@RequestBody TbStLayer tbStLayer) {
return tbStLayerDataService.selectByGlId(tbStLayer.getXxzjbh(),tbStLayer.getPageNo(),tbStLayer.getSize());
}
}
......@@ -2,6 +2,7 @@ package com.founder.view.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.viewEntity.TbStLayerData;
import org.apache.ibatis.annotations.Mapper;
......@@ -22,4 +23,5 @@ public interface TbStLayerDataMapper extends BaseMapper<TbStLayerData> {
void deleteByGlId(String layerId);
List<TbStLayerData> selectByGlId(String layerId);
}
package com.founder.view.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.viewEntity.TbStLayerData;
public interface TbStLayerDataService extends IService<TbStLayerData> {
void deleteByGlId(String layerId);
MapRestResult selectByGlId(String layerId,Integer pageNo, Integer size);
}
package com.founder.view.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.founder.commonutils.publicEntity.MapRestResult;
import com.founder.commonutils.viewEntity.TbStLayer;
import com.founder.commonutils.viewEntity.TbStLayerData;
import com.founder.view.mapper.TbStLayerDataMapper;
import com.founder.view.service.TbStLayerDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class TbStLayerDataServiceImpl extends ServiceImpl<TbStLayerDataMapper, TbStLayerData> implements TbStLayerDataService {
......@@ -17,4 +23,25 @@ public class TbStLayerDataServiceImpl extends ServiceImpl<TbStLayerDataMapper, T
public void deleteByGlId(String layerId) {
tbStLayerDataMapper.deleteByGlId(layerId);
}
@Override
public MapRestResult selectByGlId(String layerId,Integer pageNo, Integer size) {
try {
if(pageNo != null && pageNo != 0 && size != null && size != 0) {
PageHelper.startPage(pageNo, size);
List<TbStLayerData> tbStLayerDatas = tbStLayerDataMapper.selectByGlId(layerId);
PageInfo<TbStLayerData> pageInfo = new PageInfo<>(tbStLayerDatas);
return MapRestResult.build(200,"图层数据查询成功!",pageInfo.getTotal(),pageInfo);
}else{
List<TbStLayerData> tbStLayerDatas = tbStLayerDataMapper.selectByGlId(layerId);
return MapRestResult.build(200,"图层数据查询成功!",null,tbStLayerDatas);
}
} catch (Exception e) {
e.printStackTrace();
return MapRestResult.build(500,"图层数据查询失败!",null,null);
}
}
}
......@@ -26,21 +26,32 @@ public class TbStLayerServiceImpl extends ServiceImpl<TbStLayerMapper, TbStLayer
@Override
public MapRestResult<TbStLayer> getLayers(TbStLayer tbStLayer, Integer pageNo, Integer size) {
try {
pageNo = 1;
size= 10;
PageHelper.startPage(pageNo,size);
List<TbStLayer> tbStLayerList = new ArrayList<>();
List<TbStLayer> tbStLayers = tbStLayerMapper.selectLayers(tbStLayer);
if(tbStLayers != null && tbStLayers.size() > 0){
for (TbStLayer stLayer : tbStLayers) {
List<TbStLayerData> tbStLayerDataList = tbStLayerDataMapper.selectByGlId(stLayer.getXxzjbh());
stLayer.setCount(tbStLayerDataList.size());
tbStLayerList.add(stLayer);
if(pageNo != null && pageNo != 0 && size != null && size != 0) {
PageHelper.startPage(pageNo, size);
List<TbStLayer> tbStLayerList = new ArrayList<>();
List<TbStLayer> tbStLayers = tbStLayerMapper.selectLayers(tbStLayer);
if (tbStLayers != null && tbStLayers.size() > 0) {
for (TbStLayer stLayer : tbStLayers) {
List<TbStLayerData> tbStLayerDataList = tbStLayerDataMapper.selectByGlId(stLayer.getXxzjbh());
stLayer.setCount(tbStLayerDataList.size());
tbStLayerList.add(stLayer);
}
}
}
PageInfo<TbStLayer> pageInfo = new PageInfo<>(tbStLayerList);
return MapRestResult.build(200,"图层信息查询成功!",pageInfo.getTotal(),pageInfo);
PageInfo<TbStLayer> pageInfo = new PageInfo<>(tbStLayerList);
return MapRestResult.build(200, "图层信息查询成功!", pageInfo.getTotal(), pageInfo);
}else{
List<TbStLayer> tbStLayerList = new ArrayList<>();
List<TbStLayer> tbStLayers = tbStLayerMapper.selectLayers(tbStLayer);
if (tbStLayers != null && tbStLayers.size() > 0) {
for (TbStLayer stLayer : tbStLayers) {
List<TbStLayerData> tbStLayerDataList = tbStLayerDataMapper.selectByGlId(stLayer.getXxzjbh());
stLayer.setCount(tbStLayerDataList.size());
tbStLayerList.add(stLayer);
}
}
return MapRestResult.build(200, "图层信息查询成功!", null, tbStLayerList);
}
} catch (Exception e) {
e.printStackTrace();
return MapRestResult.build(500,"图层信息查询失败!",null,null);
......
......@@ -5,7 +5,7 @@ spring.cloud.nacos.discovery.server-addr=47.92.48.137:9949
#spring.cloud.nacos.config.server-addr=26.3.13.184:8848
#spring.cloud.nacos.discovery.server-addr=26.3.13.184:8848
spring.profiles.active=dev
#spring.profiles.active=dev
# 该配置影响统一配置中心中的dataId
spring.application.name=view
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment