Compare commits
2 Commits
5d87ae1bb9
...
d38a2a0a9f
Author | SHA1 | Date |
---|---|---|
|
d38a2a0a9f | |
|
d8c24ee1a9 |
|
@ -1,11 +1,11 @@
|
||||||
package com.nu.modules.utils;
|
package com.nu.modules.utils;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||||
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
||||||
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
||||||
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
||||||
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PinyinUtils {
|
public class PinyinUtils {
|
||||||
|
|
|
@ -214,4 +214,6 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int removeLogicDeleted(@Param("ids")List<String> ids);
|
int removeLogicDeleted(@Param("ids")List<String> ids);
|
||||||
|
|
||||||
|
int existColumn(@Param("tableName") String tableName, @Param("columnName") String columnName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,24 @@
|
||||||
|
|
||||||
<!-- 通过字典code获取字典数据 -->
|
<!-- 通过字典code获取字典数据 -->
|
||||||
<select id="queryDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
<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})
|
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||||
order by s.sort_order asc, s.create_time DESC;
|
order by s.sort_order asc, s.create_time DESC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 通过字典code获取有效的字典数据项 -->
|
<!-- 通过字典code获取有效的字典数据项 -->
|
||||||
<select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
<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})
|
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||||
and s.status = 1
|
and s.status = 1
|
||||||
order by s.sort_order asc, s.create_time DESC;
|
order by s.sort_order asc, s.create_time DESC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 通过多个字典code获取字典数据 -->
|
<!-- 通过多个字典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
|
SELECT
|
||||||
dict.dict_code,
|
dict.dict_code,
|
||||||
item.item_text AS "text",
|
item.item_text AS "text",
|
||||||
|
@ -37,7 +40,8 @@
|
||||||
|
|
||||||
<!-- 通过字典code获取字典数据 -->
|
<!-- 通过字典code获取字典数据 -->
|
||||||
<select id="queryDictTextByKey" parameterType="String" resultType="String">
|
<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})
|
where s.dict_id = (select id from sys_dict where dict_code = #{code})
|
||||||
and s.item_value = #{key}
|
and s.item_value = #{key}
|
||||||
</select>
|
</select>
|
||||||
|
@ -88,12 +92,16 @@
|
||||||
|
|
||||||
<!-- 查询部门信息 作为字典数据 -->
|
<!-- 查询部门信息 作为字典数据 -->
|
||||||
<select id="queryAllDepartBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
|
<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>
|
||||||
|
|
||||||
<!-- 查询用户信息 作为字典数据 -->
|
<!-- 查询用户信息 作为字典数据 -->
|
||||||
<select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
|
<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>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,13 +109,17 @@
|
||||||
|
|
||||||
<!-- 重复校验 sql语句【已加入SQL注入check】 -->
|
<!-- 重复校验 sql语句【已加入SQL注入check】 -->
|
||||||
<sql id="checkDuplicateCountSqlFragment">
|
<sql id="checkDuplicateCountSqlFragment">
|
||||||
SELECT COUNT(1) FROM ${tableName} WHERE ${fieldName} = #{fieldVal}
|
SELECT COUNT(1)
|
||||||
|
FROM ${tableName}
|
||||||
|
WHERE ${fieldName} = #{fieldVal}
|
||||||
</sql>
|
</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>
|
<include refid="checkDuplicateCountSqlFragment"></include>
|
||||||
AND id <> #{dataId}
|
AND id <> #{dataId}
|
||||||
</select>
|
</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>
|
<include refid="checkDuplicateCountSqlFragment"></include>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -142,7 +154,7 @@
|
||||||
<!-- 查询条件组装 -->
|
<!-- 查询条件组装 -->
|
||||||
<if test="query!= null">
|
<if test="query!= null">
|
||||||
1 = 1
|
1 = 1
|
||||||
<foreach collection="query.entrySet()" item="value" index="key" >
|
<foreach collection="query.entrySet()" item="value" index="key">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="key == 'tenant_id'">
|
<when test="key == 'tenant_id'">
|
||||||
and tenant_id = #{value}
|
and tenant_id = #{value}
|
||||||
|
@ -198,7 +210,8 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询表字典的数据, 支持设置过滤条件和code值 精确匹配查询【已加入SQL注入check】 -->
|
<!-- 查询表字典的数据, 支持设置过滤条件和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}
|
select ${text} as "text", ${code} as "value" from ${table}
|
||||||
where ${code} IN (
|
where ${code} IN (
|
||||||
<foreach item="key" collection="codeValues" separator=",">
|
<foreach item="key" collection="codeValues" separator=",">
|
||||||
|
@ -214,12 +227,19 @@
|
||||||
|
|
||||||
<!--根据应用id获取字典列表和详情-->
|
<!--根据应用id获取字典列表和详情-->
|
||||||
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict">
|
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict">
|
||||||
select id,dict_name,dict_code from sys_dict
|
select id, dict_name, dict_code
|
||||||
where
|
from sys_dict
|
||||||
del_flag = 0
|
where del_flag = 0
|
||||||
and low_app_id = #{lowAppId}
|
and low_app_id = #{lowAppId}
|
||||||
and tenant_id = #{tenantId}
|
and tenant_id = #{tenantId}
|
||||||
</select>
|
</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">
|
<update id="revertLogicDeleted">
|
||||||
|
@ -230,7 +250,7 @@
|
||||||
WHERE
|
WHERE
|
||||||
del_flag = 1
|
del_flag = 1
|
||||||
AND id IN
|
AND id IN
|
||||||
<foreach collection="ids" item="dictId" open="(" close=")" separator="," >
|
<foreach collection="ids" item="dictId" open="(" close=")" separator=",">
|
||||||
#{dictId}
|
#{dictId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
@ -241,7 +261,7 @@
|
||||||
WHERE
|
WHERE
|
||||||
del_flag = 1
|
del_flag = 1
|
||||||
AND id IN
|
AND id IN
|
||||||
<foreach collection="ids" item="dictId" open="(" close=")" separator="," >
|
<foreach collection="ids" item="dictId" open="(" close=")" separator=",">
|
||||||
#{dictId}
|
#{dictId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
|
@ -268,9 +268,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||||
text = SqlInjectionUtil.getSqlInjectField(text);
|
text = SqlInjectionUtil.getSqlInjectField(text);
|
||||||
code = SqlInjectionUtil.getSqlInjectField(code);
|
code = SqlInjectionUtil.getSqlInjectField(code);
|
||||||
List<DictModel> dictModels = Lists.newArrayList();
|
List<DictModel> dictModels = Lists.newArrayList();
|
||||||
try {
|
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||||
|
if(existIzEnabled>0){
|
||||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
||||||
} catch (Exception e) {
|
}else{
|
||||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
||||||
}
|
}
|
||||||
return dictModels;
|
return dictModels;
|
||||||
|
@ -299,9 +300,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||||
text = SqlInjectionUtil.getSqlInjectField(text);
|
text = SqlInjectionUtil.getSqlInjectField(text);
|
||||||
code = SqlInjectionUtil.getSqlInjectField(code);
|
code = SqlInjectionUtil.getSqlInjectField(code);
|
||||||
List<DictModel> dictModels = Lists.newArrayList();
|
List<DictModel> dictModels = Lists.newArrayList();
|
||||||
try {
|
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||||
|
if(existIzEnabled>0){
|
||||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
||||||
} catch (Exception e) {
|
}else{
|
||||||
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
dictModels = sysDictMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
||||||
}
|
}
|
||||||
return dictModels;
|
return dictModels;
|
||||||
|
@ -540,10 +542,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||||
|
|
||||||
// 3. 返回表字典数据
|
// 3. 返回表字典数据
|
||||||
IPage<DictModel> pageList = new Page<>();
|
IPage<DictModel> pageList = new Page<>();
|
||||||
try {
|
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||||
pageList = baseMapper.queryPageTableDictWithFilter(page, table, text, code, filterSql, "1");
|
if(existIzEnabled>0){
|
||||||
} catch (Exception e) {
|
pageList = baseMapper.queryPageTableDictWithFilter(page,table, text, code, filterSql, "1");
|
||||||
pageList = baseMapper.queryPageTableDictWithFilter(page, table, text, code, filterSql, null);
|
}else{
|
||||||
|
pageList = baseMapper.queryPageTableDictWithFilter(page,table, text, code, filterSql, null);
|
||||||
}
|
}
|
||||||
return pageList.getRecords();
|
return pageList.getRecords();
|
||||||
}
|
}
|
||||||
|
@ -637,9 +640,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||||
text = SqlInjectionUtil.getSqlInjectField(text);
|
text = SqlInjectionUtil.getSqlInjectField(text);
|
||||||
code = SqlInjectionUtil.getSqlInjectField(code);
|
code = SqlInjectionUtil.getSqlInjectField(code);
|
||||||
List<DictModel> ls = Lists.newArrayList();
|
List<DictModel> ls = Lists.newArrayList();
|
||||||
try {
|
int existIzEnabled = sysDictMapper.existColumn(table, "iz_enabled");
|
||||||
|
if(existIzEnabled>0){
|
||||||
ls = baseMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
ls = baseMapper.queryTableDictWithFilter(table, text, code, filterSql, "1");
|
||||||
} catch (Exception e) {
|
}else{
|
||||||
ls = baseMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
ls = baseMapper.queryTableDictWithFilter(table, text, code, filterSql, null);
|
||||||
}
|
}
|
||||||
return ls;
|
return ls;
|
||||||
|
|
Loading…
Reference in New Issue