eride/eride-system/src/main/resources/mapper/system/EShareKeyMapper.xml
2024-12-30 14:51:24 +08:00

149 lines
7.0 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.ruoyi.system.mapper.EShareKeyMapper">
<resultMap type="EShareKey" id="EShareKeyResult">
<result property="keyId" column="key_id" />
<result property="keyName" column="key_name" />
<result property="shareId" column="share_id" />
<result property="sharePhone" column="share_phone" />
<result property="shareUserName" column="share_user_name" />
<result property="ownerId" column="owner_id" />
<result property="ownerPhone" column="owner_phone" />
<result property="ownerName" column="owner_name" />
<result property="sn" column="sn" />
<result property="status" column="status" />
<result property="expirationTime" column="expiration_time" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectEShareKeyVo">
select k.key_id, k.key_name, k.share_id,k.share_phone, k.share_user_name, k.owner_id, k.owner_name, k.owner_phone, k.sn, k.status, k.expiration_time, k.create_time from e_share_key k
</sql>
<select id="selectEShareKeyList" parameterType="EShareKey" resultMap="EShareKeyResult">
select k.key_id, k.key_name, k.share_id, k.share_phone, k.share_user_name, k.owner_id, k.owner_name, k.owner_phone,
k.sn, k.status, k.expiration_time, k.create_time from e_share_key k
left join e_user u on u.user_id = k.share_id
left join e_user m on m.user_id = k.owner_id
where 1=1 and k.del_flag = '0'
<if test="keyName != null and keyName != ''"> and k.key_name like concat('%', #{keyName}, '%')</if>
<if test="shareUserName != null "> and k.share_user_name like concat('%', #{shareUserName}, '%')</if>
<if test="sharePhone != null "> and k.share_phone like concat('%', #{sharePhone}, '%')</if>
<if test="ownerPhone != null "> and k.owner_phone like concat('%', #{ownerPhone}, '%')</if>
<if test="ownerName != null "> and k.owner_name like concat('%', #{ownerName}, '%')</if>
<if test="sn != null and sn != ''"> and k.sn like concat('%', #{sn}, '%')</if>
<if test="status != null and status != ''"> and k.status = #{status}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by k.key_id desc
</select>
<select id="selectEShareKeyByKeyId" parameterType="Long" resultMap="EShareKeyResult">
<include refid="selectEShareKeyVo"/>
where key_id = #{keyId} and k.del_flag = '0'
</select>
<select id="selectEShareKeyListByOwnerId" parameterType="Long" resultMap="EShareKeyResult">
<include refid="selectEShareKeyVo"/>
where k.owner_id = #{ownerId} and k.status != '3' and k.del_flag = '0'
</select>
<select id="selectExpiredEShareKeyListByOwnerId" parameterType="Long" resultMap="EShareKeyResult">
<include refid="selectEShareKeyVo"/>
where k.owner_id = #{ownerId} and k.status = '3' and k.del_flag = '0'
</select>
<select id="selectEShareKeyListByShareUserId" parameterType="Long" resultMap="EShareKeyResult">
<include refid="selectEShareKeyVo"/>
where k.share_id = #{shareUserId} and k.del_flag = '0'
</select>
<select id="selectEShareSnListByShareUserId" parameterType="Long" resultMap="EShareKeyResult">
SELECT
k.sn,
k.expiration_time
FROM
e_share_key k
WHERE
k.share_id = #{shareUserId}
AND k.del_flag = '0'
AND k.status = '2'
GROUP BY
k.sn
</select>
<select id="selectExpiredShareKeyList" resultMap="EShareKeyResult">
SELECT
k.key_id
FROM
e_share_key k
WHERE
k.del_flag = '0'
AND k.STATUS != '3'
AND k.expiration_time &lt; CURDATE()
</select>
<insert id="insertEShareKey" parameterType="EShareKey" useGeneratedKeys="true" keyProperty="keyId">
insert into e_share_key
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="keyName != null">key_name,</if>
<if test="shareId != null">share_id,</if>
<if test="sharePhone != null">share_phone,</if>
<if test="shareUserName != null">share_user_name,</if>
<if test="ownerId != null">owner_id,</if>
<if test="ownerPhone != null">owner_phone,</if>
<if test="ownerName != null">owner_name,</if>
<if test="sn != null">sn,</if>
<if test="status != null">status,</if>
<if test="expirationTime != null">expiration_time,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="keyName != null">#{keyName},</if>
<if test="shareId != null">#{shareId},</if>
<if test="sharePhone != null">#{sharePhone},</if>
<if test="shareUserName != null">#{shareUserName},</if>
<if test="ownerId != null">#{ownerId},</if>
<if test="ownerPhone != null">#{ownerPhone},</if>
<if test="ownerName != null">#{ownerName},</if>
<if test="sn != null">#{sn},</if>
<if test="status != null">#{status},</if>
<if test="expirationTime != null">#{expirationTime},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateEShareKey" parameterType="EShareKey">
update e_share_key
<trim prefix="SET" suffixOverrides=",">
<if test="keyName != null">key_name = #{keyName},</if>
<if test="shareId != null">share_id = #{shareId},</if>
<if test="sharePhone != null">share_phone = #{sharePhone},</if>
<if test="shareUserName != null">share_user_name = #{shareUserName},</if>
<if test="ownerId != null">owner_id = #{ownerId},</if>
<if test="ownerPhone != null">owner_phone = #{ownerPhone},</if>
<if test="ownerName != null">owner_name = #{ownerName},</if>
<if test="sn != null">sn = #{sn},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="expirationTime != null">expiration_time = #{expirationTime},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where key_id = #{keyId}
</update>
<delete id="deleteEShareKeyByKeyId" parameterType="Long">
delete from e_share_key where key_id = #{keyId}
</delete>
<delete id="deleteEShareKeyByKeyIds" parameterType="String">
delete from e_share_key where key_id in
<foreach item="keyId" collection="array" open="(" separator="," close=")">
#{keyId}
</foreach>
</delete>
</mapper>