관리 메뉴

거니의 velog

(7) MyBatis 세팅 본문

대덕인재개발원_2nd project

(7) MyBatis 세팅

Unlimited00 2023. 10. 20. 11:11

[mybatis-config.xml]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
	PUBLIC "-//mybatis.org/DTD Config 3.0//EN"
	"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

	<properties resource="kr/or/ddit/mybatis/config/dbInfo.properties"></properties>

	<settings>
<!-- 		<setting name="mapUnderscoreToCamelCase" value="true"/> -->
		<setting name="jdbcTypeForNull" value="NULL"></setting>
	</settings>

	<typeAliases>
		<typeAlias type="kr.or.ddit.vo.EmployeeVO" alias="empVo" />
		<typeAlias type="kr.or.ddit.vo.FileInfoVO" alias="fileVo" />
		<typeAlias type="kr.or.ddit.vo.SealInfoVO" alias="sealVo" />
		<typeAlias type="kr.or.ddit.vo.SignLineVO" alias="signLineVo" />
		<typeAlias type="kr.or.ddit.vo.SignAcceptVO" alias="signAccVo" />
	</typeAliases>

	<environments default="oracleDev">
		<environment id="oracleDev">
			<transactionManager type="JDBC"></transactionManager>
			<dataSource type="POOLED">
				<property name="driver" value="${driver}" />
				<property name="url" value="${url}" />
				<property name="username" value="${user}" />
				<property name="password" value="${pass}" />
			</dataSource>
		</environment>
	</environments>

	<mappers>
		<mapper resource="kr/or/ddit/mybatis/mappers/employee-mapper.xml" />
		<mapper resource="kr/or/ddit/mybatis/mappers/fileinfo-mapper.xml" />
	</mappers>
	
</configuration>

[employee-mapper.xml]

<?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="employee">
	
	<select id="selectEmpNo" parameterType="String" resultType="String">
		select empno from employee where empno = #{empno}
	</select>
	
	<select id="loginSelect" parameterType="empVo" resultType="empVo">
		<!-- select * from employee where empno = #{empno} and emppass = #{emppass} -->
		select * from employee a, jobinfo b, posinfo c 
		where a.empjob = b.empjob and a.emppos = c.emppos
		and empno = #{empno} and emppass = #{emppass}
	</select>
	
	<select id="selectEmpPass" parameterType="String" resultType="empVo">
		select empemail, emppass from employee where empno = #{empno}
	</select>
	
	<select id="dupChkEmpNo" parameterType="String" resultType="String">
		select max(empno) as maxempno from employee where empno like #{empno} || '%'
	</select>
	
	<insert id="insertEmployee" parameterType="empVo">
		INSERT INTO employee (empno, empname, empjob, empcostat, empsal, emphp1, emphp2, emphp3, empaddr, empjoindate, empretiredate, emppass, empemail, emppos, emppercol, empphoto) 
		VALUES (#{empno}, #{empname}, #{empjob}, '재직중', #{empsal}, #{emphp1}, #{emphp2}, #{emphp3}, #{empaddr}, sysdate, null, #{emppass}, #{empemail}, #{emppos}, #{emppercol}, #{empphoto})
	</insert>
	
	<select id="getAllEmpList" resultType="empVo">
		select * from employee
	</select>
	
	<select id="empUpdateInfo" parameterType="String" resultType="empVo">
		select * from employee where empno = #{empno}
	</select>
	
	<delete id="deleteEmp" parameterType="String">
		delete from employee
		where empno = #{empno}
	</delete>
	
	<update id="updateEmp" parameterType="empVo">
		UPDATE employee
		SET
		    empname = #{empname},
		    empjob = #{empjob},
		    empsal = #{empsal},
		    emphp1 = #{emphp1},
		    emphp2 = #{emphp2},
		    emphp3 = #{emphp3},
		    empaddr = #{empaddr},
		    empjoindate = sysdate,
		    emppass = #{emppass},
		    empemail = #{empemail},
		    emppos = #{emppos},
		    emppercol = #{emppercol},
		    empphoto = #{empphoto}
		WHERE
		    empno = #{empno}
	</update>
	
	<select id="signJobSearch" parameterType="String" resultType="empVo">
		select * from employee where empjob = #{empjob}
	</select>
	
	<insert id="insertSignLine" parameterType="signLineVo">
		INSERT INTO signlineinfo (signno, oriempno, empnofir, empnamefir, empjobfir, empposfir, empnosec, empnamesec, empjobsec, emppossec, empnothi, empnamethi, empjobthi, empposthi) 
		VALUES (sealinfo_seq.nextval, #{oriempno}, #{empnofir}, #{empnamefir}, #{empjobfir}, #{empposfir}, #{empnosec}, #{empnamesec}, #{empjobsec}, #{emppossec}, #{empnothi}, #{empnamethi}, #{empjobthi}, #{empposthi})
	</insert>
	
	<select id="signInsertInfo" parameterType="String" resultType="signLineVo">
		select * from signlineinfo where oriempno = ${oriempno}
	</select>
	
	<delete id="deleteSignLine" parameterType="String">
		DELETE FROM signlineinfo
		WHERE oriempno = #{oriempno}
	</delete>
	
</mapper>

[fileinfo-mapper.xml]

<?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="fileinfo">
	
	<insert id="insertFileInfo" parameterType="fileVo">
		INSERT INTO fileinfo (fileno, filewriter, originfilename, savefilename, filesize, filedate) 
		VALUES (fileinfo_seq.nextval, #{filewriter}, #{originfilename}, #{savefilename}, #{filesize}, sysdate)
	</insert>
	
	<select id="getAllFileInfo" resultType="fileVo">
		select * from fileinfo
	</select>
	
	<select id="getFileInfo" parameterType="int" resultType="fileVo">
		select * from fileinfo where fileno = #{fileno}
	</select>
	
	<select id="getFileNoMax" resultType="int">
		select max(fileno) from fileinfo
	</select>
	
	<delete id="deleteFile" parameterType="int">
		DELETE FROM fileinfo 
		WHERE fileno = #{fileno}
	</delete>
	
	<insert id="insertSeal" parameterType="sealVo">
		INSERT INTO sealinfo (sealno, fileno, empno) 
		VALUES (sealinfo_seq.nextval, #{fileno}, #{empno})
	</insert>
	
	<select id="sealInsertInfo" parameterType="String" resultType="sealVo">
		select * from sealinfo where empno = ${empno}
	</select>
	
	<delete id="deleteSeal" parameterType="String">
		delete from sealinfo where empno = ${empno}
	</delete>
	
</mapper>

'대덕인재개발원_2nd project' 카테고리의 다른 글

(9) script.js  (0) 2023.10.20
(8) CommonDAO, CommonService 세팅  (0) 2023.10.20
(6) common.css  (0) 2023.10.20
(5) 회원 삭제 페이지  (0) 2023.10.20
(4) 회원 수정 페이지  (0) 2023.10.20