package com.org.hktshop.service.certificate.impl;

import com.org.hktshop.base.BaseService;
import com.org.hktshop.entity.Page;
import com.org.hktshop.entity.system.HktAuthorizationCertificate;
import com.org.hktshop.service.certificate.HktAuthorizationCertificateService;
import com.org.hktshop.utils.ExecSqlLib;
import com.org.hktshop.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class HktAuthorizationCertificateServiceImpl extends BaseService<HktAuthorizationCertificate> implements HktAuthorizationCertificateService {
    @Override
    public void updateCertificate(HktAuthorizationCertificate hktAuthorizationCertificate) {
        String sql = "";
        if(StringUtils.isNull(hktAuthorizationCertificate.getId())){
            sql = ExecSqlLib.GetInsertSql(hktAuthorizationCertificate);
        }else {
            sql = ExecSqlLib.GetUpdateSql(hktAuthorizationCertificate);
        }
        this.baseJdbcDao.execute(sql);
    }

    @Override
    public void delCertificate(HktAuthorizationCertificate hktAuthorizationCertificate) {
        this.baseJdbcDao.execute(ExecSqlLib.GetDeleteSql(hktAuthorizationCertificate));
    }

    @Override
    public Page<HktAuthorizationCertificate> findByPage(HktAuthorizationCertificate hktAuthorizationCertificate) {
        return this.baseJdbcDao.queryPage(ExecSqlLib.GetQuerySql(hktAuthorizationCertificate),hktAuthorizationCertificate);
    }

    @Override
    public HktAuthorizationCertificate findById(HktAuthorizationCertificate hktAuthorizationCertificate) {
        return this.baseJdbcDao.query(ExecSqlLib.GetQuerySql(hktAuthorizationCertificate),hktAuthorizationCertificate);
    }

    @Override
    public List<HktAuthorizationCertificate> selectCertificate(HktAuthorizationCertificate hktAuthorizationCertificate) {
        hktAuthorizationCertificate.setStatus(1);
        return this.baseJdbcDao.queryList(ExecSqlLib.GetQuerySql(hktAuthorizationCertificate),hktAuthorizationCertificate);
    }
}
