package com.org.hktshop.controller.system;

import com.org.hktshop.Interface.system.HktExpressCompanyService;
import com.org.hktshop.base.BaseResult;
import com.org.hktshop.controller.BaseController;
import com.org.hktshop.entity.system.HktExpressCompany;
import com.org.hktshop.utils.HttpCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/async/expressCompany")
@Api(tags = "快递公司信息接口")
public class HktAdminExpressCompanyController extends BaseController {

    @Autowired
    private HktExpressCompanyService expressCompanyService;

    @PostMapping(value = "/saveHktExpressCompany")
    @ApiOperation(value = "新增快递公司信息")
    public BaseResult saveHktExpressCompany(@RequestBody HktExpressCompany hktExpressCompany) {
        try {
            expressCompanyService.saveHktExpressCompany(hktExpressCompany);
            return BaseResult.success();
        } catch (Exception ex) {
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode(), HttpCode.INTERNAL_SERVER_ERROR.getMsg());
        }
    }

    @GetMapping("/deleteHktExpressCompany")
    @ApiOperation(value = "删除快递公司信息", notes = "删除快递公司信息")
    public BaseResult deleteHktExpressCompany(@RequestParam("id") String id) {
        try {
            expressCompanyService.deleteHktExpressCompany(id);
            return BaseResult.success();
        } catch (Exception ex) {
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode(), HttpCode.INTERNAL_SERVER_ERROR.getMsg());
        }
    }

    @PostMapping(value = "/updateHktExpressCompany")
    @ApiOperation(value = "更新快递公司信息")
    public BaseResult updateHktExpressCompany(@RequestBody HktExpressCompany hktExpressCompany) {
        try {
            expressCompanyService.updateHktExpressCompany(hktExpressCompany);
            return BaseResult.success();
        } catch (Exception ex) {
            return BaseResult.fail(HttpCode.INTERNAL_SERVER_ERROR.getCode(), HttpCode.INTERNAL_SERVER_ERROR.getMsg());
        }
    }

}
