feat(user): 新增用户管理相关功能实现
- 添加后台菜单相关Mapper接口和XML配置,支持菜单按钮获取、权限校验等 - 实现后台菜单服务业务逻辑,支持菜单授权树查询、菜单增删改查及启用禁用功能 - 新增用户管理Service,支持用户增删改、角色授权、密码重置及供应商账户管理 - 实现用户供应商相关业务逻辑,包括供应商账号开通、权限分配和批量导入功能 - 集成邮件发送功能,实现忘记密码邮件通知 - 完善用户角色和权限映射管理接口及逻辑,支持批量操作和事务管理 - 引入密码加密与验证机制,保证账户安全性
This commit is contained in:
parent
f336cf7ae6
commit
bc0f87d458
|
|
@ -117,6 +117,7 @@ public class UserControllerService {
|
|||
.setPassword(PASSWORDENCODER.encode(request.getPassword()))
|
||||
.setLanguageCode(request.getLanguageCode())
|
||||
.setPurchasingGroup(request.getPurchasingGroup())
|
||||
.setCreateById(UserUtil.getUserId())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
uService.add(user);
|
||||
|
|
@ -323,6 +324,7 @@ public class UserControllerService {
|
|||
.setRemark(remark)
|
||||
.setUserCode(loginName)
|
||||
.setPassword(PASSWORDENCODER.encode(pwd))
|
||||
.setCreateById(UserUtil.getUserId())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setMustResetPwd(mustResetPwd)
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
|
|
@ -770,6 +772,15 @@ public class UserControllerService {
|
|||
|
||||
@Transactional
|
||||
public void addLdapUsers(List<UserAddLdapQO> ldapUsers) {
|
||||
List<String> existUserCodes = uService.lambdaQuery()
|
||||
.select(User::getUserCode)
|
||||
.in(User::getUserCode, ldapUsers.stream().map(UserAddLdapQO::getUserCode).collect(Collectors.toSet()))
|
||||
.list()
|
||||
.stream()
|
||||
.map(User::getUserCode)
|
||||
.collect(Collectors.toList());
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(existUserCodes))
|
||||
.throwMessage("以下用户工号已注册:" + StrUtil.join(",", existUserCodes));
|
||||
List<User> users = new ArrayList<>();
|
||||
List<UserInterior> userInteriors = new ArrayList<>();
|
||||
List<Department> departments = deptService.lambdaQuery()
|
||||
|
|
@ -792,6 +803,7 @@ public class UserControllerService {
|
|||
.setSourceId(userAddLdapQO.getDistinguishedName())
|
||||
.setRemark("LDAP用户")
|
||||
.setLanguageCode(Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.setCreateById(UserUtil.getUserId())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
users.add(user);
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ public interface MenuMapper extends BaseMapper<Menu> {
|
|||
Boolean menuIsSelected(Long roleId, Long menuId);
|
||||
|
||||
List<MenuAuthorizeVO> getAllDataForAuthorize(Long roleId);
|
||||
|
||||
List<Long> getMenuIdsByRoleIds(List<Long> roleIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import com.nflg.wms.common.util.VUtil;
|
|||
import com.nflg.wms.repository.entity.Menu;
|
||||
import com.nflg.wms.repository.entity.MenuButton;
|
||||
import com.nflg.wms.repository.entity.RoleButtonMap;
|
||||
import com.nflg.wms.repository.entity.RoleMenuMap;
|
||||
import com.nflg.wms.repository.mapper.MenuMapper;
|
||||
import com.nflg.wms.repository.service.*;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -35,7 +34,6 @@ import java.util.stream.Collectors;
|
|||
* <p>
|
||||
* 后台-菜单 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
|
|
@ -51,9 +49,6 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
|||
@Resource
|
||||
private IUserRoleMapService userRoleMapService;
|
||||
|
||||
@Resource
|
||||
private IRoleMenuMapService roleMenuMapService;
|
||||
|
||||
@Override
|
||||
public List<MenuAuthorizeVO> getMenuForAuthorize(Long roleId) {
|
||||
List<Menu> datas = lambdaQuery()
|
||||
|
|
@ -70,14 +65,9 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
|||
@Override
|
||||
public List<MenuAuthorizeVO> getNodeForAuthorize(Long roleId) {
|
||||
List<MenuAuthorizeVO> nodes = baseMapper.getAllDataForAuthorize(roleId);
|
||||
if (!UserUtil.getRoles().contains(Constant.SUPER_ADMIN)){
|
||||
List<RoleVO> userRoles=userRoleMapService.getRoleList(UserUtil.getUserId());
|
||||
List<Long> menuIds =roleMenuMapService.lambdaQuery()
|
||||
.in(RoleMenuMap::getRoleId, userRoles.stream().map(RoleVO::getId).collect(Collectors.toList()))
|
||||
.list()
|
||||
.stream()
|
||||
.map(RoleMenuMap::getMenuId)
|
||||
.toList();
|
||||
if (!UserUtil.getRoles().contains(Constant.SUPER_ADMIN)) {
|
||||
List<RoleVO> userRoles = userRoleMapService.getRoleList(UserUtil.getUserId());
|
||||
List<Long> menuIds = baseMapper.getMenuIdsByRoleIds(userRoles.stream().map(RoleVO::getId).collect(Collectors.toList()));
|
||||
nodes.removeIf(v -> !menuIds.contains(v.getId()));
|
||||
}
|
||||
List<MenuAuthorizeVO> rootNodes = nodes.stream().filter(v ->
|
||||
|
|
|
|||
|
|
@ -35,4 +35,13 @@
|
|||
where "enable" = true
|
||||
order by sort;
|
||||
</select>
|
||||
|
||||
<select id="getMenuIdsByRoleIds" resultType="java.lang.Long">
|
||||
SELECT menu_id
|
||||
FROM role_menu_map
|
||||
WHERE role_id IN
|
||||
<foreach item="roleId" collection="roleIds" separator="," open="(" close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue