diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysRoleController.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysRoleController.java index 1935199..76a8f3d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysRoleController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/controller/SysRoleController.java @@ -141,6 +141,9 @@ public class SysRoleController extends AbstractController { //ValidatorUtils.validateEntity(role); role.setCreateBy(getUser().getNickName()); role.setCreateTime(new Date()); + if(role.getRoleName().length()>32){ + return R.error("角色名称太长"); + } sysRoleService.saveRole(role); return R.ok(); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java index d30bcca..fa2d109 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java @@ -433,7 +433,11 @@ public class TenPersonController extends AbstractController { return R.error("卡号已录入"); } } - }else{ + } + else if(tenPerson.getDoorCardEntity().getDoorCard().trim().equals("")){ + + } + else{ tenPerson.setDoorCardEntity(null); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java index ec0cbf0..7a47add 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java @@ -1099,49 +1099,54 @@ public class TenPersonServiceImpl implements TenPersonService { } if (entity.getDoorCardEntity() != null) { -// TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper() -// .eq("person_id", entity.getPersonId())); + if(entity.getDoorCardEntity().getDoorCard().trim().length()>0){ + // TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper() + // .eq("person_id", entity.getPersonId())); - List personDoorCardList = tenDoorCardService.list( - new QueryWrapper() - .eq("person_id",entity.getPersonId()) - ); - for(TenDoorCardEntity cardEntity: personDoorCardList){ - tenDoorCardService.removeById(cardEntity.getDoorCardId()); - } + List personDoorCardList = tenDoorCardService.list( + new QueryWrapper() + .eq("person_id",entity.getPersonId()) + ); + for(TenDoorCardEntity cardEntity: personDoorCardList){ + tenDoorCardService.removeById(cardEntity.getDoorCardId()); + } + + TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper() + .eq("door_card",entity.getDoorCardEntity().getDoorCard()) + .eq("cell_id",entity.getCellId())); + if(oldCard==null){ + // //增加 + TenDoorCardEntity newCard = new TenDoorCardEntity(); + newCard.setPersonId(entity.getPersonId()); + if (entity.getDoorCardEntity().getValidBegin() == null) { + newCard.setValidBegin(new Date()); + } else { + newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin()); + } + if (entity.getDoorCardEntity().getValidEnd() == null) { + Date date = new Date(); + Calendar cal = Calendar.getInstance(); + cal.setTime(date);//设置起时间 + cal.add(Calendar.YEAR, 10);//增加一年 + // System.out.println("输出::"+cal.getTime()); + newCard.setValidEnd(cal.getTime()); + } else { + newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd()); + } + // newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin()); + // newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd()); + newCard.setCellId(entity.getCellId()); + newCard.setDoorCard(entity.getDoorCardEntity().getDoorCard()); + Date now = new Date(); + newCard.setCreateTime(now); + newCard.setLastUpdateTime(now); + tenDoorCardService.save(newCard); + }else{ - TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper() - .eq("door_card",entity.getDoorCardEntity().getDoorCard()) - .eq("cell_id",entity.getCellId())); - if(oldCard==null){ - // //增加 - TenDoorCardEntity newCard = new TenDoorCardEntity(); - newCard.setPersonId(entity.getPersonId()); - if (entity.getDoorCardEntity().getValidBegin() == null) { - newCard.setValidBegin(new Date()); - } else { - newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin()); } - if (entity.getDoorCardEntity().getValidEnd() == null) { - Date date = new Date(); - Calendar cal = Calendar.getInstance(); - cal.setTime(date);//设置起时间 - cal.add(Calendar.YEAR, 10);//增加一年 -// System.out.println("输出::"+cal.getTime()); - newCard.setValidEnd(cal.getTime()); - } else { - newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd()); - } -// newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin()); -// newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd()); - newCard.setCellId(entity.getCellId()); - newCard.setDoorCard(entity.getDoorCardEntity().getDoorCard()); - Date now = new Date(); - newCard.setCreateTime(now); - newCard.setLastUpdateTime(now); - tenDoorCardService.save(newCard); }else{ - + //删除卡号 + tenDoorCardService.removeById(entity.getDoorCardEntity().getDoorCardId()); } // if (oldCard != null) {