<?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.ruoyi.cms.mapper.AppReviewJobMapper">

    <resultMap type="AppReviewJob" id="AppReviewJobResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="jobId"    column="job_id"    />
        <result property="reviewDate"    column="review_date"    />
    </resultMap>

    <sql id="selectAppReviewJobVo">
        select id, user_id, work_id, review_date from app_review_job
    </sql>

    <select id="selectAppReviewJobList" parameterType="AppReviewJob" resultMap="AppReviewJobResult">
        <include refid="selectAppReviewJobVo"/>
        <where>  del_flag = '0'
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="jobId != null "> and job_id = #{jobId}</if>
            <if test="reviewDate != null "> and review_date = #{reviewDate}</if>
        </where>
    </select>
    <select id="review" resultType="com.ruoyi.cms.domain.vo.JobReviewVO">
        select j.*,r.review_date
        from job as j
        inner join app_review_job as r on r.job_id = j.job_id and user_id = #{userId}
        where j.del_flag = '0'
        and r.del_flag = '0'
        <if test="jobQuery.startDate != null "> and r.review_date &gt; concat(#{jobQuery.startDate},' 23:59:59')</if>
        <if test="jobQuery.endDate != null "> and r.review_date &lt; concat(#{jobQuery.endDate},' 23:59:59')</if>
        <if test="jobQuery.jobTitle != null and jobQuery.jobTitle!=''"> and j.job_title like concat('%',#{jobQuery.jobTitle},'%') </if>
        order by r.review_date desc
    </select>
    <select id="reviewArray" resultType="com.ruoyi.cms.domain.AppReviewJob">
        select r.review_date
        from job as j
        inner join app_review_job as r on r.job_id = j.job_id and user_id = #{userId}
        where j.del_flag = '0'
        and r.del_flag = '0'
        group by r.review_date
    </select>

    <select id="selectAppReviewJobListJob" parameterType="AppReviewJob" resultType="com.ruoyi.cms.domain.Job">
        select b.*,a.review_date as shareTime from app_review_job a inner join job b on a.job_id=b.job_id and b.del_flag='0'
        <where>  a.del_flag = '0'
            <if test="jobId != null "> and a.job_id = #{jobId}</if>
            <if test="userId != null "> and a.user_id = #{userId}</if>
        </where>
    </select>

</mapper>