package com.prolog.rdc.tms.controller;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.product.core.tools.util.JsonMapper;
import com.prolog.rdc.tms.model.dto.ShipBillPriceDTO;
import com.prolog.rdc.tms.model.vo.BmsShipBillDTO;
import com.prolog.rdc.tms.service.ShipCostStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "运输费用策略")
@RestController
@RequestMapping("/shipBillCost")
@Slf4j
public class ShipCostStrategyController {

    @Autowired
    private ShipCostStrategyService shipCostStrategyService;

    @UserLog("执行计费策略")
    @PostMapping("/costStrategy")
    @ApiOperation(httpMethod = "POST", value = "执行计费策略")
    public RestMessage<List<ShipBillPriceDTO>> costStrategy(@RequestParam BmsShipBillDTO dto) {
        log.info("执行计费策略 ->{}", JsonMapper.toJsonString(dto));
        List<ShipBillPriceDTO> shipBillPriceList = shipCostStrategyService.costStrategy(dto,"1");
        return RestMessage.newInstance(true, "操作成功", shipBillPriceList);
    }
}