From cdcbed9af813b2a02cdc01eefa24db8bec6b51a9 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期三, 27 三月 2019 12:17:33 +0800 Subject: [PATCH] 主分类 + 子分类 DAO改造 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/ForbiddenUserIdentifyCodeServiceImpl.java | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ForbiddenUserIdentifyCodeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ForbiddenUserIdentifyCodeServiceImpl.java index 7f9ead2..44ffd34 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ForbiddenUserIdentifyCodeServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/ForbiddenUserIdentifyCodeServiceImpl.java @@ -21,15 +21,16 @@ private ForbiddenUserIdentifyCodeMapper forbiddenUserIdentifyCodeMapper; @Override - public void addIdentifyCode(ForbiddenUserIdentifyCode identifyCode) throws ForbiddenUserIdentifyCodeException { + public void forbiddenIdentifyCode(ForbiddenUserIdentifyCode identifyCode) throws ForbiddenUserIdentifyCodeException { if (identifyCode == null || identifyCode.getType() == null || StringUtil.isNullOrEmpty(identifyCode.getIdentifyCode())) throw new ForbiddenUserIdentifyCodeException(1, "淇℃伅涓嶅畬鏁�"); ForbiddenUserIdentifyCode old = listByTypeAndIdentifyCode(identifyCode.getType(), identifyCode.getIdentifyCode()); - if (old != null) - throw new ForbiddenUserIdentifyCodeException(2, "淇℃伅宸插瓨鍦�"); + if (old != null) { + identifyCode.setId(old.getId()); + } identifyCode.setCreateTime(new Date()); identifyCode.setEffective(true); @@ -82,16 +83,13 @@ typeEnum = ForbiddenUserIdentifyCodeTypeEnum.alipayAccount; break; default: - break; + throw new ForbiddenUserIdentifyCodeException(1, "绫诲瀷涓嶅尮閰�"); } - if (typeEnum == null) { - throw new ForbiddenUserIdentifyCodeException(1, "绫诲瀷涓嶅尮閰�"); - } ForbiddenUserIdentifyCode codeObject = listByTypeAndIdentifyCode(typeEnum ,identifyCode); if (codeObject == null) { - // 灏佺璐︽埛 + // 灏佺 codeObject = new ForbiddenUserIdentifyCode(); codeObject.setType(typeEnum); codeObject.setIdentifyCode(identifyCode); @@ -101,7 +99,17 @@ forbiddenUserIdentifyCodeMapper.insertSelective(codeObject); } else { - codeObject.setEffective(false); + + Boolean effective = codeObject.getEffective(); + if (effective) { + // 瑙e皝 + codeObject.setEffective(false); + } else { + // 灏佺 + codeObject.setEffective(true); + } + + codeObject.setUpdateTime(new Date()); forbiddenUserIdentifyCodeMapper.updateByPrimaryKeySelective(codeObject); } -- Gitblit v1.8.0