package com.wms_main.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wms_main.dao.ITAppDbsService;
import com.wms_main.mapper.AppDbsMapper;
import com.wms_main.model.po.TAppDbs;
import com.wms_main.repository.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DBS服务实现
 */
@Service
public class TAppDbsServiceImpl extends ServiceImpl<AppDbsMapper, TAppDbs> implements ITAppDbsService {
    /**
     * 实现
     * @param dbsQuery 查询条件
     * @return 结果
     */
    @Override
    public List<TAppDbs> selectList(TAppDbs dbsQuery) {
        if (dbsQuery == null) {
            return list();
        }
        LambdaQueryWrapper<TAppDbs> dbsQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(dbsQuery.getDbsId())) {
            // dbsId
            dbsQueryWrapper.eq(TAppDbs::getDbsId, dbsQuery.getDbsId());
        }
        if (StringUtils.isNotEmpty(dbsQuery.getWorkOrder())) {
            // workOrder
            dbsQueryWrapper.eq(TAppDbs::getWorkOrder, dbsQuery.getWorkOrder());
        }
        if (StringUtils.isNotEmpty(dbsQuery.getProductIdOrigin())) {
            // productIdOrigin
            dbsQueryWrapper.eq(TAppDbs::getProductIdOrigin, dbsQuery.getProductIdOrigin());
        }
        if (StringUtils.isNotEmpty(dbsQuery.getProductId())) {
            // productId
            dbsQueryWrapper.eq(TAppDbs::getProductId, dbsQuery.getProductId());
        }
        if (dbsQuery.getTestPlanStartDate() != null) {
            // planStartDate
            dbsQueryWrapper.eq(TAppDbs::getTestPlanStartDate, dbsQuery.getTestPlanStartDate());
        }
        if (dbsQuery.getPlanProduction() != null) {
            // planProduction
            dbsQueryWrapper.eq(TAppDbs::getPlanProduction, dbsQuery.getPlanProduction());
        }
        if (StringUtils.isNotEmpty(dbsQuery.getFamily())) {
            // family
            dbsQueryWrapper.eq(TAppDbs::getFamily, dbsQuery.getFamily());
        }
        if (StringUtils.isNotEmpty(dbsQuery.getTestNo())) {
            // testNo
            dbsQueryWrapper.eq(TAppDbs::getTestNo, dbsQuery.getTestNo());
        }
        if (dbsQuery.getDbsStatus() != null) {
            // dbsStatus
            dbsQueryWrapper.eq(TAppDbs::getDbsStatus, dbsQuery.getDbsStatus());
        }
        return list(dbsQueryWrapper);
    }
}
