You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.1 KiB

<?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.forum.dao.MessageDao">
<resultMap id="messages" type="message">
<id property="id" column="id"/>
<result property="content" column="content"/>
<result property="name" column="name"/>
<result property="msg_avatar" column="msg_avatar"/>
<result property="createTime" column="create_time"/>
<collection property="replies" ofType="reply">
<id property="id" column="rid"/>
<result property="content" column="con"/>
<!-- <result property="reply_name" column="reply_name"/>-->
<result property="names" column="names"/>
<result property="createTime" column="ctime"/>
<result property="avatar" column="avatar"/>
<result property="mes_id" column="mes_id"/>
</collection>
</resultMap>
<delete id="deleteById">
delete from message where id=#{id}
</delete>
<select id="findAllMessage" resultMap="messages">
select m.*,
r.id rid,
r.content con,
r.names names,
r.create_time ctime,
r.avatar,
r.mes_id
from message m left join reply r on r.mes_id=m.id
order by m.create_time desc
</select>
<select id="getIndexMessage" resultMap="messages">
select m.*
from message m
order by m.create_time desc
limit 0,6
</select>
<select id="findAll" resultType="com.forum.entity.Message">
select id,content,name, create_time from message
</select>
<insert id="saveMessage" parameterType="message">
insert into message (content,name,create_time,msg_avatar)
values (#{content},#{name},#{createTime},#{msg_avatar})
</insert>
<insert id="saveReplyMessage" parameterType="reply">
insert into reply (content,names,create_time,mes_id,avatar)
values (#{content},#{names},#{createTime},#{mes_id},#{avatar})
</insert>
</mapper>