package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.AssetsUserMapper;
import com.gxwebsoft.oa.service.AssetsUserService;
import com.gxwebsoft.oa.entity.AssetsUser;
import com.gxwebsoft.oa.param.AssetsUserParam;
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-10-26 21:08:27
 */
@Service
public class AssetsUserServiceImpl extends ServiceImpl<AssetsUserMapper, AssetsUser> implements AssetsUserService {

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

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

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

}
