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());