This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/java/com/nis/web/dao/basics/CommonGroupManageDao.xml
2019-06-14 17:12:41 +08:00

226 lines
7.4 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nis.web.dao.basics.CommonGroupManageDao" >
<resultMap id="CommonGroupInfoMap" type="com.nis.domain.basics.CommonGroupInfo" >
<id column="group_id" property="groupId" jdbcType="INTEGER" />
<result column="group_name" property="groupName" jdbcType="VARCHAR" />
<result column="group_type" property="groupType" 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" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="service_group_id" property="serviceGroupId" jdbcType="INTEGER" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="ud_flag" property="udFlag" jdbcType="INTEGER" />
</resultMap>
<sql id="CommonGroupInfoColumns">
r.group_id,r.group_name,r.group_type,r.is_valid,r.create_time,r.edit_time,
r.creator_id,r.editor_id,r.service_group_id,r.description, ud_flag
</sql>
<!-- 查出所有 有效数据-->
<select id="findCommonGroupInfoList" resultMap="CommonGroupInfoMap">
SELECT
<include refid="CommonGroupInfoColumns"/>
<trim prefix="," prefixOverrides=",">
, s.name as creator_name
,e.name as editor_name
</trim>
FROM policy_group_info r
left join sys_user s on r.creator_id=s.id
left join sys_user e on r.editor_id=e.id
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="groupName != null and groupName != ''">
AND r.group_name like concat(concat('%',#{groupName,jdbcType=VARCHAR}),'%')
</if>
<if test="groupType != null">
AND r.group_type =#{groupType }
</if>
<if test="groupType == null">
AND r.group_type IN(5,7,8,9)
</if>
AND r.IS_VALID =1
<if test="creatorName != null and creatorName != ''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editorName != null and editorName != ''">
AND r.EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<!-- 数据范围过滤 -->
<!-- ${sqlMap.dsf} -->
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY r.group_id desc
</otherwise>
</choose>
</select>
<select id="getById" resultType="com.nis.domain.basics.CommonGroupInfo">
SELECT
<include refid="CommonGroupInfoColumns"/>
FROM
policy_group_info r
WHERE
r.group_id = #{groupId}
</select>
<insert id="insert" parameterType="com.nis.domain.basics.CommonGroupInfo" >
INSERT INTO policy_group_info(
IS_VALID,
CREATOR_ID,
CREATE_TIME,
GROUP_NAME,
GROUP_TYPE,
SERVICE_GROUP_ID,
DESCRIPTION
)values (
1,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{groupName,jdbcType=VARCHAR},
#{groupType,jdbcType=INTEGER},
#{serviceGroupId,jdbcType=INTEGER},
#{description,jdbcType=VARCHAR}
)
</insert>
<insert id="insertBatch">
INSERT INTO policy_group_info(
IS_VALID,
CREATOR_ID,
CREATE_TIME,
GROUP_NAME,
GROUP_TYPE,
SERVICE_GROUP_ID,
DESCRIPTION
)values
<foreach collection ="list" item="info" separator =",">
(
1,
#{info.creatorId,jdbcType=INTEGER},
#{info.createTime,jdbcType=TIMESTAMP},
#{info.groupName,jdbcType=VARCHAR},
#{info.groupType,jdbcType=INTEGER},
#{info.serviceGroupId,jdbcType=INTEGER},
#{info.description,jdbcType=VARCHAR}
)
</foreach>
</insert>
<update id="update" parameterType="com.nis.domain.basics.CommonGroupInfo" >
UPDATE policy_group_info
<set>
<trim suffixOverrides=",">
<if test="groupName != null and groupName != ''" >
group_name = #{groupName,jdbcType=VARCHAR},
</if>
<if test="groupType != null" >
group_type = #{groupType,jdbcType=INTEGER},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
<if test="editTime != null and editTime != ''" >
edit_time = #{editTime,jdbcType=TIMESTAMP},
</if>
</trim>
</set>
<where>
<if test="groupId != null" >
and group_id = #{groupId,jdbcType=INTEGER}
</if>
<if test="serviceGroupId != null" >
and service_group_id = #{serviceGroupId,jdbcType=INTEGER}
</if>
</where>
</update>
<select id="findCommonGroupInfosByType" resultMap="CommonGroupInfoMap">
SELECT
<include refid="CommonGroupInfoColumns"/>
FROM
policy_group_info r
WHERE
r.is_valid=1 and r.group_type=#{groupType,jdbcType=INTEGER}
</select>
<select id="findGroupInfoList" resultMap="CommonGroupInfoMap">
SELECT
<include refid="CommonGroupInfoColumns"/>
<trim prefix="," prefixOverrides=",">
, s.name as creator_name
,e.name as editor_name
</trim>
FROM
policy_group_info r
left join sys_user s on r.creator_id=s.id
left join sys_user e on r.editor_id=e.id
WHERE
r.group_id IN (${ids})
</select>
<update id="updateGroupStatus">
UPDATE
policy_group_info
SET
ud_flag = #{udFlag,jdbcType=INTEGER}
WHERE
service_group_id IN (${serviceGroupId}) AND group_type = #{groupType}
</update>
<select id="getGroupInfo" resultType="com.nis.domain.basics.CommonGroupInfo">
SELECT
<include refid="CommonGroupInfoColumns"/>
FROM
policy_group_info r
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="groupName != null and groupName != ''" >
AND group_name = #{groupName,jdbcType=VARCHAR}
</if>
<if test="groupType != null" >
AND group_type = #{groupType,jdbcType=INTEGER}
</if>
<if test="serviceGroupId != null" >
AND service_group_id = #{serviceGroupId,jdbcType=INTEGER}
</if>
<if test="isValid != null" >
AND is_valid = #{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null" >
AND is_valid != 0
</if>
</trim>
</select>
<select id="getCompileIdByGroupId" resultType="java.lang.Integer">
SELECT
compile_id
FROM
cfg_index_info
WHERE
common_group_ids LIKE concat(concat('%',#{groupId,jdbcType=VARCHAR}),'%') AND is_valid != -1
</select>
<select id="ajaxCheckIsLastOneCfg" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
${tableName} r
WHERE
r.group_id = #{groupId} AND r.cfg_id NOT IN(${cfgIds})
</select>
</mapper>