OA板块整合与实现

This commit is contained in:
lijiaqi 2023-02-23 14:04:23 +08:00
parent e770567b9b
commit 0cee91d90a
1 changed files with 45 additions and 1 deletions

View File

@ -1,20 +1,25 @@
package com.ydool.oa.formily.userdept.impl;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ydool.common.cache.ConfigCache;
import com.ydool.common.utils.PasswordUtil;
import com.ydool.oa.formily.userdept.IUserDeptService;
import com.ydool.oa.formily.userdept.UserDept;
import com.ydool.system.entity.Dept;
import com.ydool.system.entity.Job;
import com.ydool.system.entity.Menu;
import com.ydool.system.entity.User;
import com.ydool.system.service.impl.DeptServiceImpl;
import com.ydool.system.service.impl.JobServiceImpl;
import com.ydool.system.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -24,6 +29,10 @@ import java.util.stream.Collectors;
@Service
public class UserDeptServiceImpl implements IUserDeptService {
@Value("${sa-token.token-prefix}")
private String tokenPrefix;
@Autowired
private UserServiceImpl userService;
@ -166,7 +175,42 @@ public class UserDeptServiceImpl implements IUserDeptService {
@Override
public Object getUserMenuList() {
return userService.menuTreesByUserId(StpUtil.getLoginIdAsString());
User loginUser = userService.getOne(new QueryWrapper<User>().lambda()
.eq(User::getId, StpUtil.getLoginIdAsString())
.eq(User::getStatus, true)
.last("limit 1")
);
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
Dict result = Dict.create();
result.set("tokenName", tokenInfo.getTokenName());
result.set("tokenPrefix", tokenPrefix);
result.set("tokenValue", tokenInfo.getTokenValue());
result.set("name", loginUser.getUserName());
List<Menu> menus = userService.menuTreesByUserId(StpUtil.getLoginIdAsString());
result.set("menus", menus);
List<String> perms = new ArrayList<String>();
List<Menu> menuList = userService.menusByUser(StpUtil.getLoginIdAsString());
if (CollUtil.isNotEmpty(menuList)) {
perms = menuList.stream().map(Menu::getPerms).collect(Collectors.toList());
}
result.set("perms", perms);
String deptName = "";
Dept dept = deptService.getById(loginUser.getDept());
if (ObjectUtil.isNotNull(dept)) {
deptName = dept.getName();
}
result.set("deptName", deptName);
String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD,
"888888");
initPassword = PasswordUtil.password(loginUser.getSalt(), initPassword);
//是否需要强制修改密码
result.set("need_init_password", initPassword.equals(loginUser.getPassword()) ? true : false);
return result;
}