package com.cool.store.controller.webc;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.context.PartnerUserHolder;
import com.cool.store.request.SubmitLicenseRequest;
import com.cool.store.request.license.BusinessLicenseRequest;
import com.cool.store.request.license.FoodLicenseRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.SubmitLicenseResponse;
import com.cool.store.service.ApplyLicenseService;
import com.cool.store.service.CoolStoreStartFlowService;
import com.cool.store.vo.PartnerUserInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 证照办理
 */
@RestController
@RequestMapping("/mini/license")
@Api(tags = "移动端证照办理")
@Slf4j
public class ApplyLicenseController {


    @Resource
    ApplyLicenseService applyLicenseService;


    @ApiOperation("证照办理提交-营业执照")
    @PostMapping("/submitBusinessLicense")
    public ResponseResult submitBusinessLicense(@RequestBody BusinessLicenseRequest request) {
        PartnerUserInfoVO user = PartnerUserHolder.getUser();
        return ResponseResult.success(applyLicenseService.submitBusinessLicense(request,user));
    }


    @ApiOperation("证照办理提交-食品许可证")
    @PostMapping("/submitFoodLicense")
    public ResponseResult submitFoodLicense(@RequestBody FoodLicenseRequest request) {
        PartnerUserInfoVO user = PartnerUserHolder.getUser();
        return ResponseResult.success(applyLicenseService.submitFoodLicense(request,user));
    }


    @ApiOperation("证照办理提交")
    @PostMapping("/submit")
    @Deprecated
    public ResponseResult submitLicense(@RequestBody SubmitLicenseRequest request) {
        PartnerUserInfoVO user = PartnerUserHolder.getUser();
        return ResponseResult.success(applyLicenseService.submitLicense(request,user));
    }


    @ApiOperation("证照办理数据回显")
    @GetMapping("/default/get")
    public ResponseResult<SubmitLicenseResponse> getDefault(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(applyLicenseService.getDefault(shopId));
    }

    /**
     *
     * @param
     * @param status 0通过 1不通过
     * @return
     */
    @GetMapping(path = "/examine")
    @ApiOperation("证照审批列表")
    public ResponseResult licenseExamine(@RequestParam("id") Long shopId,
                                         @RequestParam("status") Integer status,
                                         @RequestParam("result") String result) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(applyLicenseService.licenseExamine(shopId,status,result,user));
    }
}
