package com.dsk.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsk.biz.domain.BusinessInfo;
import com.dsk.biz.domain.bo.BusinessListDto;
import com.dsk.biz.domain.bo.BusinessSearchDto;
import com.dsk.biz.domain.bo.CustomerBusinessSearchDto;
import com.dsk.biz.domain.vo.*;
import com.dsk.common.annotation.DataColumn;
import com.dsk.common.annotation.DataPermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 项目详情Mapper接口
 *
 * @author lxl
 * @date 2023-05-17
 */
@Mapper
public interface BusinessInfoMapper extends BaseMapper<BusinessInfo> {
    /**
     * 查询项目详情
     *
     * @param id 项目详情主键
     * @return 项目详情
     */
    public BusinessInfo selectBusinessInfoById(Integer id);

    /**
     * 查询项目建设内容
     *
     * @param id 项目详情主键
     * @return
     */
    BusinessInfo getConstruction(Integer id);

    /**
     * 查询所有项目名称(支持模糊查询)
     *
     * @return
     */
    List<BusinessLikeProjectNameListVo> selectProjectName(BusinessListDto dto);

    /**
     * 查询项目详情列表
     *
     * @param dto 项目详情
     * @return 项目详情集合
     */
    @DataPermission({
            @DataColumn(key = "deptName", value = "d.dept_id"),
            @DataColumn(key = "userName", value = "u.user_id")
    })
    Page<BusinessListVo> selectBusinessInfoList(@Param("page") IPage<BusinessListDto> page, @Param("dto")  BusinessListDto dto);

    /**
     * 新增项目详情
     *
     * @param businessInfo 项目详情
     * @return 结果
     */
    public int insertBusinessInfo(BusinessInfo businessInfo);

    /**
     * 修改项目详情
     *
     * @param businessInfo 项目详情
     * @return 结果
     */
    public int updateBusinessInfo(BusinessInfo businessInfo);

    /**
     * 删除项目详情
     *
     * @param id 项目详情主键
     * @return 结果
     */
    public int deleteBusinessInfoById(Long id);

    /**
     * 批量删除项目
     * 项目关联的其他所有表数据一并删除
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteBusinessInfoByIds(Long[] ids);

    /**
     * 根据项目统计
     *
     * @param business
     * @return
     */
    BusinessBrowseVo selectTotal(Integer business);

    /**
     * 查询项目名称是否存在
     *
     * @param projectName
     * @param userId
     * @return
     */
    int isRepetitionProjectName(@Param("projectName") String projectName,
                                @Param("userId") Long userId,
                                @Param("companyName") String companyName);

    int selectCountByStatusAndCustomerId(@Param("status") Integer status, @Param("customerId") String customerId);

    Page<CustomerBusinessListVo> selectCustomerBusinessList(IPage<CustomerBusinessSearchDto> page,@Param("dto") CustomerBusinessSearchDto dto);

    @DataPermission({
            @DataColumn(key = "deptName", value = "d.dept_id"),
            @DataColumn(key = "userName", value = "u.user_id")
    })
    int selectCountByStatus(BusinessSearchDto dto);

    @DataPermission({
            @DataColumn(key = "deptName", value = "d.dept_id"),
            @DataColumn(key = "userName", value = "u.user_id")
    })
    List<BusinessAnalyzeVo> selectAmountAnalyze(BusinessSearchDto dto);

    @DataPermission({
            @DataColumn(key = "deptName", value = "d.dept_id"),
            @DataColumn(key = "userName", value = "u.user_id")
    })
    List<BusinessAnalyzeVo> selectTypeAnalyze(BusinessSearchDto dto);

    @DataPermission({
            @DataColumn(key = "deptName", value = "d.dept_id"),
            @DataColumn(key = "userName", value = "u.user_id")
    })
    List<BusinessAnalyzeVo> selectCategoryAnalyze(BusinessSearchDto dto);

}
