直播间功能接口调整,增加一个获取评论列表,发送手机短信功能完成,手机注册功能完成
This commit is contained in:
parent
a824dd7101
commit
a966de9e4a
7
pom.xml
7
pom.xml
|
|
@ -22,6 +22,13 @@
|
|||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/fastdfs-client-java-1.25.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com</groupId>
|
||||
<artifactId>taobao-sdk</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/taobao-sdk-java-auto_1444640346387-20151013.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.ifish.API;
|
||||
|
||||
import com.taobao.api.ApiException;
|
||||
import com.taobao.api.DefaultTaobaoClient;
|
||||
import com.taobao.api.TaobaoClient;
|
||||
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
|
||||
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
public class SendMobile {
|
||||
|
||||
//公共回传参数
|
||||
private String extend = "";
|
||||
//短信类型
|
||||
private String sms_type = "normal";
|
||||
//签名模板,在阿里大鱼"管理中心-短信签名管理中"中的可用签名
|
||||
//private String sms_free_sign_name="注册验证";
|
||||
//短信模板变量
|
||||
private String sms_param = "爱鱼奇";
|
||||
//短信模板ID,在阿里大鱼"管理中心-短信签名管理中"中的可用模板
|
||||
//private String sms_template_code;
|
||||
//URL
|
||||
private String url = "http://gw.api.taobao.com/router/rest";
|
||||
//在开发平台-应用管理-概览-App Key
|
||||
private String appkey = "23252927";
|
||||
//在开发平台-应用管理-概览-App Secret
|
||||
private String secret = "c904889cc31bf6ba04707d7e1039ed1e";
|
||||
|
||||
/*当API的访问级别为‘公开’时,SessionKey不需要填写;
|
||||
当API的访问级别为‘须用户登录’时,SessionKey必须填写;
|
||||
当API的访问级别为‘隐私数据须用户登录’时,SessionKey可填可不填;
|
||||
如何获取SessionKey,请搜索‘用户授权介绍’或点击上面的‘Session获取工具*/
|
||||
//private String sessionKey;
|
||||
/**
|
||||
* 发送短信
|
||||
*
|
||||
* @param rec_num 手机号
|
||||
* @param code 验证码
|
||||
* @return
|
||||
*/
|
||||
public boolean sendSmsNum(String rec_num, String code, String sign_name, String template_code) {
|
||||
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
|
||||
AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
|
||||
req.setExtend(extend);
|
||||
req.setSmsType(sms_type);
|
||||
req.setSmsFreeSignName(sign_name);
|
||||
req.setSmsParam("{\"code\":\"" + code + "\",\"product\":" + sms_param + "}");
|
||||
req.setRecNum(rec_num);
|
||||
req.setSmsTemplateCode(template_code);
|
||||
try {
|
||||
AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
|
||||
return rsp.getResult().getSuccess();
|
||||
} catch (ApiException e) {
|
||||
e.getStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,21 @@ public class LiveRoom {
|
|||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据直播间ID获取直播间评论列表
|
||||
*
|
||||
* @param roomId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/liveRoom/v3/getleaveMessage.do", method = RequestMethod.GET)
|
||||
public Object getleaveMessage(Integer roomId, Integer firstResult, Integer pageSize) {
|
||||
try {
|
||||
return liveRoomHelperI.getLeaveMessage(firstResult, pageSize, roomId);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取直播间信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@
|
|||
package com.ifish.controller;
|
||||
|
||||
import com.ifish.bean.Tbl_User;
|
||||
import com.ifish.enums.ResultEnum;
|
||||
import com.ifish.helper.UserHelperI;
|
||||
import com.ifish.util.IfishUtil;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -33,6 +36,25 @@ public class Login {
|
|||
return userHelperI.login(user);
|
||||
}
|
||||
|
||||
@RequestMapping("/getSecurityCode.do")
|
||||
public Object getSecurityCode(String sendType, String phoneNumber) {
|
||||
try {
|
||||
return userHelperI.getSecurityCode(sendType, phoneNumber);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/registerByMobile", method = RequestMethod.GET)
|
||||
public Object registerByMobile(Tbl_User user) {
|
||||
return userHelperI.registerByMobile(user);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/registerByEmail", method = RequestMethod.GET)
|
||||
public Object registerByEmail(Tbl_User user) {
|
||||
return userHelperI.registerByEmail(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 游客注册
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.ifish.enums;
|
||||
|
||||
/**
|
||||
* 获取验证码操作类型
|
||||
*
|
||||
* @author ggw
|
||||
*
|
||||
*/
|
||||
public enum SendTypeEnum {
|
||||
register("1", "注册操作"),
|
||||
findpwd("2", "找回密码操作");
|
||||
|
||||
private SendTypeEnum(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.ifish.enums;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public enum SmsSignEnum {
|
||||
sign1("sign1", "活动验证"),
|
||||
sign2("sign2", "变更验证"),
|
||||
sign3("sign3", "登录验证"),
|
||||
sign4("sign4", "注册验证"),
|
||||
sign5("sign5", "身份验证");
|
||||
|
||||
private SmsSignEnum(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.ifish.enums;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public enum SmsTemplateEnum {
|
||||
SMS_720021("SMS_720021", "身份验证验证码"),
|
||||
SMS_720020("SMS_720020", "登陆确认验证码"),
|
||||
SMS_720019("SMS_720019", "登陆异常验证码"),
|
||||
SMS_720018("SMS_720018", "用户注册验证码"),
|
||||
SMS_720017("SMS_720017", "活动确认验证码"),
|
||||
SMS_720016("SMS_720016", "修改密码验证码"),
|
||||
SMS_720015("SMS_720015", "信息变更验证码");
|
||||
|
||||
private SmsTemplateEnum(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -288,6 +288,38 @@ public class LiveRoomHelper implements LiveRoomHelperI {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据直播间ID获取直播间评论列表
|
||||
*
|
||||
* @param roomId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getLeaveMessage(Integer firstResult, Integer pageSize, Integer roomId) {
|
||||
try {
|
||||
if (firstResult == null) {
|
||||
firstResult = 0;
|
||||
}
|
||||
if (pageSize == null) {
|
||||
pageSize = 10;
|
||||
}
|
||||
List<Map> list = null;
|
||||
String key = redisKeyHelperI.getTbl_Live_Message(firstResult, pageSize, roomId);
|
||||
String redisString = redisHelperI.getRedis(key);
|
||||
if (StringUtils.isNotBlank(redisString)) {
|
||||
list = (List<Map>) IfishUtil.JsonToList(redisString, Map.class);
|
||||
} else {
|
||||
list = tbl_Live_Room_Mapper.getLive_MessagesListByRoomId(roomId, firstResult, pageSize);
|
||||
if (list != null && list.size() > 0) {
|
||||
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(list));
|
||||
}
|
||||
}
|
||||
return IfishUtil.toJson(ResultEnum.success.getKey(), list);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取直播间信息
|
||||
*
|
||||
|
|
@ -335,7 +367,7 @@ public class LiveRoomHelper implements LiveRoomHelperI {
|
|||
if (firstResult != null && pageSize != null) {
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
List<LiveRoomPageInfo> timeList = new ArrayList<LiveRoomPageInfo>();
|
||||
if (orders != null && orders.equals("renqi")) {
|
||||
if (orders != null && orders.equals("2")) {
|
||||
timeList = tbl_Live_Room_Mapper.getLiveRoomListByRenqi(pageSize, firstResult);
|
||||
} else {
|
||||
timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,14 @@ public interface LiveRoomHelperI {
|
|||
*/
|
||||
Object leaveMessage(Tbl_Live_Message liveMessage);
|
||||
|
||||
/**
|
||||
* 根据直播间ID获取直播间评论列表
|
||||
*
|
||||
* @param roomId
|
||||
* @return
|
||||
*/
|
||||
Object getLeaveMessage(Integer firstResult, Integer pageSize, Integer roomId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取直播间信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,6 +25,28 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
@Autowired
|
||||
private RedisHelperI redisHelperI;
|
||||
|
||||
/**
|
||||
* 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getTbl_UserRedisKeyByPhoneNumber(String phoneNumber) {
|
||||
return RedisKey.USER_PHONE + phoneNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Email获取Tbl_User用户信息的Redis缓存key键值
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getTbl_UserRedisKeyByEmail(String email) {
|
||||
return RedisKey.USER_EMAIL + email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据userId获取Tbl_User用户信息的Redis缓存key键值
|
||||
*
|
||||
|
|
@ -181,6 +203,17 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
return RedisKey.LIVEROOM_COUNT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取直播间评论列表的redis缓存key键值
|
||||
*
|
||||
* @param roomId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getTbl_Live_Message(Integer firstResult, Integer pageSize, Integer roomId) {
|
||||
return RedisKey.LIVEMESSAGE_ROOMID + roomId + "_f_" + firstResult + "_p_" + pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pushId获取Tbl_push_list的redis缓存key键值
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,6 +25,22 @@ public interface RedisKeyHelperI {
|
|||
*/
|
||||
public String getTbl_UserRedisKeyByUserId(Integer userId);
|
||||
|
||||
/**
|
||||
* 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public String getTbl_UserRedisKeyByPhoneNumber(String phoneNumber);
|
||||
|
||||
/**
|
||||
* 根据Email获取Tbl_User用户信息的Redis缓存key键值
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public String getTbl_UserRedisKeyByEmail(String email);
|
||||
|
||||
/**
|
||||
* 根据mac地址获取Tbl_Device的redis缓存key键值
|
||||
*
|
||||
|
|
@ -131,6 +147,14 @@ public interface RedisKeyHelperI {
|
|||
*/
|
||||
public String getTbl_Live_Room_CountRedisKey();
|
||||
|
||||
/**
|
||||
* 获取直播间评论列表的redis缓存key键值
|
||||
*
|
||||
* @param roomId
|
||||
* @return
|
||||
*/
|
||||
public String getTbl_Live_Message(Integer firstResult, Integer pageSize, Integer roomId);
|
||||
|
||||
/**
|
||||
* 根据pushId获取Tbl_push_list的redis缓存key键值
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
package com.ifish.helper;
|
||||
|
||||
import com.ifish.API.GwellApi;
|
||||
import com.ifish.API.SendMobile;
|
||||
import com.ifish.bean.Tbl_Device;
|
||||
import com.ifish.bean.Tbl_Device_User;
|
||||
import com.ifish.bean.Tbl_HardWare_Type;
|
||||
|
|
@ -13,13 +14,20 @@ import com.ifish.bean.Tbl_User;
|
|||
import com.ifish.bean.Tbl_Vender;
|
||||
import com.ifish.enums.GwellEnum;
|
||||
import com.ifish.enums.ResultEnum;
|
||||
import com.ifish.enums.SendTypeEnum;
|
||||
import com.ifish.enums.SmsSignEnum;
|
||||
import com.ifish.enums.SmsTemplateEnum;
|
||||
import com.ifish.enums.SubDirectoryEnum;
|
||||
import com.ifish.mapper.Tbl_Hardware_Type_Mapper;
|
||||
import com.ifish.mapper.Tbl_User_Mapper;
|
||||
import com.ifish.util.IfishFilePath;
|
||||
import com.ifish.util.IfishUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -52,6 +60,9 @@ public class UserHelper implements UserHelperI {
|
|||
@Autowired
|
||||
private RedisKeyHelperI redisKeyHelperI;
|
||||
|
||||
@Autowired
|
||||
private SendMobile sendMobile;
|
||||
|
||||
/**
|
||||
* 登陆接口
|
||||
*
|
||||
|
|
@ -82,6 +93,113 @@ public class UserHelper implements UserHelperI {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机用户注册
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object registerByMobile(Tbl_User user) {
|
||||
//随机生成6位用户名
|
||||
user.setNickName("鱼友" + IfishUtil.getCharAndNumr(5));
|
||||
user.setIsRegisterGwell("0");
|
||||
user.setUserType("1");
|
||||
Date date = new Date();
|
||||
user.setCreateTime(date);
|
||||
user.setUserImg("default/" + (new Random().nextInt(7) + 1) + ".png");
|
||||
user.setUpdateTime(date);
|
||||
|
||||
//注册技威
|
||||
//4.1未注册技威,则注册获取code1,code2
|
||||
Map gwellMap = registUserGWell(user, false);
|
||||
user = (Tbl_User) gwellMap.get("user");
|
||||
if (StringUtils.isBlank(user.getP2pverifyCode1()) || StringUtils.isBlank(user.getP2pverifyCode2()) || StringUtils.isBlank(user.getGwellUserid())) {
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
Integer updateInteger = tbl_User_Mapper.updateUser(user);
|
||||
//如果修改失败,返回错误信息
|
||||
if (updateInteger <= 0) {
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
try {
|
||||
saveUserToRedis(user);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
//注册云信
|
||||
// Map<String, String> neteaseMap = neteaseIM.createAccid(user.getUserId().toString(), user.getNickName(), IfishFilePath.getPath(SubDirectoryEnum.headImage, user.getUserImg()), "");
|
||||
// if (neteaseMap != null) {
|
||||
// String code = neteaseMap.get("code");
|
||||
// if (code.equals(NeteaseEnum.status200.getKey())) {
|
||||
// user.setIsRegisterNetease(BooleanEnum.YES.getKey());
|
||||
// user.setNeteaseToken(neteaseMap.get("token"));
|
||||
// } else if (code.equals(NeteaseEnum.status414.getKey())) {
|
||||
// user.setIsRegisterNetease(BooleanEnum.YES.getKey());
|
||||
// }
|
||||
// this.userDao.update(user);
|
||||
// }
|
||||
//发送云信消息
|
||||
// User imUser = this.userDao.findUniqueByProperty(Restrictions.eq("phoneNumber", IfishFilePath.netease_phone));
|
||||
// if (imUser != null) {
|
||||
// neteaseIM.sendMsg(imUser.getUserId().toString(), user.getUserId().toString(), "感谢您使用爱鱼奇,连接智能设备请查看下方说明书,内含操作视频:http://u.eqxiu.com/s/KmmVl87l \n摄像头售后:021-54131006\n睿芯插排售后:18658232626\n绚多插排售后:18857689069\n松诺插排售后:13392205468", "");
|
||||
// }
|
||||
//返回给App的数据
|
||||
Map dataMap = new HashMap();
|
||||
dataMap.put("userId", user.getUserId().toString());
|
||||
dataMap.put("nickName", user.getNickName());
|
||||
dataMap.put("updateTime", IfishUtil.format(user.getUpdateTime()));
|
||||
dataMap.put("userId", user.getUserId());
|
||||
dataMap.put("P2PVerifyCode1", user.getP2pverifyCode1());
|
||||
dataMap.put("P2PVerifyCode2", user.getP2pverifyCode2());
|
||||
dataMap.put("gwellUserID", user.getGwellUserid());
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), dataMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱用户注册
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object registerByEmail(Tbl_User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型和手机号,发送验证码
|
||||
*
|
||||
* @param sendType
|
||||
* @param phoneNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getSecurityCode(String sendType, String phoneNumber) {
|
||||
Tbl_User user = getUserByPhoneNumber(phoneNumber);
|
||||
if (sendType.equals(SendTypeEnum.register.getKey())) {
|
||||
if (user != null) {
|
||||
//手机号注册过,发送错误码
|
||||
return IfishUtil.returnJson(ResultEnum.warn201.getKey(), "");
|
||||
} else {
|
||||
//手机未被注册,获取验证码
|
||||
return sendSecurityCode(phoneNumber, SmsSignEnum.sign4.getValue(), SmsTemplateEnum.SMS_720018.getKey());
|
||||
}
|
||||
} //找回密码
|
||||
else if (sendType.equals(SendTypeEnum.findpwd.getKey())) {
|
||||
if (user != null) {
|
||||
//手机号存在,获取验证码
|
||||
return sendSecurityCode(phoneNumber, SmsSignEnum.sign5.getValue(), SmsTemplateEnum.SMS_720021.getKey());
|
||||
} else {
|
||||
//手机号不存在,发送错误码
|
||||
return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "");
|
||||
}
|
||||
} else {
|
||||
//未知操作,返回错误码
|
||||
return IfishUtil.returnJson(ResultEnum.warn203.getKey(), "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID从缓存中获取用户对象
|
||||
*
|
||||
|
|
@ -143,6 +261,52 @@ public class UserHelper implements UserHelperI {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号从缓存或数据库中取得用户对象
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public Tbl_User getUserByPhoneNumber(String phoneNumber) {
|
||||
Tbl_User tmpUser = null;
|
||||
try {
|
||||
String userKey = redisKeyHelperI.getTbl_UserRedisKeyByPhoneNumber(phoneNumber);
|
||||
String userString = redisHelperI.getRedis(userKey);
|
||||
//1.从数据库或缓存中读取用户对象
|
||||
if (StringUtils.isNotBlank(userString)) {
|
||||
tmpUser = (Tbl_User) IfishUtil.JsonToBean(userString, Tbl_User.class);
|
||||
} else {
|
||||
tmpUser = tbl_User_Mapper.getUserByPhoneNumber(phoneNumber);
|
||||
saveUserToRedis(tmpUser);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return tmpUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据邮箱从缓存或数据库中取得用户对象
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public Tbl_User getUserByEmail(String email) {
|
||||
Tbl_User tmpUser = null;
|
||||
try {
|
||||
String userKey = redisKeyHelperI.getTbl_UserRedisKeyByEmail(email);
|
||||
String userString = redisHelperI.getRedis(userKey);
|
||||
//1.从数据库或缓存中读取用户对象
|
||||
if (StringUtils.isNotBlank(userString)) {
|
||||
tmpUser = (Tbl_User) IfishUtil.JsonToBean(userString, Tbl_User.class);
|
||||
} else {
|
||||
tmpUser = tbl_User_Mapper.getUserByUserEmail(email);
|
||||
saveUserToRedis(tmpUser);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return tmpUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱和手机登陆用户,需要进行密码验证,游客登陆不需要
|
||||
*
|
||||
|
|
@ -475,4 +639,22 @@ public class UserHelper implements UserHelperI {
|
|||
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送手机验证码
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param smsSign
|
||||
* @param smsTemplate
|
||||
* @return
|
||||
*/
|
||||
public Object sendSecurityCode(String phoneNumber, String smsSign, String smsTemplate) {
|
||||
Integer code = (int) (Math.random() * 9000 + 1000);
|
||||
boolean bln = sendMobile.sendSmsNum(phoneNumber, code.toString(), smsSign, smsTemplate);
|
||||
//发送验证码
|
||||
if (bln) {
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), code.toString());
|
||||
} else {
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,29 @@ public interface UserHelperI {
|
|||
*/
|
||||
public Map<String, Object> getDeviceInfo(Tbl_Device device, Tbl_Device_User deviceUser) throws Exception;
|
||||
|
||||
/**
|
||||
* 手机用户注册
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public Object registerByMobile(Tbl_User user);
|
||||
|
||||
/**
|
||||
* 邮箱用户注册
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public Object registerByEmail(Tbl_User user);
|
||||
|
||||
/**
|
||||
* 根据类型和手机号,发送验证码
|
||||
*
|
||||
* @param sendType
|
||||
* @param phoneNumber
|
||||
* @return
|
||||
*/
|
||||
public Object getSecurityCode(String sendType, String phoneNumber);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.ifish.bean.LiveRoomPageInfo;
|
|||
import com.ifish.bean.Tbl_Live_Message;
|
||||
import com.ifish.bean.Tbl_Live_Room;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -153,4 +154,18 @@ public interface Tbl_Live_Room_Mapper {
|
|||
*/
|
||||
@UpdateProvider(type = Tbl_Live_Room_MapperSql.class, method = "updateLiveRoom")
|
||||
Integer updateLiveRoom(@Param("live") Tbl_Live_Room live_Room);
|
||||
|
||||
/**
|
||||
* 根据直播间ID获取此直播间评论列表
|
||||
*
|
||||
* @param roomid
|
||||
* @return
|
||||
*/
|
||||
@Select("select l.message_id as messageId,l.room_id as roomId,l.user_id as userId,l.as_user_id as asUserId,"
|
||||
+ "uu.nick_name as asUserName,u.user_img as userImg,u.nick_name as userName,l.message_content as messageContent,l.create_time as createTime "
|
||||
+ "from tbl_live_message l "
|
||||
+ "LEFT JOIN tbl_user u ON l.user_id = u.user_id "
|
||||
+ "LEFT JOIN tbl_user uu ON l.as_user_id=uu.user_id "
|
||||
+ "WHERE room_id = #{roomid} LIMIT ${first},${page} ")
|
||||
List<Map> getLive_MessagesListByRoomId(@Param("roomid") Integer roomid, @Param("first") Integer firstResult, @Param("page") Integer pageSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,15 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String USER_ID_KEY = "userE:id_";
|
||||
|
||||
/**
|
||||
* 用户缓存前缀,以手机号进行存储
|
||||
*/
|
||||
public static final String USER_PHONE = "userE:ph_";
|
||||
/**
|
||||
* 用户缓存前缀,以邮箱进行存储
|
||||
*/
|
||||
public static final String USER_EMAIL = "userE:ema_";
|
||||
|
||||
/**
|
||||
* 设备用户关系缓存前缀,以设备ID和用户ID进行存储
|
||||
*/
|
||||
|
|
@ -81,6 +90,11 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String LIVEROOM_COUNT = "liveroomE:num_";
|
||||
|
||||
/**
|
||||
* 指定直播间评论列表
|
||||
*/
|
||||
public static final String LIVEMESSAGE_ROOMID = "livemessageE:rid_";
|
||||
|
||||
/**
|
||||
* 推送信息表缓存前缀,以推送Id进行存储
|
||||
*/
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue