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

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

import javax.validation.Valid;


/**
 * 用户退款记录表(UserRefundHistory)表控制层
 *
 * @author java
 * @since 2020-12-10 11:31:45
 */

@RestController
@RequestMapping("/new/api/back/userRefundHistory")
public class BackUserRefundHistoryController {

    /**
     * 服务对象
     */
    private final UserRefundHistoryService userRefundHistoryService;

    public BackUserRefundHistoryController(UserRefundHistoryService userRefundHistoryService) {
        this.userRefundHistoryService = userRefundHistoryService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 UserRefundHistory", response = Result.class)
    public Result addBackUserRefundHistory(@Valid @RequestBody UserRefundHistory userRefundHistory) {
        return Result.success(userRefundHistoryService.insert(userRefundHistory));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改 UserRefundHistory", response = Result.class)
    public Result updateBackUserRefundHistory(@RequestBody UserRefundHistory userRefundHistory) {
        return Result.success(userRefundHistoryService.update(userRefundHistory));
    }

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

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


}