注册系统用户

master
382696293@qq.com 2 years ago
parent 1703dfff0e
commit 33afe29706

@ -78,6 +78,12 @@ public class UserConstants
public static final int PASSWORD_MAX_LENGTH = 20;
/**
*
*/
public static final String WX_NICKNAME = "微信用户";
/**
*
*/

@ -44,6 +44,10 @@ public class SysUser extends BaseEntity
@Excel(name = "用户名称")
private String nickName;
/** 用户类型 */
@Excel(name = "用户类型")
private String userType;
/** 用户邮箱 */
@Excel(name = "用户邮箱")
private String email;
@ -311,6 +315,15 @@ public class SysUser extends BaseEntity
{
this.roleId = roleId;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -147,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="userType != null and userType != ''">user_type,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
@ -161,6 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="userType != null and userType != ''">#{userType},</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>

@ -4,13 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.flossom.common.core.constant.CacheConstants;
import com.flossom.common.core.constant.UserConstants;
import com.flossom.common.core.domain.R;
import com.flossom.common.core.domain.RegisterBody;
import com.flossom.common.core.domain.entity.SysUser;
import com.flossom.common.core.domain.entity.WxScriptMessage;
import com.flossom.common.core.domain.entity.WxUserMember;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import com.flossom.common.core.enums.MessageTypeEnum;
import com.flossom.common.core.enums.WxUserIntegralMessageTypeEnum;
import com.flossom.common.core.exception.ServiceException;
import com.flossom.common.core.mapper.SysUserMapper;
import com.flossom.common.core.mapper.WxScriptMessageMapper;
import com.flossom.common.core.mapper.WxUserMemberMapper;
import com.flossom.common.core.mapper.WxUserScriptLogMapper;
@ -54,6 +55,9 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
@Autowired
private WxUserScriptLogMapper wxUserScriptLogMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Override
@Transactional
public LoginUserVo login(String code) throws Exception {
@ -81,17 +85,14 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
// 2.2、微信用户表注册
wxUserMemberMapper.insertWxUserMember(wxUserMember);
// 2.3、系统表注册
/**
* TODO:
*/
RegisterBody registerBody = new RegisterBody();
registerBody.setUsername(wxUserMember.getOpenid());
registerBody.setPassword(UserConstants.WX_SYSTEM_USER_PASSWORD);
R<?> registerResult = remoteAuthService.register(registerBody);
if (R.FAIL == registerResult.getCode()) {
logger.error("测试后台账号失败:{}", registerResult.getMsg());
throw new ServiceException(registerResult.getMsg());
}
SysUser user = new SysUser();
user.setUserName(wxUserMember.getOpenid());
user.setNickName(UserConstants.WX_NICKNAME);
user.setPassword(SecurityUtils.encryptPassword(UserConstants.WX_SYSTEM_USER_PASSWORD));
// 用户类型01:微信会员用户
user.setUserType("01");
user.setCreateBy(SecurityUtils.getUsername());
sysUserMapper.insertUser(user);
// 2.4、用户注册成功发送消息
WxScriptMessage wxScriptMessage = wxScriptMessageMapper.selectOneByMessageType(MessageTypeEnum.USER_REGISTRATION.getCode());
if (wxScriptMessage != null) {

Loading…
Cancel
Save