调整Oam登录退出获取用户信息
This commit is contained in:
parent
25773526cd
commit
ce01210aab
@ -19,6 +19,11 @@ public class LoginSuccess implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ -33,4 +38,10 @@ public class LoginSuccess implements Serializable {
|
||||
* 权限
|
||||
*/
|
||||
private Set<String> role;
|
||||
|
||||
public LoginSuccess(String id, String userId, String token) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,14 +13,7 @@ public enum UserType {
|
||||
* oam系统员工
|
||||
*/
|
||||
OAM_USER(0, "oam:loginUser:"),
|
||||
/**
|
||||
* 小程序用户
|
||||
*/
|
||||
MINI_USER(1, "mini:loginUser:"),
|
||||
/**
|
||||
* 商城系统员工
|
||||
*/
|
||||
MALL_USER(2, "mall:loginUser:");
|
||||
;
|
||||
|
||||
/**
|
||||
* code
|
||||
|
||||
@ -3,10 +3,10 @@ package com.cpop.core.base.table;
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.entity.BaseInsertListener;
|
||||
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.cpop.core.base.enums.UserType;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.cpop.core.base.enums.UserType;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ -36,7 +36,7 @@ public class User extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
@ -51,7 +51,7 @@ public class User extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
@ -61,7 +61,7 @@ public class User extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 性别(0:男;1:女)
|
||||
@ -91,7 +91,7 @@ public class User extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
private UserType userType;
|
||||
|
||||
/**
|
||||
* 逻辑删除(0否1是)
|
||||
|
||||
@ -166,13 +166,12 @@ public interface Constants {
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
*/
|
||||
String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework.jndi"};
|
||||
String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", "org.springframework.jndi"};
|
||||
|
||||
/**
|
||||
* 超级管理员
|
||||
*/
|
||||
String SUPER_ADMIN = "Jambox";
|
||||
String SUPER_ADMIN = "Cpop";
|
||||
|
||||
/**
|
||||
* 超级管理员ID
|
||||
@ -182,7 +181,7 @@ public interface Constants {
|
||||
/**
|
||||
* 超级身份id
|
||||
*/
|
||||
String SUPER_IDENTITY_AUTH_ID = "100";
|
||||
String SUPER_ROLE_ID = "100";
|
||||
|
||||
/**
|
||||
* 超级管理员
|
||||
|
||||
@ -4,7 +4,7 @@ cpop:
|
||||
profile: E:/Cpop/uploadPath
|
||||
jwt:
|
||||
#白名单
|
||||
white-list: /websocket/*,/login,/doc.html,/webjars/**,/favicon.ico,/v2/api-docs/**,/swagger-resources,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/*,/mini/cardTemplate/*,/website/**,/backstage/wxCp/*,/callback/wxCp/*/registerCode,/callback/easyLearn/**,/cloudCallback/*,/mini/summit/*
|
||||
white-list: /profile/**,/backstage/login,/doc.html,/webjars/**,/favicon.ico,/v3/api-docs/**,/swagger-ui.html,/swagger-ui/**,/sysCommon/miniSyncBrandAndStore,/easyLearn/callback/*/*,/easyLearn/*,/mini/cardTemplate/*,/website/**,/backstage/wxCp/*,/callback/wxCp/*/registerCode,/callback/easyLearn/**,/cloudCallback/*,/mini/summit/*
|
||||
gateway:
|
||||
rsa-keypair:
|
||||
# 公钥文件
|
||||
|
||||
BIN
Cpop-Oam/Cpop-Oam-Web/src/main/resources/static/favicon.ico
Normal file
BIN
Cpop-Oam/Cpop-Oam-Web/src/main/resources/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@ -0,0 +1,42 @@
|
||||
package com.cpop.oam.business.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
* @since 2023-04-05 17:53
|
||||
*/
|
||||
@Data
|
||||
public class LoginForm implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 单次标识
|
||||
*/
|
||||
private String userKey;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
}
|
||||
@ -1,13 +1,20 @@
|
||||
package com.cpop.system.business.controller.backstage;
|
||||
package com.cpop.oam.business.controller.backstage;
|
||||
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cpop.core.base.entity.LoginSuccess;
|
||||
import com.cpop.core.base.entity.R;
|
||||
import com.cpop.core.base.enums.OperationLogEnum;
|
||||
import com.cpop.core.constant.Constants;
|
||||
import com.cpop.core.service.OperationLogService;
|
||||
import com.cpop.core.utils.MessageUtils;
|
||||
import com.cpop.core.utils.ServletUtils;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.system.business.service.LoginService;
|
||||
import com.cpop.core.utils.ip.IpUtils;
|
||||
import com.cpop.oam.business.bo.LoginForm;
|
||||
import com.cpop.oam.business.service.LoginService;
|
||||
import com.cpop.oam.business.vo.loginInfo.SysStaffLoginInfo;
|
||||
import com.cpop.system.business.vo.LoginUserInfoVo;
|
||||
import com.cpop.system.business.vo.MenuRouteVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -31,6 +38,36 @@ public class BackstageLoginController {
|
||||
@Autowired
|
||||
private LoginService loginService;
|
||||
|
||||
/**
|
||||
* 系统登录
|
||||
* @author DB
|
||||
* @since 2023/12/2
|
||||
* @return R<LoginSuccess>
|
||||
*/
|
||||
@Operation(summary="系统登录")
|
||||
@PostMapping("/login")
|
||||
public R<LoginSuccess> login(@RequestBody LoginForm loginForm) {
|
||||
SysStaffLoginInfo login = loginService.login(loginForm);
|
||||
// 第1步,先登录上
|
||||
StpUtil.login(login.getId(),"PC");
|
||||
SaSession session = StpUtil.getSession();
|
||||
session.set("id", login.getId())
|
||||
.set("loginIp", IpUtils.getIpAddr(ServletUtils.getRequest()))
|
||||
.set("username", login.getUsername())
|
||||
.set("userId", login.getUserId())
|
||||
.set("name", login.getName())
|
||||
.set("avatar", login.getAvatar() == null ? "" : login.getAvatar())
|
||||
.set("userType", login.getUserType())
|
||||
.set("phone", login.getPhone())
|
||||
.set("roleId", login.getRoleId())
|
||||
.set("isSuper", login.getIsSuper());
|
||||
//添加操作日志
|
||||
SpringUtils.getBean(OperationLogService.class).insertOperationLog(200, OperationLogEnum.SYSTEM_LOGIN, session, null);
|
||||
// 第2步,获取 Token 相关参数
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
return R.ok(new LoginSuccess(tokenInfo.getLoginId().toString(), login.getUserId(), tokenInfo.getTokenValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统注销
|
||||
* @author DB
|
||||
@ -1,5 +1,7 @@
|
||||
package com.cpop.system.business.service;
|
||||
package com.cpop.oam.business.service;
|
||||
|
||||
import com.cpop.oam.business.bo.LoginForm;
|
||||
import com.cpop.oam.business.vo.loginInfo.SysStaffLoginInfo;
|
||||
import com.cpop.system.business.vo.LoginUserInfoVo;
|
||||
import com.cpop.system.business.vo.MenuRouteVo;
|
||||
|
||||
@ -12,6 +14,15 @@ import java.util.Set;
|
||||
*/
|
||||
public interface LoginService {
|
||||
|
||||
/**
|
||||
* 系统登录
|
||||
* @author DB
|
||||
* @since 2024/4/24
|
||||
* @param loginForm 登录表单
|
||||
* @return SysStaffLoginInfo
|
||||
*/
|
||||
SysStaffLoginInfo login(LoginForm loginForm);
|
||||
|
||||
/**
|
||||
* 获取登录用户详情
|
||||
*
|
||||
@ -31,4 +42,6 @@ public interface LoginService {
|
||||
* @Date: 2023/5/11 9:16
|
||||
**/
|
||||
List<MenuRouteVo> getSysMenuList();
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package com.cpop.oam.business.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cpop.core.base.exception.ServiceException;
|
||||
import com.cpop.core.base.table.User;
|
||||
import com.cpop.core.constant.Constants;
|
||||
import com.cpop.core.service.UserService;
|
||||
import com.cpop.core.utils.RsaUtils;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.core.utils.bean.BeanUtils;
|
||||
import com.cpop.oam.business.bo.LoginForm;
|
||||
import com.cpop.oam.business.entity.Staff;
|
||||
import com.cpop.oam.business.service.LoginService;
|
||||
import com.cpop.oam.business.service.StaffService;
|
||||
import com.cpop.oam.business.vo.loginInfo.SysStaffLoginInfo;
|
||||
import com.cpop.system.business.entity.Menu;
|
||||
import com.cpop.system.business.service.MenuService;
|
||||
import com.cpop.system.business.vo.LoginUserInfoVo;
|
||||
import com.cpop.system.business.vo.MenuRouteVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cpop.core.base.table.table.UserTableDef.USER;
|
||||
import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF;
|
||||
import static com.cpop.system.business.entity.table.MenuTableDef.MENU;
|
||||
import static com.cpop.system.business.entity.table.RoleMenuTableDef.ROLE_MENU;
|
||||
import static com.cpop.system.business.entity.table.RoleTableDef.ROLE;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
* @createTime 2023/09/10 11:19
|
||||
* @description
|
||||
*/
|
||||
@Service("loginService")
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
|
||||
@Autowired
|
||||
private RsaUtils rsaUtils;
|
||||
|
||||
/**
|
||||
* 系统登录
|
||||
* @author DB
|
||||
* @since 2024/4/24
|
||||
* @param loginForm 登录表单
|
||||
* @return SysStaffLoginInfo
|
||||
*/
|
||||
@Override
|
||||
public SysStaffLoginInfo login(LoginForm loginForm) {
|
||||
//获取用户信息
|
||||
User user = SpringUtils.getBean(UserService.class).queryChain()
|
||||
.select(USER.ID, USER.USERNAME, USER.PASSWORD, USER.PHONE, USER.AVATAR)
|
||||
.where(USER.USERNAME.eq(loginForm.getUsername()))
|
||||
.one();
|
||||
if (user == null){
|
||||
throw new ServiceException("用户名或密码错误!");
|
||||
}
|
||||
//rsa解密
|
||||
String password = rsaUtils.decrypt(loginForm.getPassword());
|
||||
// 使用checkpw方法检查被加密的字符串是否与原始字符串匹配:
|
||||
if (!BCrypt.checkpw(password, user.getPassword())) {
|
||||
throw new ServiceException("用户名或密码错误!");
|
||||
}
|
||||
return getStaffLoginInfo(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户信息
|
||||
* @author DB
|
||||
* @since 2024/3/21
|
||||
* @param user 用户
|
||||
* @return SysStaffLoginInfo
|
||||
*/
|
||||
private SysStaffLoginInfo getStaffLoginInfo(User user){
|
||||
//获取员工信息
|
||||
SysStaffLoginInfo staffLoginInfo = BeanUtils.mapToClass(user, SysStaffLoginInfo.class);
|
||||
if (!staffLoginInfo.getUsername().equals(Constants.SUPER_ADMIN)) {
|
||||
Staff staff = SpringUtils.getBean(StaffService.class).queryChain()
|
||||
.where(STAFF.USER_ID.eq(user.getId()))
|
||||
.one();
|
||||
staffLoginInfo.setRoleId(staff.getRoleId());
|
||||
staffLoginInfo.setIsSuper(false);
|
||||
staffLoginInfo.setName(staff.getRoleId());
|
||||
staffLoginInfo.setId(staff.getId());
|
||||
} else {
|
||||
staffLoginInfo.setRoleId(Constants.SUPER_ROLE_ID);
|
||||
staffLoginInfo.setIsSuper(true);
|
||||
staffLoginInfo.setName(Constants.SUPER_ADMIN);
|
||||
staffLoginInfo.setId(Constants.SUPER_ADMIN_ID);
|
||||
}
|
||||
staffLoginInfo.setUserId(user.getId())
|
||||
.setAvatar(user.getAvatar())
|
||||
.setPhone(user.getPhone());
|
||||
return staffLoginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @author LOST.yuan
|
||||
* @since 23:01 2022/9/26
|
||||
* @return {@link String}
|
||||
**/
|
||||
@Override
|
||||
public LoginUserInfoVo getUserInfo() {
|
||||
SaSession session = StpUtil.getSession();
|
||||
return new LoginUserInfoVo()
|
||||
.setId(session.getString("id"))
|
||||
.setUserId(session.getString("userId"))
|
||||
.setUsername(session.getString("username"))
|
||||
.setRealName(session.getString("name"))
|
||||
.setAvatar(session.getString("avatar"))
|
||||
.setPermissions(StpUtil.getPermissionList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限码
|
||||
* @author DB
|
||||
* @since 2023-11-30 14:32:57
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getPermCode() {
|
||||
SaSession session = StpUtil.getSession();
|
||||
if (StringUtils.equals(Constants.SUPER_ADMIN, session.getString("username"))) {
|
||||
Set<String> permCodes = new HashSet<>();
|
||||
permCodes.add("*.*.*");
|
||||
return permCodes;
|
||||
} else {
|
||||
List<Menu> menuPermissions = SpringUtils.getBean(MenuService.class)
|
||||
.queryChain()
|
||||
.select(MENU.PERMISSION)
|
||||
.leftJoin(ROLE_MENU)
|
||||
.on(ROLE_MENU.MENU_ID.eq(MENU.ID))
|
||||
.leftJoin(ROLE)
|
||||
.on(ROLE.ID.eq(ROLE_MENU.ROLE_ID))
|
||||
.where(ROLE.ID.eq(session.getString("roleId")))
|
||||
.and(MENU.TYPE.in(1, 2))
|
||||
.and(MENU.PERMISSION.isNotNull())
|
||||
.list();
|
||||
return menuPermissions.stream().map(Menu::getPermission).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<MenuRouteVo> getSysMenuList() {
|
||||
return SpringUtils.getBean(MenuService.class).getSysMenuList();
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ public class OamWxCpServiceImpl implements OamWxCpService {
|
||||
User sysUser = new User();
|
||||
sysUser.setId(IdUtils.fastSimpleUUID())
|
||||
.setStatus(item.getStatus() == 1)
|
||||
.setUserType(UserType.OAM_USER.toString())
|
||||
.setUserType(UserType.OAM_USER)
|
||||
.setCreateUserId("1");
|
||||
sysUser.setUpdateUserId("1");
|
||||
userWxCpUserMap.put(sysUser, item);
|
||||
@ -199,7 +199,7 @@ public class OamWxCpServiceImpl implements OamWxCpService {
|
||||
throw new ServiceException("请先在企微上的Oam应用中进行注册");
|
||||
}
|
||||
User sysUser = RowUtil.toEntity(row, User.class);
|
||||
return new WxCpLoginVo(sysUser.getUserName(), sysUser.getRsaPassword());
|
||||
return new WxCpLoginVo(sysUser.getUsername(), sysUser.getRsaPassword());
|
||||
} catch (WxErrorException e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
, QueryWrapper.create()
|
||||
//去重
|
||||
.select(distinct(STAFF.ALL_COLUMNS))
|
||||
.select(USER.USER_NAME,USER.NICK_NAME, USER.EMAIL, USER.PHONE_NUMBER, USER.SEX, USER.AVATAR, USER.STATUS, USER.PASSWORD)
|
||||
.select(USER.USERNAME,USER.NICKNAME, USER.EMAIL, USER.PHONE, USER.SEX, USER.AVATAR, USER.STATUS, USER.PASSWORD)
|
||||
.select(ROLE.ROLE_NAME)
|
||||
//将部门id分组
|
||||
.select(groupConcat(STAFF_MID_DEPT.DEPT_ID).as(StaffPageVo::getDeptId))
|
||||
@ -88,7 +88,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
.and(STAFF.STAFF_TYPE.eq(bo.getStaffType()))
|
||||
//部门id
|
||||
.and(STAFF_MID_DEPT.DEPT_ID.eq(bo.getDeptId()))
|
||||
.and(USER.USER_NAME.ne(Constants.SUPER_ADMIN).or(USER.USER_NAME.isNull()))
|
||||
.and(USER.USERNAME.ne(Constants.SUPER_ADMIN).or(USER.USERNAME.isNull()))
|
||||
.groupBy(STAFF.ID)
|
||||
, StaffPageVo.class);
|
||||
}
|
||||
@ -113,7 +113,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
user.setRsaPassword(bo.getPassword());
|
||||
decryptAndResetPasswords(user);
|
||||
user.setId(IdUtils.fastSimpleUUID());
|
||||
user.setUserType(UserType.OAM_USER.toString());
|
||||
user.setUserType(UserType.OAM_USER);
|
||||
SpringUtils.getBean(UserService.class).save(user);
|
||||
}
|
||||
//再添加员工信息
|
||||
@ -142,7 +142,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
private Boolean validatedUserInfo(StaffBo bo) {
|
||||
long count = this.count(QueryWrapper.create()
|
||||
//用户名
|
||||
.where(USER.USER_NAME.eq(bo.getUserName()).or(USER.PHONE_NUMBER.eq(bo.getPhoneNumber())))
|
||||
.where(USER.USERNAME.eq(bo.getUserName()).or(USER.PHONE.eq(bo.getPhoneNumber())))
|
||||
//手机号
|
||||
.and(USER.USER_TYPE.eq(UserType.OAM_USER.toString()))
|
||||
.from(USER));
|
||||
@ -243,7 +243,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
return;
|
||||
}
|
||||
if (this.count(QueryWrapper.create()
|
||||
.where(USER.USER_NAME.eq(username))
|
||||
.where(USER.USERNAME.eq(username))
|
||||
.and(USER.ID.ne(id))) > 0) {
|
||||
throw new ServiceException(MessageUtils.message("i18n_alert_userIsExist"));
|
||||
}
|
||||
@ -260,7 +260,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
public StaffInfoVo getStaffInfo(String id) {
|
||||
return this.getOneAs(QueryWrapper.create()
|
||||
.select(STAFF.ALL_COLUMNS)
|
||||
.select(USER.USER_NAME, USER.NICK_NAME, USER.SEX, USER.PHONE_NUMBER, USER.ID.as("userId"))
|
||||
.select(USER.USERNAME, USER.NICKNAME, USER.SEX, USER.PHONE, USER.ID.as("userId"))
|
||||
.select(ROLE.ROLE_NAME)
|
||||
.from(STAFF)
|
||||
.leftJoin(USER).on(USER.ID.eq(STAFF.USER_ID))
|
||||
@ -310,7 +310,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
User user = DbChain.table(USER)
|
||||
.where(USER.ID.eq(bo.getUserId()))
|
||||
.oneAs(User.class);
|
||||
if (!StringUtils.equals(userName, Constants.SUPER_ADMIN) || !StringUtils.equals(userName, user.getUserName())) {
|
||||
if (!StringUtils.equals(userName, Constants.SUPER_ADMIN) || !StringUtils.equals(userName, user.getUsername())) {
|
||||
throw new ServiceException("非超级管理员不允许修改他人密码");
|
||||
}
|
||||
//先用rsa解密
|
||||
@ -362,7 +362,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
.where(STAFF.STAFF_TYPE.eq(0))
|
||||
//不查询停用的员工
|
||||
.and(USER.STATUS.eq(true))
|
||||
.and(USER.PHONE_NUMBER.notIn(Arrays.asList(testStaffPhone.split(",")))),
|
||||
.and(USER.PHONE.notIn(Arrays.asList(testStaffPhone.split(",")))),
|
||||
StaffVo.class);
|
||||
}
|
||||
|
||||
@ -376,15 +376,15 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
public void changeOperationStatus(OperationStatusBo bo) {
|
||||
//获取用户信息
|
||||
Staff staff = this.getById(bo.getId());
|
||||
User User = DbChain.table(USER).select(USER.PHONE_NUMBER).where(USER.ID.eq(staff.getUserId())).oneAs(User.class);
|
||||
User User = DbChain.table(USER).select(USER.PHONE).where(USER.ID.eq(staff.getUserId())).oneAs(User.class);
|
||||
JSONObject jsonBody = new JSONObject();
|
||||
if (bo.getIsOperation()) {
|
||||
jsonBody.put("_type", "oamAdd");
|
||||
jsonBody.put("name", staff.getName());
|
||||
jsonBody.put("phone", User.getPhoneNumber());
|
||||
jsonBody.put("phone", User.getPhone());
|
||||
} else {
|
||||
jsonBody.put("_type", "oamDel");
|
||||
jsonBody.put("phone", User.getPhoneNumber());
|
||||
jsonBody.put("phone", User.getPhone());
|
||||
}
|
||||
// JSONObject jsonObject = SpringUtils.getBean(RestTemplate.class).postForObject(JamboxCloudUrl.COMMON_CARD_URL, jsonBody, JSONObject.class);
|
||||
// assert jsonObject != null;
|
||||
|
||||
@ -337,7 +337,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
||||
}
|
||||
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||
if (StringUtils.isNotBlank(staffId)){
|
||||
Row staff = Db.selectOneByQuery(USER.getTableName(), QueryWrapper.create().select(USER.PHONE_NUMBER)
|
||||
Row staff = Db.selectOneByQuery(USER.getTableName(), QueryWrapper.create().select(USER.PHONE)
|
||||
.leftJoin(STAFF).on(STAFF.USER_ID.eq(USER.ID))
|
||||
.where(STAFF.ID.eq(staffId)));
|
||||
//对比当前员工是否是测试管理员
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package com.cpop.oam.business.vo.loginInfo;
|
||||
|
||||
import com.cpop.core.base.table.User;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @version: 1.0.0
|
||||
* @Author: DB
|
||||
* @description: 系统登录用户
|
||||
* @date: 2023-11-09 21:30
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysStaffLoginInfo extends User {
|
||||
|
||||
/**
|
||||
* 员工id(staffId)
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 身份id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 是否是超级管理
|
||||
*/
|
||||
private Boolean isSuper;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
}
|
||||
@ -1,97 +0,0 @@
|
||||
package com.cpop.system.business.service.impl;
|
||||
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cpop.core.constant.Constants;
|
||||
import com.cpop.system.business.entity.Menu;
|
||||
import com.cpop.system.business.entity.StoreSign;
|
||||
import com.cpop.system.business.service.LoginService;
|
||||
import com.cpop.system.business.service.MenuService;
|
||||
import com.cpop.system.business.service.StoreSignService;
|
||||
import com.cpop.system.business.vo.LoginUserInfoVo;
|
||||
import com.cpop.system.business.vo.MenuRouteVo;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
|
||||
import static com.cpop.system.business.entity.table.MenuTableDef.MENU;
|
||||
import static com.cpop.system.business.entity.table.RoleMenuTableDef.ROLE_MENU;
|
||||
import static com.cpop.system.business.entity.table.RoleTableDef.ROLE;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
* @createTime 2023/09/10 11:19
|
||||
* @description
|
||||
*/
|
||||
@Service("loginService")
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
|
||||
@Autowired
|
||||
private MenuService menuService;
|
||||
|
||||
/**
|
||||
* @author LOST.yuan
|
||||
* @Description 获取用户信息
|
||||
* @date 23:01 2022/9/26
|
||||
* @return {@link String}
|
||||
**/
|
||||
@Override
|
||||
public LoginUserInfoVo getUserInfo() {
|
||||
SaSession session = StpUtil.getSession();
|
||||
return new LoginUserInfoVo()
|
||||
.setId((String) session.get("id"))
|
||||
.setUserId((String) session.get("userId"))
|
||||
.setUsername((String) session.get("username"))
|
||||
.setRealName((String) session.get("name"))
|
||||
.setAvatar((String) session.get("avatar"))
|
||||
.setPermissions(StpUtil.getPermissionList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限码
|
||||
* @author DB
|
||||
* @since 2023-11-30 14:32:57
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getPermCode() {
|
||||
SaSession session = StpUtil.getSession();
|
||||
if (StringUtils.equals(Constants.SUPER_ADMIN, session.getString("username"))) {
|
||||
Set<String> permCodes = new HashSet<>();
|
||||
permCodes.add("*.*.*");
|
||||
return permCodes;
|
||||
} else {
|
||||
List<Menu> menuPermissions = SpringUtils.getBean(MenuService.class)
|
||||
.queryChain()
|
||||
.select(MENU.PERMISSION)
|
||||
.leftJoin(ROLE_MENU)
|
||||
.on(ROLE_MENU.MENU_ID.eq(MENU.ID))
|
||||
.leftJoin(ROLE)
|
||||
.on(ROLE.ID.eq(ROLE_MENU.ROLE_ID))
|
||||
.where(ROLE.ID.eq(session.getString("roleId")))
|
||||
.and(MENU.TYPE.in(1, 2))
|
||||
.and(MENU.PERMISSION.isNotNull())
|
||||
.list();
|
||||
return menuPermissions.stream().map(Menu::getPermission).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<MenuRouteVo> getSysMenuList() {
|
||||
return menuService.getSysMenuList();
|
||||
}
|
||||
}
|
||||
@ -2,13 +2,11 @@ package com.cpop.system.business.service.impl;
|
||||
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cpop.core.base.enums.UserType;
|
||||
import com.cpop.core.base.exception.ServiceException;
|
||||
import com.cpop.core.constant.Constants;
|
||||
import com.cpop.core.utils.StringUtils;
|
||||
import com.cpop.core.utils.bean.BeanUtils;
|
||||
import com.cpop.system.framework.enums.InitRoleEnum;
|
||||
import com.cpop.core.base.exception.ServiceException;
|
||||
import com.cpop.system.business.bo.MenuBo;
|
||||
import com.cpop.system.business.bo.MenuListBo;
|
||||
import com.cpop.system.business.entity.Menu;
|
||||
@ -16,13 +14,13 @@ import com.cpop.system.business.mapper.MenuMapper;
|
||||
import com.cpop.system.business.service.MenuService;
|
||||
import com.cpop.system.business.vo.MenuRouteVo;
|
||||
import com.cpop.system.business.vo.MenuVo;
|
||||
import com.cpop.system.framework.enums.InitRoleEnum;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cpop.system.business.entity.table.MenuTableDef.MENU;
|
||||
import static com.cpop.system.business.entity.table.RoleMenuTableDef.ROLE_MENU;
|
||||
@ -57,7 +55,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
return buildMenuRouteTree(list);
|
||||
} else {
|
||||
//一般管理员
|
||||
if (StringUtils.equals(session.getString("roleId"), InitRoleEnum.SUPER_MALL_ROLE.getId())) {
|
||||
if (StringUtils.equals(session.getString("roleId"), InitRoleEnum.SUPER_OAM_ROLE.getId())) {
|
||||
return buildMenuRouteTree(this.listAs(QueryWrapper.create()
|
||||
.where(MENU.TYPE.in(0, 1))
|
||||
//构建公共菜单与特有菜单
|
||||
|
||||
@ -13,10 +13,6 @@ public enum InitRoleEnum {
|
||||
* OAM超级管理员角色
|
||||
*/
|
||||
SUPER_OAM_ROLE("1", "SuperOamAdmin", "SuperOamAdmin", -1, UserType.OAM_USER),
|
||||
/**
|
||||
* MALL超级管理员角色
|
||||
*/
|
||||
SUPER_MALL_ROLE("2", "SuperMallAdmin", "SuperMallAdmin", -1, UserType.MALL_USER),
|
||||
/**
|
||||
* 企微注册初始化技术员工角色
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user