Commit 234b7e94 authored by ma's avatar ma

新增查询绑定状态接口

parent 8ee9100e
......@@ -48,4 +48,10 @@ public class TerminalDeviceController {
public BaseResult terminalDevieunBind(@RequestBody TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
return terminalDeviceService.terminalDeviceunBind(terminalDevieUnBindDTO);
}
@GetMapping("/get_bind_status")
@ApiOperation(value = "获取终端设备绑定状态接口", notes = "获取终端设备绑定状态接口")
public ResResult getBindStatus(TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
return terminalDeviceService.getBindStatus(terminalDevieUnBindDTO);
}
}
......@@ -3,6 +3,7 @@ package iot.sixiang.license.service;
import com.baomidou.mybatisplus.extension.service.IService;
import iot.sixiang.license.entity.Device;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import iot.sixiang.license.model.vo.DeviceVo;
......@@ -21,4 +22,6 @@ public interface DeviceService extends IService<Device> {
Boolean terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO);
Boolean terminalDevieunBind(TerminalDevieUnBindDTO terminalDevieUnBindDTO);
ResResult getBindStatus(TerminalDevieUnBindDTO terminalDevieUnBindDTO);
}
......@@ -17,4 +17,6 @@ public interface TerminalDeviceService {
BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO);
BaseResult terminalDeviceunBind(TerminalDevieUnBindDTO terminalDevieUnBindDTO);
ResResult getBindStatus(TerminalDevieUnBindDTO terminalDevieUnBindDTO);
}
......@@ -8,6 +8,7 @@ import iot.sixiang.license.entity.Device;
import iot.sixiang.license.handler.IotLicenseException;
import iot.sixiang.license.mapper.DeviceMapper;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import iot.sixiang.license.model.vo.DeviceVo;
......@@ -123,4 +124,17 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
return false;
}
@Override
public ResResult getBindStatus(TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
String snBind = terminalDevieUnBindDTO.getSnBind();
LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Device::getSnBind, snBind).last("limit 1");
Device device = deviceMapper.selectOne(queryWrapper);
if (device != null) {
return ResResult.success().record(device.getSn());
} else {
return new ResResult(405, "未绑定");
}
}
}
......@@ -123,4 +123,13 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
return BaseResult.failed();
}
}
@Override
public ResResult getBindStatus(TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
String snBind = terminalDevieUnBindDTO.getSnBind();
if (StringUtils.isEmpty(snBind)) {
return ResResult.validate_failed();
}
return deviceService.getBindStatus(terminalDevieUnBindDTO);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment