设备列表页面,获取设备列表详细信息、删除设备列表
This commit is contained in:
parent
fe9a8b1c91
commit
65a15147d9
|
@ -90,7 +90,7 @@ public class SysLoginController
|
|||
public AjaxResult getAppInfo()
|
||||
{
|
||||
AsUser user = SecurityUtils.getLoginUser().getAsUser();
|
||||
user.setDeviceId(asUserService.selectDeviceInfoByUser(user.getUserId()).getDeviceId());
|
||||
user.setDeviceId(asUserService.selectDeviceInfoByUser(user.getUserId(),null).get(0).getDeviceId());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user", user);
|
||||
return ajax;
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.device.domain.AsDevice;
|
||||
import com.ruoyi.device.domain.AsDeviceVersion;
|
||||
import com.ruoyi.device.domain.AsWateringRecord;
|
||||
|
@ -44,9 +45,14 @@ public class AppController extends BaseController
|
|||
* 根据登录用户获取绑定设备
|
||||
*/
|
||||
@GetMapping("/getDeviceInfoByUser")
|
||||
public AjaxResult list(Long userId)
|
||||
public AjaxResult list(Long userId,String deviceId)
|
||||
{
|
||||
AsDevice device = asUserService.selectDeviceInfoByUser(userId);
|
||||
List<AsDevice> device;
|
||||
if(StringUtils.isEmpty(deviceId) || "null".equals(deviceId)){
|
||||
device = asUserService.selectDeviceInfoByUser(userId,null);
|
||||
}else{
|
||||
device = asUserService.selectDeviceInfoByUser(userId,Long.parseLong(deviceId));
|
||||
}
|
||||
return AjaxResult.success(device);
|
||||
}
|
||||
|
||||
|
@ -92,4 +98,23 @@ public class AppController extends BaseController
|
|||
{
|
||||
return toAjax(asDeviceService.updateAsDevice(asDevice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备列表详细信息
|
||||
*/
|
||||
@GetMapping(value = "/getDeviceInfo/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
|
||||
{
|
||||
return success(asDeviceService.selectAsDeviceByDeviceId(deviceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备列表
|
||||
*/
|
||||
@Log(title = "设备列表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/device/{deviceIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] deviceIds)
|
||||
{
|
||||
return toAjax(asDeviceService.deleteAsDeviceByDeviceIds(deviceIds));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,5 +181,5 @@ public interface IAsUserService
|
|||
/**
|
||||
* 根据登录用户获取是否有绑定设备
|
||||
*/
|
||||
AsDevice selectDeviceInfoByUser(Long userId);
|
||||
List<AsDevice> selectDeviceInfoByUser(Long userId,Long deviceId);
|
||||
}
|
||||
|
|
|
@ -393,15 +393,15 @@ public class AsUserServiceImpl implements IAsUserService
|
|||
* @return 用户设备信息
|
||||
*/
|
||||
@Override
|
||||
public AsDevice selectDeviceInfoByUser(Long userId) {
|
||||
AsDevice asDevice = AsDevice.builder().userId(userId).build();
|
||||
public List<AsDevice> selectDeviceInfoByUser(Long userId,Long deviceId) {
|
||||
AsDevice asDevice = AsDevice.builder().userId(userId).deviceId(deviceId).build();
|
||||
List<AsDevice> asDevices = asDeviceMapper.selectAsDeviceList(asDevice);
|
||||
if(ObjectUtils.isNotEmpty(asDevices) && asDevices.size() !=0 ){
|
||||
AsDevice device = asDevices.get(0);
|
||||
//请求
|
||||
|
||||
return device;
|
||||
}
|
||||
return null;
|
||||
// if(ObjectUtils.isNotEmpty(asDevices) && asDevices.size() !=0 ){
|
||||
// AsDevice device = asDevices.get(0);
|
||||
// //请求
|
||||
//
|
||||
// return device;
|
||||
// }
|
||||
return asDevices;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
|
||||
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="deviceId != null "> and device_id != #{deviceId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user