package com.fs.company.mapper;

import java.math.BigDecimal;
import java.util.List;
import com.fs.company.domain.Company;
import com.fs.company.param.CompanyParam;
import com.fs.company.vo.CompanyOptionRespVO;
import com.fs.company.vo.CompanyVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 企业Mapper接口
 *
 * @author fs
 * @date 2021-10-04
 */
public interface CompanyMapper
{
    /**
     * 查询企业
     *
     * @param companyId 企业ID
     * @return 企业
     */
    public Company selectCompanyById(Long companyId);

    /**
     * 查询企业列表
     *
     * @param company 企业
     * @return 企业集合
     */
    public List<Company> selectCompanyList(Company company);

    /**
     * 新增企业
     *
     * @param company 企业
     * @return 结果
     */
    public int insertCompany(Company company);

    /**
     * 修改企业
     *
     * @param company 企业
     * @return 结果
     */
    public int updateCompany(Company company);

    /**
     * 删除企业
     *
     * @param companyId 企业ID
     * @return 结果
     */
    public int deleteCompanyById(Long companyId);

    /**
     * 批量删除企业
     *
     * @param companyIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyByIds(Long[] companyIds);
    @Select({"<script> " +
            "select c.*,u.user_name " +
            "from company c  left join company_user u on u.user_id=c.user_id " +
            "where is_del=0 " +
            "<if test = 'maps.companyId != null  '> " +
            "and c.company_id = #{maps.companyId}" +
            "</if>" +
            "<if test = 'maps.companyName != null and  maps.companyName !=\"\"     '> " +
            "and c.company_name like CONCAT('%',#{maps.companyName},'%') " +
            "</if>" +
            "<if test = 'maps.status != null   '> " +
            "and c.status = #{maps.status}" +
            "</if>" +
            "order by c.company_id desc " +
            "</script>"})
    List<CompanyVO> selectCompanyVOList(@Param("maps")CompanyParam param);

    List<CompanyOptionRespVO> selectCompanyOptions(String companyName);

    @Select("select concat(company_id,'_',company_name) from company where company_id=#{companyId} limit 1")
    String selectCompanyNameById(Long companyId);

    @Select("select company_id,company_name from company")
    List<CompanyVO> selectCompanyAll();
}
