Commit 325bc153 authored by 马33's avatar 马33

添加解绑接口

parent 31253801
...@@ -7,6 +7,7 @@ import iot.sixiang.license.model.ResResult; ...@@ -7,6 +7,7 @@ import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO; import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO;
import iot.sixiang.license.model.dto.ReportErrorMsgDTO; import iot.sixiang.license.model.dto.ReportErrorMsgDTO;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import iot.sixiang.license.service.TerminalDeviceService; import iot.sixiang.license.service.TerminalDeviceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -41,4 +42,10 @@ public class TerminalDeviceController { ...@@ -41,4 +42,10 @@ public class TerminalDeviceController {
public BaseResult terminalDevieBind(@RequestBody TerminalDevieBindDTO terminalDevieBindDTO) { public BaseResult terminalDevieBind(@RequestBody TerminalDevieBindDTO terminalDevieBindDTO) {
return terminalDeviceService.terminalDeviceBind(terminalDevieBindDTO); return terminalDeviceService.terminalDeviceBind(terminalDevieBindDTO);
} }
@PostMapping("/unbind")
@ApiOperation(value = "终端设备解绑接口", notes = "终端设备解绑接口")
public BaseResult terminalDevieunBind(@RequestBody TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
return terminalDeviceService.terminalDeviceunBind(terminalDevieUnBindDTO);
}
} }
package iot.sixiang.license.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class TerminalDevieUnBindDTO {
@ApiModelProperty("设备SN")
private String snBind;
}
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import iot.sixiang.license.entity.Device; import iot.sixiang.license.entity.Device;
import iot.sixiang.license.model.PageInfoModel; import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import iot.sixiang.license.model.vo.DeviceVo; import iot.sixiang.license.model.vo.DeviceVo;
/** /**
...@@ -18,4 +19,6 @@ public interface DeviceService extends IService<Device> { ...@@ -18,4 +19,6 @@ public interface DeviceService extends IService<Device> {
boolean addDevice(String appId, int count); boolean addDevice(String appId, int count);
Boolean terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO); Boolean terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO);
Boolean terminalDevieunBind(TerminalDevieUnBindDTO terminalDevieUnBindDTO);
} }
...@@ -5,6 +5,7 @@ import iot.sixiang.license.model.ResResult; ...@@ -5,6 +5,7 @@ import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO; import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO;
import iot.sixiang.license.model.dto.ReportErrorMsgDTO; import iot.sixiang.license.model.dto.ReportErrorMsgDTO;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import java.util.List; import java.util.List;
...@@ -14,4 +15,6 @@ public interface TerminalDeviceService { ...@@ -14,4 +15,6 @@ public interface TerminalDeviceService {
BaseResult reportErrorMsg(List<ReportErrorMsgDTO> reportErrorMsgDTO); BaseResult reportErrorMsg(List<ReportErrorMsgDTO> reportErrorMsgDTO);
BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO); BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO);
BaseResult terminalDeviceunBind(TerminalDevieUnBindDTO terminalDevieUnBindDTO);
} }
...@@ -9,6 +9,7 @@ import iot.sixiang.license.handler.IotLicenseException; ...@@ -9,6 +9,7 @@ import iot.sixiang.license.handler.IotLicenseException;
import iot.sixiang.license.mapper.DeviceMapper; import iot.sixiang.license.mapper.DeviceMapper;
import iot.sixiang.license.model.PageInfoModel; import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import iot.sixiang.license.model.vo.DeviceVo; import iot.sixiang.license.model.vo.DeviceVo;
import iot.sixiang.license.service.DeviceService; import iot.sixiang.license.service.DeviceService;
import iot.sixiang.license.util.CommonUtil; import iot.sixiang.license.util.CommonUtil;
...@@ -94,7 +95,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -94,7 +95,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
device.setStatus(1); device.setStatus(1);
device.setUpdateTime(new Date()); device.setUpdateTime(new Date());
int res = deviceMapper.updateById(device); int res = deviceMapper.updateById(device);
if (res >= 0) { if (res > 0) {
return true; return true;
} else { } else {
return false; return false;
...@@ -102,4 +103,20 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -102,4 +103,20 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
} }
return false; return false;
} }
@Override
public Boolean terminalDevieunBind(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) {
device.setSnBind(null);
device.setStatus(0);
device.setUpdateTime(new Date());
int res = deviceMapper.updateById(device);
return res > 0;
}
return false;
}
} }
...@@ -10,6 +10,7 @@ import iot.sixiang.license.model.ResResult; ...@@ -10,6 +10,7 @@ import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO; import iot.sixiang.license.model.dto.GetTerminalDeviceTokenDTO;
import iot.sixiang.license.model.dto.ReportErrorMsgDTO; import iot.sixiang.license.model.dto.ReportErrorMsgDTO;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.model.dto.TerminalDevieUnBindDTO;
import iot.sixiang.license.service.DeviceService; import iot.sixiang.license.service.DeviceService;
import iot.sixiang.license.service.PmsUseService; import iot.sixiang.license.service.PmsUseService;
import iot.sixiang.license.service.TerminalDeviceService; import iot.sixiang.license.service.TerminalDeviceService;
...@@ -107,4 +108,19 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -107,4 +108,19 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
return BaseResult.failed(); return BaseResult.failed();
} }
} }
@Override
public BaseResult terminalDeviceunBind(TerminalDevieUnBindDTO terminalDevieUnBindDTO) {
String snBind = terminalDevieUnBindDTO.getSnBind();
if (StringUtils.isEmpty(snBind)) {
return BaseResult.validate_failed();
}
Boolean res = deviceService.terminalDevieunBind(terminalDevieUnBindDTO);
if (res) {
deviceManager.initDevices();
return BaseResult.success();
} else {
return BaseResult.failed();
}
}
} }
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