package com.cusc.nirvana.user.rnr.fp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cusc.nirvana.user.rnr.fp.constants.UploadStatus;
import com.cusc.nirvana.user.rnr.fp.constants.UploadType;
import com.cusc.nirvana.user.rnr.fp.dao.InstructionLogDao;
import com.cusc.nirvana.user.rnr.fp.dao.entity.InstructionLogPO;
import com.cusc.nirvana.user.rnr.fp.dao.entity.InstructionPO;
import com.cusc.nirvana.user.rnr.fp.service.IInstructionLogService;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.springframework.stereotype.Service;

@Service
public class InstructionLogServiceImpl extends ServiceImpl<InstructionLogDao, InstructionLogPO> implements IInstructionLogService {


    @Override
    public InstructionLogPO insertLog(InstructionPO instructionPO, UploadType uploadType, UploadStatus status) {
        InstructionLogPO instructionLogPO = new InstructionLogPO();
        instructionLogPO.setUuid(CuscStringUtils.generateUuid());
        instructionLogPO.setRequestId(instructionPO.getRequestId());
        instructionLogPO.setIccid(instructionPO.getIccid());
        instructionLogPO.setUploadType(uploadType.getCode());
        instructionLogPO.setStatus(UploadStatus.Success == status ? UploadStatus.Success.getCode() : UploadStatus.Failed.getCode());
        baseMapper.insert(instructionLogPO);
        return instructionLogPO;
    }
}
