package com.gxwebsoft.credit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.credit.mapper.CreditUserMapper;
import com.gxwebsoft.credit.service.CreditUserService;
import com.gxwebsoft.credit.entity.CreditUser;
import com.gxwebsoft.credit.param.CreditUserParam;
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-12-15 13:16:03
 */
@Service
public class CreditUserServiceImpl extends ServiceImpl<CreditUserMapper, CreditUser> implements CreditUserService {

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

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

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

    @Override
    public CreditUser getByName(String name) {
      CreditUserParam param = new CreditUserParam();
      param.setName(name);
      return param.getOne(baseMapper.selectListRel(param));
  }

}
