package com.gxwebsoft.tower.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.tower.mapper.TowerProjectUserMapper;
import com.gxwebsoft.tower.service.TowerProjectUserService;
import com.gxwebsoft.tower.entity.TowerProjectUser;
import com.gxwebsoft.tower.param.TowerProjectUserParam;
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-06-07 15:00:32
 */
@Service
public class TowerProjectUserServiceImpl extends ServiceImpl<TowerProjectUserMapper, TowerProjectUser> implements TowerProjectUserService {

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

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

    @Override
    public TowerProjectUser getByIdRel(Integer id) {
        TowerProjectUserParam param = new TowerProjectUserParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
