refactor all
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
<?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.api.modules.blog.mapper.ArticleMapper">
|
||||
<sql id="table">article</sql>
|
||||
<!-- 查询列表的文章字段 -->
|
||||
<sql id="listColumn">
|
||||
`id`,
|
||||
`type`,
|
||||
`title`,
|
||||
`digest`,
|
||||
`likes`,
|
||||
`reads`,
|
||||
`created_at`,
|
||||
`updated_at`
|
||||
</sql>
|
||||
<!-- 列表 -->
|
||||
<sql id="normalCondition">
|
||||
FROM
|
||||
article
|
||||
WHERE
|
||||
can_list IS TRUE
|
||||
AND deleted_at IS NULL
|
||||
</sql>
|
||||
<select id="countByPage" resultType="long">
|
||||
SELECT COUNT(1) <include refid="normalCondition" />
|
||||
</select>
|
||||
<select id="selectByPage" resultType="com.imyeyu.api.modules.blog.entity.Article">
|
||||
SELECT
|
||||
<include refid="listColumn" />
|
||||
<include refid="normalCondition" />
|
||||
ORDER BY
|
||||
COALESCE(updated_at, created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
<!-- 根据关键字获取列表 -->
|
||||
<sql id="byKeywordCondition">
|
||||
<include refid="normalCondition" />
|
||||
AND (
|
||||
`title` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `digest` LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
</sql>
|
||||
<select id="countByKeyword" resultType="long">
|
||||
SELECT COUNT(1) <include refid="byKeywordCondition" />
|
||||
</select>
|
||||
<select id="selectByKeyword" resultType="com.imyeyu.api.modules.blog.entity.Article">
|
||||
SELECT
|
||||
<include refid="listColumn" />
|
||||
<include refid="byKeywordCondition" />
|
||||
ORDER BY
|
||||
COALESCE(updated_at, created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,79 +0,0 @@
|
||||
<?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.api.modules.common.mapper.AttachmentMapper">
|
||||
<sql id="table">attachment</sql>
|
||||
<select id="listByBizId" resultType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
attachment
|
||||
WHERE
|
||||
biz_type = #{bizType}
|
||||
<if test="bizId != null">
|
||||
AND biz_id = #{bizId}
|
||||
</if>
|
||||
<if test="attachTypes != null and 0 < attachTypes.size()">
|
||||
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
|
||||
<if test="page != null">
|
||||
<if test="page.orderMap != null and !page.orderMap.isEmpty()">
|
||||
ORDER BY
|
||||
<foreach collection="page.orderMap" index="key" item="value" separator=",">
|
||||
${key} ${value}
|
||||
</foreach>
|
||||
</if>
|
||||
LIMIT
|
||||
#{page.offset},
|
||||
#{page.limit}
|
||||
</if>
|
||||
</select>
|
||||
<select id="countByBizId" resultType="long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM
|
||||
attachment
|
||||
WHERE
|
||||
biz_type = #{bizType}
|
||||
<if test="bizId != null">
|
||||
AND biz_id = #{bizId}
|
||||
</if>
|
||||
<if test="attachTypes != null and 0 < attachTypes.size()">
|
||||
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>
|
||||
<select id="listByMd5s" resultType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
attachment
|
||||
WHERE
|
||||
biz_type = #{bizType}
|
||||
<if test="bizId != null">
|
||||
AND biz_id = #{bizId}
|
||||
</if>
|
||||
<if test="attachTypes != null and 0 < attachTypes.size()">
|
||||
AND attach_type IN
|
||||
<foreach collection="attachTypes" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="md5s != null and 0 < md5s.size()">
|
||||
AND `md5` IN
|
||||
<foreach collection="md5s" item="md5" open="(" separator="," close=")">
|
||||
#{md5}
|
||||
</foreach>
|
||||
</if>
|
||||
AND deleted_at IS NULL
|
||||
AND destroy_at IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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.api.modules.common.mapper.CommentMapper">
|
||||
<sql id="table">comment</sql>
|
||||
<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>
|
||||
</mapper>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?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.api.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.api.modules.common.entity.Icon">
|
||||
SELECT icon.* <include refid="byLabel" /> LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?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.api.modules.common.mapper.MultilingualMapper">
|
||||
<select id="selectByKeyList" resultType="com.imyeyu.api.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>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?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.api.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>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?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.api.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.api.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.api.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>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.api.modules.common.mapper.UserConfigMapper">
|
||||
<sql id="table">user_config</sql>
|
||||
</mapper>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?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.api.modules.common.mapper.UserPrivacyMapper">
|
||||
</mapper>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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.api.modules.common.mapper.UserProfileMapper">
|
||||
<sql id="table">user_profile</sql>
|
||||
</mapper>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?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.api.modules.git.mapper.IssueMapper">
|
||||
<sql id="table">git_issue</sql>
|
||||
<sql id="pageCondition">
|
||||
repository_id = #{issuePage.repositoryId}
|
||||
<if test="issuePage.type != null">
|
||||
AND type = #{issuePage.type}
|
||||
</if>
|
||||
<if test="issuePage.status != null">
|
||||
AND status = #{issuePage.status}
|
||||
</if>
|
||||
<if test="issuePage.keyword != null and issuePage.keyword != ''">
|
||||
AND (
|
||||
title LIKE CONCAT('%', #{issuePage.keyword}, '%')
|
||||
OR description LIKE CONCAT('%', #{issuePage.keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
AND deleted_at IS NULL
|
||||
</sql>
|
||||
<select id="countByIssuePage" resultType="long">
|
||||
SELECT COUNT(1) FROM <include refid="table" /> WHERE <include refid="pageCondition" />
|
||||
</select>
|
||||
<select id="listByIssuePage" resultType="com.imyeyu.api.modules.git.entity.Issue">
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
type,
|
||||
status,
|
||||
created_at
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
<include refid="pageCondition" />
|
||||
ORDER BY
|
||||
COALESCE(updated_at, created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?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.api.modules.git.mapper.MergeMapper">
|
||||
<sql id="table">git_merge</sql>
|
||||
<sql id="pageCondition">
|
||||
repository_id = #{mergePage.repositoryId}
|
||||
<if test="mergePage.type != null">
|
||||
AND type = #{mergePage.type}
|
||||
</if>
|
||||
<if test="mergePage.status != null">
|
||||
AND status = #{mergePage.status}
|
||||
</if>
|
||||
<if test="mergePage.keyword != null and mergePage.keyword != ''">
|
||||
AND (
|
||||
title LIKE CONCAT('%', #{mergePage.keyword}, '%')
|
||||
OR description LIKE CONCAT('%', #{mergePage.keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
AND deleted_at IS NULL
|
||||
</sql>
|
||||
<select id="countByMergePage" resultType="long">
|
||||
SELECT COUNT(1) FROM <include refid="table" /> WHERE <include refid="pageCondition" />
|
||||
</select>
|
||||
<select id="listByMergePage" resultType="com.imyeyu.api.modules.git.entity.Merge">
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
type,
|
||||
status,
|
||||
created_at
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
<include refid="pageCondition" />
|
||||
ORDER BY
|
||||
COALESCE(updated_at, created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,43 +0,0 @@
|
||||
<?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.api.modules.git.mapper.ReleaseMapper">
|
||||
<sql id="table">git_release</sql>
|
||||
<select id="listByRepositoryId" resultMap="listByRepositoryIdResult">
|
||||
SELECT
|
||||
release.*,
|
||||
attachment.id AS attachmentId,
|
||||
attachment.biz_type,
|
||||
attachment.biz_id,
|
||||
attachment.lid_title,
|
||||
attachment.name,
|
||||
attachment.size
|
||||
FROM
|
||||
<include refid="table" /> AS release
|
||||
LEFT JOIN
|
||||
attachment
|
||||
ON
|
||||
attachment.biz_type = '${@com.imyeyu.timiserver.modules.common.entity.Attachment$BizType@GIT}'
|
||||
AND attachment.biz_id = release.id
|
||||
AND attachment.attach_type = '${@com.imyeyu.timiserver.modules.git.bean.AttachType@RELEASE}'
|
||||
AND attachment.deleted_at IS NULL
|
||||
WHERE
|
||||
release.repository_id = #{repositoryId}
|
||||
AND release.deleted_at IS NULL
|
||||
ORDER BY
|
||||
COALESCE(release.updated_at, release.created_at) DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
<resultMap id="listByRepositoryIdResult" type="com.imyeyu.api.modules.git.vo.release.ReleaseView" autoMapping="true">
|
||||
<id property="id" column="id" />
|
||||
<!-- 关联附件 -->
|
||||
<collection property="attachmentList" ofType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
<id property="id" column="attachmentId" />
|
||||
<result property="bizType" column="biz_type" />
|
||||
<result property="bizId" column="biz_id" />
|
||||
<result property="lidTitle" column="lid_title" />
|
||||
<result property="name" column="name" />
|
||||
<result property="size" column="size" />
|
||||
</collection>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -1,52 +0,0 @@
|
||||
<?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.api.modules.gitea.mapper.ActionMapper">
|
||||
<select id="count" resultType="long">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
action
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="repoId != null">
|
||||
AND action.repo_id = #{repoId}
|
||||
</if>
|
||||
<if test="branch != null">
|
||||
AND action.ref_name LIKE CONCAT('%', #{branch})
|
||||
</if>
|
||||
<if test="operation != null">
|
||||
AND action.op_type = #{operation.value}
|
||||
</if>
|
||||
</select>
|
||||
<select id="list" resultType="com.imyeyu.api.modules.gitea.bean.ActionLogDTO">
|
||||
SELECT
|
||||
repository.id AS repo_id,
|
||||
repository.name AS repo_name,
|
||||
operator.id AS operator_id,
|
||||
action.ref_name,
|
||||
action.content,
|
||||
action.created_unix * 1000 AS operatedAt
|
||||
FROM
|
||||
action
|
||||
INNER JOIN
|
||||
repository ON action.repo_id = repository.id
|
||||
INNER JOIN
|
||||
user AS operator ON action.act_user_id = operator.id
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="repoId != null">
|
||||
AND action.repo_id = #{repoId}
|
||||
</if>
|
||||
<if test="branch != null">
|
||||
AND action.ref_name LIKE CONCAT('%', #{branch})
|
||||
</if>
|
||||
<if test="operation != null">
|
||||
AND action.op_type = #{operation.value}
|
||||
</if>
|
||||
ORDER BY
|
||||
action.created_unix DESC,
|
||||
action.id DESC
|
||||
LIMIT
|
||||
#{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?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.api.modules.journal.mapper.JournalMapper">
|
||||
<sql id="table">journal</sql>
|
||||
<select id="listByIds" resultType="com.imyeyu.api.modules.journal.entity.Journal">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="ids != null and 0 < ids.length">
|
||||
AND `id` IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
AND deleted_at IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?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.api.modules.journal.mapper.TravelLocationMapper">
|
||||
<sql id="table">travel_location</sql>
|
||||
<select id="listByIds" resultType="com.imyeyu.api.modules.journal.entity.TravelLocation">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
<include refid="table" />
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="ids != null and 0 < ids.length">
|
||||
AND `id` IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
AND deleted_at IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?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.api.modules.minecraft.mapper.PackMapper">
|
||||
<!-- 获取 -->
|
||||
<select id="listPacks" resultMap="listPacksResult">
|
||||
SELECT
|
||||
pack.*,
|
||||
source.name AS sourceName,
|
||||
source.type AS sourceType,
|
||||
source.data AS sourceData,
|
||||
source.is_default
|
||||
FROM
|
||||
minecraft_pack AS pack
|
||||
LEFT JOIN
|
||||
minecraft_pack_source AS source
|
||||
ON
|
||||
source.pack_id = pack.id
|
||||
WHERE
|
||||
pack.deleted_at IS NULL
|
||||
AND source.deleted_at IS NULL
|
||||
ORDER BY
|
||||
pack.is_deprecated, pack.created_at DESC, source.order ASC
|
||||
</select>
|
||||
<resultMap id="listPacksResult" type="com.imyeyu.api.modules.minecraft.entity.MinecraftPack" autoMapping="true">
|
||||
<id property="id" column="id" />
|
||||
<collection property="sourceList" ofType="com.imyeyu.api.modules.minecraft.entity.MinecraftPackSource" autoMapping="false">
|
||||
<result property="name" column="sourceName" />
|
||||
<result property="type" column="sourceType" />
|
||||
<result property="data" column="sourceData" />
|
||||
<result property="isDefault" column="is_default" />
|
||||
</collection>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?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.api.modules.minecraft.mapper.PlayerMapper">
|
||||
</mapper>
|
||||
@@ -1,56 +0,0 @@
|
||||
<?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.api.modules.system.mapper.AsyncTaskMapper">
|
||||
<sql id="table">async_task</sql>
|
||||
<insert id="insert">
|
||||
INSERT INTO <include refid="table" /> (
|
||||
uuid,
|
||||
name,
|
||||
type,
|
||||
message,
|
||||
status,
|
||||
progress,
|
||||
can_pause,
|
||||
can_interrupt,
|
||||
is_periodical,
|
||||
cron,
|
||||
start_at,
|
||||
interrupt_at,
|
||||
error_at,
|
||||
died_at,
|
||||
created_at
|
||||
) VALUES (
|
||||
#{uuid},
|
||||
#{name},
|
||||
#{type},
|
||||
#{message},
|
||||
#{status},
|
||||
#{progress},
|
||||
#{canPause},
|
||||
#{canInterrupt},
|
||||
#{isPeriodical},
|
||||
#{cron},
|
||||
#{startAt},
|
||||
#{interruptAt},
|
||||
#{errorAt},
|
||||
#{diedAt},
|
||||
#{createdAt}
|
||||
)
|
||||
</insert>
|
||||
<update id="update" parameterType="com.imyeyu.api.modules.system.entity.AsyncTask">
|
||||
UPDATE
|
||||
<include refid="table" />
|
||||
SET
|
||||
name = #{name},
|
||||
type = #{type},
|
||||
message = #{message},
|
||||
status = #{status},
|
||||
progress = #{progress},
|
||||
start_at = #{startAt},
|
||||
interrupt_at = #{interruptAt},
|
||||
error_at = #{errorAt},
|
||||
died_at = #{diedAt}
|
||||
WHERE
|
||||
uuid = #{uuid}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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.api.modules.gao.mapper.GaoCustomerMapper">
|
||||
<select id="search" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomer">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
1 = 1
|
||||
AND `deleted_at` IS NULL
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (
|
||||
`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `name` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `telephone` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `address` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR `disease` LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR CAST(`conditioning_part` AS CHAR) LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="introducerCustomerId != null and introducerCustomerId != ''">
|
||||
AND `introducer_customer_id` = #{introducerCustomerId}
|
||||
</if>
|
||||
ORDER BY `created_at` DESC
|
||||
</select>
|
||||
|
||||
<select id="selectInvitedList" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomer">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`introducer_customer_id` = #{introducerCustomerId}
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at` DESC
|
||||
</select>
|
||||
|
||||
<select id="countInvited" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`introducer_customer_id` = #{introducerCustomerId}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="statDailyNewCustomer" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `newCustomerCount`
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`created_at` >= #{beginCreatedAt}
|
||||
AND `created_at` <= #{endCreatedAt}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="countCreatedBefore" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_customer`
|
||||
WHERE
|
||||
`created_at` < #{beginCreatedAt}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,233 @@
|
||||
<?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.api.modules.gao.mapper.GaoRegistrationEventRecordMapper">
|
||||
<select id="selectByRegistrationEventAndPeriod" resultType="com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRecord">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`registration_event_id` = #{registrationEventId}
|
||||
AND `deleted_at` IS NULL
|
||||
<if test='periodType.name() == "DAY"'>
|
||||
AND DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d') = CAST(#{periodValue} AS CHAR)
|
||||
</if>
|
||||
<if test='periodType.name() == "MONTH"'>
|
||||
AND DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m') = CAST(#{periodValue} AS CHAR)
|
||||
</if>
|
||||
<if test='periodType.name() == "YEAR"'>
|
||||
AND DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y') = CAST(#{periodValue} AS CHAR)
|
||||
</if>
|
||||
ORDER BY `registered_at` DESC
|
||||
</select>
|
||||
|
||||
<select id="statByRegistrationEventAndPeriodType" resultType="com.imyeyu.api.modules.gao.vo.GaoRegistrationEventPeriodStatView">
|
||||
SELECT
|
||||
`registration_event_id` AS `registrationEventId`,
|
||||
<choose>
|
||||
<when test='periodType.name() == "DAY"'>
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d') AS UNSIGNED)
|
||||
</when>
|
||||
<when test='periodType.name() == "MONTH"'>
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m') AS UNSIGNED)
|
||||
</when>
|
||||
<otherwise>
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y') AS UNSIGNED)
|
||||
</otherwise>
|
||||
</choose> AS `periodValue`,
|
||||
COUNT(1) AS `count`
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`registration_event_id` = #{registrationEventId}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY
|
||||
`registration_event_id`,
|
||||
<choose>
|
||||
<when test='periodType.name() == "DAY"'>
|
||||
DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d')
|
||||
</when>
|
||||
<when test='periodType.name() == "MONTH"'>
|
||||
DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m')
|
||||
</when>
|
||||
<otherwise>
|
||||
DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y')
|
||||
</otherwise>
|
||||
</choose>
|
||||
ORDER BY `periodValue` DESC
|
||||
</select>
|
||||
|
||||
<select id="statByCustomerId" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerRegisterStatView">
|
||||
SELECT
|
||||
r.`customer_id` AS `customerId`,
|
||||
c.`name` AS `customerName`,
|
||||
r.`registration_event_id` AS `registrationEventId`,
|
||||
a.`name` AS `registrationEventName`,
|
||||
COUNT(1) AS `count`,
|
||||
MAX(r.`registered_at`) AS `latestRegisteredAt`
|
||||
FROM `gao_registration_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
LEFT JOIN `gao_registration_event` a ON r.`registration_event_id` = a.`id`
|
||||
WHERE
|
||||
r.`customer_id` = #{customerId}
|
||||
AND r.`deleted_at` IS NULL
|
||||
GROUP BY r.`customer_id`, c.`name`, r.`registration_event_id`, a.`name`
|
||||
ORDER BY `latestRegisteredAt` DESC
|
||||
</select>
|
||||
|
||||
<select id="statByCustomerIdAndRange" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerRegisterStatView">
|
||||
SELECT
|
||||
r.`customer_id` AS `customerId`,
|
||||
c.`name` AS `customerName`,
|
||||
r.`registration_event_id` AS `registrationEventId`,
|
||||
a.`name` AS `registrationEventName`,
|
||||
COUNT(1) AS `count`,
|
||||
MAX(r.`registered_at`) AS `latestRegisteredAt`
|
||||
FROM `gao_registration_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
LEFT JOIN `gao_registration_event` a ON r.`registration_event_id` = a.`id`
|
||||
WHERE
|
||||
r.`customer_id` = #{customerId}
|
||||
AND r.`registered_at` >= #{beginRegisteredAt}
|
||||
AND r.`registered_at` <= #{endRegisteredAt}
|
||||
AND r.`deleted_at` IS NULL
|
||||
GROUP BY r.`customer_id`, c.`name`, r.`registration_event_id`, a.`name`
|
||||
ORDER BY `latestRegisteredAt` DESC
|
||||
</select>
|
||||
|
||||
<select id="statAllCustomerByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerRegisterStatView">
|
||||
SELECT
|
||||
r.`customer_id` AS `customerId`,
|
||||
c.`name` AS `customerName`,
|
||||
r.`registration_event_id` AS `registrationEventId`,
|
||||
a.`name` AS `registrationEventName`,
|
||||
COUNT(1) AS `count`,
|
||||
MAX(r.`registered_at`) AS `latestRegisteredAt`
|
||||
FROM `gao_registration_event_record` r
|
||||
LEFT JOIN `gao_customer` c ON r.`customer_id` = c.`id`
|
||||
LEFT JOIN `gao_registration_event` a ON r.`registration_event_id` = a.`id`
|
||||
WHERE
|
||||
r.`registered_at` >= #{beginRegisteredAt}
|
||||
AND r.`registered_at` <= #{endRegisteredAt}
|
||||
AND r.`deleted_at` IS NULL
|
||||
GROUP BY r.`customer_id`, c.`name`, r.`registration_event_id`, a.`name`
|
||||
ORDER BY `latestRegisteredAt` DESC
|
||||
</select>
|
||||
|
||||
<select id="statDailyCountByCustomerIdAndRegistrationEventIdRange" resultType="com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `dailyCount`
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`customer_id` = #{customerId}
|
||||
AND `registration_event_id` = #{registrationEventId}
|
||||
AND `registered_at` >= #{beginRegisteredAt}
|
||||
AND `registered_at` <= #{endRegisteredAt}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="statDailyCountByRegistrationEventIdRange" resultType="com.imyeyu.api.modules.gao.vo.GaoRegistrationEventRecordDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `dailyCount`
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`registration_event_id` = #{registrationEventId}
|
||||
AND `registered_at` >= #{beginRegisteredAt}
|
||||
AND `registered_at` <= #{endRegisteredAt}
|
||||
AND `deleted_at` IS NULL
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(`registered_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="countBeforeByCustomerIdAndRegistrationEventId" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`customer_id` = #{customerId}
|
||||
AND `registration_event_id` = #{registrationEventId}
|
||||
AND `registered_at` < #{beginRegisteredAt}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="countBeforeByRegistrationEventId" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`registration_event_id` = #{registrationEventId}
|
||||
AND `registered_at` < #{beginRegisteredAt}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="selectLatestByCustomerIdListAndRegistrationEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRecord">
|
||||
SELECT
|
||||
r.*
|
||||
FROM `gao_registration_event_record` r
|
||||
WHERE
|
||||
r.`registration_event_id` = #{registrationEventId}
|
||||
AND r.`deleted_at` IS NULL
|
||||
AND r.`customer_id` IN
|
||||
<foreach collection="customerIdList" item="customerId" open="(" separator="," close=")">
|
||||
#{customerId}
|
||||
</foreach>
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM `gao_registration_event_record` newer
|
||||
WHERE
|
||||
newer.`customer_id` = r.`customer_id`
|
||||
AND newer.`registration_event_id` = r.`registration_event_id`
|
||||
AND newer.`deleted_at` IS NULL
|
||||
AND (
|
||||
newer.`registered_at` > r.`registered_at`
|
||||
OR (newer.`registered_at` = r.`registered_at` AND newer.`created_at` > r.`created_at`)
|
||||
OR (newer.`registered_at` = r.`registered_at` AND newer.`created_at` = r.`created_at` AND newer.`id` > r.`id`)
|
||||
)
|
||||
)
|
||||
ORDER BY r.`registered_at` DESC, r.`created_at` DESC
|
||||
</select>
|
||||
|
||||
<select id="selectLatestByCustomerId" resultType="com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRecord">
|
||||
SELECT
|
||||
r.*
|
||||
FROM `gao_registration_event_record` r
|
||||
WHERE
|
||||
r.`customer_id` = #{customerId}
|
||||
AND r.`deleted_at` IS NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM `gao_registration_event_record` newer
|
||||
WHERE
|
||||
newer.`customer_id` = r.`customer_id`
|
||||
AND newer.`registration_event_id` = r.`registration_event_id`
|
||||
AND newer.`deleted_at` IS NULL
|
||||
AND (
|
||||
newer.`registered_at` > r.`registered_at`
|
||||
OR (newer.`registered_at` = r.`registered_at` AND newer.`created_at` > r.`created_at`)
|
||||
OR (newer.`registered_at` = r.`registered_at` AND newer.`created_at` = r.`created_at` AND newer.`id` > r.`id`)
|
||||
)
|
||||
)
|
||||
ORDER BY r.`registered_at` DESC, r.`created_at` DESC
|
||||
</select>
|
||||
|
||||
<select id="selectByRange" resultType="com.imyeyu.api.modules.gao.entity.GaoRegistrationEventRecord">
|
||||
SELECT
|
||||
*
|
||||
FROM `gao_registration_event_record`
|
||||
WHERE
|
||||
`registered_at` >= #{req.beginRegisteredAt}
|
||||
AND `registered_at` <= #{req.endRegisteredAt}
|
||||
AND `deleted_at` IS NULL
|
||||
<if test="req.customerId != null and req.customerId != ''">
|
||||
AND `customer_id` = #{req.customerId}
|
||||
</if>
|
||||
<if test="req.registrationEventId != null and req.registrationEventId != ''">
|
||||
AND `registration_event_id` = #{req.registrationEventId}
|
||||
</if>
|
||||
ORDER BY `registered_at` DESC, `created_at` DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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.api.modules.common.mapper.MultilingualMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.common.entity.Multilingual">
|
||||
SELECT
|
||||
*
|
||||
FROM `multilingual`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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.api.modules.user.mapper.RoleMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.user.entity.Role">
|
||||
SELECT
|
||||
*
|
||||
FROM `role`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByModuleCodeAndCodeList" resultType="com.imyeyu.api.modules.user.entity.Role">
|
||||
SELECT
|
||||
*
|
||||
FROM `role`
|
||||
WHERE
|
||||
1 = 1
|
||||
AND `module_code` = #{moduleCode}
|
||||
<if test="codeList != null and !codeList.isEmpty()">
|
||||
AND `code` IN
|
||||
<foreach collection="codeList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="codeList == null or codeList.isEmpty()">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
|
||||
<select id="selectByModuleCode" resultType="com.imyeyu.api.modules.user.entity.Role">
|
||||
SELECT
|
||||
*
|
||||
FROM `role`
|
||||
WHERE
|
||||
`module_code` = #{moduleCode}
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at` ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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.api.modules.user.mapper.RolePermissionMapper">
|
||||
<select id="selectByRoleIdList" resultType="com.imyeyu.api.modules.user.entity.RolePermission">
|
||||
SELECT
|
||||
*
|
||||
FROM `role_permission`
|
||||
WHERE
|
||||
`role_permission`.`role_id` IN
|
||||
<foreach collection="roleIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND `role_permission`.`deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectPermissionByRoleIdList" resultType="com.imyeyu.api.modules.user.entity.Permission">
|
||||
SELECT
|
||||
permission.*
|
||||
FROM `role_permission`
|
||||
LEFT JOIN `permission` ON permission.id = role_permission.permission_id
|
||||
WHERE
|
||||
`role_permission`.`role_id` IN
|
||||
<foreach collection="roleIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND `role_permission`.`deleted_at` IS NULL
|
||||
AND `permission`.`deleted_at` IS NULL
|
||||
ORDER BY
|
||||
`permission`.code ASC
|
||||
</select>
|
||||
<insert id="createBatch">
|
||||
INSERT INTO `role_permission` (
|
||||
id,
|
||||
role_id,
|
||||
permission_id,
|
||||
created_at
|
||||
) VALUES
|
||||
<foreach collection="rolePermissionList" item="item" separator=",">
|
||||
(#{item.id}, #{item.roleId}, #{item.permissionId}, #{item.createdAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="deleteByPermissionIdList">
|
||||
UPDATE `role_permission`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP()
|
||||
WHERE
|
||||
`role_id` = #{roleId}
|
||||
AND `permission_id` IN
|
||||
<foreach collection="permissionIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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.api.modules.user.mapper.RoleRelationMapper">
|
||||
<select id="selectByParentRoleId" resultType="com.imyeyu.api.modules.user.entity.RoleRelation">
|
||||
SELECT
|
||||
*
|
||||
FROM `role_relation`
|
||||
WHERE
|
||||
`parent_role_id` = #{parentRoleId}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectChildRoleIdListByParentRoleId" resultType="java.lang.String">
|
||||
SELECT
|
||||
`child_role_id`
|
||||
FROM `role_relation`
|
||||
WHERE
|
||||
`parent_role_id` = #{parentRoleId}
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectChildRoleIdListByParentRoleIdList" resultType="java.lang.String">
|
||||
SELECT
|
||||
`child_role_id`
|
||||
FROM `role_relation`
|
||||
WHERE
|
||||
`parent_role_id` IN
|
||||
<foreach collection="parentRoleIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<insert id="createBatch">
|
||||
INSERT INTO `role_relation` (
|
||||
id,
|
||||
parent_role_id,
|
||||
child_role_id,
|
||||
created_at
|
||||
) VALUES
|
||||
<foreach collection="roleRelationList" item="item" separator=",">
|
||||
(#{item.id}, #{item.parentRoleId}, #{item.childRoleId}, #{item.createdAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="deleteByChildRoleIdList">
|
||||
UPDATE `role_relation`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP()
|
||||
WHERE
|
||||
`parent_role_id` = #{parentRoleId}
|
||||
AND `child_role_id` IN
|
||||
<foreach collection="childRoleIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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.api.modules.user.mapper.UserMapper">
|
||||
<select id="listByIdList" resultType="com.imyeyu.api.modules.user.entity.User">
|
||||
SELECT
|
||||
*
|
||||
FROM `user`
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND 1 = 0
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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.api.modules.user.mapper.UserRoleMapper">
|
||||
<insert id="createBatch">
|
||||
INSERT INTO `user_role` (
|
||||
id,
|
||||
user_id,
|
||||
role_id,
|
||||
created_at
|
||||
) VALUES
|
||||
<foreach collection="userRoleList" item="item" separator=",">
|
||||
(#{item.id}, #{item.userId}, #{item.roleId}, #{item.createdAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="deleteByRoleIdList">
|
||||
UPDATE `user_role`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP()
|
||||
WHERE
|
||||
`user_id` = #{userId}
|
||||
AND `role_id` IN
|
||||
<foreach collection="roleIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user