package com.cool.store.controller.webb;

import com.cool.store.common.InsertGroup;
import com.cool.store.common.UpdateGroup;
import com.cool.store.request.fees.FeeStandardConfigAddRequest;
import com.cool.store.request.fees.FeeStandardConfigPageRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.fees.FeeStandardConfigService;
import com.cool.store.vo.fees.FeeStandardConfigVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 加盟费用标准收费额配置
 */
@Api(tags = "加盟费用标准收费额配置")
@RestController
@RequestMapping("/pc/fees/standardConfig")
@RequiredArgsConstructor
@Validated
public class FeeStandardConfigController {

    private final FeeStandardConfigService feeStandardConfigService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public ResponseResult<Boolean> add(@RequestBody @Validated({InsertGroup.class}) FeeStandardConfigAddRequest request) {
        return ResponseResult.success(feeStandardConfigService.add(request));
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    public ResponseResult<Boolean> update(@RequestBody @Validated({UpdateGroup.class}) FeeStandardConfigAddRequest request) {
        return ResponseResult.success(feeStandardConfigService.update(request));
    }

    @ApiOperation("分页查询")
    @PostMapping("/page")
    public ResponseResult<PageInfo<FeeStandardConfigVO>> page(@RequestBody FeeStandardConfigPageRequest request) {
        return ResponseResult.success(feeStandardConfigService.page(request));
    }

    @ApiOperation("根据门店id查询配置")
    @GetMapping("/getFeeConfig")
    public ResponseResult<List<FeeStandardConfigVO>> getFeeConfig(@RequestParam @NotNull(message = "门店id不能为空") Long shopId) {
        return ResponseResult.success(feeStandardConfigService.getByShopId(shopId));
    }
}


