#E10-07# 处理sql注入验证

main
shilei 1 year ago
parent 41f751b5a4
commit 860f5afe2d

@ -1,8 +1,10 @@
package com.weaver.seconddev.jcldoor.controller;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.common.security.util.SecurityUtil;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
import com.weaver.em.msg.api.rest.OaRest;
import com.weaver.framework.remote.client.rest.RestClient;
import com.weaver.framework.rpc.annotation.RpcReference;
@ -11,9 +13,6 @@ import com.weaver.seconddev.jcldoor.util.DatabaseUtils;
import com.weaver.teams.blog.domain.RemoteBlogInfoService;
import com.weaver.teams.client.doc.remote.DocClientService;
import com.weaver.teams.domain.hr.RemoteHrKpiService;
import com.weaver.teams.domain.hr.entity.FlowData;
import com.weaver.teams.domain.hr.entity.FlowDataListReq;
import com.weaver.teams.domain.hr.entity.FlowDataListRes;
import com.weaver.teams.domain.user.SimpleEmployee;
import com.weaver.teams.security.context.UserContext;
import com.weaver.workflow.common.constant.list.listdimension.RequestListInitDimensionTabEnum;
@ -22,7 +21,6 @@ import com.weaver.workflow.common.entity.list.api.publicapi.RequestCountInfoPAEn
import com.weaver.workflow.common.entity.list.api.publicapi.RequestListInfoPAEntity;
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
import com.weaver.workrelate.performance.api.rest.RemotePerformanceService;
import okhttp3.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -32,9 +30,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
@ -75,297 +71,6 @@ public class HrmSelfHelpController {
public String tenant_key = "t7akvdnf84" ;
/**
*
* @param request
* @return
*/
@GetMapping("/testSapi1")
@WeaPermission(publicPermission = true)
public WeaResult<Object> getColumsCustomerName(HttpServletRequest request){
log.error("testSapi");
Map response = new HashMap<>();
String ids = request.getParameter("ids");
log.error("testSapi-ids:"+ids);
try{
response = restClient.postForObject("/openserver/sapi/architecture/v1/external/query/employee/list", request, Map.class);
log.error("testSapi-response"+response.toString());
}catch (Exception e){
log.error("testSapi-Exception:"+e);
}
return WeaResult.success(response);
}
// @GetMapping("/testSapi2")
// @WeaPermission(publicPermission = true)
// public WeaResult<Object> getColumsCustomerName2(HttpServletRequest request){
// // 1、请求头
// HttpHeaders httpHeaders = new HttpHeaders();
//
// httpHeaders.add("header", "value");
// HttpEntity<String> requestEntity = new HttpEntity<>(null, httpHeaders);
// // 3、请求体参数
// List<String> list = new ArrayList<>(100);
// list.add("6488080121949444347");
// Map<String,Object> params = new HashMap<>();
// params.put("ids",list);
// // 4、请求接⼝获取返回信息参数拼接在url后⾯
// RestTemplate restTemplate = new RestTemplateBuilder().build();
// ResponseEntity<WeaResult> responseEntity = restTemplate.exchange(BaseHttpUtil.urlConcatenation("/sapi/architecture/v1/external/query/employee/list",params), HttpMethod.GET, requestEntity, WeaResult.class);
// // 5、获取返回信息
// WeaResult weaResult = responseEntity.getBody();
// return weaResult;
@GetMapping("/testSapi3")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi3(HttpServletRequest request){
String request_cookie = "" ;
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies){
//判断携带的cookie是否正确
String cookiename = cookie.getName();
String cookievalue = cookie.getValue();
log.error("cookiename3:"+cookiename);
log.error("cookievalue3:"+cookievalue);
request_cookie += StringUtils.isBlank(request_cookie) ? cookiename+"="+cookievalue : "; "+cookiename+"="+cookievalue ;
}
log.error("request_cookie3:"+request_cookie);
log.error("3333333333");
JSONObject jsonObject = new JSONObject();
try {
String content = "{\"beginDate\": \"2024-01-01\", \"endDate\": \"2024-01-31\", \"userId\": \"6488080121949444347\"}";
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, content);
Request request3 = new Request.Builder()
.url("http://10.12.253.23:20600/api/attend/web/attendInfoV2/getAttendInfoStatis")
.method("POST", body)
.addHeader("Cookie", request_cookie)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request3).execute();
int code = response.code();
String data = response.body().string();
log.error("code3:"+code);
log.error("data3:"+data);
if(StringUtils.isNotBlank(data)){
jsonObject = JSONObject.parseObject(data);
}
} catch (IOException e) {
e.printStackTrace();
log.error("testSapi3-e:"+e);
}
jsonObject.put("test111","testSapi3");
return WeaResult.success(jsonObject.toString());
}
@GetMapping("/testSapi5")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi5(HttpServletRequest request){
String request_cookie = "" ;
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies){
//判断携带的cookie是否正确
log.error("getName5:" + cookie.getName());
log.error("getValue5:" + cookie.getValue());
String cookiename = cookie.getName();
String cookievalue = cookie.getValue();
if("langType".equals(cookiename) || " ETEAMS_TGC".equals(cookiename) || "JSESSIONID".equals(cookiename) || "ETEAMSID".equals(cookiename)){
request_cookie += StringUtils.isBlank(request_cookie) ? cookiename+"="+cookievalue : "; "+cookiename+"="+cookievalue ;
}
}
log.error("request_cookie5:"+request_cookie);
log.error("55555555");
JSONObject jsonObject = new JSONObject();
try {
String content = "{\"beginDate\": \"2024-01-01\", \"endDate\": \"2024-01-31\", \"userId\": \"6488080121949444347\"}";
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, content);
Request request3 = new Request.Builder()
.url("http://10.12.253.23:20600/api/attend/web/attendInfoV2/getAttendInfoStatis")
.method("POST", body)
.addHeader("Cookie", request_cookie)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request3).execute();
int code = response.code();
log.error("code5:"+code);
String data = response.body().string();
log.error("data5:"+data);
if(StringUtils.isNotBlank(data)){
jsonObject = JSONObject.parseObject(data);
}
} catch (IOException e) {
e.printStackTrace();
log.error("testSapi5-e:"+e);
}
jsonObject.put("test111","testSapi5");
return WeaResult.success(jsonObject.toString());
}
@GetMapping("/testSapi6")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi6(HttpServletRequest request){
String headcookie = request.getHeader("Cookie");
String Eteamsid = request.getHeader("Eteamsid");
log.error("testSapi6");
log.error("headcookie6:"+headcookie);
log.error("6666666111111");
log.error("Eteamsid:"+Eteamsid);
log.error("66666222222");
JSONObject jsonObject = new JSONObject();
try {
String content = "{\"beginDate\": \"2024-01-01\", \"endDate\": \"2024-01-31\", \"userId\": \"6488080121949444347\"}";
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, content);
Request request3 = new Request.Builder()
.url("http://10.12.253.23:20600/api/attend/web/attendInfoV2/getAttendInfoStatis")
.method("POST", body)
.addHeader("Cookie", headcookie)
.addHeader("Eteamsid", Eteamsid)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request3).execute();
int code = response.code();
log.error("code6:"+code);
String data = response.body().string();
log.error("data6:"+data);
if(StringUtils.isNotBlank(data)){
jsonObject = JSONObject.parseObject(data);
}
} catch (IOException e) {
e.printStackTrace();
log.error("testSapi6:"+e);
}
jsonObject.put("test111","testSapi6");
return WeaResult.success(jsonObject.toString());
}
@GetMapping("/testSapi7")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi7(HttpServletRequest request){
String headcookie = request.getHeader("Cookie");
log.error("testSapi7");
log.error("testSapi7:"+headcookie);
log.error("6666666111111");
JSONObject jsonObject = new JSONObject();
try {
String content = "{\"beginDate\": \"2024-04-01\", \"endDate\": \"2024-04-30\", \"userId\": \"6488080121949444347\"}";
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"beginDate\": \"2024-01-01\", \"endDate\": \"2024-01-31\", \"userId\": \"6488080121949444347\"}");
Request request3 = new Request.Builder()
.url("http://10.12.253.23:20600/api/attend/web/attendInfoV2/getAttendInfoStatis")
.method("POST", body)
.addHeader("Cookie", headcookie)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request3).execute();
int code = response.code();
log.error("code7:"+code);
String data = response.body().string();
log.error("data7:"+data);
if(StringUtils.isNotBlank(data)){
jsonObject = JSONObject.parseObject(data);
}
} catch (IOException e) {
e.printStackTrace();
log.error("testSapi6:"+e);
}
jsonObject.put("test111","testSapi7");
return WeaResult.success(jsonObject.toString());
}
@GetMapping("/testSapi8")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi8(HttpServletRequest request){
//com.weaver.workrelate.performance.api.rest.RemotePerformanceService#queryFlowData
Map<String,Object> dataMap = new HashMap<String,Object>();
dataMap.put("test","testSapi8");
try {
FlowDataListReq flowDataListReq = new FlowDataListReq();
flowDataListReq.setCurrent(1);
flowDataListReq.setPageSize(20);
flowDataListReq.setStartTime("2024-01-01");
flowDataListReq.setEndTime("2024-01-31");
flowDataListReq.setDateType("month");
flowDataListReq.setTenantKey("t7akvdnf84");
List<Long> userList = new ArrayList<Long>();
Long employeeId = UserContext.getCurrentEmployeeId();
userList.add(employeeId);
flowDataListReq.setUserList(userList);
FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq);
Long total = flowData.getTotal();
dataMap.put("total",total+"");
List<FlowDataListRes> flowDataList = flowData.getDataList();
for(int i = 0 ;i<flowDataList.size();i++){
FlowDataListRes flowDataListRes = flowDataList.get(i);
Long UserId = flowDataListRes.getUserId();
float Score = flowDataListRes.getScore();
dataMap.put("UserId",UserId+"");
dataMap.put("Score",Score+"");
}
} catch (Exception e) {
e.printStackTrace();
log.error("testSapi8:"+e);
}
return WeaResult.success(dataMap);
}
@GetMapping("/testSapi9")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi9(HttpServletRequest request){
@ -389,7 +94,6 @@ public class HrmSelfHelpController {
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi10(HttpServletRequest request){
//com.weaver.workrelate.performance.api.rest.RemotePerformanceService#queryFlowData
Map<String,Object> dataMap = new HashMap<String,Object>();
dataMap.put("test","testSapi10");
try {
@ -397,10 +101,11 @@ public class HrmSelfHelpController {
SimpleEmployee employee = UserContext.getCurrentUser();
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
WeaResult<RequestCountInfoPAEntity> RequestCountInfoPAEntity = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), conditionEntity);
int code = RequestCountInfoPAEntity.getCode();
Long count = RequestCountInfoPAEntity.getData().getCount();
WeaResult<RequestCountInfoPAEntity> requestCountInfo = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.DONE_FLOWALL.getTabid(), conditionEntity);
int code = requestCountInfo.getCode();
RequestCountInfoPAEntity requestCountInfoPAEntity = requestCountInfo.getData();
long count = requestCountInfoPAEntity.getCount();
dataMap.put("code",code);
dataMap.put("count",count);
@ -422,9 +127,6 @@ public class HrmSelfHelpController {
dataMap.put("test","testSapi11");
try {
SimpleEmployee employee = UserContext.getCurrentUser();
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
WeaResult<RequestCountInfoPAEntity> RequestCountInfoPAEntity = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid(), conditionEntity);
int code = RequestCountInfoPAEntity.getCode();
@ -1163,6 +865,7 @@ public class HrmSelfHelpController {
List<Map<String,Object>> indicatorList = new ArrayList<Map<String,Object>>();
if(StringUtils.isNotBlank(employeeId)){
String sql =" select left(k.real_period,10) as real_period,left(k.real_period,7) as period_month,k.kpi_scheme,k.score\n" +
" from (select real_period,kpi_scheme,score\n" +
" from hr_kpi_flow \n" +
@ -1176,6 +879,9 @@ public class HrmSelfHelpController {
") k limit 1 ";
log.error("sql20-1:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList)){
@ -1754,16 +1460,31 @@ public class HrmSelfHelpController {
}
String sql = " select count(1) as cou from cw_content " +
" where CREATOR='"+employeeId+"'\n" +
" and left(CREATE_TIME,10)>='"+startday+"' and left(CREATE_TIME,10) <= '"+endday+"'" ;
" where CREATOR= ? " +
" and left(CREATE_TIME,10)>=? and left(CREATE_TIME,10) <= ? " ;
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(employeeId);
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(startday);
sqlparam.add(sqlParamEntity);
sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(endday);
sqlparam.add(sqlParamEntity);
log.error("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(recordList.size()>0){
dataMap = recordList.get(0);
}
}catch (Exception e){
log.error("testSapi51-Exception:"+e.getMessage());
return WeaResult.fail(500,"程序执行异常");
@ -1772,6 +1493,58 @@ public class HrmSelfHelpController {
}
/***
*
* @param request
* @return
*/
@GetMapping("/testSapi511")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi511(HttpServletRequest request){
log.error("testSapi511");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String groupId = "weaver-cowork-service";
String sourceType = "LOGIC";
Map<String,Object> dataMap = new HashMap<String,Object>();
try{
String startday = request.getParameter("startday");
String endday = request.getParameter("endday");
String employeeId = request.getParameter("employeeId");
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
if(StringUtils.isBlank(startday)){
startday = year+"-01-01";
}
if(StringUtils.isBlank(endday)){
endday = sdf.format(new Date());
}
if(StringUtils.isBlank(employeeId)){
employeeId = String.valueOf(UserContext.getCurrentEmployeeId());
}
String sql =" select count(1) as cou from cw_content " +
" where CREATOR= " +SecurityUtil.ecodeForSql(employeeId)+
" and left(CREATE_TIME,10)>="+SecurityUtil.ecodeForSql(startday)+" and left(CREATE_TIME,10) <= "+SecurityUtil.ecodeForSql(endday) ;
log.error("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(recordList.size()>0){
dataMap = recordList.get(0);
}
}catch (Exception e){
log.error("testSapi51-Exception:"+e.getMessage());
return WeaResult.fail(500,"程序执行异常");
}
return WeaResult.success(dataMap);
}
/***
*
* @param request
@ -2058,7 +1831,9 @@ public class HrmSelfHelpController {
log.info("dataSql:"+dataSql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, dataSql);
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
SqlParamEntity sqlParamEntity = new SqlParamEntity();
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql,sqlparam);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList)) {
devcou = String.valueOf(recordList.get(0).get("devcou"));
@ -2070,10 +1845,166 @@ public class HrmSelfHelpController {
return WeaResult.fail(500,"程序执行异常");
}
return WeaResult.success(devcou);
}
@GetMapping("/testSapi110")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi110(HttpServletRequest request){
//com.weaver.workrelate.performance.api.rest.RemotePerformanceService#queryFlowData
Map<String,Object> dataMap = new HashMap<String,Object>();
dataMap.put("test","testSapi110");
try {
SimpleEmployee employee = UserContext.getCurrentUser();
RequestListConditionApiEntity conditionEntity = new RequestListConditionApiEntity();
WeaResult<RequestCountInfoPAEntity> requestCountInfo = wflRequestListRest.getRequestCountByTabId(employee, RequestListInitDimensionTabEnum.MINE_FLOWALL.getTabid(), conditionEntity);
log.error("testSapi110:"+requestCountInfo.toString());
int code = requestCountInfo.getCode();
log.error("testSapi110:"+code);
RequestCountInfoPAEntity requestCountInfoPAEntity = requestCountInfo.getData();
log.error("testSapi110:"+requestCountInfoPAEntity.toString());
dataMap.put("data",requestCountInfoPAEntity);
} catch (Exception e) {
e.printStackTrace();
log.error("testSapi11:"+e);
dataMap.put("count","-1");
}
return WeaResult.success(dataMap);
}
@GetMapping("/testSapi80")
@WeaPermission(publicPermission = true)
public WeaResult<Object> testSapi80(HttpServletRequest request){
// SecurityUtil.ecodeForSql(field_id);
log.error("testSapi80");
String groupId = "weaver-ebuilder-form-service";
String sourceType = "LOGIC";
List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
try{
String sql = " select ry from uf_zzfwrkpz t where delete_type=0 and tenant_key = '"+tenant_key+"'";
log.info("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(recordList.size()>0){
Map<String,Object> recordMap = recordList.get(0);
String ry = String.valueOf(recordMap.get("ry"));
if(StringUtils.isNotBlank(ry)){
dataList = getSelfServiceTypeData(groupId,sourceType);
}else{
dataList = getSelfServiceTypeData(groupId,sourceType);
}
}
}catch (Exception e){
log.error("testSapi51-Exception:"+e.getMessage());
return WeaResult.fail(500,"程序执行异常");
}
return WeaResult.success(dataList);
}
public List<Map<String,Object>> getCustemSelfServiceType(String groupId,String sourceType){
Map<String,String> optionMap = getSelfServiceTypeName(groupId,sourceType);
String sql = " select distinct taby as value_key from uf_zzfwrkp_mxb1 where delete_type=0 and tenant_key = '"+tenant_key+"'";
log.info("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
String taby = String.valueOf(recordMap.get("value_key"));
log.error("getCustemSelfServiceType-taby:"+taby);
List<Map<String,Object>> customList = new ArrayList<Map<String,Object>>();
String tabyName = "";
if(StringUtils.isNotBlank(taby)){
tabyName = optionMap.get(taby);
customList = getCustomeSelfServiceData(groupId,sourceType,taby);
}
log.error("getCustemSelfServiceType-tabyName:"+tabyName);
log.error("getCustemSelfServiceType-taby:"+taby);
recordMap.put("menu",customList);
recordMap.put("name",tabyName);
}
return recordList;
}
public Map<String,String> getSelfServiceTypeName(String groupId,String sourceType){
Map<String,String> optionMap = new HashMap<String,String>();
String field_id = "977306579913818114" ;
String sql = " select name,value_key from field_option where field_id='"+field_id+"' and delete_type=0 and tenant_key = '"+tenant_key+"'";
log.info("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
String value = String.valueOf(recordMap.get("value_key"));
String name = String.valueOf(recordMap.get("name"));
optionMap.put(value,name);
}
return optionMap;
}
public List<Map<String,Object>> getCustomeSelfServiceData(String groupId,String sourceType,String value){
String sql =" select t.taby,t.fwtb,t.fwmc,t.fwdz\n" +
" from uf_zzfwcsh t \n" +
" where t.delete_type=0 \n" +
" and t.taby=" + value +
" and t.tenant_key = '"+tenant_key+"'";
log.info("getSelfServiceData--sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
return recordList;
}
public List<Map<String,Object>> getSelfServiceTypeData(String groupId,String sourceType){
String field_id = "977306579913818114" ;
String sql = " select name,value_key from field_option where field_id='"+field_id+"' and delete_type=0 and tenant_key = '"+tenant_key+"'";
log.info("sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
for(int i=0;i<recordList.size();i++){
Map<String,Object> recordMap = recordList.get(i);
String value = String.valueOf(recordMap.get("value_key"));
List<Map<String,Object>> recordList2 = new ArrayList<Map<String,Object>>();
if(StringUtils.isNotBlank(value)){
recordList2 = getSelfServiceData(groupId,sourceType,value);
}
recordMap.put("menu",recordList2);
}
return recordList;
}
/***
*
* @param groupId
* @param sourceType
* @param value
* @return
*/
public List<Map<String,Object>> getSelfServiceData(String groupId,String sourceType,String value){
String sql =" select t.taby,t.fwtb,t.fwmc,t.fwdz\n" +
" from uf_zzfwcsh t \n" +
" where t.delete_type=0 \n" +
" and t.taby=" + value +
" and t.tenant_key = '"+tenant_key+"'";
log.info("getSelfServiceData--sql:"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
return recordList;
}

@ -3,6 +3,7 @@ package com.weaver.seconddev.jcldoor.util;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
@ -247,6 +248,16 @@ public class DatabaseUtils {
}
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
//执行sql 参数sourceType groupId sql sqlparam
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(base64(sql));
executeSqlEntity.setGroupId(groupId);
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
executeSqlEntity.setParams(sqlparam);
return dataSetService.executeSql(executeSqlEntity);
}
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
if(pageNo<=0){
pageNo = 1;

Loading…
Cancel
Save