package com.njzscloud.dispose.cst.order.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.cst.order.pojo.entity.OrderEvaluateEntity;
import com.njzscloud.dispose.cst.order.pojo.param.CreateOrderEvaluateParam;
import com.njzscloud.dispose.cst.order.pojo.param.OrderEvaluateQueryParam;
import com.njzscloud.dispose.cst.order.service.OrderEvaluateService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单评价表
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/orderEvaluate")
@RequiredArgsConstructor
public class OrderEvaluateController {

    private final OrderEvaluateService orderEvaluateService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody CreateOrderEvaluateParam param) {
        orderEvaluateService.add(param);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody OrderEvaluateEntity orderEvaluateEntity) {
        orderEvaluateService.modify(orderEvaluateEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        orderEvaluateService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<OrderEvaluateEntity> detail(@RequestParam("id") Long id) {
        return R.success(orderEvaluateService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<OrderEvaluateEntity>> paging(PageParam pageParam, OrderEvaluateQueryParam queryParam) {
        return R.success(orderEvaluateService.paging(pageParam, queryParam));
    }

    /**
     * 根据订单ID查询评价
     */
    @GetMapping("/getByOrderId")
    public R<OrderEvaluateEntity> getByOrderId(@RequestParam("orderId") Long orderId) {
        return R.success(orderEvaluateService.getByOrderId(orderId));
    }
}
