140 lines
3.1 KiB
XML
140 lines
3.1 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.suisung.mall.im.mapper.LayGroupUserMapper">
|
|
|
|
<sql id="layGroupUserColumns">
|
|
a.id,
|
|
a.create_by,
|
|
a.create_date,
|
|
a.update_by,
|
|
a.update_date,
|
|
a.remarks,
|
|
a.del_flag,
|
|
a.user_id,
|
|
a.group_id
|
|
</sql>
|
|
|
|
<sql id="layGroupUserJoins">
|
|
LEFT JOIN t_group b ON b.id = a.group_id
|
|
</sql>
|
|
|
|
|
|
<select id="get" resultType="com.suisung.mall.im.pojo.entity.LayGroupUser" >
|
|
SELECT
|
|
<include refid="layGroupUserColumns"/>
|
|
FROM group_user a
|
|
<include refid="layGroupUserJoins"/>
|
|
WHERE a.id = #{id}
|
|
</select>
|
|
|
|
<select id="findList" resultType="com.suisung.mall.im.pojo.entity.LayGroupUser" >
|
|
SELECT
|
|
<include refid="layGroupUserColumns"/>
|
|
FROM group_user a
|
|
<include refid="layGroupUserJoins"/>
|
|
<where>
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
<if test="user_id != null and user_id != ''">
|
|
AND a.user_id = #{user_id}
|
|
</if>
|
|
<if test="group_id != null and group_id != ''">
|
|
AND a.group_id = #{group_id}
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.create_date ASC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="findAllList" resultType="com.suisung.mall.im.pojo.entity.LayGroupUser" >
|
|
SELECT
|
|
<include refid="layGroupUserColumns"/>
|
|
FROM group_user a
|
|
<include refid="layGroupUserJoins"/>
|
|
<where>
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
</where>
|
|
<choose>
|
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
ORDER BY ${page.orderBy}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY a.create_date ASC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<insert id="insertNew">
|
|
INSERT INTO group_user(
|
|
id,
|
|
create_by,
|
|
create_date,
|
|
update_by,
|
|
update_date,
|
|
remarks,
|
|
del_flag,
|
|
user_id,
|
|
group_id
|
|
) VALUES (
|
|
#{id},
|
|
#{create_by},
|
|
now(),
|
|
#{update_by},
|
|
now(),
|
|
#{remarks},
|
|
#{del_flag},
|
|
#{user_id},
|
|
#{group_id}
|
|
)
|
|
</insert>
|
|
|
|
<update id="update">
|
|
UPDATE group_user SET
|
|
update_by = #{update_by},
|
|
update_date = now(),
|
|
remarks = #{remarks},
|
|
user_id = #{user_id},
|
|
group_id = #{group_id}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
|
|
<!--物理删除-->
|
|
<update id="delete">
|
|
DELETE FROM group_user
|
|
<choose>
|
|
<when test="id !=null and id != ''">
|
|
WHERE id = #{id}
|
|
</when>
|
|
<otherwise>
|
|
WHERE group_id = #{group_id}
|
|
</otherwise>
|
|
</choose>
|
|
</update>
|
|
|
|
<!--逻辑删除-->
|
|
<update id="deleteByLogic">
|
|
UPDATE group_user SET
|
|
del_flag = #{DEL_FLAG_DELETE}
|
|
<choose>
|
|
<when test="id !=null and id != ''">
|
|
WHERE id = #{id}
|
|
</when>
|
|
<otherwise>
|
|
WHERE group_id = #{group_id}
|
|
</otherwise>
|
|
</choose>
|
|
</update>
|
|
|
|
|
|
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
|
|
<select id="findUniqueByProperty" resultType="com.suisung.mall.im.pojo.entity.LayGroupUser" statementType="STATEMENT">
|
|
select * FROM group_user where ${propertyName} = '${value}'
|
|
</select>
|
|
|
|
</mapper> |