package com.mvc.service.copy;


import com.mvc.dao.CertifAccMapper;
import com.mvc.entity.CertifAcc;
import com.mvc.model.CertifAccModel;
import com.mvc.utils.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CertifAccService {

    @Autowired
    private CertifAccMapper certifAccMapper;

    public CertifAccModel saveCertifAcc(CertifAccModel model) {
        model.setCertifCode(StringUtil.getUuid());
        CertifAcc CertifAcc = new CertifAcc();
        BeanUtils.copyProperties(model, CertifAcc);
        int insert = certifAccMapper.insert(CertifAcc);
        model.setId(CertifAcc.getId());
        return model;
    }

    public CertifAccModel updateCertifAcc(CertifAccModel model) {
        CertifAcc CertifAcc = certifAccMapper.selectByPrimaryKey(model.getId());
        BeanUtils.copyProperties(model, CertifAcc);
        int i = certifAccMapper.updateByPrimaryKey(CertifAcc);
        return model;
    }

    public int deleteCertifAcc(int id) {
        int i = certifAccMapper.deleteByPrimaryKey(id);
        return i;
    }
}
