
package com.tmerclub.cloud.delivery.controller.admin;

import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.delivery.dto.DeliveryCompanyDTO;
import com.tmerclub.cloud.delivery.service.DeliveryCompanyService;
import com.tmerclub.cloud.delivery.vo.DeliveryCompanyVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
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;

/**
 * 物流公司
 *
 * @author tmerclub
 * @date 2020-12-07 15:10:00
 */
@RestController("adminDeliveryCompanyController")
@RequestMapping("/mp/deliveryCompany")
@Tag(name = "物流公司")
public class DeliveryCompanyController {

    @Autowired
    private DeliveryCompanyService deliveryCompanyService;

    @GetMapping("/page")
    @Operation(summary = "分页获取物流公司列表", description = "分页获取物流公司列表")
    public ServerResponseEntity<PageVO<DeliveryCompanyVO>> page(@Valid PageDTO pageDTO, DeliveryCompanyDTO deliveryCompanyDTO) {
        PageVO<DeliveryCompanyVO> pageVO = deliveryCompanyService.page(pageDTO, deliveryCompanyDTO);
        return ServerResponseEntity.success(pageVO);
    }

    @GetMapping("/list")
    @Operation(summary = "获取物流公司列表", description = "获取物流公司列表")
    public ServerResponseEntity<List<DeliveryCompanyVO>> list() {
        return ServerResponseEntity.success(deliveryCompanyService.list());
    }

    @GetMapping
    @Operation(summary = "根据id获取物流公司信息", description = "根据id获取物流公司信息")
    public ServerResponseEntity<DeliveryCompanyVO> getById(@RequestParam("deliveryCompanyId") Long deliveryCompanyId) {
        return ServerResponseEntity.success(deliveryCompanyService.getByDeliveryCompanyId(deliveryCompanyId));
    }

}
