package com.gxwebsoft.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.project.mapper.ProjectUserMapper;
import com.gxwebsoft.project.service.ProjectUserService;
import com.gxwebsoft.project.entity.ProjectUser;
import com.gxwebsoft.project.param.ProjectUserParam;
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 ProjectUserServiceImpl extends ServiceImpl<ProjectUserMapper, ProjectUser> implements ProjectUserService {

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

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

    @Override
    public ProjectUser getByIdRel(Integer appUserId) {
        ProjectUserParam param = new ProjectUserParam();
        param.setAppUserId(appUserId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
