package com.fs.oms.mapper;

import java.util.List;

import com.fs.oms.domain.OmsStore;
import com.fs.oms.domain.OmsWarehouse;
import com.fs.oms.vo.OmsStoreVO;
import com.fs.oms.vo.OmsWarehouseVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 仓库Mapper接口
 *
 * @author fs
 * @date 2023-05-24
 */
public interface OmsWarehouseMapper
{
    /**
     * 查询仓库
     *
     * @param warehouseId 仓库ID
     * @return 仓库
     */
    public OmsWarehouse selectOmsWarehouseById(Long warehouseId);

    /**
     * 查询仓库列表
     *
     * @param omsWarehouse 仓库
     * @return 仓库集合
     */
    public List<OmsWarehouse> selectOmsWarehouseList(OmsWarehouse omsWarehouse);


    /**
     * 查询仓库列表
     *
     * @param OmsWarehouse 仓库
     * @return 仓库集合
     */
    @Select({"<script> " +

            "SELECT w.*,sys.nick_name createUserName  from oms_warehouse w LEFT JOIN sys_user sys on w.create_user_id=sys.user_id " +
            " where 1=1 " +

            "<if test = 'maps.warehouseName != null and maps.warehouseName != \"\"     '> " +
            "and w.warehouse_name =#{maps.warehouseName} " +
            "</if>" +
            "<if test = 'maps.warehouseCode != null and maps.warehouseCode != \"\"     '> " +
            "and w.warehouse_code =#{maps.warehouseCode} " +
            "</if>" +
            "<if test = 'maps.linkUsername != null and maps.linkUsername != \"\"     '> " +
            "and w.link_username =#{maps.linkUsername} " +
            "</if>" +
            "<if test = 'maps.linkPhone != null and maps.linkPhone != \"\"     '> " +
            "and w.link_phone =#{maps.linkPhone} " +
            "</if>" +
            "<if test = 'maps.warehouseType != null   '> " +
            "and w.status =#{maps.warehouseType} " +
            "</if>" +
            "<if test = 'maps.status != null   '> " +
            "and s.status =#{maps.status} " +
            "</if>" +
            " order by  w.warehouse_id desc "+
            "</script>"})
    public List<OmsWarehouseVO> selectOmsStoreListVO(@Param("maps") OmsWarehouse omsWarehouse);

    /**
     * 新增仓库
     *
     * @param omsWarehouse 仓库
     * @return 结果
     */
    public int insertOmsWarehouse(OmsWarehouse omsWarehouse);

    /**
     * 修改仓库
     *
     * @param omsWarehouse 仓库
     * @return 结果
     */
    public int updateOmsWarehouse(OmsWarehouse omsWarehouse);

    /**
     * 删除仓库
     *
     * @param warehouseId 仓库ID
     * @return 结果
     */
    public int deleteOmsWarehouseById(Long warehouseId);

    /**
     * 批量删除仓库
     *
     * @param warehouseIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteOmsWarehouseByIds(Long[] warehouseIds);


    List<OmsWarehouse> selectOmsWarehouseName(OmsWarehouse omsWarehouse);
}
