package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.AppUrlMapper;
import com.gxwebsoft.oa.service.AppUrlService;
import com.gxwebsoft.oa.entity.AppUrl;
import com.gxwebsoft.oa.param.AppUrlParam;
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-04-15 13:01:34
 */
@Service
public class AppUrlServiceImpl extends ServiceImpl<AppUrlMapper, AppUrl> implements AppUrlService {

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

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

    @Override
    public AppUrl getByIdRel(Integer appUrlId) {
        AppUrlParam param = new AppUrlParam();
        param.setAppUrlId(appUrlId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
