add register code

master
冯凯 2023-10-20 15:20:35 +08:00
parent 56a1c1f035
commit 92b014a3cd
5 changed files with 49 additions and 14 deletions

View File

@ -153,12 +153,14 @@ public class SysUserController extends BaseController
//---------------------------------------- //----------------------------------------
//注册 //注册
@PostMapping("/register/user") @PostMapping("/register/user")
public Result<Boolean> registerUser(@RequestBody CommonBody commonBody){ public Result<?> registerUser(@RequestBody CommonBody commonBody){
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) // if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{ // {
return Result.error("当前系统没有开启注册功能!"); // return Result.error("当前系统没有开启注册功能!");
} // }
return Result.success(userService.registerNewUser(commonBody));
int i = userService.registerNewUser(commonBody);
return i>0?Result.success("","注册成功"):Result.error("注册失败");
} }

View File

@ -133,5 +133,13 @@ public interface SysUserMapper {
//----------------------------------------------- //-----------------------------------------------
int insertNewUser(CommonBody commonBody);
//添新的患者
int insertPatient(CommonBody commonBody);
//为新增用户添加角色
void addUserRole(int patientId, Integer roleId, int i);
//添加新的医生
int insertDoctor(CommonBody commonBody);
} }

View File

@ -210,5 +210,5 @@ public interface ISysUserService
Result getEmailCode(String email); Result getEmailCode(String email);
Boolean registerNewUser(CommonBody commonBody); int registerNewUser(CommonBody commonBody);
} }

View File

@ -578,10 +578,28 @@ public class SysUserServiceImpl implements ISysUserService
//----------------------------- //-----------------------------
@Override @Override
public Boolean registerNewUser(CommonBody commonBody) { @Transactional
int i= userMapper.insertNewUser(commonBody); public int registerNewUser(CommonBody commonBody) {
return null;
//1证明是患者 不用审核直接注册成功
if (commonBody.getRoleId()==1){
//先添加患者表
int patientId= userMapper.insertPatient(commonBody);
//添加用户角色
userMapper.addUserRole(patientId,commonBody.getRoleId(),101);
return patientId;
}
//2证明是医生则需要审核
if (commonBody.getRoleId()==2){
int doctorId= userMapper.insertDoctor(commonBody);
//添加用户角色
userMapper.addUserRole(doctorId,commonBody.getRoleId(),100);
return doctorId;
}
return 0;
} }
} }

View File

@ -173,8 +173,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate() sysdate()
) )
</insert> </insert>
<!--新增用户--> <!--添加新患者-->
<insert id="insertNewUser"></insert> <insert id="insertPatient">
insert into tb_patient values (#{name},#{password},#{email},#{6666},#{avatar},#{gender},#{height},#{weight},#{age},#{wechatNumber})
<!--为用户添加角色-->
</insert>
<insert id="addUserRole"></insert>
<!--添加新的医生-->
<insert id="insertDoctor"></insert>
<update id="updateUser" parameterType="SysUser"> <update id="updateUser" parameterType="SysUser">
update sys_user update sys_user