wl_management/src/main/resources/mapper/performance/IndicatorLibraryMapper.xml
DirectionOfMind c74d643f2f fix
2021-01-20 16:38:16 +08:00

151 lines
5.6 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.lz.modules.performance.dao.IndicatorLibraryMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.lz.modules.performance.entity.IndicatorLibrary">
<id column="id" property="id"/>
<result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="name" property="name"/>
<result column="type" property="type"/>
<result column="indicator_type" property="indicatorType"/>
<result column="weight" property="weight"/>
<result column="key_result" property="keyResult"/>
<result column="sort" property="sort"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, name AS name, type AS type, indicator_type AS indicatorType, weight AS weight, key_result AS keyResult, sort AS sort
</sql>
<select id="selectIndicatorLibraryById" resultType="IndicatorLibrary" >
select * from lz_indicator_library where id=#{id} and is_delete = 0 limit 1
</select>
<insert id="insertIndicatorLibrary" parameterType="IndicatorLibrary" useGeneratedKeys="true" keyProperty="id" >
insert into lz_indicator_library(
<if test="name != null">name, </if>
<if test="type != null">type, </if>
<if test="indicatorType != null">indicator_type, </if>
<if test="weight != null">weight, </if>
<if test="keyResult != null">key_result, </if>
<if test="sort != null">sort, </if>
is_delete,
gmt_create,
gmt_modified
)values(
<if test="name != null">#{ name}, </if>
<if test="type != null">#{ type}, </if>
<if test="indicatorType != null">#{ indicatorType}, </if>
<if test="weight != null">#{ weight}, </if>
<if test="keyResult != null">#{ keyResult}, </if>
<if test="sort != null">#{ sort}, </if>
0,
now(),
now()
)
</insert>
<update id="updateIndicatorLibraryById" parameterType="IndicatorLibrary" >
update
lz_indicator_library
<trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
<if test="indicatorType != null">indicator_type = #{indicatorType},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="keyResult != null">key_result = #{keyResult},</if>
<if test="sort != null">sort = #{sort}</if>
</trim>
,gmt_modified = now()
where id = #{id}
</update>
<update id="updateCoverIndicatorLibraryById" parameterType="IndicatorLibrary" >
update
lz_indicator_library
set
is_delete = #{isDelete},
gmt_create = #{gmtCreate},
name = #{name},
type = #{type},
indicator_type = #{indicatorType},
weight = #{weight},
key_result = #{keyResult},
sort = #{sort}
,gmt_modified = now()
where id = #{id}
</update>
<update id="deleteIndicatorLibraryById" parameterType="java.lang.Long">
update lz_indicator_library set is_delete = 1 where id=#{id} limit 1
</update>
<select id="selectIndicatorLibrarysByReq" resultType="com.lz.modules.performance.dto.IndicatorLibraryDto">
select id ,name,type,indicator_type, weight, key_result, sort from lz_indicator_library
where is_delete = 0
<if test="req.name!=null and req.name!=''">
and name LIKE CONCAT('%',#{req.name},'%')
</if>
<if test="req.indicatorType!=null">
and indicator_type = #{req.indicatorType}
</if>
order by sort
</select>
<update id="deleteIndicatorLibrarysByIds">
update lz_indicator_library set is_delete = 1 where is_delete = 0 AND
id in
(
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</update>
<update id="updateIndicatorLibrarysMove">
update lz_indicator_library set indicator_type = #{indicatorType} where is_delete = 0 AND
id in
(
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</update>
<select id="statisticalByIndicatorType"
resultType="com.lz.modules.performance.dto.StatisticalIndicatorTypeDto">
SELECT t.id indicatorType,t.name,IFNULL(l.count,0) count from lz_indicator_type t
LEFT JOIN (SELECT name,indicator_type,count(indicator_type) count from lz_indicator_library where is_delete = 0
<if test="indicatorType!=null">
and l.indicator_type=#{indicatorType}
</if>
GROUP BY indicator_type) l
on t.is_delete = 0 and t.id = l.indicator_type
</select>
<update id="deleteIndicatorLibrarysByIndicatorType" parameterType="java.lang.Integer">
update lz_indicator_library set is_delete = 1 where indicator_type=#{indicatorType}
</update>
<select id="countIndicatorLibrarysByIndicatorType" resultType="java.lang.Integer">
select COUNT(1) from lz_indicator_library where indicator_type=#{indicatorType} and is_delete = 0
</select>
</mapper>