package com.hc.web.controller.browser.app;

import com.hc.business.model.OrderRefundLog;
import com.hc.business.service.OrderRefundLogService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 退费用户明细表(OrderRefundLog)表控制层
 *
 * @author makejava
 * @since 2024-01-20 11:48:47
 */

@RestController
@RequestMapping("/new/api/app/orderRefundLog")
public class AppOrderRefundLogController {

    /**
     * 服务对象
     */
    private final OrderRefundLogService orderRefundLogService;

    public AppOrderRefundLogController(OrderRefundLogService orderRefundLogService) {
        this.orderRefundLogService = orderRefundLogService;
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 OrderRefundLog", response = Result.class)
    public Result selectDetail(@PathVariable("id") Integer id) {
        return Result.success(this.orderRefundLogService.queryById(id));
    }

    @PostMapping("/insert")
    @ApiOperation(value = "新增 OrderRefundLog", response = Result.class)
    public Result addOrderRefundLog(@Valid @RequestBody OrderRefundLog orderRefundLog) {
        return Result.success(orderRefundLogService.insert(orderRefundLog));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 OrderRefundLog", response = Result.class)
    public Result updateOrderRefundLog(@RequestBody OrderRefundLog orderRefundLog) {
        return Result.success(orderRefundLogService.update(orderRefundLog));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "依据主键删除 OrderRefundLog", response = Result.class)
    public Result deleteOrderRefundLog(@PathVariable("id") Integer id) {
        return Result.success(orderRefundLogService.deleteById(id));
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取 OrderRefundLog列表(分页)", response = Result.class)
    public Result list(@RequestParam(defaultValue = "0") Integer page,
                                     @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(orderRefundLogService.queryAllByLimit(page, size));
    }

    @GetMapping("/queryByRefundId")
    @ApiOperation(value = "获取退费单下的人员", response = Result.class)
    public Result queryByRefundId(@RequestParam(defaultValue = "0") Integer refundId) {
        return Result.success(orderRefundLogService.queryByRefundId(refundId));
    }
}
