package cn.com.ty.lift.enterprise.region.dao.mapper;

import cn.com.ty.lift.enterprise.region.dao.entity.Region;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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


/**
 * <p>
 * 区域表 Mapper 接口
 * </p>
 *
 * @author wang-hai-cheng
 * @since 2019-12-09
 */
public interface RegionMapper extends BaseMapper<Region> {
    @Select("select city_code cityCode, province_code provinceCode from region where id = #{id}")
    List<Map<String, Object>> selectProjectRegions(@Param("id") Long id);

    @Select("select user_id userId,name from user_info")
    List<Map<String, Object>> selectUserInfo();

    @Select("select region_id regionId,num from project")
    List<Map<String, Object>> selectProjects();

    @Select("select count(*) count from project where region_id= #{regionId}")
    Map<String, Object> selectProjectCount(@Param("regionId") Long regionId);

    @Select("select code,name from area_code")
    List<Map<String, Object>> selectAreaCodes();

    @Select("select user_id userId,name from user_info where user_id in (${userOrClerks})")
    List<Map<String, Object>> selectRegionMember(@Param("userOrClerks") String userOrClerks);

    @Select("select name,code from area_code where parent=#{cityCode}")
    List<Map<String, Object>> areas(String cityCode);

    @Select("select name from user_info where user_id = #{userId}")
    String selectNameByUserId(Long userId);
}