org.openea.eap.module.system.service.dict.DictDataServiceImplExt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eap-module-system-biz Show documentation
Show all versions of eap-module-system-biz Show documentation
system 模块下,我们放通用业务,支撑上层的核心业务。
例如说:用户、部门、权限、数据字典等等
The newest version!
package org.openea.eap.module.system.service.dict;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.openea.eap.framework.common.enums.CommonStatusEnum;
import org.openea.eap.framework.common.pojo.PageResult;
import org.openea.eap.framework.datasource.EapDynamicDataSourceUtil;
import org.openea.eap.module.system.controller.admin.dict.vo.data.DictDataExportReqVO;
import org.openea.eap.module.system.controller.admin.dict.vo.data.DictDataPageReqVO;
import org.openea.eap.module.system.dal.dataobject.dict.DictDataDO;
import org.openea.eap.module.system.dal.dataobject.dict.DictTypeDO;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 数据字典扩展实现类
*/
@Service
@Slf4j
public class DictDataServiceImplExt extends DictDataServiceImpl implements DictDataService{
@Override
public PageResult getDictDataPage(DictDataPageReqVO reqVO) {
String dataType = reqVO.getDataType();
if(ObjectUtil.isEmpty(dataType) || DictTypeDO.DATA_TYPE_DATA.equals(dataType)){
return super.getDictDataPage(reqVO);
}
// json/sql/api
if(DictTypeDO.DATA_TYPE_JSON.equals(dataType)){
List dictDataList = getDictDataListByJson(reqVO.getDictType());
return new PageResult<>(dictDataList, 0L + dictDataList.size());
}
if(DictTypeDO.DATA_TYPE_SQL.equals(dataType)){
// todo 后续扩展分页支持
List dictDataList = getDictDataListBySql(reqVO.getDictType());
return new PageResult<>(dictDataList, 0L + dictDataList.size());
}
return new PageResult<>();
}
@Override
public List getDictDataList(DictDataExportReqVO reqVO) {
String dataType = reqVO.getDataType();
if(ObjectUtil.isEmpty(dataType) || "data".equals(dataType)){
return super.getDictDataList(reqVO);
}
// json/sql/api
if(DictTypeDO.DATA_TYPE_JSON.equals(dataType)){
return getDictDataListByJson(reqVO.getDictType());
}
if(DictTypeDO.DATA_TYPE_SQL.equals(dataType)){
return getDictDataListBySql(reqVO.getDictType());
}
return Collections.emptyList();
}
public List getDictDataListByJson(String dictType){
List dictDataList = new ArrayList<>();
try{
DictTypeDO dictTypeDO = this.dictTypeService.getDictType(dictType);
JSONArray jsonArray = JSON.parseArray(dictTypeDO.getDataJson());
for(int i=0; i getDictDataListBySql(String dictType){
List dictDataList = new ArrayList<>();
try{
DictTypeDO dictTypeDO = this.dictTypeService.getDictType(dictType);
String ds = dictTypeDO.getDataDs();
String sql = dictTypeDO.getDataSql();
// todo sql 参数解析替换
JdbcTemplate jdbcTemplate = EapDynamicDataSourceUtil.getJdbcTemplate(ds);
// 是否限制最大数量?
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy