package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAppUserMapper;
import com.gxwebsoft.oa.service.OaAppUserService;
import com.gxwebsoft.oa.entity.OaAppUser;
import com.gxwebsoft.oa.param.OaAppUserParam;
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 OaAppUserServiceImpl extends ServiceImpl<OaAppUserMapper, OaAppUser> implements OaAppUserService {

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

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

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

}
