package com.neusoft.smart.pos.gateway.controller;

import com.neusoft.smart.pos.dto.org.request.PostShopRequest;
import com.neusoft.smart.pos.dto.org.request.PutShopRequest;
import com.neusoft.smart.pos.dto.org.response.PostShopResponse;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.gateway.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/unionService/shop")
@Api(value = "门店管理restful接口", description = "门店管理restful接口")
public class ShopController {
    
    @Autowired
    private ShopService shopService;
    
    @ApiOperation(value = "门店信息新建接口", notes = "门店信息新建接口")
    @PostMapping("/shop")
    public ResponseData<PostShopResponse> saveShop(@RequestBody PostShopRequest shopRequest) {
        return new ResponseData<>(shopService.saveShop(shopRequest));
    }
    
    @ApiOperation(value = "门店信息更新接口", notes = "门店信息更新接口")
    @PutMapping("/shop")
    public ResponseData<Integer> updateShop(@RequestBody PutShopRequest shopRequest) {
        return new ResponseData<>(shopService.updateShop(shopRequest));
    }
    
    @ApiOperation(value = "门店信息详情接口", notes = "门店信息详情接口")
    @GetMapping("/detail")
    public ResponseData<PostShopResponse> getShopDetail(@RequestParam(value = "shopId") int shopId) {
        return new ResponseData<>(shopService.get(shopId));
    }
}
