package com.muyu.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.system.domain.SysFirm;
import com.muyu.system.mapper.SysFirmMapper;
import com.muyu.system.service.ISysFirmService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;

/**
 * 企业基础信息Service业务层处理
 *
 * @author muyu
 * @date 2024-09-18
 */
@Service
public class SysFirmServiceImpl
        extends ServiceImpl<SysFirmMapper, SysFirm>
        implements ISysFirmService {

    @Resource
    private SysFirmMapper sysFirmMapper;

    /**
     * 精确查询企业基础信息
     *
     * @param id 企业基础信息主键
     * @return 企业基础信息
     */
    @Override
    public SysFirm selectSysFirmById(Long id)
    {
        LambdaQueryWrapper<SysFirm> queryWrapper = new LambdaQueryWrapper<>();
        Assert.notNull(id, "id不可为空");
        queryWrapper.eq(SysFirm::getId, id);
        return this.getOne(queryWrapper);
    }


    /**
     * 查询企业基础信息列表
     *
     * @param sysFirm 企业基础信息
     * @return 企业基础信息
     */
    @Override
    public List<SysFirm> selectSysFirmList(SysFirm sysFirm) {
        return sysFirmMapper.selectSysFirmList(sysFirm);
    }

    /**
    * 唯一 判断
    * @param sysFirm 企业基础信息
     * @return 企业基础信息
    */
    @Override
    public Boolean checkIdUnique(SysFirm sysFirm) {
        LambdaQueryWrapper<SysFirm> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysFirm::getId, sysFirm.getId());
        return this.count(queryWrapper) > 0;
    }



}
