Compare commits
2 Commits
16b7d99012
...
87204c512e
Author | SHA1 | Date |
---|---|---|
|
87204c512e | |
|
1608b66fad |
|
@ -25,7 +25,7 @@ import com.four.system.service.ISysDeptService;
|
|||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
|
@ -130,4 +130,8 @@ public class SysDeptController extends BaseController
|
|||
deptService.checkDeptDataScope(deptId);
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -110,24 +110,45 @@ public class SysUserController extends BaseController
|
|||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/info/{userName}")
|
||||
public R<LoginUser> info (@PathVariable("userName") String userName)
|
||||
{
|
||||
SysUser sysUser = userService.selectUserByUserName(userName);
|
||||
if(StringUtils.isNull(sysUser)){
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
|
||||
Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||
|
||||
Set<String> permission = permissionService.getMenuPermission(sysUser);
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setSysUser(sysUser);
|
||||
sysUserVo.setRoles(roles);
|
||||
sysUserVo.setPermissions(permission);
|
||||
return R.ok(sysUserVo);
|
||||
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@GetMapping("/info/{email}")
|
||||
public R<LoginUser> info(@PathVariable("email") String email)
|
||||
{
|
||||
SysUser sysUser = userService.selectUserByUserName(email);
|
||||
if (StringUtils.isNull(sysUser))
|
||||
{
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
// 角色集合
|
||||
@GetMapping("infoByEmail/{email}")
|
||||
public R<LoginUser> getUserInfoByEmail(@PathVariable("email") String email){
|
||||
SysUser sysUser = userService.selectByEmail(email);
|
||||
if(StringUtils.isNull(sysUser)){
|
||||
return R.fail("邮箱或密码错误");
|
||||
}
|
||||
Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(sysUser);
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setSysUser(sysUser);
|
||||
sysUserVo.setRoles(roles);
|
||||
sysUserVo.setPermissions(permissions);
|
||||
return R.ok(sysUserVo);
|
||||
|
||||
|
||||
Set<String> permission = permissionService.getMenuPermission(sysUser);
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setSysUser(sysUser);
|
||||
loginUser.setRoles(roles);
|
||||
loginUser.setPermissions(permission);
|
||||
return R.ok(loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,10 +171,22 @@ public class SysUserController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
* 注册
|
||||
*/
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping("/healthRegister")
|
||||
public R<Boolean> healthRegister(@RequestBody SysUser sysUser){
|
||||
if(!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))){
|
||||
return R.fail("当前系统没有开启注册功能");
|
||||
}
|
||||
if(!userService.checkEmailUnique(sysUser)){
|
||||
return R.fail("保存用户'" + sysUser.getEmail() + "'失败,注册账号已存在");
|
||||
}
|
||||
return R.ok(userService.healthRegister(sysUser));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo()
|
||||
{
|
||||
|
@ -169,6 +202,23 @@ public class SysUserController extends BaseController
|
|||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 维度健康获取用户信息
|
||||
* */
|
||||
@GetMapping("healthGetInfo")
|
||||
public AjaxResult healthGetInfo(){
|
||||
SysUser user = userService.selectHealthUserById(SecurityUtils.getUserId());
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
|
||||
Set<String> permission = permissionService.getMenuPermission(user);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user",user);
|
||||
ajax.put("roles",roles);
|
||||
ajax.put("permission",permission);
|
||||
return ajax;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取详细信息
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.four.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.four.system.api.domain.SysUser;
|
||||
|
||||
|
@ -9,6 +11,8 @@ import com.four.system.api.domain.SysUser;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@Mapper
|
||||
public interface SysUserMapper
|
||||
{
|
||||
/**
|
||||
|
@ -41,7 +45,7 @@ public interface SysUserMapper
|
|||
* @param email 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String email);
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -124,4 +128,26 @@ public interface SysUserMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param email 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser selectByEmail(String email);
|
||||
|
||||
Boolean selectHealthUserId(SysUser sysUser);
|
||||
|
||||
public int insertHealthUser(SysUser sysUser);
|
||||
|
||||
SysUser selectHealthUserById(Long userId);
|
||||
}
|
||||
|
|
|
@ -6,23 +6,23 @@ import com.four.system.api.domain.SysUser;
|
|||
|
||||
/**
|
||||
* 权限信息 服务层
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysPermissionService
|
||||
{
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
*
|
||||
* @param user 用户Id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
public Set<String> getRolePermission(SysUser user);
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
*
|
||||
* @param user 用户Id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermission(SysUser user);
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface ISysUserService
|
|||
* @param email 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String email);
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -203,4 +203,13 @@ public interface ISysUserService
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
|
||||
SysUser selectUserByUserName(String userName);
|
||||
|
||||
SysUser selectByEmail(String email);
|
||||
|
||||
public boolean healthRegister(SysUser sysUser);
|
||||
|
||||
public SysUser selectHealthUserById(Long userId);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.four.system.service.ISysUserService;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@SuppressWarnings("all")
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
@ -106,11 +107,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
* @param email 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String email)
|
||||
{
|
||||
return userMapper.selectUserByUserName(email);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -542,4 +539,34 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName) {
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectByEmail(String email) {
|
||||
return userMapper.selectByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean healthRegister(SysUser sysUser) {
|
||||
System.out.println(sysUser);
|
||||
int i = userMapper.insertHealthUser(sysUser);
|
||||
Long userId = sysUser.getUserId();
|
||||
Long[] logs =new Long[]{sysUser.getUserId()};
|
||||
insertUserRole(userId,logs);
|
||||
|
||||
if(i>0 && sysUser.getRoleId() == 101 && StringUtils.isNotNull(sysUser.getInvitationCode())){
|
||||
System.out.println("等待接口开放");
|
||||
}
|
||||
return i>0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectHealthUserById(Long userId) {
|
||||
return userMapper.selectHealthUserById(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,11 +136,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.email = #{email} and u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
|
@ -158,34 +153,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" resultType="com.four.system.api.domain.SysUser">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_name = #{userName} and u.del_flag = '0'
|
||||
</select>
|
||||
<select id="selectByEmail" resultType="com.four.system.api.domain.SysUser">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.email = #{email} and u.del_flag = '0'
|
||||
</select>
|
||||
<select id="selectHealthUserById" resultType="com.four.system.api.domain.SysUser">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="user_id != null and userId != 0">user_id,</if>
|
||||
<if test="dept_id != null and deptId != 0">dept_id,</if>
|
||||
<if test="user_name != null and userName != ''">user_name,</if>
|
||||
<if test="nick_name != null and nickName != ''">nick_name,</if>
|
||||
<if test="user_type != null and userType != ''">user_type,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||
<if test="sex != null and sex != ''">sex,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
<if test="password != null and password != ''">password,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="del_flag != null and delFlag != ''">del_flag,</if>
|
||||
<if test="login_ip != null and loginIp != ''">login_ip,</if>
|
||||
<if test="login_date != null and loginDate != ''">login_date,</if>
|
||||
<if test="create_by != null and createBy != ''">create_by,</if>
|
||||
<if test="create_time != null and createTime != ''">create_time,</if>
|
||||
<if test="update_by != null and updateBy != ''">update_by,</if>
|
||||
<if test="update_time != null and updateTime != ''">update_time,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="user_sign != null and userSign != ''">user_sign,</if>
|
||||
<if test="bind_wechat_status != null and bindWechatStatus != ''">bind_wechat_status,</if>
|
||||
<if test="real_name_authentication_status != null and realNameAuthenticationStatus != ''">real_name_authentication_status,</if>
|
||||
<if test="bind_bank_card_status != null and bindBankCardStatus != ''">bind_bank_card_status,</if>
|
||||
<if test="user_money != null and userMoney != ''">user_money,</if>
|
||||
<if test="invitation_code != null and invitationCode != ''">invitation_code,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">#{sex},</if>
|
||||
<if test="password != null and password != ''">#{password},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="user_id != null and user_id != 0">#{userId},</if>
|
||||
<if test="dept_id != null and dept_id != 0">#{deptId},</if>
|
||||
<if test="user_name != null and user_name != ''">#{userName},</if>
|
||||
<if test="nick_name != null and nick_name != ''">#{nickName},</if>
|
||||
<if test="user_type != null and user_type != ''">#{userType},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||
<if test="sex != null and sex != ''">#{sex},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
<if test="password != null and password != ''">#{password},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="del_flag != null and del_flag != ''">#{delFlag},</if>
|
||||
<if test="login_ip != null and login_ip != ''">#{loginIp},</if>
|
||||
<if test="login_date != null and login_date != ''">#{loginDate},</if>
|
||||
<if test="create_by != null and create_by != ''">#{createBy},</if>
|
||||
<if test="create_time != null and create_time != ''">#{createTime},</if>
|
||||
<if test="update_by != null and update_by != ''">#{updateBy},</if>
|
||||
<if test="update_time != null and update_time != ''">#{updateTime},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="user_sign != null and user_sign != ''">#{userSign},</if>
|
||||
<if test="bind_wechat_status != null and bind_wechat_status != ''">#{bindWechatStatus},</if>
|
||||
<if test="real_name_authentication_status != null and real_name_authentication_status != ''">#{realNameAuthenticationStatus},</if>
|
||||
<if test="bind_bank_card_status != null and bind_bank_card_status != ''">#{bindBankCardStatus},</if>
|
||||
<if test="user_money != null and user_money != ''">#{userMoney},</if>
|
||||
<if test="invitation_code != null and invitation_code != ''">#{invitationCode},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
|
Loading…
Reference in New Issue