package com.yida.data.form.customForm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUserParent;
import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic;
import com.yida.data.form.customForm.mapper.CoreCustomFormRelationUserParentMapper;
import com.yida.data.form.customForm.service.CoreCustomFormRelationUserParentService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ccl
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class CoreCustomFormRelationUserParentServiceImpl extends ServiceImpl
        <CoreCustomFormRelationUserParentMapper, CoreCustomFormRelationUserParent> implements CoreCustomFormRelationUserParentService {
    @Override
    public CoreCustomFormStatistic findParentStatistic(Long formId) {
        Integer total = baseMapper.findTotal(formId);
        Integer notCommit =baseMapper.findParentStatistic(formId);
        CoreCustomFormStatistic formStatistic = new CoreCustomFormStatistic();
        formStatistic.setCustomFormId(formId);
        formStatistic.setNotSubmitNum(notCommit);
        formStatistic.setTotalNum(total);
        formStatistic.setSubmitNum(total-notCommit);
        return formStatistic;
    }
}
