iot-gateway/src/main/resources/mappers/noticeMappers/BulletinMapper.xml

59 lines
3.5 KiB
XML
Raw Normal View History

2024-11-16 12:17:07 +08:00
<?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">
2024-11-26 16:16:08 +08:00
<resultMap id="BulletinMap" type="com.zsc.edu.gateway.modules.notice.vo.BulletinVo" autoMapping="true">
2024-11-16 12:17:07 +08:00
<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"/>
2024-11-26 16:16:08 +08:00
<result column="file_name" jdbcType="VARCHAR" property="fileName"/>
<result column="mime_type" jdbcType="VARCHAR" property="mimeType"/>
<result column="upload_time" jdbcType="TIMESTAMP" property="uploadTime"/>
<result column="url" jdbcType="VARCHAR" property="url"/>
<result column="is_read" jdbcType="BOOLEAN" property="isRead"/>
2024-11-16 12:17:07 +08:00
</resultMap>
<select id="selectByBulletinId" resultMap="BulletinMap">
2024-11-26 16:16:08 +08:00
select sb.*,a.id as attachment_id,a.file_name as attachment_file_name,a.mime_type as attachment_mime_type,a.url as attachment_url,a.upload_time as attachment_upload_time,sbu.is_read
2024-11-16 12:17:07 +08:00
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
2024-11-26 16:16:08 +08:00
left join sys_bulletin_user sbu on sb.id=sbu.bulletin_id
left join sys_user su on sbu.user_id=su.id
where sb.id=#{bulletinId}
</select>
2024-11-16 12:17:07 +08:00
<select id="selectPageByConditions" resultType="com.zsc.edu.gateway.modules.notice.vo.BulletinVo">
select sb.*,a.id as attachment_id,a.file_name as attachment_file_name,a.mime_type as attachment_mime_type,a.url
as attachment_url,a.upload_time as attachment_upload_time,sbu.is_read
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
left join sys_bulletin_user sbu on sb.id=sbu.bulletin_id
left join sys_user su on sbu.user_id=su.id where 1=1
<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>
<if test="query.isRead != null">
AND sbu.is_read = #{query.isRead}
</if>
order by sb.top DESC,sb.publish_time DESC,sb.create_time DESC
2024-11-16 12:17:07 +08:00
</select>
</mapper>