This repository has been archived on 2025-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
Files
springboot-xinda-dev/xinda-open-api/src/main/java/com/xinda/data/controller/DeviceShareController.java
Administrator 867209e6dd 111
2025-01-20 20:09:10 +08:00

122 lines
3.7 KiB
Java

package com.xinda.data.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.xinda.iot.domain.DeviceUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.iot.domain.DeviceShare;
import com.xinda.iot.service.IDeviceShareService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;
/**
* 设备分享Controller
*
* @author kerwincui
* @date 2024-04-03
*/
@RestController
@RequestMapping("/iot/share")
public class DeviceShareController extends BaseController
{
@Autowired
private IDeviceShareService deviceShareService;
/**
* 查询设备分享列表
*/
@PreAuthorize("@ss.hasPermi('iot:share:list')")
@GetMapping("/list")
public TableDataInfo list(DeviceShare deviceShare)
{
startPage();
List<DeviceShare> list = deviceShareService.selectDeviceShareList(deviceShare);
return getDataTable(list);
}
/**
* 导出设备分享列表
*/
@PreAuthorize("@ss.hasPermi('iot:share:export')")
@Log(title = "设备分享", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DeviceShare deviceShare)
{
List<DeviceShare> list = deviceShareService.selectDeviceShareList(deviceShare);
ExcelUtil<DeviceShare> util = new ExcelUtil<DeviceShare>(DeviceShare.class);
util.exportExcel(response, list, "设备分享数据");
}
/**
* 获取设备分享详细信息
*/
@PreAuthorize("@ss.hasPermi('iot:share:query')")
@GetMapping(value = "/detail")
public AjaxResult getInfo(Long deviceId,Long userId)
{
return success(deviceShareService.selectDeviceShareByDeviceIdAndUserId(deviceId,userId));
}
/**
* 新增设备分享
*/
@PreAuthorize("@ss.hasPermi('iot:share:add')")
@Log(title = "设备分享", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DeviceShare deviceShare)
{
return toAjax(deviceShareService.insertDeviceShare(deviceShare));
}
/**
* 修改设备分享
*/
@PreAuthorize("@ss.hasPermi('iot:share:edit')")
@Log(title = "设备分享", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DeviceShare deviceShare)
{
return toAjax(deviceShareService.updateDeviceShare(deviceShare));
}
/**
* 删除设备分享
*/
@PreAuthorize("@ss.hasPermi('iot:share:remove')")
@Log(title = "设备分享", businessType = BusinessType.DELETE)
@DeleteMapping("/{deviceIds}")
public AjaxResult remove(@PathVariable Long[] deviceIds)
{
return toAjax(deviceShareService.deleteDeviceShareByDeviceIds(deviceIds));
}
/**
* 删除设备分享
*/
@PreAuthorize("@ss.hasPermi('iot:share:remove')")
@Log(title = "设备分享", businessType = BusinessType.DELETE)
@DeleteMapping()
public AjaxResult delete(@RequestBody DeviceShare deviceShare)
{
return toAjax(deviceShareService.deleteDeviceShareByDeviceIdAndUserId(deviceShare));
}
/**
* 获取设备分享用户信息
*/
@GetMapping("/shareUser")
@PreAuthorize("@ss.hasPermi('iot:share:user')")
public AjaxResult userList(DeviceShare share)
{
return AjaxResult.success(deviceShareService.selectShareUser(share));
}
}