package com.fdkankan.platform.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fdkankan.platform.goods.entity.CameraDetail;
import com.fdkankan.platform.goods.entity.CameraDetailNumEntity;
import com.fdkankan.platform.user.request.RequestCamera;
import com.fdkankan.platform.user.vo.ResponseCamera;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 相机子表 Mapper 接口
 * </p>
 *
 * @author 
 * @since 2021-12-24
 */
@Mapper
public interface ICameraDetailMapper extends BaseMapper<CameraDetail> {


    @Select("SELECT camera_type as cameraType,count(1) as cameraTypenum FROM t_camera_detail " +
            "WHERE user_id = #{userId} and camera_type = #{type} GROUP BY camera_type ")
    List<CameraDetailNumEntity> selectTypeNum(@Param("userId") Long userId, @Param("type") Integer type);

    @Select("SELECT camera_type as cameraType,count(1) as cameraTypenum FROM t_camera_detail " +
            "WHERE user_id = #{userId}  GROUP BY camera_type ")
    List<CameraDetailNumEntity> selectTypeNumAll(@Param("userId") Long userId);

    @Select(" SELECT sum(balance) FROM t_camera_detail WHERE user_id = #{userId} AND REC_STATUS = 'A' ")
    long getSumBalanceByUserId(@Param("userId") Long userId);

    Page<ResponseCamera> queryListByParams(Page<ResponseCamera> page, @Param("param")RequestCamera param);

    Page<ResponseCamera> queryCompanyCameraListByParams(Page<ResponseCamera> page, @Param("param")RequestCamera param);


    Page<ResponseCamera> cameraList(Page<ResponseCamera> page, @Param("param")RequestCamera param);
}
