package com.fdkankan.platform.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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);

    List<ResponseCamera> queryListByParams(@Param("searchKey") String searchKey, @Param("type") Integer type,
                                           @Param("startDate") String startDate, @Param("endDate") String endDate,
                                           @Param("start") int start, @Param("pageSize") int pageSize, @Param("orderBy") String orderBy);

    Integer queryCountByParams(@Param("searchKey") String searchKey, @Param("type") Integer type,
                               @Param("startDate") String startDate, @Param("endDate") String endDate);

    List<ResponseCamera> queryCompanyCameraListByParams(@Param("searchKey") String searchKey, @Param("userName") String userName,
                                                        @Param("start")int start, @Param("pageSize")int pageSize, @Param("orderBy")String orderBy);
    Integer queryCompanyCameraCountByParams(@Param("searchKey")String searchKey, @Param("userName")String userName);

    Integer cameraCount(@Param("param")RequestCamera param);

    List<ResponseCamera> cameraList(@Param("param")RequestCamera param, @Param("start")Integer start, @Param("pageSize")int pageSize, @Param("orderBy")String orderBy);
}
