调整字典查询sql:先判断是否存在iz_enabled字段 如果存在则带上 避免try catch拦截时控制台仍然报错问题
This commit is contained in:
parent
33aae96b73
commit
d8c24ee1a9
|
@ -1,11 +1,11 @@
|
|||
package com.nu.modules.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
public class PinyinUtils {
|
||||
|
|
|
@ -214,4 +214,6 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
|||
* @return
|
||||
*/
|
||||
int removeLogicDeleted(@Param("ids")List<String> ids);
|
||||
|
||||
int existColumn(@Param("tableName") String tableName, @Param("columnName") String columnName);
|
||||
}
|
||||
|
|
|
@ -4,21 +4,24 @@
|
|||
|
||||
<!-- 通过字典code获取字典数据 -->
|
||||
<select id="queryDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select s.item_value as "value",s.item_text as "text",s.item_color as color from sys_dict_item s
|
||||
select s.item_value as "value", s.item_text as "text", s.item_color as color
|
||||
from sys_dict_item s
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
order by s.sort_order asc, s.create_time DESC;
|
||||
</select>
|
||||
|
||||
<!-- 通过字典code获取有效的字典数据项 -->
|
||||
<select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select s.item_value as "value",s.item_text as "text", s.item_color as "color" from sys_dict_item s
|
||||
select s.item_value as "value", s.item_text as "text", s.item_color as "color"
|
||||
from sys_dict_item s
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
and s.status = 1
|
||||
order by s.sort_order asc, s.create_time DESC;
|
||||
</select>
|
||||
|
||||
<!-- 通过多个字典code获取字典数据 -->
|
||||
<select id="queryDictItemsByCodeList" parameterType="java.util.List" resultType="org.jeecg.common.system.vo.DictModelMany">
|
||||
<select id="queryDictItemsByCodeList" parameterType="java.util.List"
|
||||
resultType="org.jeecg.common.system.vo.DictModelMany">
|
||||
SELECT
|
||||
dict.dict_code,
|
||||
item.item_text AS "text",
|
||||
|
@ -37,7 +40,8 @@
|
|||
|
||||
<!-- 通过字典code获取字典数据 -->
|
||||
<select id="queryDictTextByKey" parameterType="String" resultType="String">
|
||||
select s.item_text from sys_dict_item s
|
||||
select s.item_text
|
||||
from sys_dict_item s
|
||||
where s.dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
and s.item_value = #{key}
|
||||
</select>
|
||||
|
@ -88,12 +92,16 @@
|
|||
|
||||
<!-- 查询部门信息 作为字典数据 -->
|
||||
<select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select id as "value",depart_name as "text" from sys_depart where del_flag = '0'
|
||||
select id as "value", depart_name as "text"
|
||||
from sys_depart
|
||||
where del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 查询用户信息 作为字典数据 -->
|
||||
<select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select username as "value",realname as "text" from sys_user where del_flag = '0'
|
||||
select username as "value", realname as "text"
|
||||
from sys_user
|
||||
where del_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
|
@ -101,13 +109,17 @@
|
|||
|
||||
<!-- 重复校验 sql语句【已加入SQL注入check】 -->
|
||||
<sql id="checkDuplicateCountSqlFragment">
|
||||
SELECT COUNT(1) FROM ${tableName} WHERE ${fieldName} = #{fieldVal}
|
||||
SELECT COUNT(1)
|
||||
FROM ${tableName}
|
||||
WHERE ${fieldName} = #{fieldVal}
|
||||
</sql>
|
||||
<select id="duplicateCheckCountSql" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
|
||||
<select id="duplicateCheckCountSql" resultType="Long"
|
||||
parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
|
||||
<include refid="checkDuplicateCountSqlFragment"></include>
|
||||
AND id <> #{dataId}
|
||||
</select>
|
||||
<select id="duplicateCheckCountSqlNoDataId" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
|
||||
<select id="duplicateCheckCountSqlNoDataId" resultType="Long"
|
||||
parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
|
||||
<include refid="checkDuplicateCountSqlFragment"></include>
|
||||
</select>
|
||||
|
||||
|
@ -142,7 +154,7 @@
|
|||
<!-- 查询条件组装 -->
|
||||
<if test="query!= null">
|
||||
1 = 1
|
||||
<foreach collection="query.entrySet()" item="value" index="key" >
|
||||
<foreach collection="query.entrySet()" item="value" index="key">
|
||||
<choose>
|
||||
<when test="key == 'tenant_id'">
|
||||
and tenant_id = #{value}
|
||||
|
@ -198,7 +210,8 @@
|
|||
</select>
|
||||
|
||||
<!-- 查询表字典的数据, 支持设置过滤条件和code值 精确匹配查询【已加入SQL注入check】 -->
|
||||
<select id="queryTableDictByKeysAndFilterSql" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
<select id="queryTableDictByKeysAndFilterSql" parameterType="String"
|
||||
resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table}
|
||||
where ${code} IN (
|
||||
<foreach item="key" collection="codeValues" separator=",">
|
||||
|
@ -214,12 +227,19 @@
|
|||
|
||||
<!--根据应用id获取字典列表和详情-->
|
||||
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict">
|
||||
select id,dict_name,dict_code from sys_dict
|
||||
where
|
||||
del_flag = 0
|
||||
select id, dict_name, dict_code
|
||||
from sys_dict
|
||||
where del_flag = 0
|
||||
and low_app_id = #{lowAppId}
|
||||
and tenant_id = #{tenantId}
|
||||
</select>
|
||||
<select id="existColumn" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from information_schema.columns
|
||||
where TABLE_SCHEMA = DATABASE()
|
||||
AND table_name = #{tableName}
|
||||
and column_name = #{columnName}
|
||||
</select>
|
||||
|
||||
<!-- 还原被逻辑删除的字典 -->
|
||||
<update id="revertLogicDeleted">
|
||||
|
@ -230,7 +250,7 @@
|
|||
WHERE
|
||||
del_flag = 1
|
||||
AND id IN
|
||||
<foreach collection="ids" item="dictId" open="(" close=")" separator="," >
|
||||
<foreach collection="ids" item="dictId" open="(" close=")" separator=",">
|
||||
#{dictId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
@ -241,7 +261,7 @@
|
|||
WHERE
|
||||
del_flag = 1
|
||||
AND id IN
|
||||
<foreach collection="ids" item="dictId" open="(" close=")" separator="," >
|
||||
<foreach collection="ids" item="dictId" open="(" close=")" separator=",">
|
||||
#{dictId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
|
|
@ -268,9 +268,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||
text = SqlInjectionUtil.getSqlInjectField(text);
|
||||
code = SqlInjectionUtil.getSqlInjectField(code);
|
||||
List<DictModel> dictModels = Lists.newArrayList();
|
||||
try {
|
||||
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||
if(existIzEnabled>0){
|
||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
||||
} catch (Exception e) {
|
||||
}else{
|
||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
||||
}
|
||||
return dictModels;
|
||||
|
@ -299,9 +300,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||
text = SqlInjectionUtil.getSqlInjectField(text);
|
||||
code = SqlInjectionUtil.getSqlInjectField(code);
|
||||
List<DictModel> dictModels = Lists.newArrayList();
|
||||
try {
|
||||
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||
if(existIzEnabled>0){
|
||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
||||
} catch (Exception e) {
|
||||
}else{
|
||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
||||
}
|
||||
return dictModels;
|
||||
|
@ -540,10 +542,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||
|
||||
// 3. 返回表字典数据
|
||||
IPage<DictModel> pageList = new Page<>();
|
||||
try {
|
||||
pageList = baseMapper.queryPageTableDictWithFilter(page, table, text, code, filterSql, "1");
|
||||
} catch (Exception e) {
|
||||
pageList = baseMapper.queryPageTableDictWithFilter(page, table, text, code, filterSql, null);
|
||||
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||
if(existIzEnabled>0){
|
||||
pageList = baseMapper.queryPageTableDictWithFilter(page,table, text, code, filterSql, "1");
|
||||
}else{
|
||||
pageList = baseMapper.queryPageTableDictWithFilter(page,table, text, code, filterSql, null);
|
||||
}
|
||||
return pageList.getRecords();
|
||||
}
|
||||
|
@ -637,9 +640,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||
text = SqlInjectionUtil.getSqlInjectField(text);
|
||||
code = SqlInjectionUtil.getSqlInjectField(code);
|
||||
List<DictModel> ls = Lists.newArrayList();
|
||||
try {
|
||||
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||
if(existIzEnabled>0){
|
||||
ls = baseMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
||||
} catch (Exception e) {
|
||||
}else{
|
||||
ls = baseMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
||||
}
|
||||
return ls;
|
||||
|
|
Loading…
Reference in New Issue