package com.usky.fire.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usky.fire.domain.BaseCompany;
import com.usky.fire.domain.BaseCompanyChange;
import com.usky.fire.domain.BaseStreetTown;
import com.usky.fire.mapper.BaseCompanyChangeMapper;
import com.usky.fire.service.BaseCompanyChangeService;
import com.usky.common.mybatis.core.AbstractCrudService;
import com.usky.fire.service.vo.CompanyDataVo;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 单位信息变更表 服务实现类
 * </p>
 *
 * @author han
 * @since 2023-02-23
 */
@Service
public class BaseCompanyChangeServiceImpl extends AbstractCrudService<BaseCompanyChangeMapper, BaseCompanyChange> implements BaseCompanyChangeService {
    @Override
    public void baseCompanyChangeAdd(BaseCompanyChange baseCompanyChange) {
        this.save(baseCompanyChange);
    }

    @Override
    public List<BaseCompanyChange> baseCompanyChangeOne(String companyId) {
        LambdaQueryWrapper<BaseCompanyChange> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.select()
                .eq(StringUtils.isNotBlank(companyId),BaseCompanyChange::getCompanyId, companyId)
                .orderByDesc(BaseCompanyChange::getId)
                .last(" limit 1");
        List<BaseCompanyChange> list = this.list(queryWrapper);
        return list;
    }
}
