package com.ruoyi.web.controller.sqlserver; 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.UserSyncDTO; import com.ruoyi.system.mapper.UserSyncMapper; import java.util.List; /** * SQL Server 用户数据查询 Controller * * 专门用于从 SQL Server 数据库查询用户数据 * 不涉及任何 MySQL 数据库操作 * * @author ruoyi * @date 2025-10-18 */ @RestController @RequestMapping("/sqlserver/user") public class SqlServerUserController extends BaseController { @Autowired private UserSyncMapper userSyncMapper; /** * 查询 SQL Server 中的 OA 用户列表 * * 数据源:SQL Server (OA_User 表) * * @return OA 用户列表 */ @PreAuthorize("@ss.hasPermi('sqlserver:user:list')") @GetMapping("/list") public AjaxResult getOaUsers() { try { // 从 SQL Server 查询数据 // Mapper 上的 @DataSource(DataSourceType.SQLSERVER) 注解确保使用 SQL Server 数据源 List list = userSyncMapper.selectOaUsers(); return AjaxResult.success("查询成功", list); } catch (Exception e) { logger.error("查询 SQL Server 用户数据失败", e); return AjaxResult.error("查询 SQL Server 用户数据失败:" + e.getMessage()); } } }