package com.gxwebsoft.cms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.cms.mapper.DesignSignUpMapper;
import com.gxwebsoft.cms.service.DesignSignUpService;
import com.gxwebsoft.cms.entity.DesignSignUp;
import com.gxwebsoft.cms.param.DesignSignUpParam;
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-08 15:21:56
 */
@Service
public class DesignSignUpServiceImpl extends ServiceImpl<DesignSignUpMapper, DesignSignUp> implements DesignSignUpService {

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

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

    @Override
    public DesignSignUp getByIdRel(Integer id) {
        DesignSignUpParam param = new DesignSignUpParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
