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


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.manage.system.api.param.CommonIdParam;
import com.yuchen.saas.park.api.dto.property.PropertyMeterQueryDto;
import com.yuchen.saas.park.api.dto.property.PropertyOfflineCollectionAccountAddDto;
import com.yuchen.saas.park.api.entity.property.PropertyMeter;
import com.yuchen.saas.park.api.entity.property.PropertyOfflineCollectionAccount;
import com.yuchen.saas.park.api.vo.property.PropertyOfflineCollectionAccountVo;
import com.yuchen.saas.park.service.service.property.IPropertyOfflineCollectionAccountService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 园区线下收费设置(园区线下收款账户配置) 前端控制器
 * </p>
 *
 * @author cxj
 * @since 2023-12-15
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/propertyOfflineCollectionAccount")
@Validated
public class PropertyOfflineCollectionAccountController {

    private final IPropertyOfflineCollectionAccountService baseService;

    @GetMapping("listByParkId")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "根据园区获取园区线下收费设置", notes = "根据园区获取园区线下收费设置")
    public R<List<PropertyOfflineCollectionAccountVo>> listByParkId(@ApiParam(name = "parkId", value = "园区id", required = true) @NonNull @RequestParam Long parkId,
                                                                    @ApiParam(name = "collectionAccountType", value = "收款账户类型:1银行账户,2第三方账户", required = false)  @RequestParam Integer collectionAccountType) {
        List<PropertyOfflineCollectionAccountVo> list = baseService.listByParkId(parkId,collectionAccountType);
        return R.data(list);
    }

    @PostMapping("/add")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增", notes = "新增")
    public R add(@RequestBody PropertyOfflineCollectionAccountAddDto dto) {
        return R.status(baseService.add(dto));
    }

    @PostMapping("/delete")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "删除")
    public R delete(@Valid @RequestBody CommonIdParam param) {
        return R.status(baseService.del(param.getId()));
    }
}
