smartGeoinfoOriginal/target/classes/egovframework/mapper/sgis/surveysystem/SurveyResponseMapper.xml

62 lines
2.1 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="sgis.surveysystem.mapper.SurveyResponseMapper">
<resultMap id="surveyResponseResultMap" type="sgis.surveysystem.domain.SurveyResponse">
<id property="responseId" column="response_id"/>
<result property="surveyId" column="survey_id"/>
<result property="respondentId" column="respondent_id"/>
<result property="submittedAt" column="submitted_at"/>
</resultMap>
<insert id="insertSurveyResponse" parameterType="sgis.surveysystem.domain.SurveyResponse">
INSERT INTO tb_survey_responses (
response_id,
survey_id,
respondent_id,
submitted_at
) VALUES (
#{responseId, jdbcType=OTHER},
#{surveyId, jdbcType=OTHER},
#{respondentId, jdbcType=OTHER},
#{submittedAt}
)
</insert>
<select id="findSurveyResponseById" resultMap="surveyResponseResultMap">
SELECT
response_id,
survey_id,
respondent_id,
submitted_at
FROM tb_survey_responses
WHERE response_id = #{responseId, jdbcType=OTHER}
</select>
<select id="findResponsesBySurveyId" resultMap="surveyResponseResultMap">
SELECT
response_id,
survey_id,
respondent_id,
submitted_at
FROM tb_survey_responses
WHERE survey_id = #{surveyId, jdbcType=OTHER}
ORDER BY submitted_at DESC
</select>
<select id="findResponsesByRespondentId" resultMap="surveyResponseResultMap">
SELECT
response_id,
survey_id,
respondent_id,
submitted_at
FROM tb_survey_responses
WHERE respondent_id = #{respondentId, jdbcType=OTHER}
ORDER BY submitted_at DESC
</select>
<delete id="deleteSurveyResponse">
DELETE FROM tb_survey_responses
WHERE response_id = #{responseId, jdbcType=OTHER}
</delete>
</mapper>