package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsEmailMapper;
import com.gxwebsoft.oa.service.OaAssetsEmailService;
import com.gxwebsoft.oa.entity.OaAssetsEmail;
import com.gxwebsoft.oa.param.OaAssetsEmailParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 企业邮箱记录表Service实现
 *
 * @author 科技小王子
 * @since 2024-10-18 18:27:02
 */
@Service
public class OaAssetsEmailServiceImpl extends ServiceImpl<OaAssetsEmailMapper, OaAssetsEmail> implements OaAssetsEmailService {

    @Override
    public PageResult<OaAssetsEmail> pageRel(OaAssetsEmailParam param) {
        PageParam<OaAssetsEmail, OaAssetsEmailParam> page = new PageParam<>(param);
        page.setDefaultOrder("create_time desc");
        List<OaAssetsEmail> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<OaAssetsEmail> listRel(OaAssetsEmailParam param) {
        List<OaAssetsEmail> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<OaAssetsEmail, OaAssetsEmailParam> page = new PageParam<>();
        page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public OaAssetsEmail getByIdRel(Integer emailId) {
        OaAssetsEmailParam param = new OaAssetsEmailParam();
        param.setEmailId(emailId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
