package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.HualalaFoodCategoryMapper;
import com.gxwebsoft.apps.service.HualalaFoodCategoryService;
import com.gxwebsoft.apps.entity.HualalaFoodCategory;
import com.gxwebsoft.apps.param.HualalaFoodCategoryParam;
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 2023-01-12 09:49:46
 */
@Service
public class HualalaFoodCategoryServiceImpl extends ServiceImpl<HualalaFoodCategoryMapper, HualalaFoodCategory> implements HualalaFoodCategoryService {

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

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

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

}
