迭代 注册方法1.0
parent
124cd25cd3
commit
3805218b67
|
@ -20,6 +20,7 @@
|
|||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-common-core</artifactId>
|
||||
<version>3.6.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
@ -113,6 +113,11 @@
|
|||
<groupId>com.health</groupId>
|
||||
<artifactId>health-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-common-core</artifactId>
|
||||
<version>3.6.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
|
|
@ -154,10 +154,6 @@ public class SysUserController extends BaseController
|
|||
//注册
|
||||
@PostMapping("/register/user")
|
||||
public Result<?> registerUser(@RequestBody CommonBody commonBody){
|
||||
// if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||
// {
|
||||
// return Result.error("当前系统没有开启注册功能!");
|
||||
// }
|
||||
|
||||
int i = userService.registerNewUser(commonBody);
|
||||
return i>0?Result.success("","注册成功"):Result.error("注册失败");
|
||||
|
|
|
@ -135,11 +135,13 @@ public interface SysUserMapper {
|
|||
//-----------------------------------------------
|
||||
|
||||
//添新的患者
|
||||
int insertPatient(CommonBody commonBody);
|
||||
|
||||
|
||||
//为新增用户添加角色
|
||||
void addUserRole(@Param("patientId") int patientId, @Param("roleId") Integer roleId, @Param("i") int i);
|
||||
|
||||
//添加新的医生
|
||||
int insertDoctor(CommonBody commonBody);
|
||||
|
||||
//添加患者或者医生公用这个动态sql
|
||||
int insertNewUser(CommonBody commonBody);
|
||||
}
|
||||
|
|
|
@ -580,26 +580,18 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@Override
|
||||
@Transactional
|
||||
public int registerNewUser(CommonBody commonBody) {
|
||||
//默认是患者角色
|
||||
|
||||
|
||||
//1证明是患者 不用审核直接注册成功
|
||||
if (commonBody.getRoleId()==1){
|
||||
//先添加患者表
|
||||
int patientId= userMapper.insertPatient(commonBody);
|
||||
//添加用户角色
|
||||
userMapper.addUserRole(patientId,commonBody.getRoleId(),101);
|
||||
|
||||
return patientId;
|
||||
}
|
||||
//2证明是医生则需要审核
|
||||
int role=101;
|
||||
//添加用户不管是患者还是医生
|
||||
int userId=userMapper.insertNewUser(commonBody);
|
||||
//如果角色标识roleId==2的时候再赋值为102
|
||||
if (commonBody.getRoleId()==2){
|
||||
|
||||
int doctorId= userMapper.insertDoctor(commonBody);
|
||||
//添加用户角色
|
||||
userMapper.addUserRole(doctorId,commonBody.getRoleId(),100);
|
||||
return doctorId;
|
||||
role=102;
|
||||
}
|
||||
return 0;
|
||||
//为用户添加角色
|
||||
userMapper.addUserRole(userId,role,commonBody.getRoleId());
|
||||
return userId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,17 +173,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
<!--添加新患者-->
|
||||
<insert id="insertPatient">
|
||||
insert into tb_patient values (0,#{name},#{password},#{email},null,#{avatar},#{gender},#{height},#{weight},#{age},#{wechatNumber})
|
||||
<!--为用户添加角色-->
|
||||
</insert>
|
||||
|
||||
|
||||
<insert id="addUserRole">
|
||||
insert into tb_user_role values (#{patientId},#{roleId},#{i})
|
||||
</insert>
|
||||
|
||||
<!--添加新的医生-->
|
||||
<insert id="insertDoctor"></insert>
|
||||
|
||||
<!--添加患者或者医生公用这个动态sql-->
|
||||
<insert id="insertNewUser">
|
||||
|
||||
<choose>
|
||||
<when test="roleId==1">
|
||||
insert into tb_patient(
|
||||
<if test="patientId!=null"> patient_id,</if>
|
||||
<if test="patientName!=null and patientName!=''">patient_name,</if>
|
||||
<if test="password!=null and password!=''">patient_password,</if>
|
||||
<if test="email!=null and email!=''">patient_email,</if>
|
||||
<if test="inviteCode!=null and inviteCode!=''">invite_code,</if>
|
||||
<if test="avatar!=null and avatar!=''"> patient_avatar,</if>
|
||||
<if test="gender!=null">gender,</if>
|
||||
<if test="height!=null">height,</if>
|
||||
<if test="weight!=null">weight,</if>
|
||||
<if test="age!=null">age,</if>
|
||||
<if test="chatNumber!=null and chatNumber!=''">chat_number,</if>
|
||||
)
|
||||
values
|
||||
(
|
||||
<if test="patientId!=null"> #{patientId},</if>
|
||||
<if test="patientName!=null and patientName!=''">#{name},</if>
|
||||
<if test="password!=null and password!=''">#{password},</if>
|
||||
<if test="email!=null and email!=''">#{email},</if>
|
||||
<if test="inviteCode!=null and inviteCode!=''">#{inviteCode},</if>
|
||||
<if test="avatar!=null and avatar!=''"> #{avatar},</if>
|
||||
<if test="gender!=null">#{gender},</if>
|
||||
<if test="height!=null">#{height},</if>
|
||||
<if test="weight!=null">#{weight},</if>
|
||||
<if test="age!=null">#{age},</if>
|
||||
<if test="chatNumber!=null and chatNumber!=''">#{wechatNumber},</if>
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
insert into tb_doctor
|
||||
(
|
||||
<if test="doctorId!=null"> doctor_id,</if>
|
||||
<if test="doctorName!=null and doctorName!=''">doctor_name,</if>
|
||||
<if test="password!=null and password!=''">password,</if>
|
||||
<if test="email!=null and email!=''">email,</if>
|
||||
<if test="hospital!=null and hospital!=''">hospital,</if>
|
||||
<if test="deptId!=null">dept_id,</if>
|
||||
<if test="titleId!=null ">title_id,</if>
|
||||
<if test="introduce!=null and introduce!=''">introduce,</if>
|
||||
<if test="skilled!=null and skilled!=''">skilled,</if>
|
||||
<if test="avatar!=null and avatar!=''">avatar,</if>
|
||||
)
|
||||
values
|
||||
(
|
||||
<if test="doctorId!=null"> #{doctorId},</if>
|
||||
<if test="name!=null and name!=''">#{name},</if>
|
||||
<if test="password!=null and password!=''">#{password},</if>
|
||||
<if test="email!=null and email!=''">#{email},</if>
|
||||
<if test="hospital!=null and hospital!=''">#{hospital},</if>
|
||||
<if test="deptId!=null">#{deptId},</if>
|
||||
<if test="titleId!=null ">#{titleId},</if>
|
||||
<if test="introduce!=null and introduce!=''">#{introduce},</if>
|
||||
<if test="skilled!=null and skilled!=''">#{skilled},</if>
|
||||
<if test="avatar!=null and avatar!=''">#{avatar},</if>
|
||||
)
|
||||
</otherwise>
|
||||
</choose>
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="SysUser">
|
||||
update sys_user
|
||||
|
|
Loading…
Reference in New Issue