package com.winsun.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.winsun.bean.PackageUpgrade;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.mapper.Wrapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: chancy
 * @Date: 2020/2/25 11:31
 */
@Mapper
@Component
public interface AppMapper extends BaseMapper<PackageUpgrade> {

    @Select("<script>SELECT * FROM `hhr_xyzx_yd_yrym_list` <where> ${ew.sqlSegment} </where> </script>")
    List<Map<String, Object>> selectPackage(@Param("ew") Wrapper<PackageUpgrade> wrapper);

    @Insert("insert into `hhr_order_history` values(#{id},#{status},#{date},#{operator}) ")
    Integer inserOrderHis(@Param("id") String id, @Param("status") String status, @Param("date") Date date, @Param("operator") String operator);

    @Select("select *  from `hhr_order_history` where  order_id = #{oredrId}")
    List<Map<String, Object>> selectOrderHis(String oredrId);

    @Select("select school_id schoolId from `hhr_user_school` where  user_id = #{partner}")
    String selectSchoolId(String partner);

    @Select("select school_name schoolName from `hhr_school` where  id = #{schoolId}")
    String selectSchoolById(String schoolId);

    @Select("select user_id userId from `hhr_supervisor_school` where  school = #{schoolId} ORDER BY user_id asc")
    List<String> selectsupervisorBySchool(String schoolId);

    @Select("select package_id packageId from `hhr_school_package` where  school_id = #{schoolId}")
    List<String> selectPackageId(String schoolId);

    @Select("SELECT school FROM hhr_supervisor_school WHERE user_id = #{userId}")
    List<String> selectManagerSchool(@Param("userId") String userId);

    @Select("<script> SELECT user_id AS userId FROM hhr_user_school WHERE school_id in" +
            "<foreach collection='schoolIds' item='item' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            " </script>")
    List<String> selectUserBySchool(@Param("schoolIds") List<String> schoolIds);


    @Select("select * from hhr_ycsll_yrym_list where acc_nbr = #{acc_nbr}")
    List<Map<String,Object>> selectYCSLL(@Param("acc_nbr") String acc_nbr);
}
