package com.gxwebsoft.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.project.mapper.ProjectUrlMapper;
import com.gxwebsoft.project.service.ProjectUrlService;
import com.gxwebsoft.project.entity.ProjectUrl;
import com.gxwebsoft.project.param.ProjectUrlParam;
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 2025-03-14 16:21:11
 */
@Service
public class ProjectUrlServiceImpl extends ServiceImpl<ProjectUrlMapper, ProjectUrl> implements ProjectUrlService {

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

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

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

}
