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

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

import javax.validation.Valid;


/**
 * 用户发票表(ZccmUserInvoices)表控制层
 *
 * @author java
 * @since 2020-12-02 10:50:41
 */

@RestController
@RequestMapping("/new/api/front/userInvoices")
public class FrontUserInvoicesController {

    /**
     * 服务对象
     */
    private final ZccmUserInvoicesService userInvoicesService;

    public FrontUserInvoicesController(ZccmUserInvoicesService userInvoicesService) {
        this.userInvoicesService = userInvoicesService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增 ZccmUserInvoices", response = Result.class)
    public Result addFrontUserInvoices(@Valid @RequestBody ZccmUserInvoices userInvoices) {
        return Result.success(userInvoicesService.insert(userInvoices));
    }

    @GetMapping("/user/{userId}")
    @ApiOperation(value = "获取用户发票信息", response = Result.class)
    public Result queryDetailByUserId(@ApiParam(value = "用户id") @PathVariable("userId") Integer userId) {
        return Result.success(userInvoicesService.queryDetailByUserId(userId));
    }

}