package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAppUrlMapper;
import com.gxwebsoft.oa.service.OaAppUrlService;
import com.gxwebsoft.oa.entity.OaAppUrl;
import com.gxwebsoft.oa.param.OaAppUrlParam;
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-09-10 20:57:41
 */
@Service
public class OaAppUrlServiceImpl extends ServiceImpl<OaAppUrlMapper, OaAppUrl> implements OaAppUrlService {

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

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

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

}
