package com.multictrl.modules.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.hutool.core.util.StrUtil;
import com.multictrl.common.service.impl.CrudServiceImpl;
import com.multictrl.modules.business.dao.DockDao;
import com.multictrl.modules.business.dto.DockDTO;
import com.multictrl.modules.business.entity.DockEntity;
import com.multictrl.modules.business.service.DockService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 机库信息表
 *
 * @author Sdy
 * @since 1.0.0 2026-04-17
 */
@Service
public class DockServiceImpl extends CrudServiceImpl<DockDao, DockEntity, DockDTO> implements DockService {

    @Override
    public QueryWrapper<DockEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");
        String key = (String) params.get("key");

        QueryWrapper<DockEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.and(StrUtil.isNotBlank(key), qw ->
                qw.like("dock_name", key).or().eq("dock_sn", key));
        wrapper.orderByDesc("update_date");

        return wrapper;
    }

    @Override
    public DockDao getDao() {

        return baseDao;
    }
}