Initial project
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.AttachmentMapper">
|
||||
<sql id="table">attachment</sql>
|
||||
<select id="listByAttachType" resultType="com.imyeyu.server.modules.common.entity.Attachment">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
biz_type = #{bizType}
|
||||
AND biz_id = #{bizId}
|
||||
<if test="attachTypes != null and 0 < attachTypes.length">
|
||||
AND attach_type IN
|
||||
<foreach collection="attachTypes" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
AND deleted_at IS NULL
|
||||
AND destroy_at IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,143 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.CommentMapper">
|
||||
<sql id="table">comment</sql>
|
||||
<!-- 主评论 -->
|
||||
<select id="list" resultMap="listResult">
|
||||
SELECT
|
||||
-- 主评论
|
||||
comment.id,
|
||||
comment.biz_type,
|
||||
comment.biz_id,
|
||||
comment.user_id,
|
||||
comment.nick,
|
||||
comment.content,
|
||||
comment.created_at,
|
||||
|
||||
-- 回复数量
|
||||
reply_count.reply_length,
|
||||
|
||||
-- 回复
|
||||
reply.id AS reply_id,
|
||||
reply.comment_id,
|
||||
reply.sender_id,
|
||||
reply.sender_nick,
|
||||
reply.receiver_id,
|
||||
reply.receiver_nick,
|
||||
reply.content AS reply_content,
|
||||
reply.created_at AS reply_created_at
|
||||
FROM (
|
||||
-- 查询主评论
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
biz_type = #{bizType}
|
||||
AND biz_id = #{bizId}
|
||||
AND deleted_at IS NULL
|
||||
ORDER BY
|
||||
created_at ${orderMap.createdAt}
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
) AS comment
|
||||
LEFT JOIN (
|
||||
-- 查询前 6 条回复(时间升序)
|
||||
SELECT
|
||||
*
|
||||
FROM (
|
||||
SELECT
|
||||
comment_reply.*,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY comment_id
|
||||
ORDER BY created_at ASC
|
||||
) AS seq
|
||||
FROM
|
||||
comment_reply
|
||||
WHERE
|
||||
deleted_at IS NULL
|
||||
) AS reply
|
||||
WHERE
|
||||
seq < 7
|
||||
) AS reply
|
||||
ON
|
||||
reply.comment_id = comment.id
|
||||
LEFT JOIN(
|
||||
-- 统计回复总数
|
||||
SELECT
|
||||
comment_id AS id,
|
||||
COUNT(*) AS reply_length
|
||||
FROM
|
||||
comment_reply
|
||||
WHERE
|
||||
deleted_at IS NULL
|
||||
GROUP BY
|
||||
comment_id
|
||||
) AS reply_count
|
||||
ON
|
||||
reply_count.id = comment.id
|
||||
</select>
|
||||
<resultMap id="listResult" type="com.imyeyu.server.modules.common.vo.comment.CommentView">
|
||||
<id property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="nick" column="nick" />
|
||||
<result property="content" column="content" />
|
||||
<result property="repliesLength" column="reply_length" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<!-- 关联回复 -->
|
||||
<collection property="replies" ofType="com.imyeyu.server.modules.common.vo.comment.CommentReplyView">
|
||||
<id property="id" column="reply_id" />
|
||||
<result property="commentId" column="comment_id" />
|
||||
<result property="senderId" column="sender_id" />
|
||||
<result property="senderNick" column="sender_nick" />
|
||||
<result property="receiverId" column="receiver_id" />
|
||||
<result property="receiverNick" column="receiver_nick" />
|
||||
<result property="content" column="reply_content" />
|
||||
<result property="createdAt" column="reply_created_at" />
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="countAll" resultType="long">
|
||||
SELECT
|
||||
SUM(result.total_comment + result.total_reply)
|
||||
FROM (
|
||||
SELECT
|
||||
COUNT(DISTINCT comment.id) AS total_comment,
|
||||
COUNT(comment_reply.comment_id) AS total_reply
|
||||
FROM
|
||||
comment
|
||||
LEFT JOIN
|
||||
comment_reply
|
||||
ON
|
||||
comment_reply.comment_id = comment.id
|
||||
WHERE
|
||||
comment.biz_type = #{bizType}
|
||||
AND comment.biz_id = #{bizId}
|
||||
AND comment.deleted_at IS NULL
|
||||
AND comment_reply.deleted_at IS NULL
|
||||
) AS result
|
||||
</select>
|
||||
|
||||
<sql id="byUserIdCondition">
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
AND deleted_at IS NULL
|
||||
</sql>
|
||||
<select id="countByUserId" resultType="long">
|
||||
SELECT COUNT(1) <include refid="byUserIdCondition" />
|
||||
</select>
|
||||
<select id="listByUserId" resultType="com.imyeyu.server.modules.common.vo.comment.CommentView">
|
||||
SELECT
|
||||
id,
|
||||
biz_type,
|
||||
biz_id,
|
||||
content,
|
||||
created_at
|
||||
<include refid="byUserIdCondition" />
|
||||
ORDER BY
|
||||
created_at ${orderMap.createdAt}
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.IconMapper">
|
||||
<sql id="table">icon</sql>
|
||||
<!-- 根据标签获取部分 -->
|
||||
<sql id="byLabel">
|
||||
FROM (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
icon_labels
|
||||
WHERE
|
||||
${lang} LIKE CONCAT('%', #{label}, '%')
|
||||
AND icon_labels.deleted_at IS NULL
|
||||
) AS labels
|
||||
LEFT JOIN
|
||||
icon_label
|
||||
ON
|
||||
icon_label.icon_label_id = labels.id
|
||||
AND labels.id IS NOT NULL
|
||||
LEFT JOIN
|
||||
<include refid="table" />
|
||||
ON
|
||||
icon.id = icon_label.icon_id
|
||||
WHERE
|
||||
icon.id IS NOT NULL
|
||||
AND icon.deleted_at IS NULL
|
||||
</sql>
|
||||
<select id="countByLabel" resultType="long">
|
||||
SELECT COUNT(1) <include refid="byLabel" />
|
||||
</select>
|
||||
<select id="listByLabel" resultType="com.imyeyu.server.modules.common.entity.Icon">
|
||||
SELECT icon.* <include refid="byLabel" /> LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.MultilingualMapper">
|
||||
<select id="selectByKeyList" resultType="com.imyeyu.server.modules.common.entity.Multilingual">
|
||||
SELECT * FROM multilingual WHERE key IN
|
||||
<foreach collection='keys' item='item' open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
AND deleted_at IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.SettingMapper">
|
||||
<sql id="table">setting</sql>
|
||||
<select id="listByKeys">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
key IN
|
||||
<foreach collection="keys" item="key" open="(" separator="," close=")">
|
||||
#{key}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.TaskMapper">
|
||||
<!-- 所有公开任务 -->
|
||||
<select id="listAll4Public" resultMap="findAll4PublicResult">
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
digest,
|
||||
status,
|
||||
td.*
|
||||
FROM
|
||||
task
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
*
|
||||
FROM (
|
||||
-- 任务详情
|
||||
SELECT
|
||||
id AS detial_id,
|
||||
task_id,
|
||||
bizType,
|
||||
status AS tdStatus,
|
||||
digest AS tdDigest,
|
||||
created_at,
|
||||
ROW_NUMBER() OVER (PARTITION BY task_id ORDER BY created_at DESC) AS seq
|
||||
FROM
|
||||
task_detail
|
||||
WHERE
|
||||
deleted_at IS NULL
|
||||
) AS cr
|
||||
WHERE
|
||||
seq < 7
|
||||
) AS td
|
||||
ON
|
||||
td.task_id = task.id
|
||||
WHERE
|
||||
is_public = 1
|
||||
AND deleted_at IS NULL
|
||||
</select>
|
||||
<resultMap id="findAll4PublicResult" type="com.imyeyu.server.modules.common.entity.Task">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="digest" column="digest"/>
|
||||
<result property="status" column="status"/>
|
||||
<!-- 关联任务 -->
|
||||
<collection property="details" ofType="com.imyeyu.server.modules.common.entity.TaskDetail">
|
||||
<id property="id" column="detial_id"/>
|
||||
<result property="bizType" column="bizType"/>
|
||||
<result property="status" column="tdStatus"/>
|
||||
<result property="digest" column="tdDigest"/>
|
||||
<result property="createdAt" column="created_at"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.UserConfigMapper">
|
||||
<sql id="table">user_config</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.UserPrivacyMapper">
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.imyeyu.server.modules.common.mapper.UserProfileMapper">
|
||||
<sql id="table">user_profile</sql>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user