/**
 * BladeX Commercial License Agreement
 * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
 * <p>
 * Use of this software is governed by the Commercial License Agreement
 * obtained after purchasing a license from BladeX.
 * <p>
 * 1. This software is for development use only under a valid license
 * from BladeX.
 * <p>
 * 2. Redistribution of this software's source code to any third party
 * without a commercial license is strictly prohibited.
 * <p>
 * 3. Licensees may copyright their own code but cannot use segments
 * from this software for such purposes. Copyright of this software
 * remains with BladeX.
 * <p>
 * Using this software signifies agreement to this License, and the software
 * must not be used for illegal purposes.
 * <p>
 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
 * not liable for any claims arising from secondary or illegal development.
 * <p>
 * Author: Chill Zhuang (bladejava@qq.com)
 */
package org.springblade.zhaocai.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.pojo.entity.Dept;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 当前登录用户部门公司查询控制器
 *
 * @author Chill
 */
@NonDS
@RestController
@RequestMapping("current-user")
@AllArgsConstructor
@PreAuth(menu = "procurement-plan")
@Tag(name = "当前用户信息", description = "当前登录用户部门公司查询接口")
public class UserDeptController extends BladeController {

	private final ISysClient sysClient;

	/**
	 * 获取当前登录用户所属公司
	 */
	@GetMapping("/company")
	@ApiOperationSupport(order = 1)
	@Operation(summary = "获取当前登录用户所属公司", description = "根据当前登录用户部门ID向上查找dept_category=1的公司")
	public R<Dept> getCurrentUserCompany() {
		return sysClient.getCurrentUserCompany();
	}

	/**
	 * 获取当前登录用户所属部门
	 */
	@GetMapping("/dept")
	@ApiOperationSupport(order = 2)
	@Operation(summary = "获取当前登录用户所属部门", description = "根据当前登录用户部门ID查找dept_category=2的部门")
	public R<Dept> getCurrentUserDept() {
		return sysClient.getCurrentUserDept();
	}

}
