package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.DealerUserMapper;
import com.gxwebsoft.shop.service.DealerUserService;
import com.gxwebsoft.shop.entity.DealerUser;
import com.gxwebsoft.shop.param.DealerUserParam;
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-07-28 19:21:15
 */
@Service
public class DealerUserServiceImpl extends ServiceImpl<DealerUserMapper, DealerUser> implements DealerUserService {

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

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

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

}
