package com.org.hktshop.controller.user;

import com.org.hktshop.base.BaseResult;
import com.org.hktshop.controller.HktBaseController;
import com.org.hktshop.entity.user.HktWarehouseMap;
import com.org.hktshop.service.user.HktWarehouseMapService;
import com.org.hktshop.utils.HttpCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/shop/warehouseMap")
@Api(tags = "门店地址接口")
public class HktUserWarehouseMapController extends HktBaseController {

    @Autowired
    private HktWarehouseMapService warehouseMapService;

    @GetMapping("/getWarehouseMapList")
    @ApiOperation(value = "获取门店地址信息", notes = "获取门店地址信息")
    public BaseResult getWarehouseMapList() {
        try {
            List<HktWarehouseMap> hktWarehouseMapList = warehouseMapService.getHktWarehouseMapList();
            return BaseResult.successWithData(hktWarehouseMapList);
        } catch (Exception ex) {
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode(), HttpCode.INTERNAL_SERVER_ERROR.getMsg());
        }
    }

    @GetMapping("/getHktWarehouseMapById")
    @ApiOperation(value = "门店信息id查", notes = "门店信息id查")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")
    public BaseResult phoneCode(@RequestParam("id") String id) {
        try {
            HktWarehouseMap hktWarehouseMap = warehouseMapService.getHktWarehouseMapById(id);
            return BaseResult.successWithData(hktWarehouseMap);
        } catch (Exception ex) {
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode(), HttpCode.INTERNAL_SERVER_ERROR.getMsg());
        }
    }

}
