package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsUserMapper;
import com.gxwebsoft.oa.service.OaAssetsUserService;
import com.gxwebsoft.oa.entity.OaAssetsUser;
import com.gxwebsoft.oa.param.OaAssetsUserParam;
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 OaAssetsUserServiceImpl extends ServiceImpl<OaAssetsUserMapper, OaAssetsUser> implements OaAssetsUserService {

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

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

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

}
