package com.prolog.rdc.tms.app.controller.business;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.business.ShipbillEvaluationDTO;
import com.prolog.rdc.tms.app.model.vo.business.ShipbillEvaluationAddOrUpdateVO;
import com.prolog.rdc.tms.app.model.vo.business.ShipbillEvaluationQueryVO;
import com.prolog.rdc.tms.app.service.business.ShipbillEvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author hongbo.pan
 * @date 2022/11/1
 */
@RestController
@Api(tags = "业务APP--运单服务评价控制层")
@RequestMapping("/shipbillEvaluation")
public class ShipbillEvaluationController {

    @Autowired
    private ShipbillEvaluationService shipbillEvaluationService;

    @UserLog("新增或修改运单服务评价")
    @ApiOperation(value = "新增或修改运单服务评价", notes = "新增或修改运单服务评价")
    @PostMapping("/addOrUpdate")
    public RestMessage addOrUpdate(@RequestBody @Valid ShipbillEvaluationAddOrUpdateVO vo) {
        shipbillEvaluationService.addOrUpdate(vo);
        return RestMessage.newInstance(true, "操作成功！", null);
    }

    @UserLog("运单服务评价查询")
    @ApiOperation(value = "运单服务评价查询", notes = "运单服务评价查询")
    @PostMapping("/findEvaluation")
    public RestMessage<List<ShipbillEvaluationDTO>> findEvaluation(@RequestBody ShipbillEvaluationQueryVO vo) {
        List<ShipbillEvaluationDTO> list = shipbillEvaluationService.findEvaluation(vo);
        return RestMessage.newInstance(true, "查询成功！", list);
    }

}
