package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.BcTemporaryMapper;
import com.gxwebsoft.apps.service.BcTemporaryService;
import com.gxwebsoft.apps.entity.BcTemporary;
import com.gxwebsoft.apps.param.BcTemporaryParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.UserService;
import org.springframework.stereotype.Service;

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

/**
 * 临时报餐管理Service实现
 *
 * @author 科技小王子
 * @since 2023-04-24 21:47:57
 */
@Service
public class BcTemporaryServiceImpl extends ServiceImpl<BcTemporaryMapper, BcTemporary> implements BcTemporaryService {

    @Resource
    private UserService userService;

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

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

    @Override
    public BcTemporary getByIdRel(Integer temporaryId) {
        BcTemporaryParam param = new BcTemporaryParam();
        param.setTemporaryId(temporaryId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
