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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.api.rental.dto.RentalOrderDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.rental.RentalOrderDO;
import cn.iocoder.yudao.module.system.service.rental.RentalOrderService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class RentalOrderApiImpl implements RentalOrderApi {

    @Resource
    private RentalOrderService rentalOrderService;

    @Override
    public CommonResult<Boolean> updateOrder(RentalOrderDTO updateReqVO) {
        rentalOrderService.update(BeanUtils.toBean(updateReqVO, RentalOrderDO.class));
        return success(true);
    }

    @Override
    public CommonResult<RentalOrderDTO> getOrder(String orderNo) {
        RentalOrderDO rentalOrder = rentalOrderService.getRentalOrder(orderNo);
        return success(BeanUtils.toBean(rentalOrder, RentalOrderDTO.class));
    }
}
