package com.yuchen.saas.park.service.controller.property;

import com.yuchen.saas.park.api.dto.property.PropertyBillingSettingsSaveDto;
import com.yuchen.saas.park.api.entity.property.PropertyBillingSettings;
import com.yuchen.saas.park.service.service.property.PropertyBillingSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "账单设置")
@RestController
@RequestMapping("/billingSettings")
public class PropertyBillingSettingsController {
    @Autowired
    private PropertyBillingSettingsService propertyBillingSettingsService;

    @PostMapping("/save")
    @ApiOperation(value = "保存", notes = "保存")
    public R save(@Valid @RequestBody PropertyBillingSettingsSaveDto saveDto) {
        propertyBillingSettingsService.saveBillingSettings(saveDto);
        return R.success();
    }


    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "详情")
    public R<PropertyBillingSettings> detail(@RequestParam("parkId") Long parkId) {
        return R.data(propertyBillingSettingsService.getBillingSettings(parkId));
    }

}
