package com.jeeplus.sys.feign;

import com.jeeplus.sys.domain.Office;
import com.jeeplus.sys.service.OfficeService;
import com.jeeplus.sys.service.dto.OfficeDTO;
import com.jeeplus.sys.service.mapstruct.OfficeWrapper;
import com.jeeplus.sys.utils.TenantUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OfficeApiImpl implements IOfficeApi {

    @Autowired
    OfficeService officeService;

    @Override
    public OfficeDTO getOfficeDTOByName(String name) {
        return OfficeWrapper.INSTANCE.toDTO ( officeService.lambdaQuery ( ).eq ( Office::getTenantId, TenantUtils.getTenantId ( ) ).eq ( Office::getName, name ).one ( ) );
    }

    @Override
    public Office selectById(String id) {
        return officeService.getById(id);
    }

    @Override
    public OfficeDTO getOfficeById(String id) {
        return officeService.getOfficeById(id);
    }

    @Override
    public List<String> getOfficeNameByIds(List<String> ids) {
        return officeService.getOfficeNameByIds(ids);
    }

    @Override
    public List<Office> selectListByParentId(String parentId) {
        return officeService.selectListByParentId(parentId);
    }

    @Override
    public List<Office> selectListByIsPublic(String isPublic) {
        return officeService.selectListByIsPublic(isPublic);
    }

    @Override
    public OfficeDTO getParentOfficeById(String id) {
        return officeService.getParentOfficeById(id);
    }
}
