package com.fjhx.mail.service.enterprise.impl;

import com.fjhx.mail.entity.enterprise.po.EnterpriseDomain;
import com.fjhx.mail.mapper.enterprise.EnterpriseDomainMapper;
import com.fjhx.mail.service.enterprise.EnterpriseDomainService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mail.entity.enterprise.vo.EnterpriseDomainVo;
import com.fjhx.mail.entity.enterprise.dto.EnterpriseDomainSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.mail.entity.enterprise.dto.EnterpriseDomainDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 企业邮箱域名 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-06
 */
@Service
public class EnterpriseDomainServiceImpl extends ServiceImpl<EnterpriseDomainMapper, EnterpriseDomain> implements EnterpriseDomainService {

    @Override
    public Page<EnterpriseDomainVo> getPage(EnterpriseDomainSelectDto dto) {
        IWrapper<EnterpriseDomain> wrapper = getWrapper();
        wrapper.orderByDesc("ed", EnterpriseDomain::getId);
        Page<EnterpriseDomainVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    @Override
    public EnterpriseDomainVo detail(Long id) {
        EnterpriseDomain EnterpriseDomain = this.getById(id);
        EnterpriseDomainVo result = BeanUtil.toBean(EnterpriseDomain, EnterpriseDomainVo.class);
        return result;
    }

    @Override
    public void add(EnterpriseDomainDto enterpriseDomainDto) {
        this.save(enterpriseDomainDto);
    }

    @Override
    public void edit(EnterpriseDomainDto enterpriseDomainDto) {
        this.updateById(enterpriseDomainDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

}
