|
@@ -11,9 +11,10 @@
|
|
|
<result column="project_id" property="projectId" jdbcType="INTEGER"/>
|
|
<result column="project_id" property="projectId" jdbcType="INTEGER"/>
|
|
|
<result column="del_flag" property="delFlag" jdbcType="CHAR"/>
|
|
<result column="del_flag" property="delFlag" jdbcType="CHAR"/>
|
|
|
<result column="contact_id" property="contactId" jdbcType="INTEGER"/>
|
|
<result column="contact_id" property="contactId" jdbcType="INTEGER"/>
|
|
|
|
|
+ <result column="store_id" property="storeId" jdbcType="INTEGER"/>
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
|
<sql id="Base_Column_List">
|
|
|
- id, user_id, to_user_id, create_time, update_time, type, project_id, del_flag, contact_id
|
|
|
|
|
|
|
+ id, user_id, to_user_id, create_time, update_time, type, project_id, del_flag, contact_id, store_id
|
|
|
</sql>
|
|
</sql>
|
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
|
|
|
select
|
|
select
|
|
@@ -25,13 +26,14 @@
|
|
|
DELETE FROM users_session
|
|
DELETE FROM users_session
|
|
|
WHERE id = #{id,jdbcType=INTEGER}
|
|
WHERE id = #{id,jdbcType=INTEGER}
|
|
|
</delete>
|
|
</delete>
|
|
|
- <insert id="insert" parameterType="com.izouma.awesomeadmin.model.UsersSession" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
|
|
+ <insert id="insert" parameterType="com.izouma.awesomeadmin.model.UsersSession" useGeneratedKeys="true"
|
|
|
|
|
+ keyProperty="id">
|
|
|
INSERT INTO users_session (id, user_id, to_user_id,
|
|
INSERT INTO users_session (id, user_id, to_user_id,
|
|
|
create_time, update_time, type,
|
|
create_time, update_time, type,
|
|
|
- project_id, del_flag, contact_id)
|
|
|
|
|
|
|
+ project_id, del_flag, contact_id, store_id)
|
|
|
VALUES (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{toUserId,jdbcType=INTEGER},
|
|
VALUES (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{toUserId,jdbcType=INTEGER},
|
|
|
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER},
|
|
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER},
|
|
|
- #{projectId,jdbcType=INTEGER}, #{delFlag,jdbcType=CHAR}, #{contactId,jdbcType=INTEGER})
|
|
|
|
|
|
|
+ #{projectId,jdbcType=INTEGER}, #{delFlag,jdbcType=CHAR}, #{contactId,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER})
|
|
|
</insert>
|
|
</insert>
|
|
|
<insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.UsersSession" useGeneratedKeys="true"
|
|
<insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.UsersSession" useGeneratedKeys="true"
|
|
|
keyProperty="id">
|
|
keyProperty="id">
|
|
@@ -64,6 +66,9 @@
|
|
|
<if test="contactId != null">
|
|
<if test="contactId != null">
|
|
|
contact_id,
|
|
contact_id,
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <if test="storeId != null">
|
|
|
|
|
+ store_id,
|
|
|
|
|
+ </if>
|
|
|
</trim>
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="id != null">
|
|
<if test="id != null">
|
|
@@ -93,6 +98,9 @@
|
|
|
<if test="contactId != null">
|
|
<if test="contactId != null">
|
|
|
#{contactId,jdbcType=INTEGER},
|
|
#{contactId,jdbcType=INTEGER},
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <if test="storeId != null">
|
|
|
|
|
+ #{storeId,jdbcType=INTEGER},
|
|
|
|
|
+ </if>
|
|
|
</trim>
|
|
</trim>
|
|
|
</insert>
|
|
</insert>
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.UsersSession">
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.UsersSession">
|
|
@@ -119,6 +127,9 @@
|
|
|
<if test="delFlag != null">
|
|
<if test="delFlag != null">
|
|
|
del_flag = #{delFlag,jdbcType=CHAR},
|
|
del_flag = #{delFlag,jdbcType=CHAR},
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <if test="storeId != null">
|
|
|
|
|
+ store_id = #{storeId,jdbcType=INTEGER},
|
|
|
|
|
+ </if>
|
|
|
</set>
|
|
</set>
|
|
|
where id = #{id,jdbcType=INTEGER}
|
|
where id = #{id,jdbcType=INTEGER}
|
|
|
</update>
|
|
</update>
|
|
@@ -139,15 +150,13 @@
|
|
|
SET update_time = NOW()
|
|
SET update_time = NOW()
|
|
|
WHERE
|
|
WHERE
|
|
|
del_flag = 'N'
|
|
del_flag = 'N'
|
|
|
- AND (
|
|
|
|
|
- (user_id = #{userId} AND to_user_id = #{toUserId})
|
|
|
|
|
- OR (to_user_id = #{userId} AND user_id = #{toUserId})
|
|
|
|
|
- )
|
|
|
|
|
- AND project_id = #{projectId}
|
|
|
|
|
|
|
+ AND user_id = #{userId}
|
|
|
|
|
+ AND store_id = #{storeId}
|
|
|
</update>
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
|
- <select id="queryUsersSessionsByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.UsersSession">
|
|
|
|
|
|
|
+ <select id="queryUsersSessionsByPage" parameterType="java.util.Map"
|
|
|
|
|
+ resultType="com.izouma.awesomeadmin.model.UsersSession">
|
|
|
select
|
|
select
|
|
|
<include refid="Base_Column_List"/>
|
|
<include refid="Base_Column_List"/>
|
|
|
from users_session
|
|
from users_session
|
|
@@ -169,74 +178,62 @@
|
|
|
<if test="usersSession.projectId != null and !"".equals(usersSession.projectId)">
|
|
<if test="usersSession.projectId != null and !"".equals(usersSession.projectId)">
|
|
|
and project_id=#{usersSession.projectId}
|
|
and project_id=#{usersSession.projectId}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <if test="usersSession.storeId != null and !"".equals(usersSession.storeId)">
|
|
|
|
|
+ and store_id=#{usersSession.storeId}
|
|
|
|
|
+ </if>
|
|
|
</where>
|
|
</where>
|
|
|
order by update_time desc
|
|
order by update_time desc
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="queryAllUsersSession" parameterType="java.util.Map" resultMap="UsersSessionResultMap">
|
|
<select id="queryAllUsersSession" parameterType="java.util.Map" resultMap="UsersSessionResultMap">
|
|
|
|
|
+ SELECT DISTINCT
|
|
|
|
|
+ us.user_id,
|
|
|
|
|
+ us.type,
|
|
|
|
|
+ us.store_id,
|
|
|
|
|
+ MAX(us.update_time) update_time,
|
|
|
|
|
+ COUNT(chat.id) AS amount
|
|
|
|
|
+ FROM
|
|
|
|
|
+ users_session us
|
|
|
|
|
+ LEFT JOIN chat_info chat ON chat.user_id = us.user_id
|
|
|
|
|
+ AND chat.store_id = us.store_id
|
|
|
|
|
+ AND chat.type_flag = us.type
|
|
|
|
|
+ AND chat.state = 0
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ us.user_id != 1
|
|
|
|
|
+
|
|
|
|
|
+ AND us.store_id IN (
|
|
|
SELECT
|
|
SELECT
|
|
|
- tmp.id,
|
|
|
|
|
- tmp.user_id,
|
|
|
|
|
- tmp.to_user_id,
|
|
|
|
|
- tmp.create_time,
|
|
|
|
|
- tmp.update_time,
|
|
|
|
|
- tmp.type,
|
|
|
|
|
- tmp.project_id,
|
|
|
|
|
- tmp.nick_name,
|
|
|
|
|
- tmp.icon,
|
|
|
|
|
- tmp.amount,
|
|
|
|
|
- CASE WHEN ctime.time IS NULL THEN tmp.create_time ELSE MAX(ctime.time) END AS chattime
|
|
|
|
|
|
|
+ id
|
|
|
FROM
|
|
FROM
|
|
|
- (
|
|
|
|
|
- SELECT
|
|
|
|
|
- us.id,
|
|
|
|
|
- us.user_id,
|
|
|
|
|
- us.to_user_id,
|
|
|
|
|
- us.create_time,
|
|
|
|
|
- us.update_time,
|
|
|
|
|
- us.type,
|
|
|
|
|
- us.project_id,
|
|
|
|
|
- tu.nick_name,
|
|
|
|
|
- tu.icon,
|
|
|
|
|
- COUNT(chat.id) AS amount
|
|
|
|
|
- FROM
|
|
|
|
|
- users_session us
|
|
|
|
|
- LEFT JOIN user_info tu ON us.to_user_id = tu.id
|
|
|
|
|
- LEFT JOIN chat_info chat ON chat.user_id = us.to_user_id
|
|
|
|
|
- AND chat.to_user_id = us.user_id
|
|
|
|
|
- AND chat.state = 0
|
|
|
|
|
- AND CASE WHEN chat.project_id IS NULL THEN 1 ELSE chat.project_id = us.project_id END
|
|
|
|
|
- WHERE
|
|
|
|
|
- us.user_id = #{userId}
|
|
|
|
|
- AND us.type = 0
|
|
|
|
|
- AND us.del_flag = 'N'
|
|
|
|
|
- GROUP BY
|
|
|
|
|
- us.project_id,
|
|
|
|
|
- us.user_id,
|
|
|
|
|
- us.to_user_id
|
|
|
|
|
- ) tmp
|
|
|
|
|
- LEFT JOIN chat_info ctime ON (
|
|
|
|
|
- ctime.user_id = tmp.to_user_id
|
|
|
|
|
- AND ctime.to_user_id = tmp.user_id
|
|
|
|
|
- )
|
|
|
|
|
- OR (
|
|
|
|
|
- ctime.user_id = tmp.user_id
|
|
|
|
|
- AND ctime.to_user_id = tmp.to_user_id
|
|
|
|
|
- )
|
|
|
|
|
- and ctime.project_id = tmp.project_id
|
|
|
|
|
|
|
+ store_info
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ del_flag = 'N'
|
|
|
|
|
+ )
|
|
|
|
|
+ AND us.del_flag = 'N'
|
|
|
|
|
+
|
|
|
|
|
+ <if test="userId != null and !"".equals(userId)">
|
|
|
|
|
+ AND us.user_id = #{userId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="storeId != null and !"".equals(storeId)">
|
|
|
|
|
+ AND us.store_id = #{storeId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="type != null and !"".equals(type)">
|
|
|
|
|
+ AND us.type = #{type}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="beginTime != null and !"".equals(beginTime)">
|
|
|
|
|
+ <![CDATA[ and us.update_time >= #{beginTime}]]>
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="endTime != null and !"".equals(endTime)">
|
|
|
|
|
+ <![CDATA[ and us.update_time <= #{endTime}]]>
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
GROUP BY
|
|
GROUP BY
|
|
|
- tmp.id,
|
|
|
|
|
- tmp.user_id,
|
|
|
|
|
- tmp.to_user_id,
|
|
|
|
|
- tmp.create_time,
|
|
|
|
|
- tmp.update_time,
|
|
|
|
|
- tmp.type,
|
|
|
|
|
- tmp.project_id,
|
|
|
|
|
- tmp.nick_name,
|
|
|
|
|
- tmp.icon,
|
|
|
|
|
- tmp.amount
|
|
|
|
|
|
|
+ us.user_id,
|
|
|
|
|
+ us.type,
|
|
|
|
|
+ us.store_id
|
|
|
ORDER BY
|
|
ORDER BY
|
|
|
- chattime DESC
|
|
|
|
|
|
|
+ update_time DESC
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -244,45 +241,38 @@
|
|
|
|
|
|
|
|
SELECT DISTINCT
|
|
SELECT DISTINCT
|
|
|
us.user_id,
|
|
us.user_id,
|
|
|
- us.to_user_id,
|
|
|
|
|
- us.contact_id,
|
|
|
|
|
us.type,
|
|
us.type,
|
|
|
- us.project_id,
|
|
|
|
|
- tu.nick_name,
|
|
|
|
|
- tu.icon,
|
|
|
|
|
- myInfo.nick_name AS my_nick_name,
|
|
|
|
|
- myInfo.icon AS my_icon,
|
|
|
|
|
- MAX(us.update_time) update_time
|
|
|
|
|
|
|
+ us.store_id,
|
|
|
|
|
+ MAX(us.update_time) update_time,
|
|
|
|
|
+ COUNT(chat.id) AS amount
|
|
|
FROM
|
|
FROM
|
|
|
users_session us
|
|
users_session us
|
|
|
- LEFT JOIN user_info tu ON us.to_user_id = tu.id
|
|
|
|
|
- LEFT JOIN user_info myInfo ON us.user_id = myInfo.id
|
|
|
|
|
|
|
+ LEFT JOIN chat_info chat ON chat.user_id = us.user_id
|
|
|
|
|
+ AND chat.store_id = us.store_id
|
|
|
|
|
+ AND chat.type_flag = us.type
|
|
|
|
|
+ AND chat.state = 0
|
|
|
WHERE
|
|
WHERE
|
|
|
us.user_id != 1
|
|
us.user_id != 1
|
|
|
- AND us.to_user_id != 1
|
|
|
|
|
- AND us.type = 0
|
|
|
|
|
- AND us.project_id IN (
|
|
|
|
|
|
|
+
|
|
|
|
|
+ AND us.store_id IN (
|
|
|
SELECT
|
|
SELECT
|
|
|
id
|
|
id
|
|
|
FROM
|
|
FROM
|
|
|
- project_info
|
|
|
|
|
|
|
+ store_info
|
|
|
WHERE
|
|
WHERE
|
|
|
del_flag = 'N'
|
|
del_flag = 'N'
|
|
|
)
|
|
)
|
|
|
- AND us.to_user_id = us.contact_id
|
|
|
|
|
AND us.del_flag = 'N'
|
|
AND us.del_flag = 'N'
|
|
|
|
|
|
|
|
<if test="userId != null and !"".equals(userId)">
|
|
<if test="userId != null and !"".equals(userId)">
|
|
|
- AND (us.user_id = #{userId} or us.to_user_id = #{userId})
|
|
|
|
|
|
|
+ AND us.user_id = #{userId}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="projectId != null and !"".equals(projectId)">
|
|
|
|
|
- AND us.project_id = #{projectId}
|
|
|
|
|
|
|
+ <if test="storeId != null and !"".equals(storeId)">
|
|
|
|
|
+ AND us.store_id = #{storeId}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="companyId != null and !"".equals(companyId)">
|
|
|
|
|
- AND us.project_id in (select id from project_info where company_id = #{companyId})
|
|
|
|
|
|
|
+ <if test="type != null and !"".equals(type)">
|
|
|
|
|
+ AND us.type = #{type}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
<if test="beginTime != null and !"".equals(beginTime)">
|
|
<if test="beginTime != null and !"".equals(beginTime)">
|
|
|
<![CDATA[ and us.update_time >= #{beginTime}]]>
|
|
<![CDATA[ and us.update_time >= #{beginTime}]]>
|
|
|
</if>
|
|
</if>
|
|
@@ -293,21 +283,15 @@
|
|
|
|
|
|
|
|
GROUP BY
|
|
GROUP BY
|
|
|
us.user_id,
|
|
us.user_id,
|
|
|
- us.to_user_id,
|
|
|
|
|
- us.contact_id,
|
|
|
|
|
us.type,
|
|
us.type,
|
|
|
- us.project_id,
|
|
|
|
|
- tu.nick_name,
|
|
|
|
|
- tu.icon,
|
|
|
|
|
- my_nick_name,
|
|
|
|
|
- my_icon
|
|
|
|
|
|
|
+ us.store_id
|
|
|
ORDER BY
|
|
ORDER BY
|
|
|
update_time DESC
|
|
update_time DESC
|
|
|
|
|
|
|
|
-
|
|
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
- <select id="queryUsersSession" parameterType="com.izouma.awesomeadmin.model.UsersSession" resultType="com.izouma.awesomeadmin.model.UsersSession">
|
|
|
|
|
|
|
+ <select id="queryUsersSession" parameterType="com.izouma.awesomeadmin.model.UsersSession"
|
|
|
|
|
+ resultType="com.izouma.awesomeadmin.model.UsersSession">
|
|
|
select
|
|
select
|
|
|
<include refid="Base_Column_List"/>
|
|
<include refid="Base_Column_List"/>
|
|
|
from users_session
|
|
from users_session
|
|
@@ -332,6 +316,9 @@
|
|
|
<if test="contactId != null and !"".equals(contactId)">
|
|
<if test="contactId != null and !"".equals(contactId)">
|
|
|
and contact_id=#{contactId}
|
|
and contact_id=#{contactId}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <if test="storeId != null and !"".equals(storeId)">
|
|
|
|
|
+ and store_id=#{storeId}
|
|
|
|
|
+ </if>
|
|
|
</where>
|
|
</where>
|
|
|
LIMIT 1
|
|
LIMIT 1
|
|
|
</select>
|
|
</select>
|
|
@@ -350,19 +337,10 @@
|
|
|
FROM
|
|
FROM
|
|
|
chat_info
|
|
chat_info
|
|
|
WHERE
|
|
WHERE
|
|
|
- (
|
|
|
|
|
- (
|
|
|
|
|
user_id = #{userId}
|
|
user_id = #{userId}
|
|
|
- AND to_user_id = #{toUserId}
|
|
|
|
|
- )
|
|
|
|
|
- OR (
|
|
|
|
|
- user_id = #{toUserId}
|
|
|
|
|
- AND to_user_id = #{userId}
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
AND state != 2
|
|
AND state != 2
|
|
|
- <if test="projectId != null and !"".equals(projectId)">
|
|
|
|
|
- AND project_id = #{projectId}
|
|
|
|
|
|
|
+ <if test="storeId != null and !"".equals(storeId)">
|
|
|
|
|
+ AND store_id = #{storeId}
|
|
|
</if>
|
|
</if>
|
|
|
ORDER BY
|
|
ORDER BY
|
|
|
time DESC
|
|
time DESC
|
|
@@ -378,16 +356,20 @@
|
|
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
|
|
<result column="type" property="type" jdbcType="INTEGER"/>
|
|
<result column="type" property="type" jdbcType="INTEGER"/>
|
|
|
<result column="project_id" property="projectId" jdbcType="INTEGER"/>
|
|
<result column="project_id" property="projectId" jdbcType="INTEGER"/>
|
|
|
- <result column="nick_name" property="nickName"/>
|
|
|
|
|
- <result column="icon" property="icon"/>
|
|
|
|
|
- <result column="my_nick_name" property="myNickName"/>
|
|
|
|
|
- <result column="my_icon" property="myIcon"/>
|
|
|
|
|
- <result column="project_name" property="projectName"/>
|
|
|
|
|
|
|
+ <result column="store_id" property="storeId" jdbcType="INTEGER"/>
|
|
|
<result column="chattime" property="chattime"/>
|
|
<result column="chattime" property="chattime"/>
|
|
|
<association
|
|
<association
|
|
|
property="chatInfo" javaType="com.izouma.awesomeadmin.model.ChatInfo"
|
|
property="chatInfo" javaType="com.izouma.awesomeadmin.model.ChatInfo"
|
|
|
select="getChat"
|
|
select="getChat"
|
|
|
- column="{ userId = user_id , toUserId = to_user_id , projectId = project_id }"/>
|
|
|
|
|
|
|
+ column="{ userId = user_id , storeId = store_id}"/>
|
|
|
|
|
+ <association property="storeInfo"
|
|
|
|
|
+ javaType="com.izouma.awesomeadmin.model.StoreInfo"
|
|
|
|
|
+ select="com.izouma.awesomeadmin.dao.StoreInfoMapper.queryStoreInfo"
|
|
|
|
|
+ column="{ id = store_id }"/>
|
|
|
|
|
+ <association property="userInfo"
|
|
|
|
|
+ javaType="com.izouma.awesomeadmin.model.UserInfo"
|
|
|
|
|
+ select="com.izouma.awesomeadmin.dao.UserInfoMapper.queryUserInfo"
|
|
|
|
|
+ column="{ id = user_id }"/>
|
|
|
|
|
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|