<?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.energy.manage.service.mappers.company.WindCompanyMapper">

    <sql id="BASE_COMPANY_SQL">
      wc.id AS id,
      wc.company_code AS companyCode,
      wc.company_name AS companyName,
      wc.parent_id AS parentId,
      wc.state AS state,
      wc.province_id AS provinceId,
      wc.described as described,
      wc.parentid_depth AS parentidDepth,
      wc.sort AS sort,
      wc.del_state AS delState,
      wc.create_by AS createBy,
      wc.create_time AS createTime,
      wc.update_by AS updateBy,
      wc.update_time AS updateTime
    </sql>

    <select id="getAllWindCompany" resultType="com.energy.manage.service.domain.vo.company.WindCompanyPageVo">
        SELECT <include refid="BASE_COMPANY_SQL"/>
        FROM wind_company wc
        ORDER BY wc.id ASC
    </select>


    <!-- 排序 - 批量更改顺序 -->
    <update id="updateWindCompanySort" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index">
            update
            wind_company set
            parent_id = #{item.parentId},
            sort=#{item.sort}
            where 1=1
            and id =#{item.id};
        </foreach>
    </update>

</mapper>
