package com.chinaweal.aiccs.aiccs.expelled.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chinaweal.aiccs.aiccs.expelled.entity.ExpelledResultInfo;
import com.chinaweal.aiccs.aiccs.expelled.mapper.ExpelledResultInfoMapper;
import com.chinaweal.aiccs.aiccs.expelled.service.IExpelledResultInfoService;
import com.chinaweal.aiccs.utils.BeanUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @Description: 市场主体拟除名名单结果表实现类
 * @Author: TiAmo-cc
 * @Email: 1049976610@qq.com
 * @Date: 2026/1/5 11:43
 */
@Service
public class ExpelledResultInfoServiceImpl extends ServiceImpl<ExpelledResultInfoMapper, ExpelledResultInfo> implements IExpelledResultInfoService {

    @Override
    public void saveExpelledResultInfo(ExpelledResultInfo query) {
        ExpelledResultInfo resultInfo = getExpelledResultInfo(query.getAuditId(), query.getEntId());
        if (resultInfo == null) {
            resultInfo = new ExpelledResultInfo();
            resultInfo.setId(UUID.randomUUID().toString());
        }
        BeanUtil.copyBean(query, resultInfo);
        saveOrUpdate(resultInfo);
    }

    @Override
    public ExpelledResultInfo getExpelledResultInfo(String auditId, String entId) {
        return getOne(new LambdaQueryWrapper<ExpelledResultInfo>().eq(ExpelledResultInfo::getAuditId, auditId).eq(ExpelledResultInfo::getEntId, entId));
    }

    @Override
    public List<ExpelledResultInfo> searchResultInfoByAudit(String auditId) {
        return list(new LambdaQueryWrapper<ExpelledResultInfo>().eq(ExpelledResultInfo::getAuditId, auditId));
    }
}
