package com.zd.airbottle.service.impl;

import java.util.List;

import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.security.utils.SaveUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.airbottle.mapper.QpQualificationCertificateMapper;
import com.zd.airbottle.domain.QpQualificationCertificate;
import com.zd.airbottle.service.IQpQualificationCertificateService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 资质证照Service业务层处理
 *
 * @author zd
 * @date 2022-05-19
 */
@Service
public class QpQualificationCertificateServiceImpl implements IQpQualificationCertificateService {
    @Autowired
    private QpQualificationCertificateMapper qpQualificationCertificateMapper;

    /**
     * 查询资质证照
     *
     * @param id 资质证照主键
     * @return 资质证照
     */
    @Override
    public QpQualificationCertificate selectQpQualificationCertificateById(Long id) {
        return qpQualificationCertificateMapper.selectQpQualificationCertificateById(id);
    }

    /**
     * 查询资质证照列表
     *
     * @param qpQualificationCertificate 资质证照
     * @return 资质证照
     */
    @Override
    public List<QpQualificationCertificate> selectQpQualificationCertificateList(QpQualificationCertificate qpQualificationCertificate) {
        return qpQualificationCertificateMapper.selectQpQualificationCertificateList(qpQualificationCertificate);
    }

    /**
     * 新增资质证照
     *
     * @param qpQualificationCertificate 资质证照
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertQpQualificationCertificate(QpQualificationCertificate qpQualificationCertificate) {
        SaveUtil.setCommonAttr(qpQualificationCertificate);
        return qpQualificationCertificateMapper.insertQpQualificationCertificate(qpQualificationCertificate);
    }

    /**
     * 修改资质证照
     *
     * @param qpQualificationCertificate 资质证照
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateQpQualificationCertificate(QpQualificationCertificate qpQualificationCertificate) {
        qpQualificationCertificate.setUpdateBy(SecurityUtils.getUsername());
        qpQualificationCertificate.setUpdateTime(DateUtils.getNowDate());
        return qpQualificationCertificateMapper.updateQpQualificationCertificate(qpQualificationCertificate);
    }

    /**
     * 批量删除资质证照
     *
     * @param ids 需要删除的资质证照主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteQpQualificationCertificateByIds(Long[] ids) {
        return qpQualificationCertificateMapper.deleteQpQualificationCertificateByIds(ids);
    }

    /**
     * 删除资质证照信息
     *
     * @param id 资质证照主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteQpQualificationCertificateById(Long id) {
        return qpQualificationCertificateMapper.deleteQpQualificationCertificateById(id);
    }
}
