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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: WangShuo
 * @Date: 2024/10/09/下午5:44
 * @Version 1.0
 * @注释:
 */
@Api("pcPos")
@RestController
@RequestMapping("/pc/pos")
public class PCPosController {

    @Resource
    private PosAndOrderInfoService posAndOrderInfoService;

    @ApiOperation("提交或修改")
    @PostMapping("/submitOrUpdate")
    public ResponseResult<Integer> submitOrUpdate(@RequestBody @Validated PostAndOrderRequest request){
        request.setType(PosAndOrderEnum.POS.getCode());
        return ResponseResult.success(posAndOrderInfoService.submitOrUpdate(request, CurrentUserHolder.getUserId()));
    }

    @ApiOperation("获取")
    @GetMapping("/get")
    public ResponseResult<PosAndOrderResponse> get(@RequestParam("shopId") Long shopId){
        return ResponseResult.success(posAndOrderInfoService.get(shopId,PosAndOrderEnum.POS.getCode()));
    }
}
