iot-gateway/src/main/resources/mappers/noticeMappers/BulletinMapper.xml
zhuangtianxiang 528318ff0a refactor(notice): 重构公告模块
- 优化公告查询接口,新增分页查询功能
- 重构公告发布逻辑,支持批量发布
- 完善公告详情接口,增加用户信息
- 新增公告删除接口
- 优化公告状态切换逻辑
-调整公告附件处理方式
2024-12-09 16:16:04 +08:00

65 lines
3.5 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.zsc.edu.gateway.modules.notice.repo.BulletinRepository">
<resultMap id="BulletinMap" type="com.zsc.edu.gateway.modules.notice.vo.BulletinVo">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="state" jdbcType="INTEGER" property="state"/>
<result column="top" jdbcType="BOOLEAN" property="top"/>
<result column="edit_time" jdbcType="TIMESTAMP" property="editTime"/>
<result column="publish_time" jdbcType="TIMESTAMP" property="publishTime"/>
<result column="close_time" jdbcType="TIMESTAMP" property="closeTime"/>
<result column="content" jdbcType="VARCHAR" property="content"/>
<result column="edit_user_id" jdbcType="BIGINT" property="editUserId"/>
<result column="publish_user_id" jdbcType="BIGINT" property="publishUserId"/>
<result column="close_user_id" jdbcType="BIGINT" property="closeUserId"/>
<result column="edit_user_name" jdbcType="VARCHAR" property="editUsername"/>
<result column="publish_user_name" jdbcType="VARCHAR" property="publishUsername"/>
<result column="close_user_name" jdbcType="VARCHAR" property="closeUsername"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="create_time" jdbcType="DATE" property="createTime"/>
<result column="update_time" jdbcType="DATE" property="updateTime"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<collection property="attachmentVos" ofType="com.zsc.edu.gateway.modules.attachment.vo.AttachmentVo"
autoMapping="true" columnPrefix="attachment_">
<id column="id" jdbcType="VARCHAR" property="attachmentId"/>
<result column="url" jdbcType="VARCHAR" property="url"/>
<result column="file_ame" jdbcType="VARCHAR" property="fileName"/>
</collection>
</resultMap>
<select id="selectByBulletinId" resultMap="BulletinMap">
SELECT sb.*, a.id as attachment_id,a.url as attachment_url,a.file_name as attachment_file_name
FROM
sys_bulletin sb
LEFT JOIN sys_bulletin_attach sba ON sb.id = sba.bulletin_id
LEFT JOIN attachment a ON a.id = sba.attachment_id
<where>
<if test="bulletinId !=null">
sb.id = #{bulletinId}
</if>
</where>
</select>
<select id="selectPageByConditions" resultMap="BulletinMap">
SELECT sb.*, a.id as attachment_id,a.file_name as attachment_file_name,a.url as attachment_url
FROM
sys_bulletin sb
LEFT JOIN sys_bulletin_attach sba ON sb.id = sba.bulletin_id
LEFT JOIN attachment a ON a.id = sba.attachment_id
<where>
<if test="query.title != null and query.title != ''">
AND sb.title LIKE CONCAT('%', #{query.title}, '%')
</if>
<if test="query.state != null">
AND sb.state = #{query.state}
</if>
<if test="query.publishTimeBegin != null and query.publishTimeEnd != null">
AND sb.publish_time BETWEEN #{query.publishTimeBegin} AND #{query.publishTimeEnd}
</if>
</where>
order by sb.top DESC,sb.publish_time DESC,sb.create_time DESC
</select>
</mapper>