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

import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUser;
import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic;
import com.yida.data.form.customForm.mapper.CoreCustomFormRelationUserMapper;
import com.yida.data.form.customForm.service.CoreCustomFormRelationUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 表单对应可见人员表 Service实现
 *
 * @author ccl
 * @date 2021-11-05 15:41:11
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class CoreCustomFormRelationUserServiceImpl extends ServiceImpl
        <CoreCustomFormRelationUserMapper, CoreCustomFormRelationUser> implements CoreCustomFormRelationUserService {

    private final CoreCustomFormRelationUserMapper coreCustomFormRelationUserMapper;

    @Override
    public Integer findUserNum(Long id) {
        return baseMapper.findUserNum(id);
    }

    @Override
    public CoreCustomFormStatistic findStatistic(Long formId) {
        Integer num = baseMapper.findNotCommit(formId);
        CoreCustomFormStatistic formStatistic = new CoreCustomFormStatistic();
        formStatistic.setTotalNum(findUserNum(formId));
        formStatistic.setNotSubmitNum(num);
        formStatistic.setSubmitNum(findUserNum(formId)-num);
        formStatistic.setCustomFormId(formId);
        return formStatistic;
    }

    @Override
    public Page<CoreCustomFormRelationUser> findUserList(Page<CoreCustomFormRelationUser> page, Integer type, String name, Long formId) {

        return baseMapper.findUserList(page,type,name,formId);
    }
}
