package com.cool.store.controller.webc;


import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.request.AddSignFranchiseRequest;
import com.cool.store.response.AddSignFranchiseResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.SignFranchiseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "Mini加盟合同签约")
@RestController
@RequestMapping("/mini/signFranchise")
public class MiniSignFranchiseController {
    @Resource
    SignFranchiseService signFranchiseService;

    @ApiOperation("提交(更新)加盟合同签约")
    @PostMapping("/submitOrUpdate")
    public ResponseResult<Boolean> submitSignFranchise(@RequestBody AddSignFranchiseRequest request) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return signFranchiseService.submitSignFranchise(request,user);
    }

    @ApiOperation("获取默认值")
    @GetMapping("/default/get")
    public ResponseResult<AddSignFranchiseResponse> getSignFranchise(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(signFranchiseService.getSignFranchise(shopId));
    }

    @ApiOperation("重新缴费(加盟合同阶段退回后)")
    @GetMapping("/rePay")
    public ResponseResult<Boolean> rePay(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(signFranchiseService.rePay(shopId));
    }

}
