package com.ruoyi.web.controller.system;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.*;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.system.domain.DepartmentSyncDTO;
|
import com.ruoyi.system.domain.UserSyncDTO;
|
import com.ruoyi.system.service.IDepartmentSyncService;
|
import com.ruoyi.system.service.IUserSyncService;
|
|
import java.util.List;
|
|
/**
|
* 部门和用户同步Controller
|
*
|
* @author ruoyi
|
* @date 2025-10-18
|
*/
|
@RestController
|
@RequestMapping("/system/dept/sync")
|
public class DepartmentSyncController extends BaseController
|
{
|
@Autowired
|
private IDepartmentSyncService departmentSyncService;
|
|
@Autowired
|
private IUserSyncService userSyncService;
|
|
|
|
/**
|
* 同步分公司和部门数据(使用外部传入的数据源)
|
*
|
* 适用场景:
|
* 1. 已从其他来源获取了部门数据
|
* 2. 需要对数据进行预处理后再同步
|
* 3. 批量同步多个数据源
|
*
|
* @param branchDepts 分公司数据列表
|
* @return 同步结果
|
*/
|
@PreAuthorize("@ss.hasPermi('system:dept:sync')")
|
@PostMapping("/branch/data")
|
public AjaxResult syncBranchDepartmentsWithData(@RequestBody List<DepartmentSyncDTO> branchDepts)
|
{
|
return departmentSyncService.syncBranchDepartments(branchDepts);
|
}
|
|
/**
|
* 同步转运部和子部门数据(使用外部传入的数据源)
|
*
|
* 同步逻辑:
|
* 1. 确保总公司(ID=101)下存在"转运部"
|
* 2. 创建转运部的子部门
|
*
|
* @param transportDepts 转运部子部门数据列表
|
* @return 同步结果
|
*/
|
@PreAuthorize("@ss.hasPermi('system:dept:sync')")
|
@PostMapping("/transport/data")
|
public AjaxResult syncTransportDepartmentsWithData(@RequestBody List<DepartmentSyncDTO> transportDepts)
|
{
|
return departmentSyncService.syncTransportDepartments(transportDepts);
|
}
|
|
|
|
/**
|
* 同步OA用户数据(使用外部传入的数据源)
|
*
|
* 适用场景:
|
* 1. 已从其他来源获取了用户数据
|
* 2. 需要对数据进行预处理后再同步
|
* 3. 批量同步多个数据源
|
*
|
* @param oaUsers OA用户数据列表
|
* @return 同步结果
|
*/
|
@PreAuthorize("@ss.hasPermi('system:user:sync')")
|
@PostMapping("/user/data")
|
public AjaxResult syncOaUsersWithData(@RequestBody List<UserSyncDTO> oaUsers)
|
{
|
return userSyncService.syncOaUsers(oaUsers);
|
}
|
}
|