Skip to content

Commit

Permalink
style: 调整后端部分方法名 save => add
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Dec 24, 2023
1 parent 2720275 commit 45bd3e1
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public String socialLogin(AuthUser authUser) {
user.setGender(GenderEnum.valueOf(authUser.getGender().name()));
user.setAvatar(authUser.getAvatar());
user.setDeptId(SysConstants.SUPER_DEPT_ID);
Long userId = userService.save(user);
Long userId = userService.add(user);
RoleDO role = roleService.getByCode(SysConstants.ADMIN_ROLE_CODE);
userRoleService.save(Collections.singletonList(role.getId()), userId);
userRoleService.add(Collections.singletonList(role.getId()), userId);
userSocial = new UserSocialDO();
userSocial.setUserId(userId);
userSocial.setSource(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
public interface RoleDeptService {

/**
* 保存
* 新增
*
* @param deptIds
* 部门 ID 列表
* @param roleId
* 角色 ID
* @return true:成功;false:无变更/失败
*/
boolean save(List<Long> deptIds, Long roleId);
boolean add(List<Long> deptIds, Long roleId);

/**
* 根据角色 ID 删除
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
public interface RoleMenuService {

/**
* 保存
* 新增
*
* @param menuIds
* 菜单 ID 列表
* @param roleId
* 角色 ID
* @return true:成功;false:无变更/失败
*/
boolean save(List<Long> menuIds, Long roleId);
boolean add(List<Long> menuIds, Long roleId);

/**
* 根据角色 ID 删除
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
public interface UserRoleService {

/**
* 保存
* 新增
*
* @param roleIds
* 角色 ID 列表
* @param userId
* 用户 ID
* @return true:成功;false:无变更/失败
*/
boolean save(List<Long> roleIds, Long userId);
boolean add(List<Long> roleIds, Long userId);

/**
* 根据用户 ID 删除
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
public interface UserService extends BaseService<UserResp, UserDetailResp, UserQuery, UserReq> {

/**
* 保存用户信息
* 新增
*
* @param user
* 用户信息
* @return ID
*/
Long save(UserDO user);
Long add(UserDO user);

/**
* 上传头像
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class RoleDeptServiceImpl implements RoleDeptService {

@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(List<Long> deptIds, Long roleId) {
public boolean add(List<Long> deptIds, Long roleId) {
// 检查是否有变更
List<Long> oldDeptIdList = roleDeptMapper.lambdaQuery().select(RoleDeptDO::getDeptId)
.eq(RoleDeptDO::getRoleId, roleId).list().stream().map(RoleDeptDO::getDeptId).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class RoleMenuServiceImpl implements RoleMenuService {

@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(List<Long> menuIds, Long roleId) {
public boolean add(List<Long> menuIds, Long roleId) {
// 检查是否有变更
List<Long> oldMenuIdList = roleMenuMapper.lambdaQuery().select(RoleMenuDO::getMenuId)
.eq(RoleMenuDO::getRoleId, roleId).list().stream().map(RoleMenuDO::getMenuId).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public Long add(RoleReq req) {
req.setStatus(DisEnableStatusEnum.ENABLE);
Long roleId = super.add(req);
// 保存角色和菜单关联
roleMenuService.save(req.getMenuIds(), roleId);
roleMenuService.add(req.getMenuIds(), roleId);
// 保存角色和部门关联
roleDeptService.save(req.getDeptIds(), roleId);
roleDeptService.add(req.getDeptIds(), roleId);
return roleId;
}

Expand All @@ -103,9 +103,9 @@ public void update(RoleReq req, Long id) {
// 更新关联信息
if (!SysConstants.ADMIN_ROLE_CODE.equals(oldRole.getCode())) {
// 保存角色和菜单关联
boolean isSaveMenuSuccess = roleMenuService.save(req.getMenuIds(), id);
boolean isSaveMenuSuccess = roleMenuService.add(req.getMenuIds(), id);
// 保存角色和部门关联
boolean isSaveDeptSuccess = roleDeptService.save(req.getDeptIds(), id);
boolean isSaveDeptSuccess = roleDeptService.add(req.getDeptIds(), id);
// 如果角色编码、功能权限或数据权限有变更,则清除关联的在线用户(重新登录以获取最新角色权限)
if (ObjectUtil.notEqual(req.getCode(), oldCode) || ObjectUtil.notEqual(req.getDataScope(), oldDataScope)
|| isSaveMenuSuccess || isSaveDeptSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class UserRoleServiceImpl implements UserRoleService {

@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(List<Long> roleIds, Long userId) {
public boolean add(List<Long> roleIds, Long userId) {
// 检查是否有变更
List<Long> oldRoleIdList = userRoleMapper.lambdaQuery().select(UserRoleDO::getRoleId)
.eq(UserRoleDO::getUserId, userId).list().stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
private DeptService deptService;

@Override
public Long save(UserDO user) {
public Long add(UserDO user) {
user.setStatus(DisEnableStatusEnum.ENABLE);
baseMapper.insert(user);
return user.getId();
Expand All @@ -104,7 +104,7 @@ public Long add(UserReq req) {
.set(UserDO::getPassword, SecureUtils.md5Salt(SysConstants.DEFAULT_PASSWORD, userId.toString()))
.set(UserDO::getPwdResetTime, LocalDateTime.now()).eq(UserDO::getId, userId).update();
// 保存用户和角色关联
userRoleService.save(req.getRoleIds(), userId);
userRoleService.add(req.getRoleIds(), userId);
return userId;
}

Expand Down Expand Up @@ -132,7 +132,7 @@ public void update(UserReq req, Long id) {
// 更新信息
super.update(req, id);
// 保存用户和角色关联
userRoleService.save(req.getRoleIds(), id);
userRoleService.add(req.getRoleIds(), id);
}

@Override
Expand Down Expand Up @@ -248,7 +248,7 @@ public void resetPassword(Long id) {
public void updateRole(UserRoleUpdateReq updateReq, Long id) {
super.getById(id);
// 保存用户和角色关联
userRoleService.save(updateReq.getRoleIds(), id);
userRoleService.add(updateReq.getRoleIds(), id);
}

@Override
Expand Down

0 comments on commit 45bd3e1

Please sign in to comment.