package cn.iocoder.yudao.module.bpm.api.oa;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.api.oa.vo.refund.BpmOARefundDTO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOARefundDO;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOARefundService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

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

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;

/**
 * Flowable 流程实例 Api 实现类
 */
@RestController
@Validated
public class BpmOARefundApiImpl implements BpmOARefundApi{

    @Resource
    private BpmOARefundService refundService;

    @Override
    public CommonResult<Map<String, BpmOARefundDTO>> getListByOrderNo(List<String> orderNos) {
        List<BpmOARefundDO> list = refundService.getListByOrderNo(orderNos);
        return success(convertMap(BeanUtils.toBean(list, BpmOARefundDTO.class), BpmOARefundDTO::getOrderNo));
    }

    @Override
    public CommonResult<Boolean> updateStatus(String orderNo) {
        refundService.updateStatus(orderNo);
        return success(true);
    }
}
