设备分享3
This commit is contained in:
@ -67,7 +67,7 @@ public class DeviceShareController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/permission")
|
||||
public R<Void> permission(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) {
|
||||
return toAjax(deviceShareService.deviceShare(bo));
|
||||
return toAjax(deviceShareService.permission(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,6 +212,46 @@ public class DeviceShareService {
|
||||
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
|
||||
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
|
||||
if (bindRecord == null) {
|
||||
throw new ServiceException("设备未绑定");
|
||||
}
|
||||
Long userId = bindRecord.getBindingUserId();
|
||||
|
||||
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
|
||||
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
|
||||
Long count = appDeviceShareMapper.selectCount(lqw);
|
||||
if (count > 0) {
|
||||
|
||||
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
|
||||
uw.eq("device_id", bo.getDeviceId());
|
||||
uw.eq("phonenumber", bo.getPhonenumber());
|
||||
uw.set("permission", bo.getPermission());
|
||||
uw.set("update_by", userId);
|
||||
uw.set("update_time", new Date());
|
||||
|
||||
return appDeviceShareMapper.update(uw);
|
||||
} else {
|
||||
AppDeviceShare appDeviceShare = new AppDeviceShare();
|
||||
appDeviceShare.setDeviceId(bo.getDeviceId());
|
||||
appDeviceShare.setPhonenumber(bo.getPhonenumber());
|
||||
appDeviceShare.setPermission(bo.getPermission());
|
||||
appDeviceShare.setCreateBy(userId);
|
||||
return appDeviceShareMapper.insert(appDeviceShare);
|
||||
}
|
||||
}
|
||||
|
||||
public int permission(AppDeviceShareBo bo) {
|
||||
Device device = deviceMapper.selectById(bo.getDeviceId());
|
||||
if (device == null) {
|
||||
throw new ServiceException("设备不存在");
|
||||
}
|
||||
LambdaQueryWrapper<AppDeviceBindRecord> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId());
|
||||
AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw);
|
||||
if (bindRecord == null) {
|
||||
throw new ServiceException("设备未绑定");
|
||||
}
|
||||
Long userId = bindRecord.getBindingUserId();
|
||||
|
||||
LambdaQueryWrapper<AppDeviceShare> lqw = new LambdaQueryWrapper<>();
|
||||
|
Reference in New Issue
Block a user