package com.gxwebsoft.cms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.cms.mapper.DesignMapper;
import com.gxwebsoft.cms.service.DesignService;
import com.gxwebsoft.cms.entity.Design;
import com.gxwebsoft.cms.param.DesignParam;
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-03-04 21:20:40
 */
@Service
public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> implements DesignService {

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

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

    @Override
    public Design getByIdRel(Integer pageId) {
        DesignParam param = new DesignParam();
        param.setPageId(pageId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
