package com.gxwebsoft.oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.AppUserMapper;
import com.gxwebsoft.oa.service.AppUserService;
import com.gxwebsoft.oa.entity.AppUser;
import com.gxwebsoft.oa.param.AppUserParam;
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-05-31 13:18:55
 */
@Service
public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements AppUserService {

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

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

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

}
