package com.crm.manager.controller;

import com.crm.manager.service.golden.GoldenOrderFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.model.dto.golden.order.GoldenOrderListDto;
import com.crm.rely.backend.model.entity.golden.order.GoldenOrderSearchEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

@RestController
@RequestMapping("/order")
public class GoldenOrderController {

    @Autowired
    private GoldenOrderFeignService goldenOrderService;

    @PostMapping("/search/list")
    public ResultWithPagerDto<GoldenOrderListDto> pageList(@RequestBody GoldenOrderSearchEntity entity) throws Exception {
        return goldenOrderService.searchPageList(entity);
    }

    @PostMapping("/complete")
    public BaseResultDto completeOrder(@RequestBody @Validated SingleLongEntity entity) throws Exception {

        return goldenOrderService.completeOrder(entity);
    }

    @PostMapping("/cancel")
    public BaseResultDto cancelOrder(@RequestBody @Validated SingleLongEntity entity) throws Exception {

        return goldenOrderService.cancelOrder(entity);
    }

}
