board2mapper
<?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="org.lhr.mapper.Board2Mapper">
<!-- 글쓰기를 하기 위한 dao (insert) -->
<insert id="write2">
insert into tbl_board (title, content,writer)
values(#{title}, #{content},#{writer});
</insert>
<select id="list2" resultType="org.lhr.DTO.BoardDTO">
select *
from(
select @rownum:=@rownum+1 as rownum, b.*
from(select @rownum:=0) as tmp, tbl_board as b
<if test='type == "t"'>
where title like concat('%',#{keyword},'%')
</if>
<if test='type == "c"'>
where content like concat('%',#{keyword},'%')
</if>
<if test='type == "w"'>
where writer like concat('%',#{keyword},'%')
</if>
<if test='type == "tc"'>
where title like concat('%',#{keyword},'%')
or content like concat('%',#{keyword},'%')
</if>
order by bno desc
) as pagingboard
<![CDATA[where rownum>(#{pageNum}-1)*#{amount} and rownum<=#{pageNum}*#{amount}]]>
</select>
<select id="detail2" resultType="org.lhr.DTO.BoardDTO">
select * from tbl_board where bno=#{bno};
</select>
<update id="update2">
update tbl_board set title=#{title}, content=#{content}, updatedate=sysdate() where bno=#{bno};
</update>
<delete id="delete2">
delete from tbl_board where bno=#{bno};
</delete>
<select id="getTotal" resultType="int">
select count(*) from lbm_board
</select>
</mapper>
boardmapper
<?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="org.lhr.mapper.BoardMapper">
<insert id="boardWrite">
<selectKey keyProperty="bno" order="BEFORE" resultType="int">
select max(bno)+1 bno from tbl_board
</selectKey>
insert into tbl_board(title,content,writer)
values (#{title},#{content},#{writer})
</insert>
<select id="detail" resultType="org.lhr.DTO.BoardDTO">
select * from tbl_board where bno=#{bno};
</select>
<select id="getList" resultType="org.lhr.DTO.BoardDTO">
select *
from(
select @rownum:=@rownum+1 as rownum, b.*
from(select @rownum:=0) as tmp, tbl_board as b
<if test='type == "t"'>
where title like concat('%',#{keyword},'%')
</if>
<if test='type == "c"'>
where content like concat('%',#{keyword},'%')
</if>
<if test='type == "w"'>
where writer like concat('%',#{keyword},'%')
</if>
<if test='type == "tc"'>
where title like concat('%',#{keyword},'%')
or content like concat('%',#{keyword},'%')
</if>
order by bno desc
) as pagingboard
<![CDATA[where rownum>(#{pageNum}-1)*#{amount} and rownum<=#{pageNum}*#{amount}]]>
</select>
<!-- 게시판 글쓰기 insert -->
<insert id="boardInsert">
insert into tbl_board (title,content,writer)
values(#{title},#{content},#{writer});
</insert>
<!-- 게시판 update -->
<update id="boardUpdate">
UPDATE tbl_board SET writer = #{writer} where bno=#{bno};
</update>
<!-- 게시판 delete -->
<delete id="boardDelete">
DELETE FROM tbl_board WHERE bno=#{bno};
</delete>
<select id="getTotal" resultType="int">
select count(*) from lbm_board
</select>
</mapper>
lbmmapper
<?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="org.lhr.mapper.LBMMapper">
<insert id="addmember">
insert into LBM_member(id,pw,name,gender,homephone,phone,email)
values(#{id},#{pw},#{name},#{gender},#{homephone},#{phone},#{email});
</insert>
<insert id="write">
insert into LBM_board(title,content) values(#{title},#{content});
</insert>
<update id="modify">
update LBM_board set title=#{title},content=#{content} where bno=#{bno};
</update>
<delete id="delete">
delete from LBM_board where bno=#{bno};
</delete>
<select id="boardlist" resultType="org.lhr.DTO.LBMboardDTO">
select * from LBM_board;
</select>
<select id="boarddetail" resultType="org.lhr.DTO.LBMboardDTO">
select * from LBM_board where bno=#{bno};
</select>
</mapper>
membermapper
<?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="org.lhr.mapper.MemberMapper">
<select id="memberlist" resultType="org.lhr.DTO.MemberDTO">
select *
from(
select @rownum:=@rownum+1 as rownum, b.*
from(select @rownum:=0) as tmp, member2 as b
<if test='type=="i"'>
where id like concat('%',#{keyword},'%')
</if>
<if test='type=="a"'>
where addr like concat('%',#{keyword},'%')
</if>
order by id asc
) as pagingmember
<![CDATA[where rownum>(#{pageNum}-1)*#{amount} and rownum<=#{pageNum}*#{amount}]]>
</select>
<select id="getTotal" resultType="int">
select count(*) from member2
</select>
<select id="memberdetail" resultType="org.lhr.DTO.MemberDTO">
select * from member2 where id=#{id};
</select>
<update id="memberupdate">
update member2 set addr=#{addr},password=#{password} where id=#{id};
</update>
<delete id="memberdelete">
delete from member2 where id=#{id};
</delete>
<insert id="memberinsert">
insert into member2 (addr,id,password) values(#{addr},#{id},#{password});
</insert>
</mapper>
timemapper
<?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="org.lhr.mapper.TimeMapper">
<select id="getTime2" resultType="String">
select sysdate()
</select>
</mapper>
'Programming > 게시판 만들기' 카테고리의 다른 글
[게시판 만들기] uploadcontroller 0 (0) | 2021.02.15 |
---|---|
[게시판 만들기] js (0) | 2021.02.14 |
[게시판 만들기] service & implement (0) | 2021.02.14 |
[게시판 만들기] MAPPER (0) | 2021.02.14 |
[게시판 만들기] DTO (0) | 2021.02.14 |