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.

55 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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.TagDao">
<select id="getTag" resultType="Tag">
select id,name from tag where id = #{id}
</select>
<insert id="saveTag" parameterType="Tag">
insert into tag values (#{id},#{name});
</insert>
<!--两个id可能会相冲取别名即可-->
<resultMap id="tags" type="Tag">
<id property="id" column="tid"/>
<result property="name" column="name"/>
<collection property="forums" ofType="Forum">
<id property="id" column="bid"/>
<result property="title" column="title"/>
</collection>
</resultMap>
<select id="getAllTag" resultType="com.forum.entity.Tag">
select * from tag
</select>
<select id="getForumTag" resultMap="tags">
select t.id tid, t.name, b.id bid, b.title
from tag t, forum b, forum_tags bt
where t.id = bt.tag_id and b.id = bt.forum_id
</select>
<select id="getTagByName" resultType="Tag">
select * from tag where name = #{name}
</select>
<select id="getTagById" resultType="Tag">
select * from tag where id = #{id}
</select>
<select id="countTag" resultType="java.lang.Integer">
select count(*) from tag
</select>
<delete id="deleteTag">
delete from tag where id = #{id}
</delete>
<update id="updateTag" parameterType="Tag">
update tag set name = #{name} where id = #{id};
</update>
</mapper>