package com.jwipc.supplier.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.supplier.dto.SupplierContactsDTO;
import com.jwipc.supplier.logic.SupplierContactLogic;
import com.jwipc.supplier.model.param.ContactQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.jwipc.supplier.constant.ModuleConst.MODULE_ROOT;

/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping(MODULE_ROOT + "/contact/rest")
@RequiredArgsConstructor
public class SupplierContactRestController {
    private final SupplierContactLogic supplierContactLogic;

    /**
     * 查询供应商联系人列表
     */
    @GetMapping("/list")
    public PageView getList(ContactQuery contactQuery) {
        return supplierContactLogic.getList(contactQuery);
    }

    /**
     * 查询供应商联系人列表
     */
    @GetMapping("/getOne")
    public ResponseEntity getOne(ContactQuery contactQuery) {
        return ResponseEntity.ok(supplierContactLogic.getOne(contactQuery));
    }

    @GetMapping("/getListBySupplierCodeAndType")
    public List<SupplierContactsDTO> getListBySupplierCodeAndType(String supplierCode, String type) {
        return supplierContactLogic.getListBySupplierCodeAndType(supplierCode,type);
    }
}
