105 lines
4.2 KiB
XML
105 lines
4.2 KiB
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="com.zioinfo.hrm.recruitment.RecruitmentMapper">
|
|
|
|
<select id="findPostings" resultType="map">
|
|
SELECT jp.id, jp.title, jp.department_id, d.dept_name,
|
|
jp.employment_type, jp.headcount, jp.status,
|
|
jp.start_date, jp.end_date, jp.created_by, jp.created_at,
|
|
(SELECT COUNT(*) FROM hrm_applicants a WHERE a.posting_id=jp.id) AS applicant_count
|
|
FROM hrm_job_postings jp
|
|
LEFT JOIN hrm_departments d ON jp.department_id=d.id
|
|
<where>
|
|
<if test="status != null and status != ''">AND jp.status=#{status}</if>
|
|
<if test="keyword != null and keyword != ''">AND jp.title ILIKE '%'||#{keyword}||'%'</if>
|
|
</where>
|
|
ORDER BY jp.created_at DESC
|
|
LIMIT #{limit} OFFSET #{offset}
|
|
</select>
|
|
|
|
<select id="countPostings" resultType="long">
|
|
SELECT COUNT(*) FROM hrm_job_postings jp
|
|
<where>
|
|
<if test="status != null and status != ''">AND jp.status=#{status}</if>
|
|
<if test="keyword != null and keyword != ''">AND jp.title ILIKE '%'||#{keyword}||'%'</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="findPostingById" resultType="map">
|
|
SELECT jp.*, d.dept_name FROM hrm_job_postings jp
|
|
LEFT JOIN hrm_departments d ON jp.department_id=d.id
|
|
WHERE jp.id=#{id}
|
|
</select>
|
|
|
|
<insert id="insertPosting">
|
|
INSERT INTO hrm_job_postings (title, department_id, employment_type, headcount, description, requirements, status, start_date, end_date, created_by)
|
|
VALUES (#{title}, #{departmentId}, #{employmentType}, #{headcount}, #{description}, #{requirements}, #{status}, #{startDate}, #{endDate}, #{createdBy})
|
|
</insert>
|
|
|
|
<update id="updatePosting">
|
|
UPDATE hrm_job_postings SET
|
|
title=#{title}, department_id=#{departmentId}, employment_type=#{employmentType},
|
|
headcount=#{headcount}, description=#{description}, requirements=#{requirements},
|
|
start_date=#{startDate}, end_date=#{endDate}, updated_at=NOW()
|
|
WHERE id=#{id}
|
|
</update>
|
|
|
|
<update id="updatePostingStatus">
|
|
UPDATE hrm_job_postings SET status=#{status}, updated_at=NOW() WHERE id=#{id}
|
|
</update>
|
|
|
|
<select id="findApplicants" resultType="map">
|
|
SELECT a.id, a.posting_id, a.applicant_name, a.email, a.status,
|
|
a.apply_date, a.memo, a.created_at
|
|
FROM hrm_applicants a
|
|
<where>
|
|
<if test="postingId != null">AND a.posting_id=#{postingId}</if>
|
|
<if test="status != null and status != ''">AND a.status=#{status}</if>
|
|
</where>
|
|
ORDER BY a.apply_date DESC
|
|
</select>
|
|
|
|
<select id="findApplicantById" resultType="map">
|
|
SELECT a.*, jp.title AS posting_title
|
|
FROM hrm_applicants a
|
|
JOIN hrm_job_postings jp ON a.posting_id=jp.id
|
|
WHERE a.id=#{id}
|
|
</select>
|
|
|
|
<insert id="insertApplicant">
|
|
INSERT INTO hrm_applicants (posting_id, applicant_name, email, phone, resume_url, cover_letter, status, apply_date, created_by)
|
|
VALUES (#{postingId}, #{applicantName}, #{email}, #{phone}, #{resumeUrl}, #{coverLetter}, #{status}, NOW(), #{createdBy})
|
|
</insert>
|
|
|
|
<update id="updateApplicantStatus">
|
|
UPDATE hrm_applicants SET status=#{status}, memo=#{memo}, updated_at=NOW() WHERE id=#{id}
|
|
</update>
|
|
|
|
<select id="findInterviews" resultType="map">
|
|
SELECT i.id, i.posting_id, i.applicant_id, a.applicant_name,
|
|
i.interview_type, i.scheduled_at, i.location, i.interviewers,
|
|
i.result, i.notes, i.created_by
|
|
FROM hrm_interviews i
|
|
JOIN hrm_applicants a ON i.applicant_id=a.id
|
|
<where>
|
|
<if test="postingId != null">AND i.posting_id=#{postingId}</if>
|
|
<if test="applicantId != null">AND i.applicant_id=#{applicantId}</if>
|
|
</where>
|
|
ORDER BY i.scheduled_at
|
|
</select>
|
|
|
|
<insert id="insertInterview">
|
|
INSERT INTO hrm_interviews (posting_id, applicant_id, interview_type, scheduled_at, location, interviewers, created_by)
|
|
VALUES (#{postingId}, #{applicantId}, #{interviewType}, #{scheduledAt}, #{location}, #{interviewers}, #{createdBy})
|
|
</insert>
|
|
|
|
<update id="updateInterview">
|
|
UPDATE hrm_interviews SET
|
|
interview_type=#{interviewType}, scheduled_at=#{scheduledAt},
|
|
location=#{location}, result=#{result}, notes=#{notes}, updated_at=NOW()
|
|
WHERE id=#{id}
|
|
</update>
|
|
|
|
</mapper>
|