refactor: 修改unique为duplicated命名更加直观,增加h2数据库的id自增起始值。

This commit is contained in:
valarchie
2022-10-29 23:55:58 +08:00
parent 451a5034bc
commit d7cf8573fd
21 changed files with 115 additions and 110 deletions

View File

@@ -78,7 +78,7 @@ public class DeptApplicationService {
@Transactional
public void addDept(AddDeptCommand addCommand, LoginUser loginUser) {
DeptModel deptModel = addCommand.toModel();
if (!deptService.isDeptNameUnique(deptModel.getDeptName(), null, deptModel.getParentId())) {
if (deptService.isDeptNameDuplicated(deptModel.getDeptName(), null, deptModel.getParentId())) {
throw new ApiException(ErrorCode.Business.DEPT_NAME_IS_NOT_UNIQUE, deptModel.getDeptName());
}
@@ -94,7 +94,7 @@ public class DeptApplicationService {
getDeptModel(updateCommand.getDeptId());
DeptModel deptModel = updateCommand.toModel();
if (!deptService.isDeptNameUnique(deptModel.getDeptName(), deptModel.getDeptId(), deptModel.getParentId())) {
if (deptService.isDeptNameDuplicated(deptModel.getDeptName(), deptModel.getDeptId(), deptModel.getParentId())) {
throw new ApiException(ErrorCode.Business.DEPT_NAME_IS_NOT_UNIQUE, deptModel.getDeptName());
}

View File

@@ -19,7 +19,7 @@ public class MenuModel extends SysMenuEntity {
public void checkMenuNameUnique(ISysMenuService menuService) {
if (!menuService.isMenuNameUnique(getMenuName(), getMenuId(), getParentId())) {
if (menuService.isMenuNameDuplicated(getMenuName(), getMenuId(), getParentId())) {
throw new ApiException(ErrorCode.Business.MENU_NAME_IS_NOT_UNIQUE);
}
}

View File

@@ -43,11 +43,11 @@ public class PostApplicationService {
PostModel postModel = addCommand.toModel();
// check这种全局唯一性的判断 不适合放在 model领域类当中 所以放在db service中 比较合适
if (!postService.isPostNameUnique(null, postModel.getPostName())) {
if (postService.isPostNameDuplicated(null, postModel.getPostName())) {
throw new ApiException(ErrorCode.Business.POST_NAME_IS_NOT_UNIQUE, postModel.getPostName());
}
if (!postService.isPostCodeUnique(null, postModel.getPostCode())) {
if (postService.isPostCodeDuplicated(null, postModel.getPostCode())) {
throw new ApiException(ErrorCode.Business.POST_CODE_IS_NOT_UNIQUE, postModel.getPostCode());
}
@@ -60,11 +60,11 @@ public class PostApplicationService {
PostModel postModel = updateCommand.toModel();
// check这种全局唯一性的判断 不适合放在 model领域类当中 所以放在db service中 比较合适
if (!postService.isPostNameUnique(postModel.getPostId(), postModel.getPostName())) {
if (postService.isPostNameDuplicated(postModel.getPostId(), postModel.getPostName())) {
throw new ApiException(ErrorCode.Business.POST_NAME_IS_NOT_UNIQUE, postModel.getPostName());
}
if (!postService.isPostCodeUnique(postModel.getPostId(), postModel.getPostCode())) {
if (postService.isPostCodeDuplicated(postModel.getPostId(), postModel.getPostCode())) {
throw new ApiException(ErrorCode.Business.POST_CODE_IS_NOT_UNIQUE, postModel.getPostCode());
}

View File

@@ -31,7 +31,7 @@ public class RoleModel extends SysRoleEntity {
private List<Long> deptIds;
public void checkRoleNameUnique(ISysRoleService roleService) {
if (!roleService.isRoleNameUnique(getRoleId(), getRoleName())) {
if (roleService.isRoleNameDuplicated(getRoleId(), getRoleName())) {
throw new ApiException(ErrorCode.Business.ROLE_NAME_IS_NOT_UNIQUE, getRoleName());
}
}
@@ -43,7 +43,7 @@ public class RoleModel extends SysRoleEntity {
}
public void checkRoleKeyUnique(ISysRoleService roleService) {
if (!roleService.isRoleKeyUnique(getRoleId(), getRoleKey())) {
if (roleService.isRoleKeyDuplicated(getRoleId(), getRoleKey())) {
throw new ApiException(ErrorCode.Business.ROLE_KEY_IS_NOT_UNIQUE, getRoleKey());
}
}

View File

@@ -18,21 +18,21 @@ import lombok.NoArgsConstructor;
public class UserModel extends SysUserEntity {
public void checkUsernameIsUnique(ISysUserService userService) {
if (!userService.isUserNameUnique(getUsername())) {
if (userService.isUserNameDuplicated(getUsername())) {
throw new ApiException(ErrorCode.Business.USER_NAME_IS_NOT_UNIQUE);
}
}
public void checkPhoneNumberIsUnique(ISysUserService userService) {
if (StrUtil.isNotEmpty(getPhoneNumber()) && !userService.isPhoneUnique(getPhoneNumber(),
if (StrUtil.isNotEmpty(getPhoneNumber()) && userService.isPhoneDuplicated(getPhoneNumber(),
getUserId())) {
throw new ApiException(ErrorCode.Business.USER_PHONE_NUMBER_IS_NOT_UNIQUE);
}
}
public void checkEmailIsUnique(ISysUserService userService) {
if (StrUtil.isNotEmpty(getEmail()) && !userService.isEmailUnique(getEmail(), getUserId())) {
if (StrUtil.isNotEmpty(getEmail()) && userService.isEmailDuplicated(getEmail(), getUserId())) {
throw new ApiException(ErrorCode.Business.USER_EMAIL_IS_NOT_UNIQUE);
}
}

View File

@@ -1,9 +1,9 @@
--- int后面不能带数字 索引相关的语句也不允许, 保留最简单原始的语句即可
create sequence if not exists sys_config_seq start with 6 increment by 1;
create table sys_config
(
config_id int auto_increment,
config_id int default next value for sys_config_seq,
config_name varchar(128) default '' not null comment '配置名称',
config_key varchar(128) default '' not null comment '配置键名',
config_options varchar(1024) default '' not null comment '可选的选项',
@@ -19,9 +19,10 @@ create table sys_config
deleted int default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_dept_seq start with 11 increment by 1;
create table sys_dept
(
dept_id int auto_increment,
dept_id int default next value for sys_dept_seq,
parent_id bigint default 0 not null comment '父部门id',
ancestors text not null comment '祖级列表',
dept_name varchar(64) default '' not null comment '部门名称',
@@ -40,9 +41,10 @@ create table sys_dept
deleted tinyint default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_login_info_seq start with 1 increment by 1;
create table sys_login_info
(
info_id bigint auto_increment,
info_id bigint default next value for sys_login_info_seq,
username varchar(50) default '' not null comment '用户账号',
ip_address varchar(128) default '' not null comment '登录IP地址',
login_location varchar(255) default '' not null comment '登录地点',
@@ -54,9 +56,10 @@ create table sys_login_info
deleted tinyint default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_menu_seq start with 63 increment by 1;
create table sys_menu
(
menu_id bigint auto_increment,
menu_id bigint default next value for sys_menu_seq,
menu_name varchar(64) not null comment '菜单名称',
parent_id bigint default 0 not null comment '父菜单ID',
order_num int default 0 not null comment '显示顺序',
@@ -80,9 +83,10 @@ create table sys_menu
deleted tinyint default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_notice_seq start with 3 increment by 1;
create table sys_notice
(
notice_id int auto_increment,
notice_id int default next value for sys_notice_seq,
notice_title varchar(64) not null comment '公告标题',
notice_type smallint not null comment '公告类型1通知 2公告',
notice_content text null comment '公告内容',
@@ -97,9 +101,10 @@ create table sys_notice
deleted tinyint default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_operation_log_seq start with 1 increment by 1;
create table sys_operation_log
(
operation_id bigint auto_increment,
operation_id bigint default next value for sys_operation_log_seq,
business_type smallint default 0 not null comment '业务类型0其它 1新增 2修改 3删除',
request_method smallint default 0 not null comment '请求方式',
request_module varchar(64) default '' not null comment '请求模块',
@@ -120,9 +125,10 @@ create table sys_operation_log
deleted tinyint default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_post_seq start with 5 increment by 1;
create table sys_post
(
post_id bigint auto_increment,
post_id bigint default next value for sys_post_seq,
post_code varchar(64) not null comment '岗位编码',
post_name varchar(64) not null comment '岗位名称',
post_sort int not null comment '显示顺序',
@@ -137,9 +143,10 @@ create table sys_post
deleted tinyint default 0 not null comment '逻辑删除'
);
create sequence if not exists sys_role_seq start with 4 increment by 1;
create table sys_role
(
role_id bigint auto_increment,
role_id bigint default next value for sys_role_seq,
role_name varchar(32) not null comment '角色名称',
role_key varchar(128) not null comment '角色权限字符串',
role_sort int not null comment '显示顺序',
@@ -162,9 +169,10 @@ create table sys_role_menu
menu_id bigint auto_increment not null comment '菜单ID'
);
create sequence if not exists sys_user_seq start with 4 increment by 1;
create table sys_user
(
user_id bigint auto_increment,
user_id bigint default next value for sys_user_seq,
post_id bigint null comment '职位id',
role_id bigint null comment '角色id',
dept_id bigint null comment '部门ID',

View File

@@ -19,14 +19,14 @@ class SysDeptServiceImplTest {
@Test
@Rollback
void testIsDeptNameUnique() {
boolean addWithSame = deptService.isDeptNameUnique("AgileBoot科技", null, null);
boolean updateWithSame = deptService.isDeptNameUnique("AgileBoot科技", 1L, null);
boolean addSameInParent = deptService.isDeptNameUnique("深圳总公司", null, 1L);
void testIsDeptNameDuplicated() {
boolean addWithSame = deptService.isDeptNameDuplicated("AgileBoot科技", null, null);
boolean updateWithSame = deptService.isDeptNameDuplicated("AgileBoot科技", 1L, null);
boolean addSameInParent = deptService.isDeptNameDuplicated("深圳总公司", null, 1L);
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertFalse(addSameInParent);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertTrue(addSameInParent);
}

View File

@@ -3,10 +3,8 @@ package com.agileboot.integrationtest.db;
import cn.hutool.core.collection.CollUtil;
import com.agileboot.integrationtest.IntegrationTestApplication;
import com.agileboot.orm.entity.SysMenuEntity;
import com.agileboot.orm.enums.MenuTypeEnum;
import com.agileboot.orm.service.ISysMenuService;
import java.util.List;
import java.util.Objects;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
@@ -42,14 +40,14 @@ class SysMenuServiceImplTest {
@Test
@Rollback
void testIsMenuNameUnique() {
boolean addWithSame = menuService.isMenuNameUnique("用户管理", null, 1L);
boolean updateWithSame = menuService.isMenuNameUnique("用户管理", 5L, 1L);
boolean addWithoutSame = menuService.isMenuNameUnique("用户管理", null, 2L);
void testIsMenuNameDuplicated() {
boolean addWithSame = menuService.isMenuNameDuplicated("用户管理", null, 1L);
boolean updateWithSame = menuService.isMenuNameDuplicated("用户管理", 5L, 1L);
boolean addWithoutSame = menuService.isMenuNameDuplicated("用户管理", null, 2L);
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}
@Test

View File

@@ -1,7 +1,6 @@
package com.agileboot.integrationtest.db;
import com.agileboot.integrationtest.IntegrationTestApplication;
import com.agileboot.orm.service.ISysDeptService;
import com.agileboot.orm.service.ISysPostService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -20,27 +19,27 @@ class SysPostServiceImplTest {
@Test
@Rollback
void testIsPostNameUnique() {
boolean addWithSame = postService.isPostNameUnique(null, "董事长");
boolean updateWithSame = postService.isPostNameUnique(1L, "董事长");
boolean addWithoutSame = postService.isPostNameUnique(null, "董事长1");
void testIsPostNameDuplicated() {
boolean addWithSame = postService.isPostNameDuplicated(null, "董事长");
boolean updateWithSame = postService.isPostNameDuplicated(1L, "董事长");
boolean addWithoutSame = postService.isPostNameDuplicated(null, "董事长1");
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}
@Test
@Rollback
void testIsPostCodeUnique() {
boolean addWithSame = postService.isPostCodeUnique(null, "ceo");
boolean updateWithSame = postService.isPostCodeUnique(1L, "ceo");
boolean addWithoutSame = postService.isPostCodeUnique(null, "ceo1");
void testIsPostCodeDuplicated() {
boolean addWithSame = postService.isPostCodeDuplicated(null, "ceo");
boolean updateWithSame = postService.isPostCodeDuplicated(1L, "ceo");
boolean addWithoutSame = postService.isPostCodeDuplicated(null, "ceo1");
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}

View File

@@ -20,27 +20,27 @@ class SysRoleServiceImplTest {
@Test
@Rollback
void testIsRoleNameUnique() {
boolean addWithSame = roleService.isRoleNameUnique(null, "超级管理员");
boolean updateWithSame = roleService.isRoleNameUnique(1L, "超级管理员");
boolean addWithoutSame = roleService.isRoleNameUnique(null, "超级管理员1");
void testIsRoleNameDuplicated() {
boolean addWithSame = roleService.isRoleNameDuplicated(null, "超级管理员");
boolean updateWithSame = roleService.isRoleNameDuplicated(1L, "超级管理员");
boolean addWithoutSame = roleService.isRoleNameDuplicated(null, "超级管理员1");
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}
@Test
@Rollback
void testIsRoleCodeUnique() {
boolean addWithSame = roleService.isRoleKeyUnique(null, "admin");
boolean updateWithSame = roleService.isRoleKeyUnique(1L, "admin");
boolean addWithoutSame = roleService.isRoleKeyUnique(null, "admin1");
void testIsRoleKeyDuplicated() {
boolean addWithSame = roleService.isRoleKeyDuplicated(null, "admin");
boolean updateWithSame = roleService.isRoleKeyDuplicated(1L, "admin");
boolean addWithoutSame = roleService.isRoleKeyDuplicated(null, "admin1");
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}

View File

@@ -34,36 +34,36 @@ class SysUserServiceImplTest {
@Test
@Rollback
void testIsUserNameUnique() {
boolean isUnique = userService.isUserNameUnique("admin");
void testIsUserNameDuplicated() {
boolean isDuplicated = userService.isUserNameDuplicated("admin");
Assertions.assertTrue(isUnique);
Assertions.assertTrue(isDuplicated);
}
@Test
@Rollback
void testIsPhoneUnique() {
boolean addWithSame = userService.isPhoneUnique("15888888889", null);
boolean updateWithSame = userService.isPhoneUnique("15888888889", 1L);
boolean addWithoutSame = userService.isPhoneUnique("15888888899", null);
void testIsPhoneDuplicated() {
boolean addWithSame = userService.isPhoneDuplicated("15888888889", null);
boolean updateWithSame = userService.isPhoneDuplicated("15888888889", 1L);
boolean addWithoutSame = userService.isPhoneDuplicated("15888888899", null);
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}
@Test
@Rollback
void testIsEmailUnique() {
boolean addWithSame = userService.isEmailUnique("agileboot@163.com", null);
boolean updateWithSame = userService.isEmailUnique("agileboot@163.com", 1L);
boolean addWithoutSame = userService.isEmailUnique("agileboot@164.com", null);
void testIsEmailDuplicated() {
boolean addWithSame = userService.isEmailDuplicated("agileboot@163.com", null);
boolean updateWithSame = userService.isEmailDuplicated("agileboot@163.com", 1L);
boolean addWithoutSame = userService.isEmailDuplicated("agileboot@164.com", null);
Assertions.assertFalse(addWithSame);
Assertions.assertTrue(updateWithSame);
Assertions.assertTrue(addWithoutSame);
Assertions.assertTrue(addWithSame);
Assertions.assertFalse(updateWithSame);
Assertions.assertFalse(addWithoutSame);
}
@Test

View File

@@ -21,7 +21,7 @@ public interface ISysDeptService extends IService<SysDeptEntity> {
* @param parentId
* @return
*/
boolean isDeptNameUnique(String deptName, Long deptId, Long parentId);
boolean isDeptNameDuplicated(String deptName, Long deptId, Long parentId);
/**
* 检测部门底下是否还有正在使用中的子部门

View File

@@ -37,7 +37,7 @@ public interface ISysMenuService extends IService<SysMenuEntity> {
* @param parentId
* @return
*/
boolean isMenuNameUnique(String menuName, Long menuId, Long parentId);
boolean isMenuNameDuplicated(String menuName, Long menuId, Long parentId);
/**
* 是否存在菜单子节点

View File

@@ -17,13 +17,13 @@ public interface ISysPostService extends IService<SysPostEntity> {
* 校验岗位名称
* @return 结果
*/
boolean isPostNameUnique(Long postId, String postName);
boolean isPostNameDuplicated(Long postId, String postName);
/**
* 校验岗位编码
* @return 结果
*/
boolean isPostCodeUnique(Long postId, String postCode);
boolean isPostCodeDuplicated(Long postId, String postCode);
/**

View File

@@ -18,13 +18,13 @@ public interface ISysRoleService extends IService<SysRoleEntity> {
* 校验角色名称是否唯一
* @return 结果
*/
boolean isRoleNameUnique(Long roleId, String roleName);
boolean isRoleNameDuplicated(Long roleId, String roleName);
/**
* 校验角色权限是否唯一
* @return 结果
*/
boolean isRoleKeyUnique(Long roleId, String roleKey);
boolean isRoleKeyDuplicated(Long roleId, String roleKey);

View File

@@ -25,7 +25,7 @@ public interface ISysUserService extends IService<SysUserEntity> {
* @param userId
* @return
*/
boolean isPhoneUnique(String phone, Long userId);
boolean isPhoneDuplicated(String phone, Long userId);
/**
* 检测邮箱是否唯一
@@ -33,14 +33,14 @@ public interface ISysUserService extends IService<SysUserEntity> {
* @param userId
* @return
*/
boolean isEmailUnique(String email, Long userId);
boolean isEmailDuplicated(String email, Long userId);
/**
* 检测用户名是否
* @param userName
* @return
*/
boolean isUserNameUnique(String userName);
boolean isUserNameDuplicated(String userName);
/**
* 获取用户的角色

View File

@@ -26,13 +26,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDeptEntity
@Override
public boolean isDeptNameUnique(String deptName, Long deptId, Long parentId) {
public boolean isDeptNameDuplicated(String deptName, Long deptId, Long parentId) {
QueryWrapper<SysDeptEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dept_name", deptName)
.ne(deptId != null, "dept_id", deptId)
.eq(parentId != null, "parent_id", parentId);
return !this.baseMapper.exists(queryWrapper);
return this.baseMapper.exists(queryWrapper);
}

View File

@@ -43,12 +43,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenuEntity
}
@Override
public boolean isMenuNameUnique(String menuName, Long menuId, Long parentId) {
public boolean isMenuNameDuplicated(String menuName, Long menuId, Long parentId) {
QueryWrapper<SysMenuEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("menu_name", menuName)
.ne(menuId != null, "menu_id", menuId)
.eq(parentId != null, "parent_id", parentId);
return !this.baseMapper.exists(queryWrapper);
return this.baseMapper.exists(queryWrapper);
}

View File

@@ -31,19 +31,19 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPostEntity
* @return 结果
*/
@Override
public boolean isPostNameUnique(Long postId, String postName) {
public boolean isPostNameDuplicated(Long postId, String postName) {
QueryWrapper<SysPostEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.ne(postId != null, "post_id", postId)
.eq("post_name", postName);
return !baseMapper.exists(queryWrapper);
return baseMapper.exists(queryWrapper);
}
@Override
public boolean isPostCodeUnique(Long postId, String postCode) {
public boolean isPostCodeDuplicated(Long postId, String postCode) {
QueryWrapper<SysPostEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.ne(postId != null, "post_id", postId)
.eq("post_code", postCode);
return !baseMapper.exists(queryWrapper);
return baseMapper.exists(queryWrapper);
}

View File

@@ -27,19 +27,19 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity
private SysUserMapper userMapper;
@Override
public boolean isRoleNameUnique(Long roleId, String roleName) {
public boolean isRoleNameDuplicated(Long roleId, String roleName) {
QueryWrapper<SysRoleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.ne(roleId != null, "role_id", roleId)
.eq("role_name", roleName);
return !this.baseMapper.exists(queryWrapper);
return this.baseMapper.exists(queryWrapper);
}
@Override
public boolean isRoleKeyUnique(Long roleId, String roleKey) {
public boolean isRoleKeyDuplicated(Long roleId, String roleKey) {
QueryWrapper<SysRoleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.ne(roleId != null, "role_id", roleId)
.eq("role_key", roleKey);
return !this.baseMapper.exists(queryWrapper);
return this.baseMapper.exists(queryWrapper);
}
@Override

View File

@@ -27,7 +27,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity
@Override
public boolean isUserNameUnique(String username) {
public boolean isUserNameDuplicated(String username) {
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username", username);
return this.baseMapper.exists(queryWrapper);
@@ -35,20 +35,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity
@Override
public boolean isPhoneUnique(String phone, Long userId) {
public boolean isPhoneDuplicated(String phone, Long userId) {
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.ne(userId != null, "user_id", userId)
.eq("phone_number", phone);
return !baseMapper.exists(queryWrapper);
return baseMapper.exists(queryWrapper);
}
@Override
public boolean isEmailUnique(String email, Long userId) {
public boolean isEmailDuplicated(String email, Long userId) {
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.ne(userId != null, "user_id", userId)
.eq("email", email);
return !baseMapper.exists(queryWrapper);
return baseMapper.exists(queryWrapper);
}