模板管理 后台功能完成
parent
584de18633
commit
84694611c8
@ -0,0 +1,22 @@
|
||||
package cn.estsh.i3plus.core.api.iservice.base;
|
||||
|
||||
import cn.estsh.i3plus.pojo.model.report.TemplateModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-20 16:04
|
||||
* @Modify:
|
||||
**/
|
||||
public interface IReportService {
|
||||
|
||||
@ApiOperation(value = "HQL 入侵检查",notes = "入侵检查")
|
||||
void checkReportHQL(String hql);
|
||||
|
||||
@ApiOperation(value = "HQL 执行",notes = "执行 HQL")
|
||||
List selectTemplateModel(TemplateModel model) throws Exception;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.estsh.i3plus.core.apiservice.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-20 16:11
|
||||
* @Modify:
|
||||
**/
|
||||
public interface IReportDao {
|
||||
|
||||
List<Object[]> findByHqlObjects(String hql, String[] paramName, Object[] paramValue) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cn.estsh.i3plus.core.apiservice.daoimpl;
|
||||
|
||||
import cn.estsh.i3plus.core.apiservice.dao.IReportDao;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-20 16:14
|
||||
* @Modify:
|
||||
**/
|
||||
@Service
|
||||
public class ReportDaoImpl implements IReportDao {
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(ReportDaoImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public List<Object[]> findByHqlObjects(String hql, String[] paramName, Object[] paramValue) throws Exception {
|
||||
LOGGER.info(" find HQL:{} paramName:{} paramValue:{}", hql, paramName, paramValue);
|
||||
Query queryObject = entityManager.createQuery(hql);
|
||||
if(paramName != null && paramValue != null){
|
||||
for (int i = 0; i < paramName.length; i++) {
|
||||
if (paramValue[i] != null) {
|
||||
queryObject.setParameter(paramName[i], paramValue[i].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return queryObject.getResultList();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.base;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.base.IReportService;
|
||||
import cn.estsh.i3plus.core.apiservice.dao.IReportDao;
|
||||
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
|
||||
import cn.estsh.i3plus.pojo.model.report.TemplateModel;
|
||||
import org.hibernate.QueryException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-20 16:06
|
||||
* @Modify:
|
||||
**/
|
||||
@Service
|
||||
public class ReportService implements IReportService {
|
||||
|
||||
private Logger LOGGER = LoggerFactory.getLogger(ReportService.class);
|
||||
|
||||
@Autowired
|
||||
private IReportDao reportDao;
|
||||
|
||||
|
||||
@Override
|
||||
public void checkReportHQL(String hql) {
|
||||
LOGGER.info("报表 HQL 注入检查:{}",hql);
|
||||
// HQL 非法入侵检查
|
||||
hql = HqlPack.getSafeParam(hql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List selectTemplateModel(TemplateModel model) throws Exception{
|
||||
LOGGER.info("报表执行 model :{}",model);
|
||||
return reportDao.findByHqlObjects(model.getHql(), model.getParamName(), model.getParamValue());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue