<?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.PositionMapper">
  <resultMap id="BaseResultMap" type="com.jeeplus.test.jobPosion.domain.Position">
    <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="description" jdbcType="VARCHAR" property="description" />
    <result column="category_id" jdbcType="VARCHAR" property="categoryId" />
  </resultMap>
  <sql id="Base_Column_List">
    p.id,
    p.create_by,
    p.create_date,
    p.update_by,
    p.update_date,
    p.remarks,
    p.del_flag,
    p.`name`,
    p.description,
    p.category_id
  </sql>

  <sql id="Sql_List">
    p.id,
    p.create_by,
    p.create_date,
    p.update_by,
    p.update_date,
    p.remarks,
    p.del_flag,
    p.`name`,
    p.description
  </sql>

  <select id="findList" resultType="com.jeeplus.test.jobPosion.domain.Position">
    select
    <include refid="Sql_List"></include>,
    pc.name as category_id
    from `position` p
    left join position_category pc on p.category_id = pc.id
    ${ew.customSqlSegment}
  </select>

  <update id="updateSortByIdList">
    <foreach collection="list" separator=";" item="item">
      update `position`
      set sort = #{item.sort}
      where id = #{item.id}
    </foreach>
  </update>
</mapper>