| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | import com.ruoyi.system.dto.SysVisitorMachinePageRequest; |
| | | import com.ruoyi.system.dto.SysVisitorMachineStatusRequest; |
| | | import com.ruoyi.system.service.ISysVisitorMachineService; |
| | | import com.ruoyi.web.controller.tool.MiddlePlatformDataQuery; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * 访客机管理接口 |
| | |
| | | @Autowired |
| | | private ISysVisitorMachineService visitorMachineService; |
| | | |
| | | @Autowired |
| | | private RuoYiConfig ruoyiConfig; |
| | | |
| | | /** |
| | | * 分页查询访客机列表 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.SELECT) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:view')") |
| | | @PostMapping("/page") |
| | | public AjaxResult page(@RequestBody(required = false) SysVisitorMachinePageRequest request) |
| | | { |
| | | // 集群版对接中台时,访客机设备查询使用中台海康设备列表。 |
| | | if (ruoyiConfig.isConnectMiddlePlatform()) |
| | | { |
| | | try |
| | | { |
| | | return success(MiddlePlatformDataQuery.visitorMachinePage(request)); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return middlePlatformError(e); |
| | | } |
| | | } |
| | | return success(visitorMachineService.pageList(request)); |
| | | } |
| | | |
| | |
| | | * 查看访客机详情 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.SELECT) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:view')") |
| | | @PostMapping("/detail") |
| | | public AjaxResult detail(@RequestBody SysVisitorMachineDetailRequest request) |
| | | { |
| | | // 详情接口按中台设备标识查询,并由适配器补齐前端使用的 machineId/deviceId 字段。 |
| | | if (ruoyiConfig.isConnectMiddlePlatform()) |
| | | { |
| | | try |
| | | { |
| | | return success(MiddlePlatformDataQuery.visitorMachineDetail(request.getMachineId())); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return middlePlatformError(e); |
| | | } |
| | | } |
| | | return success(visitorMachineService.detail(request)); |
| | | } |
| | | |
| | |
| | | * 新增访客机 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.INSERT) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:add')") |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@RequestBody SysVisitorMachineAddRequest request) |
| | | { |
| | |
| | | * 编辑访客机 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.UPDATE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:edit')") |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@RequestBody SysVisitorMachineEditRequest request) |
| | | { |
| | |
| | | * 启用或禁用访客机 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.UPDATE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:status')") |
| | | @PostMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysVisitorMachineStatusRequest request) |
| | | { |
| | |
| | | * 注销访客机 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.UPDATE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:logout')") |
| | | @PostMapping("/logout") |
| | | public AjaxResult logout(@RequestBody SysVisitorMachineLogoutRequest request) |
| | | { |
| | |
| | | * 删除访客机 |
| | | */ |
| | | @Log(title = "访客机管理", businessType = BusinessType.DELETE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:machine:remove')") |
| | | @PostMapping("/delete") |
| | | public AjaxResult delete(@RequestBody SysVisitorMachineDeleteRequest request) |
| | | { |
| | | return toAjax(visitorMachineService.delete(request, getUsername())); |
| | | } |
| | | |
| | | /** |
| | | * 目的:中台查询异常时返回统一业务错误,避免异常栈直接暴露给前端。 |
| | | */ |
| | | private AjaxResult middlePlatformError(IOException e) |
| | | { |
| | | return error("中台数据查询失败:" + e.getMessage()); |
| | | } |
| | | } |