package com.org.hktshop.controller.user;

import com.org.hktshop.Interface.system.HktExpressCompanyService;
import com.org.hktshop.base.BaseResult;
import com.org.hktshop.controller.HktBaseController;
import com.org.hktshop.entity.system.HktExpressCompany;
import com.org.hktshop.utils.HttpCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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/expressCompany")
@Api(tags = "快递公司信息接口")
public class HktUserExpressCompanyController extends HktBaseController {
    @Autowired
    private HktExpressCompanyService expressCompanyService;

    @GetMapping("/getHktExpressCompanyList")
    @ApiOperation(value = "获取快递公司", notes = "获取快递公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "city", value = "城市", required = true, paramType = "query"),
            @ApiImplicitParam(name = "province", value = "省份", required = true, paramType = "query")
    })
    public BaseResult getHktExpressCompanyList(@RequestParam("city") String city,@RequestParam("province") String province) {
        try {
            List<HktExpressCompany> hktExpressCompanyList = expressCompanyService.getHktExpressCompanyList(city,province);
            return BaseResult.successWithData(hktExpressCompanyList);
        } catch (Exception ex) {
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode(), HttpCode.INTERNAL_SERVER_ERROR.getMsg());
        }
    }
}
