|
@@ -19,6 +19,8 @@
|
|
|
<result property="admin_id" column="admin_id" />
|
|
|
<result property="create_time" column="create_time" />
|
|
|
<result property="status" column="status" />
|
|
|
+ <result property="type_name" column="type_name" />
|
|
|
+ <result property="user_id" column="user_id" />
|
|
|
|
|
|
<!-- 分类关联映射 -->
|
|
|
<association property="category" javaType="TemplateCategory">
|
|
@@ -93,4 +95,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
+ <!-- 分页查询模板列表 pageTemplate -->
|
|
|
+ <select id="pageTemplate" parameterType="DcTemplate" resultMap="TemplateResult">
|
|
|
+ SELECT
|
|
|
+ t.id,
|
|
|
+ t.code,
|
|
|
+ t.name,
|
|
|
+ t.category_id,
|
|
|
+ t.create_time,
|
|
|
+ t.status,
|
|
|
+ c.name as type_name
|
|
|
+ FROM dc_template t
|
|
|
+ LEFT JOIN dc_template_category c ON t.category_id = c.id
|
|
|
+ <where>
|
|
|
+ t.status != 4
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ AND t.name like concat('%', #{name}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="category_id != null">
|
|
|
+ AND t.category_id = #{category_id}
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ AND t.status = #{status}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ORDER BY t.id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 分页查询模板列表 pageTemplate -->
|
|
|
+
|
|
|
+ <!-- 检查模板名称是否存在 -->
|
|
|
+ <select id="checkNameUnique" parameterType="DcTemplate" resultMap="TemplateResult">
|
|
|
+ SELECT id, name FROM dc_template
|
|
|
+ WHERE name = #{name} AND status != 4
|
|
|
+ LIMIT 1
|
|
|
+ </select>
|
|
|
+ <!-- 检查模板名称是否存在 -->
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 创建模板 -->
|
|
|
+ <insert id="insertTemplate" parameterType="DcTemplate" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ INSERT INTO dc_template (
|
|
|
+ <if test="code != null">code,</if>
|
|
|
+ <if test="name != null">name,</if>
|
|
|
+ <if test="intro != null">intro,</if>
|
|
|
+ <if test="lay_id != null">lay_id,</if>
|
|
|
+ <if test="type != null">type,</if>
|
|
|
+ <if test="content != null">content,</if>
|
|
|
+ <if test="attrs != null">attrs,</if>
|
|
|
+ <if test="category_id != null">category_id,</if>
|
|
|
+ <if test="admin_id != null">admin_id,</if>
|
|
|
+ <if test="status != null">status,</if>
|
|
|
+ <if test="user_id != null">status,</if>
|
|
|
+
|
|
|
+ create_time
|
|
|
+ ) VALUES (
|
|
|
+ <if test="code != null">#{code},</if>
|
|
|
+ <if test="name != null">#{name},</if>
|
|
|
+ <if test="intro != null">#{intro},</if>
|
|
|
+ <if test="lay_id != null">#{lay_id},</if>
|
|
|
+ <if test="type != null">#{type},</if>
|
|
|
+ <if test="content != null">#{content},</if>
|
|
|
+ <if test="attrs != null">#{attrs},</if>
|
|
|
+ <if test="category_id != null">#{category_id},</if>
|
|
|
+ <if test="admin_id != null">#{admin_id},</if>
|
|
|
+ <if test="status != null">#{status},</if>
|
|
|
+ <if test="user_id != null">#{user_id},</if>
|
|
|
+ sysdate()
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <!-- 创建模板 -->
|
|
|
+
|
|
|
+ <!-- 更新模板编码 -->
|
|
|
+ <update id="updateTemplateCode" parameterType="DcTemplate">
|
|
|
+ UPDATE dc_template
|
|
|
+ SET code = #{code}
|
|
|
+ WHERE id = #{id}
|
|
|
+ <!-- 数据权限控制 -->
|
|
|
+ AND (admin_id = #{params.userId} OR 1 = 0)
|
|
|
+ </update>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|