package com.hzs.system.config.controller.api;


import cn.hutool.core.bean.BeanUtil;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.enums.EOperationMethod;
import com.hzs.common.core.enums.EOperationModule;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.system.config.service.IBdDeliveryCentreService;
import com.hzs.system.config.vo.BdDeliveryCentreNoPageVO;
import com.hzs.system.config.vo.BdDeliveryCentreVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 配送中心设置 前端控制器
 * </p>
 *
 * @author zhangjing
 * @since 2023-02-23
 */
@RestController
@RequestMapping("/api/delivery-centre")
public class ApiBdDeliveryCentreController extends BaseController {

    @Autowired
    private IBdDeliveryCentreService deliveryCentreService;

    /**
     * @description: 配送中心下拉选
     * @author: zhang jing
     * @date: 2023/3/3 9:31
     * @param: [deliveryCentreVO]
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @Log(module = EOperationModule.DELIVERYCENTRE, method = EOperationMethod.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(BdDeliveryCentreVO deliveryCentreVO) {
        List<BdDeliveryCentreVO> listVO = deliveryCentreService.queryDeliveryCentreList(deliveryCentreVO);
        List<BdDeliveryCentreNoPageVO> list = new ArrayList<>();
        listVO.forEach(item -> list.add(BeanUtil.copyProperties(item, BdDeliveryCentreNoPageVO.class)));
        return getDataTable(list);
    }

}
