|
@@ -51,12 +51,19 @@ public class PersonDeviceRelationController {
|
|
|
MessageResult<PersonDeviceRelation> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- personDeviceRelation.setId(UUID.randomUUID().toString());
|
|
|
- personDeviceRelation.setDelFlag(false);
|
|
|
- personDeviceRelation.setCreateBy(subject);
|
|
|
- personDeviceRelation.setCreateTime(new Date());
|
|
|
-
|
|
|
- int affectCount = personDeviceRelationService.insert(personDeviceRelation);
|
|
|
+ int affectCount = 0;
|
|
|
+
|
|
|
+ PersonDeviceRelation item = personDeviceRelationService.findByDeviceIdAndPersonId(personDeviceRelation.getDeviceId(),personDeviceRelation.getPersonId());
|
|
|
+
|
|
|
+ if(item == null) {
|
|
|
+
|
|
|
+ personDeviceRelation.setId(UUID.randomUUID().toString());
|
|
|
+ personDeviceRelation.setDelFlag(false);
|
|
|
+ personDeviceRelation.setCreateBy(subject);
|
|
|
+ personDeviceRelation.setCreateTime(new Date());
|
|
|
+
|
|
|
+ affectCount = personDeviceRelationService.insert(personDeviceRelation);
|
|
|
+ }
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|