package com.cool.store.controller.webb;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.enums.PosAndOrderEnum;
import com.cool.store.request.PostAndOrderRequest;
import com.cool.store.response.PosAndOrderResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.PosAndOrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: WangShuo
 * @Date: 2024/10/12/上午10:37
 * @Version 1.0
 * @注释:
 */
@RestController
@RequestMapping("/pc/xFAndTP")
@Api("PC信发系统和营帐通")
public class XinFaSysAndTentPassController {

    @Resource
    private PosAndOrderInfoService posAndOrderInfoService;

    @ApiOperation("获取信发系统详情")
    @GetMapping("/getXinFaSys")
    private ResponseResult<PosAndOrderResponse> getXinFaSys(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(posAndOrderInfoService.get(shopId, PosAndOrderEnum.XIN_FA_SYS.getCode()));
    }

    @ApiOperation("获取营帐通详情")
    @GetMapping("/getTentPass")
    private ResponseResult<PosAndOrderResponse> TentPass(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(posAndOrderInfoService.get(shopId, PosAndOrderEnum.TENT_PASS.getCode()));
    }
    @ApiOperation("提交或修改信发系统")
    @PostMapping("/subOrUpdateXinFa")
    private ResponseResult<Integer> subOrUpdateXinFa(@RequestBody PostAndOrderRequest request) {
        request.setType(PosAndOrderEnum.XIN_FA_SYS.getCode());
        return ResponseResult.success(posAndOrderInfoService.submitOrUpdate(request, CurrentUserHolder.getUserId()));
    }
    @ApiOperation("提交或修改营帐通")
    @PostMapping("/subOrUpdateTentPass")
    private ResponseResult<Integer> subOrUpdateTentPass(@RequestBody PostAndOrderRequest request) {
        request.setType(PosAndOrderEnum.TENT_PASS.getCode());
        return ResponseResult.success(posAndOrderInfoService.submitOrUpdate(request, CurrentUserHolder.getUserId()));
    }
}
