邮箱-绑定邮箱
This commit is contained in:
@@ -24,8 +24,8 @@ public class Account {
|
||||
private Long uid;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String phoneAreaCode;
|
||||
private String email;
|
||||
|
||||
private Long erbanNo;
|
||||
|
||||
|
@@ -27,8 +27,8 @@ public class UserVo {
|
||||
private Date birth;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String phoneAreaCode;
|
||||
private String email;
|
||||
|
||||
private Byte star;
|
||||
|
||||
|
@@ -79,6 +79,16 @@ public class AccountService extends ServiceImpl<AccountMapper, Account> {
|
||||
return accountList.get(0);
|
||||
}
|
||||
|
||||
public Account getAccountByEmail(String email) {
|
||||
QueryWrapper<Account> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(Account::getEmail, email);
|
||||
List<Account> accountList = list(wrapper);
|
||||
if (CollectionUtils.isEmpty(accountList)) {
|
||||
return null;
|
||||
}
|
||||
return accountList.get(0);
|
||||
}
|
||||
|
||||
public Account getAccountByErBanNo(Long erbanNo) {
|
||||
QueryWrapper<Account> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(Account::getErbanNo, erbanNo);
|
||||
|
@@ -108,17 +108,6 @@ public class UsersBaseService extends BaseService {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean checkWxPubFansOpenidExists(String wxPubFansOpenid) {
|
||||
UsersExample usersExample = new UsersExample();
|
||||
usersExample.createCriteria().andWxPubFansOpenidEqualTo(wxPubFansOpenid);
|
||||
List<Users> usersList = usersMapper.selectByExample(usersExample);
|
||||
if (CollectionUtils.isEmpty(usersList)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Users> getUsersListByUids(List<Long> uids) {
|
||||
UsersExample usersExample = new UsersExample();
|
||||
usersExample.createCriteria().andUidIn(uids);
|
||||
@@ -289,6 +278,33 @@ public class UsersBaseService extends BaseService {
|
||||
saveUserCache(userDb);
|
||||
}
|
||||
|
||||
public void boundEmail(Long uid, String email) {
|
||||
UsersExample usersExample = new UsersExample();
|
||||
usersExample.createCriteria().andEmailEqualTo(email);
|
||||
List<Users> dbUserList = usersMapper.selectByExample(usersExample);
|
||||
if (!CollectionUtils.isEmpty(dbUserList)){
|
||||
throw new ServiceException(BusiStatus.THE_PHONE_NUMBER_HAS_BEEN_REGISTERED);
|
||||
}
|
||||
|
||||
Account dbAcount = accountService.getAccountByEmail(email);
|
||||
if (null != dbAcount){
|
||||
throw new ServiceException(BusiStatus.THE_PHONE_NUMBER_HAS_BEEN_REGISTERED);
|
||||
}
|
||||
|
||||
Users user = new Users();
|
||||
user.setUid(uid);
|
||||
user.setEmail(email);
|
||||
usersMapper.updateByPrimaryKeySelective(user);
|
||||
|
||||
Account account = new Account();
|
||||
account.setUid(uid);
|
||||
account.setEmail(email);
|
||||
accountService.updateById(account);
|
||||
|
||||
Users userDb = usersMapper.selectByPrimaryKey(user.getUid());
|
||||
saveUserCache(userDb);
|
||||
}
|
||||
|
||||
private void saveUserCache(Users users) {
|
||||
if (users == null) {
|
||||
return;
|
||||
@@ -310,6 +326,11 @@ public class UsersBaseService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkEmailExists(String email) {
|
||||
Account account = accountService.getAccountByEmail(email);
|
||||
return account != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户资料 平台号、手机号码、性别不能修改。必须通过单独的接口修改
|
||||
*
|
||||
@@ -487,11 +508,4 @@ public class UsersBaseService extends BaseService {
|
||||
deleteUserRelateCache(uid.toString());
|
||||
}
|
||||
|
||||
public String getTicketCacheByUid(Long uid) {
|
||||
String ticketStr = jedisService.hget(RedisKey.uid_ticket.getKey(), uid.toString());
|
||||
if (!org.apache.commons.lang3.StringUtils.isEmpty(ticketStr)) {
|
||||
return ticketStr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -962,7 +962,7 @@ public enum RedisKey {
|
||||
modify_pwd_sign,//String.用于注销校验
|
||||
blind_phone_sign,//String.用于注销校验
|
||||
user_frozen_sign,//String,用于注销恢复
|
||||
|
||||
blind_email_sign,//String.用于注销校验
|
||||
|
||||
dynamic_square_top_lock,//广场置顶锁
|
||||
dynamic_topic_top_lock,//话题置顶锁
|
||||
|
@@ -77,6 +77,7 @@ import com.accompany.core.vo.headwear.UserHeadwearVo;
|
||||
import com.accompany.core.vo.live.LiveUserInfoSkillVo;
|
||||
import com.accompany.core.vo.user.UserNameplateVo;
|
||||
import com.accompany.core.vo.vip.UserVipInfoVO;
|
||||
import com.accompany.email.service.EmailService;
|
||||
import com.accompany.payment.service.RechargeUserService;
|
||||
import com.accompany.sms.service.SmsService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -149,6 +150,8 @@ public class UsersService extends BaseService {
|
||||
@Autowired
|
||||
protected SmsService smsService;
|
||||
@Autowired
|
||||
private EmailService emailService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
private AccountBlockService accountBlockService;
|
||||
@@ -415,6 +418,7 @@ public class UsersService extends BaseService {
|
||||
userVo.setErbanNo(user.getErbanNo());
|
||||
userVo.setPhone(StringUtils.maskPhone(user.getPhoneAreaCode(), user.getPhone()));
|
||||
userVo.setPhoneAreaCode(user.getPhoneAreaCode());
|
||||
userVo.setEmail(user.getEmail());
|
||||
userVo.setAvatar(user.getAvatar());
|
||||
userVo.setBirth(user.getBirth());
|
||||
userVo.setGender(user.getGender());
|
||||
@@ -1395,6 +1399,23 @@ public class UsersService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
public void boundEmail(Long uid, String email, String code) {
|
||||
if (usersBaseService.checkEmailExists(email)) {
|
||||
//todo code
|
||||
throw new ServiceException(BusiStatus.THE_PHONE_NUMBER_HAS_BEEN_REGISTERED);
|
||||
}
|
||||
|
||||
if (!emailService.verifyEmailCode(email, code)) {
|
||||
throw new ServiceException(BusiStatus.SMSCODEERROR);
|
||||
}
|
||||
|
||||
usersBaseService.boundEmail(uid, email);
|
||||
|
||||
//记录最近30天内绑定手机号
|
||||
jedisService.setex(RedisKey.blind_phone_sign.getKey(String.valueOf(uid)),
|
||||
30 * 24 * 60 * 60, String.valueOf(new Date().getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 最近一天有登录记录的主播
|
||||
*
|
||||
@@ -1482,5 +1503,4 @@ public class UsersService extends BaseService {
|
||||
public List<Users> listUid(Integer offect, Integer pageSize) {
|
||||
return usersMapper.listUid(offect, pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -768,9 +768,10 @@ public class UsersController extends BaseController {
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("绑定手机号")
|
||||
@PostMapping(value = "/boundPhone")
|
||||
@Authorization
|
||||
public BusiResult boundPhone(@RequestParam("phone") String phone,
|
||||
public BusiResult<Boolean> boundPhone(@RequestParam("phone") String phone,
|
||||
@RequestParam("code") String code,
|
||||
@RequestParam("phoneAreaCode") String phoneAreaCode,
|
||||
HttpServletRequest request) throws Exception {
|
||||
@@ -778,9 +779,21 @@ public class UsersController extends BaseController {
|
||||
if (phoneBlackService.checkIsNeedInterceptWithPhoneAreaCode(phoneAreaCode, phone)) {
|
||||
throw new ServiceException(BusiStatus.PHONE_NUMBER_BE_INTERCEPTED);
|
||||
}
|
||||
return new BusiResult(usersService.boundPhone(getUid(request), phone, code, phoneAreaCode));
|
||||
Boolean success = usersService.boundPhone(getUid(request), phone, code, phoneAreaCode);
|
||||
return BusiResult.success(success);
|
||||
}
|
||||
|
||||
@ApiOperation("绑定邮箱")
|
||||
@PostMapping(value = "/boundEmail")
|
||||
@Authorization
|
||||
public BusiResult<Void> boundPhone(String email,
|
||||
String code,
|
||||
HttpServletRequest request) {
|
||||
email = decryptSensitiveInfo(request, email);
|
||||
Long uid = getUid(request);
|
||||
usersService.boundEmail(uid, email, code);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@Authorization
|
||||
@PostMapping("/setting/update")
|
||||
|
Reference in New Issue
Block a user