package jnpf.franchisee.controller;

import jnpf.franchisee.FranchiseeApi;
import jnpf.franchisee.service.FranchiseeService;
import jnpf.model.franchisee.vo.FranchiseeIdName;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;


@Slf4j
@Validated
@RestController
@RequestMapping("/web/franchise-api")
public class FranchiseeApiController implements FranchiseeApi {

    @Autowired
    private FranchiseeService franchiseeService;

    /**
     * 获取所有加盟商信息
     * @return
     */
    @Override
    @GetMapping("/getFranchiseeIdNameList")
    public List<FranchiseeIdName> getFranchiseeIdNameList() {
        return franchiseeService.queryIdListByPrefix(null);
    }

    /**
     * 根据ID列表获取加盟商信息
     * @param ids
     * @return
     */
    @Override
    public List<FranchiseeIdName> getFranchiseeIdNameListByIds(Collection<String> ids) {
        return franchiseeService.getFranchiseeIdNameListByIds(ids);
    }

    /**
     * 根据ID获取加盟商信息
     * @param id
     * @return
     */
    @Override
    public FranchiseeIdName getFranchiseeIdNameListById(String id) {
        return franchiseeService.getFranchiseeIdNameListById(id);
    }

    /**
     * 根据名称获取加盟商信息
     * @param name
     * @return
     */
    @Override
    public List<FranchiseeIdName> getFranchiseeIdNameListByName(String name) {
        return franchiseeService.getFranchiseeIdNameListByName(name);
    }

    /**
     * 根据名称列表获取加盟商信息
     * @param names
     * @return
     */
    @Override
    public List<FranchiseeIdName> getFranchiseeIdNameListByNames(Collection<String> names) {
        return franchiseeService.getFranchiseeIdNameListByNames(names);
    }

    @Override
    public FranchiseeIdName getFranchiseeIdNameListByCode(String code) {
        return franchiseeService.getFranchiseeIdNameListByCode(code);
    }

    @Override
    public List<FranchiseeIdName> getFranchiseeIdNameListByCodes(Collection<String> codes) {
        return franchiseeService.getFranchiseeIdNameListByCodes(codes);
    }
}
