package com.ruoyi.web.controller.sqlserver;
|
|
import com.ruoyi.common.annotation.DataSource;
|
import com.ruoyi.common.enums.DataSourceType;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.system.domain.DepartmentSyncDTO;
|
import com.ruoyi.system.mapper.DepartmentSyncMapper;
|
|
import java.util.List;
|
|
/**
|
* SQL Server 部门数据查询 Controller
|
*
|
* 专门用于从 SQL Server 数据库查询部门数据
|
* 不涉及任何 MySQL 数据库操作
|
*
|
* @author ruoyi
|
* @date 2025-10-18
|
*/
|
@RestController
|
@RequestMapping("/sqlserver/department")
|
@DataSource(DataSourceType.SQLSERVER)
|
public class SqlServerDepartmentController extends BaseController
|
{
|
@Autowired
|
private DepartmentSyncMapper departmentSyncMapper;
|
|
/**
|
* 查询 SQL Server 中合作单位下的所有分公司
|
*
|
* 数据源:SQL Server (uv_department 视图)
|
*
|
* @return 分公司列表
|
*/
|
@PreAuthorize("@ss.hasPermi('sqlserver:department:list')")
|
@GetMapping("/branch/list")
|
public AjaxResult getBranchDepartments()
|
{
|
try
|
{
|
// 从 SQL Server 查询数据
|
// Mapper 上的 @DataSource(DataSourceType.SQLSERVER) 注解确保使用 SQL Server 数据源
|
List<DepartmentSyncDTO> list = departmentSyncMapper.selectBranchDepartments();
|
|
return AjaxResult.success("查询成功", list);
|
}
|
catch (Exception e)
|
{
|
logger.error("查询 SQL Server 部门数据失败", e);
|
return AjaxResult.error("查询 SQL Server 部门数据失败:" + e.getMessage());
|
}
|
}
|
}
|