master
parent
fba688b503
commit
460a68fcfa
|
@ -68,9 +68,15 @@ public class SysLoginService {
|
|||
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||
|
||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||
if (username.contains("@")){
|
||||
recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"登录邮箱不存在");
|
||||
throw new ServiceException("登录邮箱"+username+"不存在");
|
||||
}else {
|
||||
recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"登录用户不存在");
|
||||
throw new ServiceException("登录用户"+username+"不存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (Result.FAIL == userResult.getCode()) {
|
||||
throw new ServiceException(userResult.getMsg());
|
||||
}
|
||||
|
@ -84,8 +90,15 @@ public class SysLoginService {
|
|||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
if (username.contains("@")){
|
||||
user.setEmail(null);
|
||||
}
|
||||
passwordService.validate(user, password);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
if (username.contains("@")){
|
||||
recordLogService.recordLogininfor(username,Constants.LOGIN_SUCCESS,"邮箱登录成功");
|
||||
}else {
|
||||
recordLogService.recordLogininfor(username,Constants.LOGIN_SUCCESS,"用户登录成功");
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
|
@ -99,7 +112,8 @@ public class SysLoginService {
|
|||
public void register (String username, String password) {
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
// throw new ServiceException("用户/密码必须填写");
|
||||
throw new ServiceException("用户/邮箱/密码必须填写");
|
||||
}
|
||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||
|
|
|
@ -58,7 +58,12 @@ public class SysPasswordService {
|
|||
retryCount = retryCount + 1;
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, String.format("密码输入错误%s次", retryCount));
|
||||
redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
|
||||
throw new ServiceException("用户不存在/密码错误");
|
||||
if (user.getEmail()==null){
|
||||
throw new ServiceException("邮箱不存在/密码错误");
|
||||
}else {
|
||||
throw new ServiceException("用户不存在/密码错误");
|
||||
}
|
||||
|
||||
} else {
|
||||
clearLoginRecordCache(username);
|
||||
}
|
||||
|
|
|
@ -135,4 +135,6 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||
* @return 结果
|
||||
*/
|
||||
public SysMenu checkMenuNameUnique (@Param("menuName") String menuName, @Param("parentId") Long parentId);
|
||||
|
||||
List<SysMenu> selectSysMenuList(List<Long> longs);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
queryWrapper.gt(SysConfig::getCreateTime, beginDate);
|
||||
}
|
||||
Object endTime = config.getParams().get("endTime");
|
||||
if (Objects.nonNull(endTime) && endTime instanceof Date endDate){
|
||||
queryWrapper.lt(SysConfig::getCreateTime, endDate);
|
||||
if (Objects.nonNull(endTime)&& endTime instanceof Date endDate){
|
||||
queryWrapper.lt(SysConfig::getCreateTime,endDate);
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,16 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
|
|||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
// List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||
// if (StringUtils.isNotEmpty(dictDatas)){
|
||||
// return dictDatas;
|
||||
// }
|
||||
// dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
// if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
// DictUtils.setDictCache(dictType,dictDatas);
|
||||
// return dictDatas;
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.stream.Collectors;
|
|||
* @author muyu
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||
|
||||
@Autowired
|
||||
|
@ -51,6 +51,22 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
return selectMenuList(new SysMenu(), userId);
|
||||
}
|
||||
|
||||
public List<SysMenu> selectSysMenuList(List<SysMenu> menuList){
|
||||
List<Long> longs = menuList.stream()
|
||||
.map(menu -> menu.getParentId())
|
||||
.filter(parentId -> parentId != 0)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (longs.size()==0){
|
||||
return null;
|
||||
}
|
||||
List<SysMenu> sysMenus = menuMapper.selectSysMenuList(longs);
|
||||
List<SysMenu> sysMenus1 = selectSysMenuList(sysMenus);
|
||||
if (sysMenus1 != null){
|
||||
sysMenus.addAll(sysMenus1);
|
||||
}
|
||||
return sysMenus;
|
||||
}
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
|
@ -93,7 +109,6 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
/**
|
||||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
|
|
|
@ -183,12 +183,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope (Long roleId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())){
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
if (StringUtils.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
if (StringUtils.isEmpty(roles)){
|
||||
throw new ServiceException("没有权限访问角色数据");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,8 +386,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
*/
|
||||
@Override
|
||||
public int insertAuthUsers (Long roleId, Long[] userIds) {
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
|
||||
ArrayList<SysUserRole> list = new ArrayList<>();
|
||||
for (Long userId : userIds) {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
|
|
|
@ -185,6 +185,7 @@
|
|||
<include refid="selectMenuVo"/>
|
||||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||
</select>
|
||||
<select id="selectSysMenuList" resultType="com.muyu.system.domain.SysMenu"></select>
|
||||
|
||||
<update id="updateMenu" parameterType="com.muyu.system.domain.SysMenu">
|
||||
update sys_menu
|
||||
|
|
Loading…
Reference in New Issue