登录 增加
parent
521683992c
commit
0382a152d6
|
@ -0,0 +1,18 @@
|
|||
package com.health.system.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 冯凯
|
||||
* @version 1.0
|
||||
* @description:
|
||||
* @date 2023/10/21 1:23
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class EmailLoginUser {
|
||||
|
||||
private Integer roleId;
|
||||
|
||||
private String email;
|
||||
}
|
|
@ -48,6 +48,7 @@
|
|||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>base-system-common</artifactId>
|
||||
<version>3.6.4</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
|
|
|
@ -11,10 +11,7 @@ import com.health.common.log.enums.BusinessType;
|
|||
import com.health.common.security.annotation.InnerAuth;
|
||||
import com.health.common.security.annotation.RequiresPermissions;
|
||||
import com.health.common.security.utils.SecurityUtils;
|
||||
import com.health.system.common.domain.SysDept;
|
||||
import com.health.system.common.domain.SysRole;
|
||||
import com.health.system.common.domain.SysUser;
|
||||
import com.health.system.common.domain.User;
|
||||
import com.health.system.common.domain.*;
|
||||
import com.health.system.common.domain.model.LoginUser;
|
||||
import com.health.system.server.service.*;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -123,6 +120,33 @@ public class SysUserController extends BaseController
|
|||
return Result.success(sysUserVo);
|
||||
}
|
||||
|
||||
//-------------邮箱获取用户信息------------------
|
||||
|
||||
@PostMapping("/email/info")
|
||||
public Result<LoginUser> emailInfo(@RequestBody EmailLoginUser emailLoginUser){
|
||||
System.out.println("收到请求对象是:"+emailLoginUser);
|
||||
//先根据邮箱查询有无此人
|
||||
CommonBody commonBody=userService.selectByEmail(emailLoginUser);
|
||||
if (StringUtils.isNull(commonBody)){
|
||||
return Result.error("邮箱不存在");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(commonBody.getHospital())){
|
||||
System.out.println("是医生");
|
||||
commonBody.setRoleId(2);
|
||||
}else{
|
||||
System.out.println("是患者");
|
||||
commonBody.setRoleId(1);
|
||||
}
|
||||
//查询该用户下的所有角色
|
||||
Set<String> roles=permissionService.getEmailRolePermission(commonBody);
|
||||
System.out.println("所有角色是"+roles);
|
||||
LoginUser loginUserVo = new LoginUser();
|
||||
loginUserVo.setCommonBody(commonBody);
|
||||
loginUserVo.setRoles(roles);
|
||||
System.out.println("最后的返回对象是:"+loginUserVo);
|
||||
return Result.success(loginUserVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*/
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.health.system.server.mapper;
|
|||
|
||||
import com.health.system.common.domain.SysRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -106,4 +107,7 @@ public interface SysRoleMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleByIds(Long[] roleIds);
|
||||
|
||||
//0---------------------------------------------------------------
|
||||
List<String> selectEmailRoleByUserId(@Param("userId") Integer userId, @Param("roleTag") Integer roleTag);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.health.system.server.mapper;
|
||||
|
||||
import com.health.common.core.user.CommonBody;
|
||||
import com.health.system.common.domain.EmailLoginUser;
|
||||
import com.health.system.common.domain.SysUser;
|
||||
import com.health.system.common.domain.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
@ -144,4 +145,7 @@ public interface SysUserMapper {
|
|||
|
||||
//添加患者或者医生公用这个动态sql
|
||||
int insertNewUser(CommonBody commonBody);
|
||||
|
||||
//------------------------------------------
|
||||
CommonBody selectUserByUserEmail(EmailLoginUser emailLoginUser);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.health.system.server.service;
|
||||
|
||||
import com.health.common.core.user.CommonBody;
|
||||
import com.health.system.common.domain.SysUser;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -25,4 +26,7 @@ public interface ISysPermissionService {
|
|||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermission(SysUser user);
|
||||
|
||||
//---------------------------------
|
||||
Set<String> getEmailRolePermission(CommonBody commonBody);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.health.system.server.service;
|
|||
|
||||
import com.health.system.common.domain.SysRole;
|
||||
import com.health.system.common.domain.SysUserRole;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -171,4 +173,7 @@ public interface ISysRoleService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
//-----------------------------------------------------------
|
||||
Set<String> selectEmailRoleByUserId(Integer userId, Integer roleId);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.health.common.core.domain.Result;
|
||||
import com.health.common.core.user.CommonBody;
|
||||
import com.health.system.common.domain.EmailLoginUser;
|
||||
import com.health.system.common.domain.SysUser;
|
||||
import com.health.system.common.domain.User;
|
||||
|
||||
|
@ -210,4 +211,7 @@ public interface ISysUserService
|
|||
|
||||
|
||||
int registerNewUser(CommonBody commonBody);
|
||||
|
||||
//-------------------------
|
||||
CommonBody selectByEmail(EmailLoginUser emailLoginUser);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.health.system.server.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.hash.Hash;
|
||||
import com.health.common.core.user.CommonBody;
|
||||
import com.health.system.common.domain.SysRole;
|
||||
import com.health.system.common.domain.SysUser;
|
||||
import com.health.system.server.service.ISysMenuService;
|
||||
|
@ -44,6 +46,15 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
|
|||
return roles;
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Set<String> getEmailRolePermission(CommonBody commonBody) {
|
||||
HashSet<String> roles = new HashSet<>();
|
||||
roles.addAll(roleService.selectEmailRoleByUserId(commonBody.getUserId(),commonBody.getRoleId()));
|
||||
return roles;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
|
@ -71,4 +82,6 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
|
|||
}
|
||||
return perms;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -88,6 +88,15 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
return permsSet;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
@Override
|
||||
public Set<String> selectEmailRoleByUserId(Integer userId,Integer roleTag) {
|
||||
List<String> roleList=roleMapper.selectEmailRoleByUserId(userId,roleTag);
|
||||
HashSet<String> roleSet = new HashSet<>();
|
||||
roleSet.addAll(roleList);
|
||||
return roleSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
|
@ -374,4 +383,6 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
}
|
||||
return userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -574,11 +574,18 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
System.out.println("获取的自增userId是"+userId1);
|
||||
//如果角色标识roleId==2的时候再赋值为102
|
||||
if (commonBody.getRoleId()==2){
|
||||
role=102;
|
||||
role=100;
|
||||
}
|
||||
//为用户添加角色
|
||||
userMapper.addUserRole(userId1,role,commonBody.getRoleId());
|
||||
return userId;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
@Override
|
||||
public CommonBody selectByEmail(EmailLoginUser emailLoginUser) {
|
||||
CommonBody commonBody= userMapper.selectUserByUserEmail(emailLoginUser);
|
||||
return commonBody;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,8 +92,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectRoleVo"/>
|
||||
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
|
||||
</select>
|
||||
<!--用户角色sql-->
|
||||
<select id="selectEmailRoleByUserId" resultType="java.lang.String">
|
||||
SELECT * FROM tb_user_role ur
|
||||
LEFT JOIN
|
||||
tb_role r on ur.role_id=r.role_id
|
||||
where ur.user_id=#{userId} and ur.role_tag=#{roleTag}
|
||||
</select>
|
||||
|
||||
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
insert into sys_role(
|
||||
<if test="roleId != null and roleId != 0">role_id,</if>
|
||||
<if test="roleName != null and roleName != ''">role_name,</if>
|
||||
|
|
|
@ -141,6 +141,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||
</select>
|
||||
<!--邮箱查用户-->
|
||||
<select id="selectUserByUserEmail" resultType="com.health.common.core.user.CommonBody">
|
||||
<if test="roleId==1">
|
||||
select * from tb_patient where email=#{email}
|
||||
</if>
|
||||
<if test="roleId==2">
|
||||
select * from tb_doctor where email=#{email}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
|
Loading…
Reference in New Issue