<?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.jeeplus.test.jobPosion.mapper.JobPositionMapper">
  <resultMap id="BaseResultMap" type="com.jeeplus.test.jobPosion.domain.JobPosition">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="no" jdbcType="VARCHAR" property="no" />
    <result column="office_id" jdbcType="VARCHAR" property="officeId" />
    <result column="staff_num" jdbcType="INTEGER" property="staffNum" />
    <result column="position_id" jdbcType="VARCHAR" property="positionId" />
    <result column="qualification" jdbcType="VARCHAR" property="qualification" />
    <result column="obligation" jdbcType="VARCHAR" property="obligation" />
    <result column="use_flag" jdbcType="VARCHAR" property="useFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    jp.id,
    jp.create_by,
    jp.create_date,
    jp.update_by,
    jp.update_date,
    jp.remarks,
    jp.del_flag,
    jp.`name`,
    jp.`no`,
    jp.office_id,
    jp.staff_num,
    jp.position_id,
    jp.qualification,
    jp.obligation,
    jp.use_flag
  </sql>

  <sql id="Sql_List">
    jp.id,
    jp.create_by,
    jp.create_date,
    jp.update_by,
    jp.update_date,
    jp.remarks,
    jp.del_flag,
    jp.`name`,
    jp.`no`,
    jp.staff_num,
    jp.qualification,
    jp.obligation,
    jp.use_flag
  </sql>


  <select id="findList" resultType="com.jeeplus.test.jobPosion.domain.JobPosition">
    select
    <include refid="Sql_List"></include>,
    so.name as office_id,
    p.name as position_id
    from job_position jp
    left join sys_office so on so.id = jp.office_id
    left join `position` p on p.id = jp.position_id
    ${ew.customSqlSegment}
    order by jp.create_date desc
  </select>

  <update id="updateUseFlagById">
    <foreach collection="ids" item="item" separator=";">
      update job_position jp
      set jp.use_flag = #{useFlag}
      where jp.id = #{item}
    </foreach>
  </update>

</mapper>