package cn.iocoder.yudao.module.system.api.carteen;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
import cn.iocoder.yudao.module.system.dal.mysql.carteen.CarteenMapper;
import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

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

/**
 * 门店管理 Service 实现类
 *
 * @author 开发账号
 */
@Service
@Validated
public class CarteenApiImpl implements CarteenApi {

    @Resource
    private CarteenMapper carteenMapper;

    @Resource
    private DishesMapper dishesMapper;

    @Override
    public CarteenRespDto getCarteen(Long id){
        DishesDO dishesDO = dishesMapper.selectById(id);
        CarteenDO carteenDO = carteenMapper.selectById(dishesDO.getCarteenId());
        return BeanUtils.toBean(carteenDO, CarteenRespDto.class);
    }

    /**
     * @param id
     * @return
     * @Description: 根据id获取门店信息
     * @Author: qjq
     * @Date: 2024/4/12 下午3:30
     */
    @Override
    public CarteenRespDto getCarteenById(Long id) {
        return BeanUtils.toBean(carteenMapper.selectById(id), CarteenRespDto.class);
    }

    /**
     * @return
     * @Description: 获取门店列表
     * @Author: qjq
     * @Date: 2024/4/15 上午10:18
     */
    @Override
    public List<CarteenRespDto> getCarteenList() {
        return BeanUtils.toBean(carteenMapper.selectList(null), CarteenRespDto.class);
    }
}