package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAppRenewMapper;
import com.gxwebsoft.oa.service.OaAppRenewService;
import com.gxwebsoft.oa.entity.OaAppRenew;
import com.gxwebsoft.oa.param.OaAppRenewParam;
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-09-10 20:57:41
 */
@Service
public class OaAppRenewServiceImpl extends ServiceImpl<OaAppRenewMapper, OaAppRenew> implements OaAppRenewService {

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

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

    @Override
    public OaAppRenew getByIdRel(Integer appRenewId) {
        OaAppRenewParam param = new OaAppRenewParam();
        param.setAppRenewId(appRenewId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
