|
|
@ -25,6 +25,7 @@ import com.qs.serve.modules.exl.service.ExlColumnConfService; |
|
|
|
import com.qs.serve.modules.exl.service.ExlTableConfService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.mybatis.spring.SqlSessionTemplate; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
@ -66,6 +67,29 @@ public class ExlTableDataController { |
|
|
|
LambdaQueryWrapper<ExlColumnConf> columnLqw = new LambdaQueryWrapper<>(); |
|
|
|
columnLqw.eq(ExlColumnConf::getTableConfId,tableConfigId); |
|
|
|
List<ExlColumnConf> columnList = exlColumnConfService.list(columnLqw); |
|
|
|
// query
|
|
|
|
Map<String, Object> queryMap = buildQueryMap(map, columnList); |
|
|
|
String targetTableName = ExlConst.TABLE_NAME_PRE + tableConf.getTableName(); |
|
|
|
Long count = exlTableConfMapper.countData(targetTableName,queryMap); |
|
|
|
PageVo vo = new PageVo(); |
|
|
|
vo.initPageByTotal(count); |
|
|
|
if(count>0){ |
|
|
|
// page
|
|
|
|
Integer pageSize = PageUtil.getPageSize(); |
|
|
|
Integer startRow = PageUtil.getStartRow(); |
|
|
|
queryMap.put("startRow",startRow); |
|
|
|
queryMap.put("pageSize",pageSize); |
|
|
|
List<Map<String,Object>> list = exlTableConfMapper.listData(targetTableName,queryMap); |
|
|
|
vo.setList(list); |
|
|
|
}else { |
|
|
|
vo.setList(new ArrayList()); |
|
|
|
} |
|
|
|
return R.ok(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private Map<String, Object> buildQueryMap(Map<String, String> map, List<ExlColumnConf> columnList) { |
|
|
|
Map<String,Object> queryMap = new HashMap<>(10); |
|
|
|
// condition
|
|
|
|
List<ExlConditionDto> ge_conditions = new ArrayList<>(); |
|
|
|
List<ExlConditionDto> le_conditions = new ArrayList<>(); |
|
|
@ -96,33 +120,33 @@ public class ExlTableDataController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// page
|
|
|
|
Integer pageSize = PageUtil.getPageSize(); |
|
|
|
Integer startRow = PageUtil.getStartRow(); |
|
|
|
// query
|
|
|
|
Map<String,Object> queryMap = new HashMap<>(10); |
|
|
|
queryMap.put("startRow",startRow); |
|
|
|
queryMap.put("pageSize",pageSize); |
|
|
|
queryMap.put("leList",le_conditions); |
|
|
|
queryMap.put("geList",ge_conditions); |
|
|
|
queryMap.put("eqList",eq_conditions); |
|
|
|
queryMap.put("likeList",like_conditions); |
|
|
|
String targetTableName = ExlConst.TABLE_NAME_PRE + tableConf.getTableName(); |
|
|
|
Long count = exlTableConfMapper.countData(targetTableName,queryMap); |
|
|
|
PageVo vo = new PageVo(); |
|
|
|
vo.initPageByTotal(count); |
|
|
|
if(count>0){ |
|
|
|
List<Map<String,Object>> list = exlTableConfMapper.listData(targetTableName,queryMap); |
|
|
|
vo.setList(list); |
|
|
|
}else { |
|
|
|
vo.setList(new ArrayList()); |
|
|
|
} |
|
|
|
return R.ok(vo); |
|
|
|
return queryMap; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public R<?> export(){ |
|
|
|
return null; |
|
|
|
/** |
|
|
|
* 导出数据 |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/export") |
|
|
|
public R<?> export(@RequestParam Map<String,String> map){ |
|
|
|
String tableConfigId = map.get(ExlConst.TABLE_CONFIG_PARAM); |
|
|
|
map.remove(ExlConst.TABLE_CONFIG_PARAM); |
|
|
|
// table
|
|
|
|
ExlTableConf tableConf = exlTableConfService.getById(tableConfigId); |
|
|
|
// columns
|
|
|
|
LambdaQueryWrapper<ExlColumnConf> columnLqw = new LambdaQueryWrapper<>(); |
|
|
|
columnLqw.eq(ExlColumnConf::getTableConfId,tableConfigId); |
|
|
|
List<ExlColumnConf> columnList = exlColumnConfService.list(columnLqw); |
|
|
|
// query
|
|
|
|
Map<String, Object> queryMap = buildQueryMap(map, columnList); |
|
|
|
String targetTableName = ExlConst.TABLE_NAME_PRE + tableConf.getTableName(); |
|
|
|
List<Map<String,Object>> list = exlTableConfMapper.listData(targetTableName,queryMap); |
|
|
|
return R.ok(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|