package com.trade.service.contract.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trade.service.contract.entity.ESignFlow;
import com.trade.service.contract.mapper.ESignFlowMapper;
import com.trade.service.contract.service.ESignFlowService;
import org.springframework.stereotype.Component;

@Component
public class ESignFlowServiceImpl extends ServiceImpl<ESignFlowMapper, ESignFlow> implements ESignFlowService {

    @Override
    public boolean add(ESignFlow eSignFlow) {
        return save(eSignFlow);
    }

    @Override
    public ESignFlow getByFlowId(String flowId) {
        QueryWrapper<ESignFlow> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("flow_id", flowId);
        return getBaseMapper().selectOne(queryWrapper);
    }

    @Override
    public void updateStatus(Long id, Integer status) {
        lambdaUpdate().set(ESignFlow::getStatus, status).eq(ESignFlow::getId, id).update();
    }
}
