package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopStoreUserMapper;
import com.gxwebsoft.shop.service.ShopStoreUserService;
import com.gxwebsoft.shop.entity.ShopStoreUser;
import com.gxwebsoft.shop.param.ShopStoreUserParam;
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 2026-01-30 15:00:25
 */
@Service
public class ShopStoreUserServiceImpl extends ServiceImpl<ShopStoreUserMapper, ShopStoreUser> implements ShopStoreUserService {

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

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

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

}
