package com.bonus.canteen.core.drp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.common.page.PageVO;
import com.bonus.canteen.core.drp.dto.DrpCertificatePageDto;
import com.bonus.canteen.core.drp.mapper.DrpCertificateMapper;
import com.bonus.canteen.core.drp.model.DrpCertificate;
import com.bonus.canteen.core.drp.service.DrpCertificateService;
import com.bonus.canteen.core.drp.vo.DrpCertificateVo;
import com.github.pagehelper.page.PageMethod;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("drpCertificateService")
public class DrpCertificateServiceImpl extends ServiceImpl<DrpCertificateMapper, DrpCertificate> implements DrpCertificateService {
   @Override
   public PageVO<DrpCertificateVo> pageDrpCertificate(DrpCertificatePageDto content) {
      PageMethod.startPage(content);
      List<DrpCertificateVo> results = this.baseMapper.listDrpCertificate(content);
      return PageVO.of(results);
   }
//
//   public void addDrpCertificate(DrpCertificateDto content) {
//      this.checkData(content);
//      DrpCertificate drpCertificate = (DrpCertificate) LeBeanUtil.copyCreateProperties(content, DrpCertificate.class);
//      drpCertificate.setCertId(Id.next());
//      this.save(drpCertificate);
//   }
//
//   public void editDrpCertificate(DrpCertificateDto content) {
//      this.checkData(content);
//      DrpCertificate drpCertificate = (DrpCertificate)LeBeanUtil.copyCreateProperties(content, DrpCertificate.class);
//      this.updateById(drpCertificate);
//   }
//
//   public void delDrpCertificate(Long certId) {
//      DrpCertificate drpCertificate = (DrpCertificate)this.getById(certId);
//      Assert.notNull(drpCertificate, () -> {
//         return new LeException("证书不存在");
//      });
//      drpCertificate.setDelFlag(DelFlagEnum.DEL_TRUE.key());
//      this.updateById(drpCertificate);
//   }
//
//   private void checkData(DrpCertificateDto content) {
//      long count = this.count(((LambdaQueryWrapper)Wrappers.lambdaQuery(DrpCertificate.class).eq(DrpCertificate::getCertName, content.getCertName())).ne(ObjectUtil.isNotNull(content.getCertId()), DrpCertificate::getCertId, content.getCertId()));
//      Assert.isTrue(count == 0L, () -> {
//         return new LeException("证书名称已存在");
//      });
//   }

}
