package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.ModulesMapper;
import com.gxwebsoft.common.system.service.ModulesService;
import com.gxwebsoft.common.system.entity.Modules;
import com.gxwebsoft.common.system.param.ModulesParam;
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 2023-10-18 15:53:43
 */
@Service
public class ModulesServiceImpl extends ServiceImpl<ModulesMapper, Modules> implements ModulesService {

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

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

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

}
