package com.bjtdba.userCenter.service.impl;

import com.bjtdba.entity.userCenter.UserDisabledCertificate;
import com.bjtdba.userCenter.dao.UserDisabledCertificateDao;
import com.bjtdba.userCenter.service.UserDisabledCertificateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 残疾认证表(UserDisabledCertificate)表服务实现类
 *
 * @author 何海强
 * @since 2022-11-17 14:16:43
 */
@Service("userDisabledCertificateService")
public class UserDisabledCertificateServiceImpl implements UserDisabledCertificateService {
    @Resource
    private UserDisabledCertificateDao userDisabledCertificateDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserDisabledCertificate queryById(Integer id) {
        return this.userDisabledCertificateDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param userDisabledCertificate 筛选条件
     * @return 查询结果
     */
//    @Override
//    public Page<UserDisabledCertificate> queryByPage(UserDisabledCertificate userDisabledCertificate, PageRequest pageRequest) {
//        long total = this.userDisabledCertificateDao.count(userDisabledCertificate);
//        return new PageImpl<>(this.userDisabledCertificateDao.queryAllByLimit(userDisabledCertificate, pageRequest), pageRequest, total);
//    }

    public List<UserDisabledCertificate> queryList(UserDisabledCertificate userDisabledCertificate){
        return userDisabledCertificateDao.queryAllByLimit(userDisabledCertificate);
    }

    public long counts(UserDisabledCertificate userDisabledCertificate){
        return userDisabledCertificateDao.count(userDisabledCertificate);
    }

    /**
     * 新增数据
     *
     * @param userDisabledCertificate 实例对象
     * @return 实例对象
     */
    @Override
    public UserDisabledCertificate insert(UserDisabledCertificate userDisabledCertificate) {
        this.userDisabledCertificateDao.insert(userDisabledCertificate);
        return userDisabledCertificate;
    }

    /**
     * 修改数据
     *
     * @param userDisabledCertificate 实例对象
     * @return 实例对象
     */
    @Override
    public UserDisabledCertificate update(UserDisabledCertificate userDisabledCertificate) {
        this.userDisabledCertificateDao.update(userDisabledCertificate);
        return this.queryById(userDisabledCertificate.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.userDisabledCertificateDao.deleteById(id) > 0;
    }
}
