This commit is contained in:
墨大叔 2024-05-21 14:33:47 +08:00
parent cd0c2c0a93
commit b66a5f3e15
3 changed files with 12 additions and 8 deletions

View File

@ -108,12 +108,12 @@ public interface ISmDeviceService
* @param storeId 店铺ID
* @param deviceNo 设备编号SN
*/
boolean bindBySn(Long storeId, String deviceNo);
String bindBySn(Long storeId, String deviceNo);
/**
* 通过MAC绑定设备
*/
boolean bindByMac(Long storeId, String mac);
String bindByMac(Long storeId, String mac);
/**
* 商户解绑设备

View File

@ -465,18 +465,22 @@ public class SmDeviceServiceImpl implements ISmDeviceService
@Override
@Transactional
public boolean bindBySn(Long storeId, String deviceNo) {
public String bindBySn(Long storeId, String deviceNo) {
SmDeviceVo device = selectByDeviceNo(deviceNo);
return this.bind(storeId, device);
}
@Override
public boolean bindByMac(Long storeId, String mac) {
public String bindByMac(Long storeId, String mac) {
SmDeviceVo device = selectByMac(mac);
return this.bind(storeId, device);
}
private boolean bind(Long storeId, SmDeviceVo device) {
private String bind(Long storeId, SmDeviceVo device) {
// 如果绑定的店铺是原来的店铺则直接返回MAC
if (device.getStoreId() != null && device.getStoreId().equals(storeId)) {
return device.getMac();
}
ServiceUtil.assertion(device == null, "设备未录入");
ServiceUtil.assertion(device.getStoreId() != null, "该设备已被绑定");
@ -493,7 +497,7 @@ public class SmDeviceServiceImpl implements ISmDeviceService
smDeviceBindRecordService.record(store.getUserId(), device.getDeviceId());
}, 0, TimeUnit.SECONDS);
return true;
return device.getMac();
}
/**

View File

@ -106,9 +106,9 @@ public class AppDeviceController extends BaseController {
return error("设备编号和mac不能同时为空");
}
if (StringUtils.hasText(device.getDeviceNo())) {
return success(smDeviceService.bindBySn(device.getStoreId(), device.getDeviceNo()));
return AjaxResult.success("操作成功", smDeviceService.bindBySn(device.getStoreId(), device.getDeviceNo()));
} else {
return success(smDeviceService.bindByMac(device.getStoreId(), device.getMac()));
return AjaxResult.success("操作成功", smDeviceService.bindByMac(device.getStoreId(), device.getMac()));
}
}