package co.yixiang.yshop.module.express.controller.app.express;

import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressRespVO;
import co.yixiang.yshop.module.express.convert.express.ExpressConvert;
import co.yixiang.yshop.module.express.dal.dataobject.express.ExpressDO;
import co.yixiang.yshop.module.express.service.express.ExpressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;


@Slf4j
@RestController
@Tag(name = "用户 APP - 物流")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/order/express")
public class AppExpressController {

    @Resource
    private ExpressService expressService;

    @GetMapping("/list")
    @Operation(summary = "获得快递公司列表")
    public CommonResult<List<ExpressRespVO>> getExpressList() {
        List<ExpressDO> list = expressService.getExpressList();
        return success(ExpressConvert.INSTANCE.convertList(list));
    }
}
