已完成:

①字典列表,配置编码移到配置内容前一列
    ②系统字典与业务字典的item_code字段int类型改为varchar(64)
    ③业务字典和系统字典表增加一个字段,level_no,层级(新增、修改已加入)
    ④完成条件分页查询(折叠逻辑与无条件查询一致,)
    ⑤优化分页查询代码(预留介入条件排序),
  
  待完善:修改、删除时下层级递归处理待添加事务性及测试(待手动抛异常重点测试)
                      生效范围测试尚未完毕,待处理
         jquery Validate验证层级关系受<sys:treeselect>影响,待处理
                      样式调整:分页样式(尚未调整),
This commit is contained in:
zhangshilin
2018-03-08 20:30:01 +08:00
parent fb383e8cf1
commit 67645d21ca
15 changed files with 717 additions and 185 deletions

View File

@@ -39,17 +39,29 @@ public interface ServiceDictInfoDao extends CrudDao<ServiceDictInfo> {
*/
List<ServiceDictInfo> getDictByParentId(Integer parentId);
/**
* 查询字典列表(含条件查询(==)
* 查询条件查询顶层字典列表(含条件查询(==)
* @param serviceDictInfo
* @return
*/
List<ServiceDictInfo> findDictSearchList(ServiceDictInfo serviceDictInfo);
List<ServiceDictInfo> findDictTopSearchList(ServiceDictInfo serviceDictInfo);
/**
* 查询字典列表(含条件查询(!=)
* 查询条件查询顶层字典列表(含条件查询(!=)
* @param serviceDictInfo
* @return
*/
List<ServiceDictInfo> findDictSearchListN(ServiceDictInfo serviceDictInfo);
List<ServiceDictInfo> findDictTopSearchListN(ServiceDictInfo serviceDictInfo);
/**
* 查询条件查询所有字典列表(含条件查询(==)
* @param serviceDictInfo
* @return
*/
List<ServiceDictInfo> findAllDictSearchList(ServiceDictInfo serviceDictInfo);
/**
* 查询条件查询所有字典列表(含条件查询(!=)
* @param serviceDictInfo
* @return
*/
List<ServiceDictInfo> findAllDictSearchListN(ServiceDictInfo serviceDictInfo);
/**
@@ -57,6 +69,11 @@ public interface ServiceDictInfoDao extends CrudDao<ServiceDictInfo> {
* @param serviceDictInfo
*/
void insertDict(ServiceDictInfo serviceDictInfo);
/**
* 保存层级
* @param serviceDictInfo
*/
void updateLevelNo(ServiceDictInfo serviceDictInfo);
/**
* 根据主键查询字典详细信息
@@ -69,7 +86,7 @@ public interface ServiceDictInfoDao extends CrudDao<ServiceDictInfo> {
* @param itemCode
* @return
*/
List<ServiceDictInfo> findByItemCode(Integer itemCode);
List<ServiceDictInfo> findByItemCode(String itemCode);
/**
* 查询itemCode最大值
* @return

View File

@@ -5,10 +5,11 @@
<resultMap id="dictResultMap" type="com.nis.domain.basics.ServiceDictInfo" >
<id column="service_dict_id" property="serviceDictId" jdbcType="INTEGER" />
<result column="item_type" property="itemType" jdbcType="INTEGER" />
<result column="item_code" property="itemCode" jdbcType="INTEGER" />
<result column="item_code" property="itemCode" jdbcType="VARCHAR" />
<result column="item_value" property="itemValue" jdbcType="VARCHAR" />
<result column="item_desc" property="itemDesc" jdbcType="VARCHAR" />
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
<result column="level_no" property="levelNo" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
@@ -46,6 +47,7 @@
s.item_desc AS itemDesc,
s.parent_id AS "parent.serviceDictId",
s.is_leaf AS isLeaf,
s.level_no AS levelNo,
s.is_valid AS isValid,
s.creator_id AS "serviceDictCreator.id",
s.create_time AS createTime,
@@ -137,7 +139,7 @@
<include refid="serviceDictInfoColumns"/>
FROM service_dict_info s
<include refid="menuJoins"/>
WHERE s.is_valid =1
WHERE s.is_valid =1 AND s.parent_id != 0
</select>
<!-- 查询所有非叶子配置 -->
@@ -146,72 +148,151 @@
<include refid="serviceDictInfoColumns"/>
FROM service_dict_info s
WHERE s.is_valid = 1 AND s.is_leaf = 0 AND item_type = #{itemType}
ORDER BY s.create_time desc
</select>
<!-- 条件查询分页(==) -->
<select id="findDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
SELECT * FROM service_dict_info WHERE is_valid=1
<if test="itemType != null and itemType != '' " >
AND item_type like '%${itemType}%'
</if>
<if test="itemCode != null and itemCode != '' " >
AND item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND item_value like '%${itemValue}%'
</if>
<if test="beginDate !=null" >
AND create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY create_time desc
</otherwise>
</choose>
</select>
<!-- 条件查询分页(!=) -->
<select id="findDictSearchListN" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
SELECT * FROM service_dict_info WHERE is_valid=1
<!-- 条件查询顶层分页(==) -->
<select id="findDictTopSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
SELECT * FROM service_dict_info s WHERE s.is_valid=1
<if test="itemCode != null and itemCode != '' " >
AND item_code like '%${itemCode}%'
AND s.item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND item_value like '%${itemValue}%'
AND s.item_value like '%${itemValue}%'
</if>
<if test="itemType != null and itemType != '' " >
AND item_type != ${itemType}
AND s.item_type = ${itemType}
</if>
<if test="beginDate !=null" >
AND s.create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND s.create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
AND s.parent_id not in (
SELECT s2.service_dict_id FROM service_dict_info s2 WHERE s2.is_valid=1
<if test="itemCode != null and itemCode != '' " >
AND s2.item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND s2.item_value like '%${itemValue}%'
</if>
<if test="itemType != null and itemType != '' " >
AND s2.item_type = ${itemType}
</if>
<if test="beginDate !=null" >
AND s2.create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND s2.create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
)
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY s.${page.orderBy}
</when>
<otherwise>
ORDER BY s.create_time desc
</otherwise>
</choose>
</select>
<!-- 条件查询顶层分页(!=) -->
<select id="findDictTopSearchListN" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
SELECT * FROM service_dict_info s WHERE s.is_valid=1
<if test="itemCode != null and itemCode != '' " >
AND s.item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND s.item_value like '%${itemValue}%'
</if>
<if test="itemType != null and itemType != '' " >
AND s.item_type != ${itemType}
</if>
<if test="beginDate !=null" >
AND s.create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND s.create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
AND s.parent_id not in (
SELECT s2.service_dict_id FROM service_dict_info s2 WHERE s2.is_valid=1
<if test="itemCode != null and itemCode != '' " >
AND s2.item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND s2.item_value like '%${itemValue}%'
</if>
<if test="itemType != null and itemType != '' " >
AND s2.item_type != ${itemType}
</if>
<if test="beginDate !=null" >
AND s2.create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND s2.create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
)
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY s.${page.orderBy}
</when>
<otherwise>
ORDER BY s.create_time desc
</otherwise>
</choose>
</select>
<!-- 条件查询所有列表 (==)-->
<select id="findAllDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
SELECT * FROM service_dict_info WHERE is_valid=1
<if test="itemValue != null and itemValue != '' " >
AND item_value like '%${itemValue}%'
</if>
<if test="itemCode != null and itemCode != '' " >
AND item_code like '%${itemCode}%'
</if>
<if test="itemType != null and itemType != '' " >
AND item_type = #{itemType}
</if>
<if test="beginDate !=null" >
AND create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY create_time desc
</otherwise>
</choose>
</select>
<!-- 条件查询所有列表 (!=)-->
<select id="findAllDictSearchListN" resultMap="dictResultMap" parameterType="com.nis.domain.basics.ServiceDictInfo">
SELECT * FROM service_dict_info WHERE is_valid=1
<if test="itemValue != null and itemValue != '' " >
AND item_value like '%${itemValue}%'
</if>
<if test="itemCode != null and itemCode != '' " >
AND item_code like '%${itemCode}%'
</if>
<if test="itemType != null and itemType != '' " >
AND item_type != #{itemType}
</if>
<if test="beginDate !=null" >
AND create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
</select>
<!-- 根据主键查询字典详细信息 -->
@@ -246,10 +327,10 @@
<!-- 新增字典信息 -->
<insert id="insertDict" parameterType="com.nis.domain.basics.ServiceDictInfo" useGeneratedKeys="true" keyProperty="id" >
insert into service_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf, is_valid, creator_id, create_time, editor_id, edit_time)
insert into service_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf, level_no, is_valid, creator_id, create_time, editor_id, edit_time)
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=INTEGER},
#{itemValue,jdbcType=VARCHAR}, #{itemDesc,jdbcType=VARCHAR},
#{parent.serviceDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
#{parent.serviceDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER},#{levelNo,jdbcType=VARCHAR}, #{isValid,jdbcType=INTEGER},
#{serviceDictCreator.id,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{serviceDictEditor.id,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP})
</insert>
@@ -266,11 +347,19 @@
s.item_desc = #{itemDesc},
s.parent_id = #{parent.serviceDictId},
s.is_leaf = #{isLeaf},
s.level_no = #{levelNo},
s.creator_id = #{serviceDictCreator.id},
s.editor_id = #{serviceDictEditor.id},
s.edit_time = #{editTime}
WHERE s.service_dict_id = #{serviceDictId}
</update>
<!-- 保存层级 -->
<update id="updateLevelNo">
UPDATE service_dict_info s SET
s.level_no = #{levelNo}
WHERE s.service_dict_id = #{serviceDictId}
</update>
<!-- 删除 -->
@@ -296,7 +385,5 @@
</mapper>

View File

@@ -24,13 +24,18 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
* @return
*/
List<SysDictInfo> findAllDictList(SysDictInfo sysDictInfo);
/**
* 查询字典列表(含条件查询(==)
* 查询条件查询顶层字典列表(含条件查询(==)
* @param sysDictInfo
* @return
*/
List<SysDictInfo> findDictSearchList(SysDictInfo sysDictInfo);
List<SysDictInfo> findDictTopSearchList(SysDictInfo sysDictInfo);
/**
* 查询字典列表(含条件查询(==)
* @param sysDictInfo
* @return
*/
List<SysDictInfo> findAllDictSearchList(SysDictInfo sysDictInfo);
@@ -60,7 +65,7 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
* @param itemCode
* @return
*/
List<SysDictInfo> findByItemCode(Integer itemCode);
List<SysDictInfo> findByItemCode(String itemCode);
/**
* 根据上级id选出所有下级
@@ -74,6 +79,11 @@ public interface SysDictInfoDao extends CrudDao<SysDictInfo> {
* @return
*/
Integer findMaxItemCode();
/**
* 保存层级
* @param sysDictInfo
*/
void updateLevelNo(SysDictInfo sysDictInfo);

View File

@@ -5,10 +5,11 @@
<resultMap id="dictResultMap" type="com.nis.domain.basics.SysDictInfo" >
<id column="sys_dict_id" property="sysDictId" jdbcType="INTEGER" />
<result column="item_type" property="itemType" jdbcType="INTEGER" />
<result column="item_code" property="itemCode" jdbcType="INTEGER" />
<result column="item_code" property="itemCode" jdbcType="VARCHAR" />
<result column="item_value" property="itemValue" jdbcType="VARCHAR" />
<result column="item_desc" property="itemDesc" jdbcType="VARCHAR" />
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
<result column="level_no" property="levelNo" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
@@ -37,6 +38,7 @@
s.item_desc AS itemDesc,
s.parent_id AS "parent.sysDictId",
s.is_leaf AS isLeaf,
s.level_no AS levelNo,
s.is_valid AS isValid,
s.creator_id AS "sysDictCreator.id",
s.create_time AS createTime,
@@ -88,12 +90,60 @@
WHERE s.is_valid =1
</select>
<!-- 条件查询分页(==) -->
<select id="findDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
<!-- 条件查询顶层分页(==) -->
<select id="findDictTopSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
SELECT * FROM sys_dict_info s WHERE s.is_valid=1
<if test="itemCode != null and itemCode != '' " >
AND s.item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND s.item_value like '%${itemValue}%'
</if>
<if test="itemType != null and itemType != '' " >
AND s.item_type = ${itemType}
</if>
<if test="beginDate !=null" >
AND s.create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND s.create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
AND s.parent_id not in (
SELECT s2.sys_dict_id FROM sys_dict_info s2 WHERE s2.is_valid=1
<if test="itemCode != null and itemCode != '' " >
AND s2.item_code like '%${itemCode}%'
</if>
<if test="itemValue!= null and itemValue != '' " >
AND s2.item_value like '%${itemValue}%'
</if>
<if test="itemType != null and itemType != '' " >
AND s2.item_type = ${itemType}
</if>
<if test="beginDate !=null" >
AND s2.create_time &gt;= #{beginDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate !=null" >
AND s2.create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
)
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY s.${page.orderBy}
</when>
<otherwise>
ORDER BY s.create_time desc
</otherwise>
</choose>
</select>
<!-- 条件查询所有(==) -->
<select id="findAllDictSearchList" resultMap="dictResultMap" parameterType="com.nis.domain.basics.SysDictInfo">
SELECT * FROM sys_dict_info WHERE is_valid=1
<if test="itemType != null and itemType != '' " >
AND item_type like '%${itemType}%'
AND item_type = ${itemType}
</if>
<if test="itemCode != null and itemCode != '' " >
AND item_code like '%${itemCode}%'
@@ -106,18 +156,7 @@
</if>
<if test="endDate !=null" >
AND create_time &lt;= DATE_ADD(#{endDate,jdbcType=TIMESTAMP},INTERVAL 1 DAY)
</if>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY create_time desc
</otherwise>
</choose>
</select>
<!-- 根据主键查询字典详细信息 -->
@@ -131,10 +170,10 @@
<!-- 新增字典信息 -->
<insert id="insertDict" parameterType="com.nis.domain.basics.SysDictInfo" useGeneratedKeys="true" keyProperty="id" >
insert into sys_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf, is_valid, creator_id, create_time, editor_id, edit_time)
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=INTEGER},
insert into sys_dict_info (item_type, item_code, item_value, item_desc, parent_id, is_leaf,level_no, is_valid, creator_id, create_time, editor_id, edit_time)
values ( #{itemType,jdbcType=INTEGER}, #{itemCode,jdbcType=VARCHAR},
#{itemValue,jdbcType=VARCHAR}, #{itemDesc,jdbcType=VARCHAR},
#{parent.sysDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
#{parent.sysDictId,jdbcType=INTEGER}, #{isLeaf,jdbcType=INTEGER}, #{levelNo,jdbcType=INTEGER}, #{isValid,jdbcType=INTEGER},
#{sysDictCreator.id,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{sysDictEditor.id,jdbcType=INTEGER}, #{editTime,jdbcType=TIMESTAMP})
</insert>
@@ -159,6 +198,7 @@
s.item_desc = #{itemDesc},
s.parent_id = #{parent.sysDictId},
s.is_leaf = #{isLeaf},
s.level_no = #{levelNo},
s.creator_id = #{sysDictCreator.id},
s.editor_id = #{sysDictEditor.id},
s.edit_time = #{editTime}
@@ -191,5 +231,12 @@
<select id="findMaxItemCode" resultType="java.lang.Integer">
select max(s.item_code) from sys_dict_info s
</select>
<!-- 保存层级 -->
<update id="updateLevelNo">
UPDATE sys_dict_info s SET
s.level_no = #{levelNo}
WHERE s.sys_dict_id = #{sysDictId}
</update>
</mapper>