From c4d5e459e6dbd6823cac7612fab341d4ec2fe658 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Wed, 6 Mar 2019 23:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=AD=97?= =?UTF-8?q?=E5=85=B8=20tree=20=E6=8E=A5=E5=8F=A3=20=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E8=B4=A6=E5=8F=B7=EF=BC=8C=E4=B8=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/iocoder/mall/admin/api/constant/AdminConstants.java | 7 +++++++ .../mall/admin/api/constant/AdminErrorCodeEnum.java | 1 + .../cn/iocoder/mall/admin/service/AdminServiceImpl.java | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminConstants.java diff --git a/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminConstants.java b/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminConstants.java new file mode 100644 index 000000000..087464d19 --- /dev/null +++ b/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminConstants.java @@ -0,0 +1,7 @@ +package cn.iocoder.mall.admin.api.constant; + +public class AdminConstants { + + public static final String USERNAME_ADMIN = "admin"; + +} \ No newline at end of file diff --git a/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminErrorCodeEnum.java b/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminErrorCodeEnum.java index 0d5e9e00f..eb1a05736 100644 --- a/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminErrorCodeEnum.java +++ b/admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/constant/AdminErrorCodeEnum.java @@ -27,6 +27,7 @@ public enum AdminErrorCodeEnum { ADMIN_USERNAME_EXISTS(1002002002, "账号已经存在"), ADMIN_STATUS_EQUALS(1002002003, "账号已经是该状态"), ADMIN_DELETE_ONLY_DISABLE(1002002004, "只有关闭的账号才可以删除"), + ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE(1002002005, "管理员的账号状态不允许变更"), // ========== 资源模块 1002003000 ========== RESOURCE_NAME_DUPLICATE(1002003000, "已经存在该名字的资源"), diff --git a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java index b470ce9bb..88a4f2eac 100644 --- a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java +++ b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java @@ -7,6 +7,7 @@ import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.admin.api.AdminService; import cn.iocoder.mall.admin.api.bo.AdminBO; import cn.iocoder.mall.admin.api.bo.AdminPageBO; +import cn.iocoder.mall.admin.api.constant.AdminConstants; import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum; import cn.iocoder.mall.admin.api.dto.AdminAddDTO; import cn.iocoder.mall.admin.api.dto.AdminPageDTO; @@ -125,6 +126,9 @@ public class AdminServiceImpl implements AdminService { if (admin == null) { return ServiceExceptionUtil.error(AdminErrorCodeEnum.ADMIN_USERNAME_NOT_REGISTERED.getCode()); } + if (AdminConstants.USERNAME_ADMIN.equals(admin.getUsername())) { + return ServiceExceptionUtil.error(AdminErrorCodeEnum.ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE.getCode()); + } // 如果状态相同,则返回错误 if (status.equals(admin.getStatus())) { return ServiceExceptionUtil.error(AdminErrorCodeEnum.ADMIN_STATUS_EQUALS.getCode());