package org.nl.acs.device.service.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.nl.acs.common.base.CommonMapper;
import org.nl.acs.device.domain.Device;
import org.springframework.stereotype.Repository;

/**
* @author jiaolm
* @date 2023-05-09
*/
@Repository
public interface DeviceMapper extends CommonMapper<Device> {
    String queryDeviceSql = "SELECT d.*, dict.label AS device_type_name, dict2.label AS region_name " +
            "FROM " +
            "ACS_DEVICE d " +
            "LEFT JOIN sys_dict dict ON dict.value = d.device_type " +
            "AND dict.`code` = 'device_type' " +
            "LEFT JOIN sys_dict dict2 ON dict2.value = d.region " +
            "AND dict2.`code` = 'region_type' ";
    String wrapperDeviceSql =  queryDeviceSql + " ${ew.customSqlSegment}";

    /**
     * 分页查询
     */
    @Select(wrapperDeviceSql)
    <P extends IPage<Device>> P queryPage(P page, @Param("ew") Wrapper<Device> queryWrapper);
}
