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

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.PlugMapper;
import com.gxwebsoft.common.system.service.PlugService;
import com.gxwebsoft.common.system.entity.Plug;
import com.gxwebsoft.common.system.param.PlugParam;
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-12 09:53:07
 */
@Service
public class PlugServiceImpl extends ServiceImpl<PlugMapper, Plug> implements PlugService {

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

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

    @Override
    public Plug getByIdRel(Integer plugId) {
        PlugParam param = new PlugParam();
        param.setPlugId(plugId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
