| | |
| | | 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.SysDoorDevicePageRequest; |
| | | import com.ruoyi.system.dto.SysDoorDeviceStatusRequest; |
| | | import com.ruoyi.system.service.ISysDoorDeviceService; |
| | | 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 ISysDoorDeviceService doorDeviceService; |
| | | |
| | | @Autowired |
| | | private RuoYiConfig ruoyiConfig; |
| | | |
| | | /** |
| | | * 分页查询门禁设备列表 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.SELECT) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:view')") |
| | | @PostMapping("/page") |
| | | public AjaxResult page(@RequestBody(required = false) SysDoorDevicePageRequest request) |
| | | { |
| | | // 集群版对接中台时,门禁设备查询使用中台海康设备列表。 |
| | | if (ruoyiConfig.isConnectMiddlePlatform()) |
| | | { |
| | | try |
| | | { |
| | | return success(MiddlePlatformDataQuery.doorDevicePage(request)); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return middlePlatformError(e); |
| | | } |
| | | } |
| | | return success(doorDeviceService.pageList(request)); |
| | | } |
| | | |
| | |
| | | * 查看门禁设备详情 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.SELECT) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:view')") |
| | | @PostMapping("/detail") |
| | | public AjaxResult detail(@RequestBody SysDoorDeviceDetailRequest request) |
| | | { |
| | | // 详情接口按中台设备标识查询,并由适配器补齐前端使用的 doorId/deviceId 字段。 |
| | | if (ruoyiConfig.isConnectMiddlePlatform()) |
| | | { |
| | | try |
| | | { |
| | | return success(MiddlePlatformDataQuery.doorDeviceDetail(request.getDoorId())); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return middlePlatformError(e); |
| | | } |
| | | } |
| | | return success(doorDeviceService.detail(request)); |
| | | } |
| | | |
| | |
| | | * 新增门禁设备 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.INSERT) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:add')") |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@RequestBody SysDoorDeviceAddRequest request) |
| | | { |
| | |
| | | * 编辑门禁设备 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.UPDATE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:edit')") |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@RequestBody SysDoorDeviceEditRequest request) |
| | | { |
| | |
| | | * 启用或禁用门禁设备 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.UPDATE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:status')") |
| | | @PostMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysDoorDeviceStatusRequest request) |
| | | { |
| | |
| | | * 注销门禁设备 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.UPDATE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:logout')") |
| | | @PostMapping("/logout") |
| | | public AjaxResult logout(@RequestBody SysDoorDeviceLogoutRequest request) |
| | | { |
| | |
| | | * 删除门禁设备 |
| | | */ |
| | | @Log(title = "门禁设备管理", businessType = BusinessType.DELETE) |
| | | @PreAuthorize("@ss.hasPermi('visitor:door:remove')") |
| | | @PostMapping("/delete") |
| | | public AjaxResult delete(@RequestBody SysDoorDeviceDeleteRequest request) |
| | | { |
| | | return toAjax(doorDeviceService.delete(request, getUsername())); |
| | | } |
| | | |
| | | /** |
| | | * 目的:中台查询异常时返回统一业务错误,避免异常栈直接暴露给前端。 |
| | | */ |
| | | private AjaxResult middlePlatformError(IOException e) |
| | | { |
| | | return error("中台数据查询失败:" + e.getMessage()); |
| | | } |
| | | } |