package com.dgtly.system.service.impl;

import com.dgtly.system.domain.EsignCorpAuthSignRecord;
import com.dgtly.system.mapper.EsignCorpAuthSignRecordMapper;
import com.dgtly.system.service.IEsignCorpAuthSignRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @FileName: EsignCorpAuthSignRecordServiceImpl
 * @Description: e签宝企业授权书签署状态记录 Service 实现
 *
 * @author: auto-generated
 * @create: 2026-05-20
 **/
@Service
public class EsignCorpAuthSignRecordServiceImpl implements IEsignCorpAuthSignRecordService {

    @Autowired
    private EsignCorpAuthSignRecordMapper esignCorpAuthSignRecordMapper;

    /**
     * 新增签署状态记录，status 若未设置则默认 1（进行中）
     */
    @Override
    public int insertRecord(EsignCorpAuthSignRecord record) {
        if (record.getStatus() == null) {
            record.setStatus(1);
        }
        return esignCorpAuthSignRecordMapper.insertEsignCorpAuthSignRecord(record);
    }

    @Override
    public EsignCorpAuthSignRecord selectByAuthId(String authId) {
        return esignCorpAuthSignRecordMapper.selectByAuthId(authId);
    }

    @Override
    public EsignCorpAuthSignRecord selectByCustomeCode(String customeCode) {
        return esignCorpAuthSignRecordMapper.selectByCustomeCode(customeCode);
    }

    @Override
    public int updateStatus(String authId, Integer status) {
        EsignCorpAuthSignRecord record = new EsignCorpAuthSignRecord();
        record.setAuthId(authId);
        record.setStatus(status);
        return esignCorpAuthSignRecordMapper.updateStatusByAuthId(record);
    }
}
