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

45 lines
3.0 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">
<resultMap id="BulletinMap" type="com.zsc.edu.gateway.modules.notice.entity.Bulletin" autoMapping="true">
<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"/>
<collection property="attachments" ofType="com.zsc.edu.gateway.modules.attachment.entity.Attachment" autoMapping="true" columnPrefix="attachment_">
<id column="id" jdbcType="BIGINT" property="id"/>
<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"/>
</collection>
</resultMap>
<select id="selectByBulletinId" resultMap="BulletinMap">
select sb.id,sb.title,sb.state,sb.top,sb.edit_user_id as edit_user_name,sb.edit_time,sb.publish_user_id as publish_user_name,sb.publish_time,sb.close_user_id as close_user_name,sb.close_time,
sb.content,sb.create_by,sb.create_time,sb.update_by,sb.update_time,a.*
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 sb.id=#{bulletinId}
</select>
<select id="selectAll" resultMap="BulletinMap">
select sb.id,sb.title,sb.state,sb.top,sb.edit_user_id as edit_user_name,sb.edit_time,sb.publish_user_id as publish_user_name,sb.publish_time,sb.close_user_id as close_user_name,sb.close_time,
sb.content,sb.create_by,sb.create_time,sb.update_by,sb.update_time,a.*
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
</select>
</mapper>