package com.keao.edu.controller;


import com.keao.edu.common.controller.BaseController;
import com.keao.edu.common.entity.HttpResponseResult;
import com.keao.edu.common.tenant.TenantContextHolder;
import com.keao.edu.user.entity.TenantInfo;
import com.keao.edu.user.service.TenantInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
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.RestController;

@RestController
@RequestMapping("tenantInfo")
@Api(tags = "机构服务")
public class TenantInfoController extends BaseController {

	@Autowired
	private TenantInfoService tenantInfoService;

	@ApiOperation("查询机构详情")
	@GetMapping(value = "/query")
	public HttpResponseResult<TenantInfo> query() {
		String tenantId = TenantContextHolder.getTenantId();
		if(StringUtils.isNotEmpty(tenantId)){
			return succeed(tenantInfoService.get(Integer.parseInt(tenantId)));
		}else {
			return succeed(new TenantInfo());
		}
	}

}
