package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.service.UserService;
import com.gxwebsoft.shop.entity.Manager;
import com.gxwebsoft.shop.mapper.ManagerMapper;
import com.gxwebsoft.shop.param.ManagerParam;
import com.gxwebsoft.shop.service.ManagerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商城会员Service实现
 *
 * @author 科技小王子
 * @since 2022-11-25 14:02:24
 */
@Service
public class ManagerServiceImpl extends ServiceImpl<ManagerMapper, Manager> implements ManagerService {

    @Resource
    private UserService userService;

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

    @Override
    public List<Manager> listRel(ManagerParam param) {
        List<Manager> list = baseMapper.selectListRel(param);

        // 排序
        PageParam<Manager, ManagerParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public Manager getByIdRel(Integer managerId) {
        ManagerParam param = new ManagerParam();
        param.setManagerId(managerId);
        return param.getOne(baseMapper.selectListRel(param));
    }



}
