package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.oa.entity.AppRenew;
import com.gxwebsoft.oa.mapper.AppRenewMapper;
import com.gxwebsoft.oa.param.AppRenewParam;
import com.gxwebsoft.oa.service.AppRenewService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 续费管理Service实现
 *
 * @author 科技小王子
 * @since 2023-11-14 14:27:57
 */
@Service
public class AppRenewServiceImpl extends ServiceImpl<AppRenewMapper, AppRenew> implements AppRenewService {

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

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

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

}
