package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.UserVerifyMapper;
import com.gxwebsoft.common.system.service.UserVerifyService;
import com.gxwebsoft.common.system.entity.UserVerify;
import com.gxwebsoft.common.system.param.UserVerifyParam;
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 2025-05-29 23:01:04
 */
@Service
public class UserVerifyServiceImpl extends ServiceImpl<UserVerifyMapper, UserVerify> implements UserVerifyService {

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

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

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

}
