wlzboy
6 天以前 3bbd80a63ac7728ac01b641a48a26befcb171a0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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());
        }
    }
}