package com.muyu.operation.service.imp;

import java.util.List;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;


import com.muyu.enterpise.domain.SysFence;
import com.muyu.operation.mapper.SysFenceMapper;
import com.muyu.operation.service.ISysFenceService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



/**
 * 围栏组Service业务层处理
 *
 * @author muyu
 * @date 2024-09-17
 */
@Service
public class SysFenceServiceImpl
        extends ServiceImpl<SysFenceMapper, SysFence>
        implements ISysFenceService {


    @Override
    public SysFence selectSysFenceById(Long id) {

        LambdaQueryWrapper<SysFence> queryWrapper = new LambdaQueryWrapper<>();
        Assert.notNull(id, "id不可为空");
        queryWrapper.eq(SysFence::getId, id);
        return this.getOne(queryWrapper);
    }

    @Override
    public List<SysFence> selectSysFenceList(SysFence sysFence) {
        LambdaQueryWrapper<SysFence> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(sysFence.getGroupCode())){
            queryWrapper.eq(SysFence::getGroupCode, sysFence.getGroupCode());
        }
        if (StringUtils.isNotEmpty(sysFence.getGroupName())){
        queryWrapper.like(SysFence::getGroupName, sysFence.getGroupName());
    }
        if (StringUtils.isNotEmpty(sysFence.getGroupType())){
        queryWrapper.eq(SysFence::getGroupType, sysFence.getGroupType());
    }
        if (StringUtils.isNotEmpty(sysFence.getState())){
        queryWrapper.eq(SysFence::getState, sysFence.getState());
    }
        return this.list(queryWrapper);

    }

    @Override
    public Boolean checkIdUnique(SysFence sysFence) {
        return null;
    }
}
