|
|
|
@ -1,5 +1,9 @@
|
|
|
|
|
package com.hyp.framework.web.service;
|
|
|
|
|
|
|
|
|
|
import com.hyp.common.core.domain.entity.SysRole;
|
|
|
|
|
import com.hyp.system.domain.SysUserRole;
|
|
|
|
|
import com.hyp.system.mapper.SysUserRoleMapper;
|
|
|
|
|
import com.hyp.system.service.ISysRoleService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import com.hyp.common.constant.CacheConstants;
|
|
|
|
@ -18,6 +22,10 @@ import com.hyp.framework.manager.factory.AsyncFactory;
|
|
|
|
|
import com.hyp.system.service.ISysConfigService;
|
|
|
|
|
import com.hyp.system.service.ISysUserService;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注册校验方法
|
|
|
|
|
*
|
|
|
|
@ -35,6 +43,13 @@ public class SysRegisterService
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysUserRoleMapper userRoleMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysRoleService roleService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注册
|
|
|
|
|
*/
|
|
|
|
@ -78,6 +93,8 @@ public class SysRegisterService
|
|
|
|
|
sysUser.setNickName(username);
|
|
|
|
|
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
|
|
boolean regFlag = userService.registerUser(sysUser);
|
|
|
|
|
//注册绑定角色
|
|
|
|
|
roleBinding(sysUser,"yxxxj_xxl");
|
|
|
|
|
if (!regFlag)
|
|
|
|
|
{
|
|
|
|
|
msg = "注册失败,请联系系统管理人员";
|
|
|
|
@ -90,6 +107,28 @@ public class SysRegisterService
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 注册绑定角色
|
|
|
|
|
* @param sysUser
|
|
|
|
|
* @param roleKey
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public void roleBinding(SysUser sysUser,String roleKey) {
|
|
|
|
|
//注册绑定角色
|
|
|
|
|
userRoleMapper.deleteUserRoleByUserId(sysUser.getUserId());
|
|
|
|
|
List<SysUserRole> list = new ArrayList<>();
|
|
|
|
|
SysUserRole ur = new SysUserRole();
|
|
|
|
|
ur.setUserId(sysUser.getUserId());
|
|
|
|
|
SysRole sysRole = roleService.selectRoleByKey(roleKey);
|
|
|
|
|
if(Objects.nonNull(sysRole)){
|
|
|
|
|
ur.setRoleId(sysRole.getRoleId());
|
|
|
|
|
}
|
|
|
|
|
list.add(ur);
|
|
|
|
|
userRoleMapper.batchUserRole(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验验证码
|
|
|
|
|
*
|
|
|
|
|