package com.winsun.mapper;

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

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

@Mapper
@Component
public interface ProductMapper extends BaseMapper<Product> {
    @Select("SELECT * FROM `product_manage` WHERE product_id = (SELECT b.`bandproduct_id` FROM hhr_user_school a  LEFT JOIN hhr_school b ON a.`school_id`=b.`id`  WHERE a.user_id=#{partner})")
    List<Map<String, Object>> findMoreUniversity(@Param("partner") String partner);

    @Select(" SELECT pm.product_university as universityName,pm.product_region as productRegion," +
            " pm.product_title productName " +
            " FROM hhr_user u " +
            " LEFT JOIN hhr_user_school us ON u.`id`=us.`user_id`" +
            " LEFT JOIN hhr_school s ON us.`school_id`=s.`id` " +
            " LEFT JOIN product_manage pm ON s.bandproduct_id=pm.product_id" +
            " WHERE u.`id`= #{id}")
    List<Map<String,Object>> queryProductById(@Param("id")String id);

}
