package com.hxhq.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.form.yq.StorageLocationSearchForm;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.StorageLocationMapper;
import com.hxhq.business.domain.StorageLocation;
import com.hxhq.business.service.IStorageLocationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 存储位置Service业务层处理
 *
 * @author hxhq
 * @date 2026-03-02
 */
@Service
public class StorageLocationServiceImpl extends ServiceImpl<StorageLocationMapper, StorageLocation> implements IStorageLocationService
{
    /**
     * 查询存储位置列表
     *
     * @param form 存储位置
     * @return 存储位置
     */
    @Override
    public List<StorageLocation> queryList(StorageLocationSearchForm form)
    {
        QueryWrapper<StorageLocation> queryWrapper = Wrappers.query();
        queryWrapper.eq("s.del_flag", 0);
        if(StringUtils.isNotEmpty(form.getName())) {
            queryWrapper.like("s.name", form.getName());
        }
        if(StringUtils.isNotEmpty(form.getLocation())) {
            queryWrapper.like("s.location", form.getLocation());
        }
        if(StringUtils.isNotEmpty(form.getShelfPlacement())) {
            queryWrapper.like("s.shelf_placement", form.getShelfPlacement());
        }
        if(form.getStatus() != null) {
            queryWrapper.eq("s.status", form.getStatus());
        }
        if(CollectionUtils.isNotEmpty(form.getDeptIdList())) {
            queryWrapper.in("s.dept_id", form.getDeptIdList());
        }
        return baseMapper.queryList(queryWrapper);
    }

}
