一个好的SpringCloud+SpringBoot b2b2c 电子商务平台涉及哪些技术、运营方案?以下是我结合公司的产品做的总结,希望可以帮助到大家!
搜索体验小程序:海哇
1. 涉及平台 平台管理、商家端(PC端、手机端)、买家平台(H5/公众号、小程序、APP端(IOS/Android)、微服务平台(业务服务)
2. 核心架构 Spring Cloud、Spring Boot、Mybatis、Redis
3. 前端框架 VUE、Uniapp、Bootstrap/H5/CSS3、IOS、Android、小程序
4. 核心思想 分布式、微服务、云架构、模块化、原子化、持续集成、集群部署、前后端分离、支持阿里Docker
5. 开发模式 前后端分离、微服务开发
6. 社交模式 VR全景虚拟现实、直播带货、短视频带货、分销分润、代跑腿配送、内容营销、社交种草、社交电商、秒杀、积分商城、限时折扣、活动商品、拼团活动等
7. 营销模式 通用版本(标准多商户入驻+二级分销体系+满减、满送、优惠券、组合销售、平台礼包等营销活动) 直播、短视频带货版本(标准多商户入驻+直播、短视频带货+二级分销体系+满减、满送、优惠券、组合销售、平台礼包等营销活动) 特殊营销方案(一):一县一特(一个县城,一个特色,集本地特产、特色、名胜、小吃、文化为一体的营销方案) 特殊营销方案(二):短距离配送(外卖、生鲜水果配送,解决1.5公里配送问题,接入第三方代跑腿服务) 特殊营销方案(三):酒店行业(酒店商家入驻,根据定位,可针对附近酒店,不同城酒店进行线上预定、下线核销等,参考去哪儿网酒店业务) 特殊营销方案(四):VR全景(商家入驻后,可以进行VR全景拍摄,VR店铺体验,全新购物方式,通过虚拟现实技术,线上线下打通,实现全新O2O,深度场景体验,感受另一个大千世界,让用户足不出户完美购物。通过VR让您的店铺曝光率更高,让天下没有难销的商品) 特殊营销方案(五):线下套餐体验(针对于实体行业,用户线上消费后生成核销码,用户到实体店铺体验套餐,可凭借核销码进行体验项目) 特殊营销方案(六):旅游业(周边游、本地游、异地游等,旅游景区和VR全景结合,用户足不出户先感受一下旅游项目、旅游攻略等,可线上订票、预定等) 特殊营销方案(七):供应求购(简易供应链供应、求购模式) 特殊营销方案(八):社交资讯(用户发布文章,可进行带货) 特殊营销方案(九):社交动态(个人信息、动态、视频,如:文字+图片、文字+视频,可进行带货;粉丝、关注、分享等) 活动商品(平台发布活动商品,如:可以进行0元领取,领取需要进行用户拉新,拉新后可进行现金奖励等) 特殊营销方案(十):异业联盟(不同行业的联盟销售,如:在某餐饮店面消费后可送附近健身卡优惠券,凭借优惠券可进行线下体验) 特殊营销方案(十一):一键代发营销(商家选择平台商品后放入自己店面销售,用户购买后商家可获取特殊分润提成,商家不需要发货,由平台厂家直接发货,并支持本店面自提)
package com.honghu.cloud.controller;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.honghu.cloud.bean.Live;
import com.honghu.cloud.bean.LiveBaby;
import com.honghu.cloud.bean.LiveFollow;
import com.honghu.cloud.bean.UserSearchLog;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.code.ResponseVO;
import com.honghu.cloud.common.page.Page;
import com.honghu.cloud.dto.AccessoryDto;
import com.honghu.cloud.dto.AddGoodsCarFormDto;
import com.honghu.cloud.dto.MessageDto;
import com.honghu.cloud.dto.SysConfigDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.feign.AccessoryFeignClient;
import com.honghu.cloud.feign.GoodsCartFeignClient;
import com.honghu.cloud.feign.GoodsShareFeignClient;
import com.honghu.cloud.feign.MessageFeignClient;
import com.honghu.cloud.feign.SysConfigFeignClient;
import com.honghu.cloud.feign.UserFeignClient;
import com.honghu.cloud.redis.RedisUtil;
import com.honghu.cloud.service.IUserSearchLogService;
import com.honghu.cloud.service.LiveBabyService;
import com.honghu.cloud.service.LiveFollowService;
import com.honghu.cloud.service.LiveService;
import com.honghu.cloud.tools.LiveUtils;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.util.CommUtil;
import com.honghu.cloud.utils.tools.Md5Encrypt;
import net.sf.json.JSONObject;
/**
* 直播间管理控制器
*
* @author Administrator
*
*/
@RestController
@RequestMapping(value = "/live")
public class LiveController {
private static final Logger logger = LoggerFactory.getLogger(LiveController.class);
@Autowired
private LiveService liveService;
@Autowired
private LiveFollowService liveFollowService;
@Autowired
private AccessoryFeignClient accessoryFeignClient;
@Autowired
private SysConfigFeignClient sysConfigFeignClient;
@Autowired
private LiveBabyService liveBabyService;
@Autowired
private UserFeignClient userFeignClient;
@Autowired
private MessageFeignClient messageFeignClient;
@Autowired
private GoodsShareFeignClient shareFeignClient;
@Autowired
private IUserSearchLogService userSearchLogService;
@Autowired
private GoodsCartFeignClient goodsCartFeignClient;
@Autowired
private RedisUtil redisUtil;
/**
* 根据id查询直播
*
* @param id
* @return
*/
@RequestMapping(value = "/apiForFeign/selectByPrimaryKey", method = RequestMethod.GET)
public Live selectByPrimaryKey(@RequestParam("id") Long id) {
return liveService.selectByPrimaryKey(id);
}
@RequestMapping(value = "/apiForFeign/selectByPrimaryKey1", method = RequestMethod.GET)
public Live selectByPrimaryKey1(@RequestParam("id") Long id) {
return liveService.selectByPrimaryKey1(id);
}
/**
* 我的直播间数据列表查询
*
* @param params
*/
@RequestMapping(value = "/getLiveList")
public ResponseVO getLiveList(HttpServletRequest request, @RequestBody JSONObject json) {
Map params = new HashMap();
String currentPage = json.optString("currentPage"); // 当前页数
String pageSize = json.optString("pageSize"); // 数据长度
String userName = json.getString("userName"); // 主播用户
String orderBy = json.optString("orderBy"); // 排序字段
String orderType = json.optString("orderType"); // 排序方式
if (StringUtils.isNotBlank(userName)) {
if (StringUtils.isNotBlank(currentPage)) {
params.put("currentPage", CommUtil.null2Int(currentPage));
}
if (StringUtils.isNotBlank(pageSize)) {
params.put("pageSize", CommUtil.null2Int(pageSize));
}
if (StringUtils.isNotBlank(orderBy)) {
params.put("orderBy", orderBy);
}
if (StringUtils.isNotBlank(orderType)) {
params.put("orderType", orderType);
}
params.put("creater_id", userName); // 当前用户编号
}
List results = liveService.queryPages(params);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, results);
}
/**
* 我的直播间数据列表查询
*
* @param params
*/
@RequestMapping(value = "/getLiveList_new")
public ResponseVO getLiveList_new(HttpServletRequest request, @RequestBody JSONObject json) {
Map params = new HashMap();
String currentPage = json.optString("currentPage"); // 当前页数
String pageSize = json.optString("pageSize"); // 数据长度
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
params = QueryTools.getParams(currentPage, 12, "live_status DESC ,addTime", "DESC");
params.put("user_id", user.getId()); // 当前用户编号
params.put("goods_num", "goods_num"); // 查询宝贝件数
Page results = liveService.list(params);
params.clear();
params.put("results", results);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, params);
}
/**
* 全部直播间数据列表查询
*
* @param params
*/
@RequestMapping(value = "/getLiveListAll")
public ResponseVO getLiveListAll(HttpServletRequest request, @RequestBody JSONObject json) {
Map params = new HashMap();
String currentPage = json.optString("currentPage"); // 当前页数
String pageSize = json.optString("pageSize"); // 数据长度
String orderBy = json.optString("orderBy"); // 排序字段
String orderType = json.optString("orderType"); // 排序方式
String type = json.optString("type"); // 排序方式
params = QueryTools.getParams(currentPage, CommUtil.null2Int(pageSize), orderBy, orderType);
if (StringUtils.isNotBlank(type) && "follow".equals(type)) {
// 查询用户关注的主播
params.put("orderType", type);
}
List list = liveService.queryPages(params);
HashMap results = new HashMap<>();
results.put("list", list);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, results);
}
@RequestMapping(value = "/getLiveListAll1")
public ResponseVO getLiveListAll1(HttpServletRequest request, @RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
Map params = new HashMap();
String currentPage = json.optString("currentPage"); // 当前页数
String pageSize = json.optString("pageSize"); // 数据长度
String type = json.optString("type"); // 排序方式
String store_id = json.optString("store_id"); // 店铺id
HashMap results = new HashMap<>();
params = QueryTools.getParams(currentPage, CommUtil.null2Int(pageSize), "a.addTime", null);
if (StringUtils.isNotBlank(type) && "follow".equals(type)) {
// 查询用户关注的主播
params.put("follow", user.getId());
}
if (StringUtils.isNotBlank(store_id)) {
UserDto UserDto = userFeignClient.getUserByStoreId(CommUtil.null2Long(store_id));
if (UserDto == null) {
Page list = new Page<>();
results.put("list", list);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, results);
}
params.put("a_user_id", UserDto.getId());
}
Page list = liveService.list1(params);
results.put("list", list);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, results);
}
/**
* 查询直播间数据
*
* @param id
* @return
*/
@RequestMapping("/getLiveById")
public ResponseVO getLiveById(@RequestBody JSONObject json, HttpServletRequest request) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
String live_id = json.optString("live_id");
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
if (StringUtils.isEmpty(live_id)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null);
}
Live live = liveService.selectByPrimaryKey(CommUtil.null2Long(live_id));
if (live == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.GOODSCLASS_CODE_NULL, null);
}
UserDto anchor = userFeignClient.selectByPrimaryKey(live.getUser_id());
if (anchor == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_CONCERN_ISNULL, null);
}
HashMap hashMap = new HashMap<>();
AccessoryDto accessoryDto = accessoryFeignClient.selectByPrimaryKey(anchor.getPhoto_id());
if (live.getLive_status() == 1) { // 若在直播中 添加热度
int n = (int) (Math.random() * 20 + 15);
live.setPopularity_num(live.getPopularity_num() == null ? 0 : live.getPopularity_num() + n);
liveService.updateById(live);
Object currentNumber = redisUtil.get("NUMBER_" + live.getId());
redisUtil.set("NUMBER_" + live.getId(), null == currentNumber ? 1 : (int) currentNumber + 1);
}
if (user_id != null) {
hashMap.put("concern", user_id);
hashMap.put("to_concern", anchor.getId());
hashMap.put("deleteStatus", 0);
LiveFollow liveFollow = liveFollowService.getLiveFollow(hashMap);
if (liveFollow != null) {
live.setFollow(1); // 已关注
}
}
hashMap.clear();
hashMap.put("anchorname", anchor.getNickName());
hashMap.put("anchorphoto", accessoryDto);
hashMap.put("live", live);
hashMap.put("user", user);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, hashMap);
}
/**
* 创建直播间 添加直播间数据
*
* @param live
*/
@RequestMapping("/add_live_baby")
public ResponseVO add_live(HttpServletRequest request, @RequestBody JSONObject json) {
String mulitId = null; // 商品id
if (json.containsKey("goods_id")) {
mulitId = json.optString("goods_id");
}
String live_id = json.optString("live_id"); // 直播id
String userName = json.optString("userName"); // 用户userName
String live_title = json.optString("live_title"); // 直播间标题
String live_cover = json.optString("live_cover"); // 直播间封面路径完整路径
String live_status = json.optString("live_status"); // 直播状态
String play_time = json.optString("play_time"); // 直播间预播时间
// 直播间id
if (StringUtils.isEmpty(live_id)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null); // 直播间ID不能为空
}
if (StringUtils.isEmpty(live_title)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TITLE_ISNULL, null); // 直播间标题不能为空
}
if (StringUtils.isEmpty(live_cover)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_COVER_ISNULL, null); // 直播间封面不能为空
}
if (StringUtils.isEmpty(userName)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); // 用户userName不能为空
}
if (StringUtils.isEmpty(live_status)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_STATUS, null); // 直播状态不能为空
}
Live live = new Live();
live.setAddTime(new Date()); // 直播间创建时间
live.setLive_title(live_title); // 直播间标题
live.setLive_cover(live_cover); // 直播间封面完整路径
live.setLive_num(CommUtil.null2Long(live_id)); // 直播间房间号
live.setCreater_id(userName); // 创建用户
live.setLive_status(Integer.valueOf(live_status)); // 直播状态
// 日期转化格式
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = simpleDateFormat.parse(play_time);
live.setPlay_time(date); // 预播时间
} catch (ParseException e) {
logger.error("LiveController >> add_live >> " + e.getMessage());
}
liveService.addLive(live); // 保存直播间数据信息
if (null != mulitId) {
String[] ids = mulitId.split(",");
for (String id : ids) {
LiveBaby liveBaby = new LiveBaby();
liveBaby.setAddTime(new Date());
liveBaby.setCreater_id(userName);
liveBaby.setGoods_id(CommUtil.null2Long(id));
liveBaby.setLive_id(CommUtil.null2Long(live_id)); // 直播间id
liveBaby.setDeleteStatus(0); // 删除标识
liveBabyService.addLiveBaby(liveBaby); // 添加直播间宝贝信息
}
}
try {
UserDto liveUser = userFeignClient.selectByUserName(userName);
Map maps = new HashMap();
maps.put("to_concern", liveUser.getId());
List list = liveFollowService.queryPages(maps);
List msgs = new ArrayList();
for (LiveFollow lf : list) {
// 发送站内消息
MessageDto msg = new MessageDto();
msg.setAddTime(new Date());
msg.setDeleteStatus(0);
msg.setMsg_cat(0);
msg.setReply_status(0);
msg.setStatus(0);
String nickName = liveUser.getNickName();
if (StringUtils.isBlank(nickName)) {
StringBuilder sb = new StringBuilder(liveUser.getMobile());
if (sb.length() >= 11) {
sb.replace(3, 7, "****");
}
nickName = sb.toString();
}
if (StringUtils.equals("1", live_status)) {
msg.setTitle("直播通知");
msg.setContent("你关注的" + nickName + "正在直播,请及时观看。");
// TODO 添加公众号推送
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String format = sdf.format(date); // 将Date类型转换成String类型
msg.setTitle("预播通知");
msg.setContent("你关注的" + nickName + "将于" + format + "开始直播,请及时观看哦!");
}
msg.setType(2);
msg.setFromUser_id(1L);
msg.setToUser_id(lf.getConcern());
msgs.add(msg);
}
messageFeignClient.saveList(msgs);
} catch (Exception e) {
logger.error("LiveController >> add_live >> sendMsg error " + e.getMessage());
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 创建直播间 添加直播间数据
*
* @param live
*/
@RequestMapping(value = "/add_live_baby_new", method = RequestMethod.POST)
public ResponseVO add_live_new(HttpServletRequest request, @RequestBody JSONObject json) {
String mulitId = null; // 商品id
if (json.containsKey("goods_id")) {
mulitId = json.optString("goods_id");
}
// String live_id = json.optString("live_id"); //直播id
String live_title = json.optString("live_title"); // 直播间标题
String live_cover = json.optString("live_cover"); // 直播间封面路径完整路径
String live_status = json.optString("live_status"); // 直播状态
String play_time = json.optString("play_time"); // 直播间预播时间
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
/*
* if(StringUtils.isEmpty(live_id)){ return
* ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null);
* //直播间ID不能为空 }
*/
if (StringUtils.isEmpty(live_title)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TITLE_ISNULL, null); // 直播间标题不能为空
}
if (StringUtils.isEmpty(live_cover)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_COVER_ISNULL, null); // 直播间封面不能为空
}
if (StringUtils.isEmpty(live_status)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_STATUS, null); // 直播状态不能为空
}
Map maps = new HashMap();
Live live = new Live();
Date date = null;
if (live_status.equals("3")) {
// 日期转化格式
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
date = simpleDateFormat.parse(play_time);
// 查询预播时间点是否存在
maps.put("a_user_id", user.getId());
maps.put("a_play_time", play_time);
List queryPages = liveService.queryPages(maps);
if (queryPages != null && queryPages.size() > 0) { // 该时间存在预播
// 不保存
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_PREVIEW_IS, null); // 预播已存在
}
live.setPlay_time(date); // 预播时间
} catch (ParseException e) {
logger.error("LiveController >> add_live >> " + e.getMessage());
}
}
live.setAddTime(new Date()); // 直播间创建时间
live.setLive_title(live_title); // 直播间标题
live.setLive_cover(live_cover); // 直播间封面完整路径
Long selectMaxLiveCode = liveService.selectMaxLiveCode();
live.setLive_num(selectMaxLiveCode == null ? 100000 : selectMaxLiveCode + 1); // 直播间房间号
live.setUser_id(user.getId());
live.setCreater_id(user.getUserName()); // 创建用户
live.setLive_status(Integer.valueOf(live_status)); // 直播状态
if (live_status.equals("1")) {
live.setDeleteStatus(1); // 若为直播,先置位删除状态 , 推流时修改
}
liveService.addLive(live); // 保存直播间数据信息
if (null != mulitId) {
String[] ids = mulitId.split(",");
for (String id : ids) {
if (!id.equals("")) {
LiveBaby liveBaby = new LiveBaby();
liveBaby.setAddTime(new Date());
liveBaby.setCreater_id(user.getUsername());
liveBaby.setGoods_id(CommUtil.null2Long(id));
liveBaby.setLive_id(CommUtil.null2Long(live.getId())); // 直播间id
liveBaby.setDeleteStatus(0); // 删除标识
liveBabyService.addLiveBaby(liveBaby); // 添加直播间宝贝信息
}
}
}
try {
// UserDto liveUser = userFeignClient.selectByUserName(userName);
maps.clear();
maps.put("to_concern", user.getId());
List list = liveFollowService.queryPages(maps);
List msgs = new ArrayList();
for (LiveFollow lf : list) {
// 发送站内消息
MessageDto msg = new MessageDto();
msg.setAddTime(new Date());
msg.setDeleteStatus(0);
msg.setMsg_cat(0);
msg.setReply_status(0);
msg.setStatus(0);
String nickName = user.getNickName();
if (StringUtils.isBlank(nickName)) {
StringBuilder sb = new StringBuilder(user.getMobile());
if (sb.length() >= 11) {
sb.replace(3, 7, "****");
}
nickName = sb.toString();
}
if (StringUtils.equals("1", live_status)) {
msg.setTitle("直播通知");
msg.setContent("你关注的" + nickName + "正在直播,请及时观看。");
// TODO 添加公众号推送
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String format = sdf.format(date); // 将Date类型转换成String类型
msg.setTitle("预播通知");
msg.setContent("你关注的" + nickName + "将于" + format + "开始直播,请及时观看哦!");
}
msg.setType(2);
msg.setFromUser_id(1L);
msg.setToUser_id(lf.getConcern());
msgs.add(msg);
}
messageFeignClient.saveList(msgs);
} catch (Exception e) {
logger.error("LiveController >> add_live >> sendMsg error " + e.getMessage());
}
HashMap hashMap = new HashMap<>();
hashMap.put("live", live);
hashMap.put("nickName", user.getNickName());
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, hashMap); // 请求处理成功
}
/**
* 添加主播关注数据
*
* @param live
*/
@RequestMapping("/add_live_follow")
public ResponseVO add_live_follow(@RequestBody JSONObject json) {
String concern = json.optString("concern"); // 关注者编号
String to_concern = json.optString("to_concern"); // 被关注者编号
if (StringUtils.isEmpty(concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_CONCERN_USERNAME_ISNULL, null); // 关注者userName不能为空
}
if (StringUtils.isEmpty(to_concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_USERNAME_ISNULL, null); // 被关注者userName不能为空
}
UserDto concernUser = userFeignClient.selectByUserName(concern); // 关注者用户
if (concernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_CONCERN_ISNULL, null); // 关注者用户不存在
}
UserDto toConcernUser = userFeignClient.selectByUserName(to_concern); // 被关注者用户
if (toConcernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注者用户不存在
}
Map maps = new HashMap();
maps.put("concern", concernUser.getId());
maps.put("to_concern", toConcernUser.getId());
LiveFollow lFollow = liveFollowService.getLiveFollow(maps);
if (null != lFollow) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_FOLLOW, null); // 主播已关注
}
LiveFollow liveFollow = new LiveFollow();
liveFollow.setAddTime(new Date()); // 添加时间
liveFollow.setConcern(concernUser.getId()); // 关注者
liveFollow.setTo_concern(toConcernUser.getId()); // 被关注者
liveFollowService.addLiveFollow(liveFollow); // 关注信息添加
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 添加主播关注数据
*
* @param live
*/
@RequestMapping("/add_live_follow_new")
public ResponseVO add_live_follow_new(@RequestBody JSONObject json, HttpServletRequest request) {
String user_id = json.optString("user_id"); // 被关注者编号
String tokenStr = request.getHeader("token");
Long concern = SecurityUserHolder.getTokenUserId(tokenStr);
if (concern == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(concern);// 关注者用户
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
UserDto toConcernUser = userFeignClient.selectByPrimaryKey(CommUtil.null2Long(user_id)); // 被关注者用户
if (toConcernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注者用户不存在
}
if (user.getId().toString().equals(user_id)) { // 关注者为登陆者
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注者用户不存在
}
Map maps = new HashMap();
maps.put("concern", user.getId());
maps.put("to_concern", toConcernUser.getId());
LiveFollow lFollow = liveFollowService.getLiveFollow(maps);
if (null != lFollow) {
liveFollowService.deleteLiveFollow(maps); // 删除主播关注数据
// return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_FOLLOW,
// null); // 主播已关注
} else {
LiveFollow liveFollow = new LiveFollow();
liveFollow.setAddTime(new Date()); // 添加时间
liveFollow.setConcern(user.getId()); // 关注者
liveFollow.setTo_concern(toConcernUser.getId()); // 被关注者
liveFollowService.addLiveFollow(liveFollow); // 关注信息添加
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 取消主播关注数据
*
* @param live
*/
@RequestMapping("/del_live_follow")
public ResponseVO del_live_follow(@RequestBody JSONObject json) {
String concern = json.optString("concern"); // 关注者编号
String to_concern = json.optString("to_concern"); // 被关注者编号
if (StringUtils.isEmpty(concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_CONCERN_USERNAME_ISNULL, null); // 关注者userName不能为空
}
if (StringUtils.isEmpty(to_concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_USERNAME_ISNULL, null); // 被关注者userName不能为空
}
UserDto concernUser = userFeignClient.selectByUserName(concern); // 关注者用户
if (concernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 关注者用户不存在
}
UserDto toConcernUser = userFeignClient.selectByUserName(to_concern); // 被关注者用户
if (toConcernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注者用户不存在
}
Map params = new HashMap();
params.put("concern", concernUser.getId());
params.put("to_concern", toConcernUser.getId());
LiveFollow lFollow = liveFollowService.getLiveFollow(params);
if (null == lFollow) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_NOT_FOLLOW, null); // 还未关注主播
}
liveFollowService.deleteLiveFollow(params); // 删除主播关注数据
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 取消主播关注数据
*
* @param live
*/
@RequestMapping("/del_live_follow_new")
public ResponseVO del_live_follow_new(@RequestBody JSONObject json, HttpServletRequest request) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String to_concern = json.optString("to_concern"); // 被关注者编号
if (StringUtils.isEmpty(to_concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_USERNAME_ISNULL, null); // 被关注者userName不能为空
}
UserDto toConcernUser = userFeignClient.selectByUserName(to_concern); // 被关注者用户
if (toConcernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注者用户不存在
}
Map params = new HashMap();
params.put("concern", user.getId());
params.put("to_concern", toConcernUser.getId());
LiveFollow lFollow = liveFollowService.getLiveFollow(params);
if (null == lFollow) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_NOT_FOLLOW, null); // 还未关注主播
}
liveFollowService.deleteLiveFollow(params); // 删除主播关注数据
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 关注用户数据信息列表
*
* @param live
*/
@RequestMapping("/follow_user")
public ResponseVO follow_user(HttpServletRequest request, @RequestBody JSONObject json) {
String currentPage = json.optString("currentPage"); // 当前页数
String pageSize = json.optString("pageSize"); // 数据长度
String orderBy = json.optString("orderBy"); // 排序字段
String orderType = json.optString("orderType"); // 排序方式
List> result = new LinkedList>();
String userName = json.getString("userName"); // 被关注者编号
if (StringUtils.isEmpty(userName)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); // 用户userName不能为空
}
UserDto user = userFeignClient.selectByUserName(userName); // 用户
if (user == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); // 用户不存在
}
Map params = new HashMap();
if (StringUtils.isNotBlank(currentPage)) {
params.put("currentPage", CommUtil.null2Int(currentPage));
}
if (StringUtils.isNotBlank(pageSize)) {
params.put("pageSize", CommUtil.null2Int(pageSize));
}
if (StringUtils.isNotBlank(orderBy)) {
params.put("orderBy", orderBy);
}
if (StringUtils.isNotBlank(orderType)) {
params.put("orderType", orderType);
}
if (StringUtils.isNotBlank(userName)) {
params.put("anchor_id", user.getId()); // 被关注用户
}
List userDtos = userFeignClient.queryPageList(params);
SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
for (UserDto userDto : userDtos) {
AccessoryDto acc = null;
if (userDto.getPhoto_id() != null) {
acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id());
}
Map us = new HashMap();
us.put("user_id", userDto.getId());
us.put("nickName", userDto.getNickName()); // 用户昵称
us.put("autograph", ""); // 用户个性签名
if (null != sysConfigDto) {
if (null != acc) {
us.put("photo", sysConfigDto.getImageWebServer() + "/" + acc.getPath() + "/" + acc.getName()); // 用户头像
} else {
us.put("photo", sysConfigDto.getImageWebServer() + "/" + sysConfigDto.getMemberIcon().getPath()
+ "/" + sysConfigDto.getMemberIcon().getName()); // 用户头像
}
}
result.add(us);
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 关注用户数据信息列表
*
* @param live
*/
@RequestMapping("/follow_user_new")
public ResponseVO follow_user_new(HttpServletRequest request, @RequestBody JSONObject json) {
String currentPage = json.optString("currentPage"); // 当前页数
String pageSize = json.optString("pageSize"); // 数据长度
String orderBy = json.optString("orderBy"); // 排序字段
String orderType = json.optString("orderType"); // 排序方式
List> result = new LinkedList>();
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
Map params = new HashMap();
if (StringUtils.isNotBlank(currentPage)) {
params.put("currentPage", CommUtil.null2Int(currentPage));
}
if (StringUtils.isNotBlank(pageSize)) {
params.put("pageSize", CommUtil.null2Int(pageSize));
}
if (StringUtils.isNotBlank(orderBy)) {
params.put("orderBy", orderBy);
}
if (StringUtils.isNotBlank(orderType)) {
params.put("orderType", orderType);
}
params.put("anchor_id", user.getId()); // 被关注用户
List userDtos = userFeignClient.queryPageList(params);
SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
for (UserDto userDto : userDtos) {
AccessoryDto acc = null;
if (userDto.getPhoto_id() != null) {
acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id());
}
Map us = new HashMap();
us.put("user_id", userDto.getId());
us.put("nickName", userDto.getNickName()); // 用户昵称
us.put("autograph", ""); // 用户个性签名
if (null != sysConfigDto) {
if (null != acc) {
us.put("photo", sysConfigDto.getImageWebServer() + "/" + acc.getPath() + "/" + acc.getName()); // 用户头像
} else {
us.put("photo", sysConfigDto.getImageWebServer() + "/" + sysConfigDto.getMemberIcon().getPath()
+ "/" + sysConfigDto.getMemberIcon().getName()); // 用户头像
}
}
result.add(us);
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null); // 请求处理成功
}
/**
* 查询直播用户数据信息
*
* @param live
*/
@RequestMapping("/liveUser")
public ResponseVO liveUser(@RequestBody JSONObject json) {
String userName = json.optString("userName"); // 用户编号
String to_concern = json.optString("to_concern"); // 关注者userName
if (StringUtils.isEmpty(userName)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); // 用户userName不能为空
}
if (StringUtils.isEmpty(to_concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_USERNAME_ISNULL, null); // 被关注者userName不能为空
}
UserDto userDto = userFeignClient.selectByUserName(userName); // 用户
if (userDto == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); // 用户不存在
}
UserDto toConcernUser = userFeignClient.selectByUserName(to_concern); // 主播用户
if (toConcernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注用户不存在
}
SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
Map result = new HashMap();
AccessoryDto acc = null;
if (userDto.getPhoto_id() != null) {
acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id());
}
Map params = new HashMap();
params.put("concern", userDto.getId());
params.put("to_concern", toConcernUser.getId());
LiveFollow lf = liveFollowService.getLiveFollow(params); // 查询关注主播数据信息
result.put("nickName", userDto.getNickName()); // 用户昵称
result.put("autograph", ""); // 用户个性签名
if (null != sysConfigDto) {
if (null != acc) {
result.put("photo", sysConfigDto.getImageWebServer() + "/" + acc.getPath() + acc.getName()); // 用户头像
} else {
result.put("photo", sysConfigDto.getImageWebServer() + "/" + sysConfigDto.getMemberIcon().getPath()
+ "/" + sysConfigDto.getMemberIcon().getName()); // 用户头像
}
}
if (null != lf) {
result.put("anchor", true); // 是否关注主播
} else {
result.put("anchor", false); // 是否关注主播
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);
}
/**
* 查询直播用户数据信息
*
* @param live
*/
@RequestMapping("/liveUser_new")
public ResponseVO liveUser_new(@RequestBody JSONObject json, HttpServletRequest request) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto userDto = userFeignClient.selectByPrimaryKey(user_id);
if (userDto == null) {
// 用户不存在
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String to_concern = json.optString("to_concern"); // 关注者userName
if (StringUtils.isEmpty(to_concern)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_USERNAME_ISNULL, null); // 被关注者userName不能为空
}
UserDto toConcernUser = userFeignClient.selectByUserName(to_concern); // 主播用户
if (toConcernUser == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TOCONCERN_ISNULL, null); // 被关注用户不存在
}
SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
Map result = new HashMap();
AccessoryDto acc = null;
if (userDto.getPhoto_id() != null) {
acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id());
}
Map params = new HashMap();
params.put("concern", userDto.getId());
params.put("to_concern", toConcernUser.getId());
LiveFollow lf = liveFollowService.getLiveFollow(params); // 查询关注主播数据信息
result.put("nickName", userDto.getNickName()); // 用户昵称
result.put("autograph", ""); // 用户个性签名
if (null != sysConfigDto) {
if (null != acc) {
result.put("photo", sysConfigDto.getImageWebServer() + "/" + acc.getPath() + acc.getName()); // 用户头像
} else {
result.put("photo", sysConfigDto.getImageWebServer() + "/" + sysConfigDto.getMemberIcon().getPath()
+ "/" + sysConfigDto.getMemberIcon().getName()); // 用户头像
}
}
if (null != lf) {
result.put("anchor", true); // 是否关注主播
} else {
result.put("anchor", false); // 是否关注主播
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);
}
/**
* 个人直播中心
*/
@RequestMapping("/liveCenter")
public Map liveCenter(HttpServletRequest request, @RequestBody JSONObject json) {
SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
String user_id = json.optString("user_id"); // 获取直播用户信息
if (StringUtils.isEmpty(user_id)) {
return ResponseCode.buildCodeMap("20001", "用户id不能为空", null);
}
List> result = new ArrayList<>();
UserDto userDto = userFeignClient.selectByUserName(user_id); // 用户
if (userDto == null) {
return ResponseCode.buildCodeMap("30001", "用户不存在", null);
}
if (null != userDto.getPhoto_id()) {
AccessoryDto acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id()); // 获取头像信息
Map user = new HashMap();
user.put("user_id", userDto.getId()); // 用户编号
user.put("userName", userDto.getUserName1()); // 用户名称
if (null != sysConfigDto) {
if (null != acc) {
user.put("photo", sysConfigDto.getImageWebServer() + "/" + acc.getPath() + acc.getName()); // 用户头像
} else {
user.put("photo", sysConfigDto.getImageWebServer() + "/" + sysConfigDto.getMemberIcon().getPath()
+ "/" + sysConfigDto.getMemberIcon().getName()); // 用户头像
}
Map params = new HashMap();
params.put("anchor_id", userDto.getId()); // 当前用户
List liveFollows = liveFollowService.queryPages(params);
user.put("fans", liveFollows.size()); // 粉丝数量
result.add(user);
}
}
return ResponseCode.buildSuccessMap(result);
}
/**
* 个人直播中心
*/
@RequestMapping("/liveCenter_new")
public Map liveCenter_new(HttpServletRequest request, @RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildCodeMap("508", "token已过期,请重新登录", null);
}
UserDto userDto = userFeignClient.selectByPrimaryKey(user_id);
if (userDto == null) {
// 用户不存在
return ResponseCode.buildCodeMap("30001", "用户不存在", null);
}
List> result = new ArrayList<>();
if (null != userDto.getPhoto_id()) {
AccessoryDto acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id()); // 获取头像信息
Map user = new HashMap();
user.put("user_id", userDto.getId()); // 用户编号
user.put("userName", userDto.getUserName1()); // 用户名称
SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
if (null != sysConfigDto) {
if (null != acc) {
user.put("photo", sysConfigDto.getImageWebServer() + "/" + acc.getPath() + acc.getName()); // 用户头像
} else {
user.put("photo", sysConfigDto.getImageWebServer() + "/" + sysConfigDto.getMemberIcon().getPath()
+ "/" + sysConfigDto.getMemberIcon().getName()); // 用户头像
}
Map params = new HashMap();
params.put("anchor_id", userDto.getId()); // 当前用户
List liveFollows = liveFollowService.queryPages(params);
user.put("fans", liveFollows.size()); // 粉丝数量
result.add(user);
}
}
return ResponseCode.buildSuccessMap(result);
}
/**
* 直播账户验证(用户+密码)
*
* @param params
*/
@RequestMapping(value = "/checking/account", method = RequestMethod.POST)
public Map checkingAccount(@RequestBody JSONObject json, HttpServletRequest request) {
String userName = json.optString("userName");
String password = json.optString("password");
if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
ResponseCode.buildCodeMap("10001", "用户名和密码不能为空", null);
}
password = Md5Encrypt.md5(password).toLowerCase();
Map paraMap = new HashMap();
paraMap.put("userName", userName);
paraMap.put("password", password);
Long user_id = userFeignClient.checkingAccount(paraMap);
if (user_id == null) {
return ResponseCode.buildCodeMap("10002", "你未开通主播", null);
}
// 根据用户id获取登录token
String token = SecurityUserHolder.getCurrentUser(user_id);
return ResponseCode.buildSuccessMap(token);
}
/**
* 直播账户验证(用户)
*
* @param params
*/
@RequestMapping(value = "/checking/username", method = RequestMethod.POST)
public Map checkingUsername(@RequestBody JSONObject json, HttpServletRequest request) {
String userName = json.optString("userName");
if (StringUtils.isEmpty(userName)) {
ResponseCode.buildCodeMap("10001", "用户名不能为空", null);
}
Map paraMap = new HashMap();
paraMap.put("userName", userName);
Long user_id = userFeignClient.checkingUserName(paraMap);
if (user_id == null) {
return ResponseCode.buildCodeMap("10002", "你未开通主播", null);
}
// 根据用户id获取登录token
String token = SecurityUserHolder.getCurrentUser(user_id);
return ResponseCode.buildSuccessMap(token);
}
/**
* 通过直播间id查询用户
*
* @param params
*/
@RequestMapping(value = "/getUser", method = RequestMethod.POST)
public ResponseVO getUser(@RequestBody JSONObject json) {
String live_id = json.optString("live_id");
if (StringUtils.isBlank(live_id)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null); // 直播间id不能为空
}
Map maps = new HashMap();
maps.put("live_num", live_id);
Live live = liveService.selectByLiveNum(maps);
UserDto userDto = null;
if (null != live && live.getCreater_id() != null) {
userDto = userFeignClient.selectByUserName(live.getCreater_id()); // 获取用户信息
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, userDto);
}
// 直播间分享海报
@RequestMapping(value = "/liveSharePic", method = RequestMethod.POST)
public ResponseVO liveSharePic(@RequestBody JSONObject json) {
String live_id = json.optString("live_id"); // 直播间ID
String userName = json.optString("username"); // 直播间分享用户
String anchor_id = json.optString("anchor_id"); // 直播间主播
if (StringUtils.isBlank(anchor_id)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ANCHOR_ID_ISNULL, null); // 主播id不能为空
}
if (StringUtils.isBlank(live_id)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null); // 直播间id不能为空
}
if (StringUtils.isBlank(userName)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_SHARE_ID_ISNULL, null); // 直播间分享用户名不能为空
}
Map maps = new HashMap();
maps.put("live_num", live_id);
Live live = liveService.selectByLiveNum(maps);
if (null == live) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_NO_FIND, null); // 未找到直播间
}
if (StringUtils.isBlank(live.getLive_title())) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_TITLE_NO_FIND, null); // 未找到直播间
}
if (StringUtils.isBlank(live.getLive_cover())) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_COVER_NO_FIND, null); // 未找到直播间
}
if (StringUtils.isBlank(live.getCreater_id())) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_CREATER_ID_NO_FIND, null); // 未找到直播间
}
Map params = new HashMap();
params.put("live_title", live.getLive_title());
params.put("live_cover", live.getLive_cover());
params.put("creater_id", live.getCreater_id());
params.put("live_id", live_id);
params.put("userName", userName);
params.put("anchor_id", anchor_id.toString());
params.put("live_status", live.getLive_status().toString());
Map result = shareFeignClient.liveSharePicture(params);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);
}
/**
* 查询用户搜索记录
*/
@RequestMapping(value = "/userSearchLogList", method = RequestMethod.POST)
public Map userSearchLogList(@RequestBody JSONObject json, HttpServletRequest request) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
HashMap result = new HashMap<>();
SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();
String[] split = sysConfig.getHotSearch().split(",");
ArrayList arrayList = new ArrayList<>();
for (int a = 0; a < split.length - 1; a++) {
arrayList.add(split[a]);
}
result.put("hot_search", arrayList);
Map params = QueryTools.getParams(null, 6, null, null);
params.put("user_id", user.getId());
Page list = userSearchLogService.list(params);
result.put("search_log", list.getResult());
return ResponseCode.buildSuccessMap(result);
}
/**
* 清除用户搜索记录
*/
@RequestMapping(value = "/delUserSearchLog", method = RequestMethod.POST)
public Map delUserSearchLog(@RequestBody JSONObject json, HttpServletRequest request) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
userSearchLogService.delUserLog(user.getId());
return ResponseCode.buildSuccessMap(null);
}
/**
* 保存搜索记录
*/
@RequestMapping(value = "/saveUserSearchLog", method = RequestMethod.POST)
public Map saveUserSearchLog(@RequestBody JSONObject json, HttpServletRequest request) {
if (StringUtils.isBlank(json.optString("search_name"))) { // 为空不做操作
return ResponseCode.buildSuccessMap(null);
}
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id != null) {
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user != null) {// 用户存在
Map params = QueryTools.getParams(null, 3, null, null);
params.put("user_id", user.getId());
params.put("search_name", json.optString("search_name"));
Page list = userSearchLogService.list(params);
if (list.getResult().size() < 1) { // 不存在, 保存记录
UserSearchLog userSearchLog = new UserSearchLog();
userSearchLog.setUser_id(user_id);
userSearchLog.setAddTime(new Date());
userSearchLog.setSearch_name(json.optString("search_name"));
userSearchLog.setDeleteStatus(0);
userSearchLogService.saveEntity(userSearchLog);
} else {
list.getResult().get(0).setAddTime(new Date()); // 更新时间
userSearchLogService.updateById(list.getResult().get(0));
}
}
}
return ResponseCode.buildSuccessMap(null);
}
/**
* 直播添加购物车商品
*
* @param params
*/
@RequestMapping(value = "/addLiveGoodsCart", method = RequestMethod.POST)
public ResponseVO addLiveGoodsCart(@RequestBody JSONObject json, HttpServletRequest request) {
Long id = CommUtil.null2Long(json.optString("id")); // 商品id
Integer count = Integer.valueOf(json.optString("count"));
String gsp = json.optString("gsp");
String buy_type = json.optString("buy_type");
String type = json.optString("type");
String combin_version = json.optString("combin_version");
String combin_ids = json.optString("combin_ids");
String userName = json.getString("userName");
String liverName = json.getString("liverName");
String liveroom_id = null;
if (StringUtils.isNotBlank(liveroom_id) && !("-1").equals(liveroom_id)) {
liveroom_id = json.optString("liveroom_id");
}
if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(liverName)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); // 用户userName不能为空
}
UserDto user = userFeignClient.selectByUserName(userName); // 用户
if (user == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); // 用户不存在
}
UserDto liver = userFeignClient.selectByUserName(liverName); // 用户
if (liver == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); // 用户不存在
}
AddGoodsCarFormDto addGoodsCarFormDto = new AddGoodsCarFormDto();
addGoodsCarFormDto.setId(id);
addGoodsCarFormDto.setCount(count);
addGoodsCarFormDto.setGsp(gsp);
addGoodsCarFormDto.setBuy_type(buy_type);
addGoodsCarFormDto.setCombin_ids(combin_ids);
addGoodsCarFormDto.setCombin_version(combin_version);
addGoodsCarFormDto.setApp_user_id(user.getId());
addGoodsCarFormDto.setType(type);
addGoodsCarFormDto.setShare_user_id(liver.getId().toString());
addGoodsCarFormDto.setLiveroom_id(liveroom_id);
Map addGoodsCart = goodsCartFeignClient.addGoodsCart(addGoodsCarFormDto);
HashMap result = new HashMap<>();
result.put("map", addGoodsCart);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);
}
/**
* 生成直播间推流地址
*/
@RequestMapping(value = "/add_live_url", method = RequestMethod.POST)
public Map add_live_url(@RequestBody JSONObject json, HttpServletRequest request) {
String imgroup_id = json.optString("imgroup_id");
String live_id = json.optString("live_id");
String live_type = json.optString("live_type");
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
if (StringUtils.isEmpty(live_id)) {
return ResponseCode.buildReturnMap(ResponseCode.PARAMETER_ERROR, null);
}
if (StringUtils.isEmpty(imgroup_id)) {
return ResponseCode.buildReturnMap(ResponseCode.LIVE_IMGROUP_ISNULL, null);
}
Live live = null;
if (StringUtils.isNotEmpty(live_type) && live_type.equals("1")) {
live = liveService.selectByPrimaryKey1(CommUtil.null2Long(live_id));
} else {
live = liveService.selectByPrimaryKey(CommUtil.null2Long(live_id));
}
if (live == null) {
return ResponseCode.buildReturnMap(ResponseCode.LIVE_NO_FIND, null);
}
HashMap maps = new HashMap<>();
SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();
live.setImgroup_id(imgroup_id); // 聊天室id
live.setStartTime(new Date()); // 添加时间
maps.put("to_concern", live.getUser_id());
maps.put("deleteStatus", 0);
// 粉丝总数
Integer selectCount = liveFollowService.selectCount(maps);
live.setFollow_num(CommUtil.null2Long(selectCount)); // 计算当前粉丝数, 之后结束在统计
live.setDeleteStatus(0); // 进行相减 拿到本场关注数
live.setLive_status(1); // 开始直播
String live_domian = sysConfig.getLive_play_domain();
String safeUrl = LiveUtils.getSafeUrl(sysConfig.getLive_key(), live_id, 86400000L);
live.setLive_url(live_domian + "/live/" + live_id + "?" + safeUrl);
liveService.updateById(live);
String url = sysConfig.getLive_domain() + "/live/" + live_id + "?" + safeUrl;
return ResponseCode.buildSuccessMap(url);
}
/**
* 直播观看人数变化
*
* @param params
*/
@RequestMapping(value = "/updateLiveAudience")
public ResponseVO getLiveListAll(@RequestBody JSONObject json) {
String live_id = json.optString("live_id"); // 直播间id
String count = json.optString("count"); // 数量
if (StringUtils.isNotBlank(live_id)) {
// 查询用户关注的主播
Live Live = liveService.selectByPrimaryKey(CommUtil.null2Long(live_id));
if (Live != null && Live.getLive_status() == 1) {
Live.setAudience_num(CommUtil.null2Long(count));
liveService.updateAudienceById(CommUtil.null2Long(live_id), CommUtil.null2Long(count));
}
}
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null);
}
/**
* 查询当前直播关注人数
*
* @param params
*/
@RequestMapping(value = "/getFollowNum")
public Map getFollowNum(@RequestBody JSONObject json) {
String live_id = json.optString("live_id"); // 直播间id
if (StringUtils.isEmpty(live_id)) {
return ResponseCode.buildReturnMap(ResponseCode.PARAMETER_ERROR, null);
}
Live live = liveService.selectByPrimaryKey(CommUtil.null2Long(live_id));
if (live == null) {
return ResponseCode.buildReturnMap(ResponseCode.LIVE_NO_FIND, null);
}
HashMap maps = new HashMap<>();
maps.put("to_concern", live.getUser_id());
maps.put("deleteStatus", 0);
// 粉丝总数
Integer Count = liveFollowService.selectCount(maps);
// 本场关注人数 进行相减 拿到本场关注数
long liveCount = Count.longValue() - live.getFollow_num().longValue();
return ResponseCode.buildSuccessMap(liveCount);
}
/**
*
* 结束直播
*
* @param params
*/
@RequestMapping(value = "/endLive")
public Map endLive(@RequestBody JSONObject json, HttpServletRequest request) {
String tokenStr = request.getHeader("token");
String live_id = json.optString("live_id"); // 直播间id
String pralis_num = json.optString("pralis_num"); // 点赞数
String duration = json.optString("duration"); // 直播间id
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildReturnMap(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
if (StringUtils.isEmpty(live_id)) {
return ResponseCode.buildReturnMap(ResponseCode.PARAMETER_ERROR, null);
}
Live live = liveService.selectByPrimaryKey(CommUtil.null2Long(live_id));
if (live == null || live.getLive_status() == 2) {
return ResponseCode.buildReturnMap(ResponseCode.LIVE_NO_FIND, null);
}
HashMap maps = new HashMap<>();
maps.put("to_concern", live.getUser_id());
maps.put("deleteStatus", 0);
// 粉丝总数
Integer Count = liveFollowService.selectCount(maps);
// 本场关注人数 进行相减 拿到本场关注数
long liveCount = Count.longValue() - live.getFollow_num().longValue();
live.setLive_status(2); // 结束直播 改为回播
live.setFollow_num(liveCount); // 本场关注人数
live.setDuration(CommUtil.null2Long(duration));
live.setEndTime(new Date());
live.setAudience_num(CommUtil.null2Long(
null == redisUtil.get("NUMBER_" + live.getId()) ? 0 : redisUtil.get("NUMBER_" + live.getId())));// 观看人数
live.setPralis_num(CommUtil.null2Long(pralis_num));
liveService.updateById(live);
return ResponseCode.buildSuccessMap(liveCount);
}
/**
* 查询当前直播关注人数
*
* @param params
*/
@RequestMapping(value = "/delLiveById")
public Map delLiveById(@RequestBody JSONObject json, HttpServletRequest request) {
String live_id = json.optString("live_id"); //
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildReturnMap(ResponseCode.TOKEN_EXPIRE, null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
if (StringUtils.isEmpty(live_id)) {
return ResponseCode.buildReturnMap(ResponseCode.PARAMETER_ERROR, null);
}
Live live = liveService.selectByPrimaryKey(CommUtil.null2Long(live_id));
if (live != null && live.getUser_id().toString().equals(user_id + "")) {
liveService.deleteLive(live.getId());// 删除
} else {
return ResponseCode.buildReturnMap(ResponseCode.PARAMETER_ERROR, null);
}
return ResponseCode.buildSuccessMap(null);
}
/**
* 直播结束接口回调
*
* @param params
*/
@RequestMapping(value = "/returnEndLiveUrl")
public void getEndLiveUrl(@RequestBody JSONObject json) {
String event_type = json.optString("event_type"); //
String stream_id = json.optString("stream_id"); // 观看人数
if (event_type.equals("100") && StringUtils.isNotBlank(stream_id)) {
Live live = liveService.selectByPrimaryKey(CommUtil.null2Long(stream_id));
if (live != null) {
String video_url = json.optString("video_url"); //
live.setLive_url(video_url);
liveService.updateById(live);
}
}
//
if (event_type.equals("0") && StringUtils.isNotBlank(stream_id)) {
Live live = liveService.selectByPrimaryKey(CommUtil.null2Long(stream_id));
if (live != null && live.getLive_status() == 1) {
HashMap maps = new HashMap<>();
maps.put("to_concern", live.getUser_id());
maps.put("deleteStatus", 0);
// 粉丝总数
Integer Count = liveFollowService.selectCount(maps);
// 本场关注人数 进行相减 拿到本场关注数
long liveCount = Count.longValue() - live.getFollow_num().longValue();
live.setLive_status(2); // 结束直播 改为回播
live.setFollow_num(liveCount); // 本场关注人数
double div = CommUtil.div(CommUtil.null2Long(json.optString("errcode")), 1000);
live.setAudience_num(CommUtil.null2Long(
null == redisUtil.get("NUMBER_" + live.getId()) ? 0 : redisUtil.get("NUMBER_" + live.getId())));// 观看人数
live.setDuration(CommUtil.null2Long(div));
long time = new Date().getTime() - live.getStartTime().getTime();
live.setDuration(CommUtil.null2Long(CommUtil.div(time, 1000)));
live.setEndTime(new Date());
liveService.updateById(live);
}
}
}
}
package com.honghu.cloud.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Maps;
import com.honghu.cloud.bean.Video;
import com.honghu.cloud.bean.VideoClass;
import com.honghu.cloud.bean.VideoComment;
import com.honghu.cloud.bean.VideoCommentLike;
import com.honghu.cloud.bean.VideoLike;
import com.honghu.cloud.bean.VideoTopic;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.code.ResponseVO;
import com.honghu.cloud.common.page.Page;
import com.honghu.cloud.dto.AccessoryDto;
import com.honghu.cloud.dto.GoodsDto;
import com.honghu.cloud.dto.SnapshotDto;
import com.honghu.cloud.dto.StoreDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.dto.UserVideoDto;
import com.honghu.cloud.feign.AccessoryFeignClient;
import com.honghu.cloud.feign.GoodsFeignClient;
import com.honghu.cloud.feign.ModularClassFeignClient;
import com.honghu.cloud.feign.OrderFormFeignClient;
import com.honghu.cloud.feign.StoreFeignClient;
import com.honghu.cloud.feign.TXTemplateFeignClient;
import com.honghu.cloud.feign.UserFeignClient;
import com.honghu.cloud.service.IVideoClassService;
import com.honghu.cloud.service.IVideoCommentService;
import com.honghu.cloud.service.IVideoService;
import com.honghu.cloud.service.IVideoTopicService;
import com.honghu.cloud.tools.AliSmsUtil;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.util.CommUtil;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
/**
* 直播间订单控制器
* @author Administrator
*
*/
@Slf4j
@RestController
@RequestMapping(value="/video")
public class VideoController {
@Autowired
private IVideoService videoService;
@Autowired
private IVideoClassService videoClassService;
@Autowired
private AccessoryFeignClient accessoryFeignClient;
@Autowired
private IVideoTopicService videoTopicService;
@Autowired
private QueryTools queryTools;
@Autowired
private UserFeignClient userFeignClient;
@Autowired
private IVideoCommentService videoCommentService;
@Autowired
private GoodsFeignClient goodsFeignClient;
@Autowired
private StoreFeignClient storeFeignClient;
@Autowired
private OrderFormFeignClient orderFormFeignClient;
@Autowired
private ModularClassFeignClient modularClassFeignClient;
@Autowired
private TXTemplateFeignClient tXTemplateFeignClient;
@RequestMapping(value = "/apiForFeign/selectByPrimaryKey", method = RequestMethod.GET)
public Video selectByPrimaryKey(@RequestParam("id")Long id) {
return videoService.selectByPrimaryKey(id);
}
@RequestMapping(value = "/apiForFeign/selectCount", method = RequestMethod.GET)
public int selectCount(@RequestBody Map params) {
return videoService.selectCount(params);
}
/**
* 视频首页
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoIndex", method = RequestMethod.POST)
public Map videoIndex(HttpServletRequest request,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id != null){
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
}
HashMap result = new HashMap<>();
HashMap params = new HashMap<>();
String currentPage =null;
if (json.containsKey("currentPage")) {
currentPage = json.optString("currentPage");
}
/*String type = json.optString("type");
if ("same_city".equals(type)) { // 附近的人 ,按位置排序
String lat = json.optString("lat");
String lng = json.optString("lng");
if (StringUtils.isNotBlank(lat) && StringUtils.isNotBlank(lng)) {
Map params2 = queryTools.getParams(currentPage, "distance", "asc");
params2.put("lat", lat);
params2.put("lng", lng);
params2.put("distance_no_exceed", 5000000); // 筛选不超过50,000米的 (50千米)
params2.put("video_distance", "video_distance"); // 经纬度
if (json.containsKey("time_stamp")) {
params2.put("a_add_Time_less_than_equal", json.optString("time_stamp")); // 时间戳
}
Page list = videoService.list(params2);
result.put("list", list.getResult());
return ResponseCode.buildSuccessMap(result);
}
}*/
//大厅小视频
//查询视频分类
params.put("display", 1); //是否显示
params.put("orderBy", "sequence"); //排序
params.put("orderType", "asc");
List VideoClass = videoClassService.queryPageList(params);
result.put("VideoClass", VideoClass);
if (VideoClass.size()>0) {
Map params2 = queryTools.getParams(currentPage, "a.sequence is null ,a.sequence asc , a.create_date", "desc");
if (json.containsKey("time_stamp")) {
params2.put("a_add_Time_less_than_equal", json.optString("time_stamp")); //时间戳
}
if (StringUtils.isNotBlank(json.optString("id"))) {
params2.put("a_video_class_id", json.optString("id")); //传分类id
}else {
params2.put("a_video_class_id", VideoClass.get(0).getId()); //查询第一个分类数据
}
params2.put("a_status", 1); //已审核
params2.put("a_watch_status_no", 1); //已审核
if (user_id!=null) {
params2.put("userId", user_id); //已审核
// params2.put("a_userid_no", user_id); //排除自己视频
}
Page list = videoService.list(params2);
result.put("list", list.getResult());
}
return ResponseCode.buildSuccessMap(result);
}
/**
* 某用户的视频列表
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoStore", method = RequestMethod.POST)
public Map videoStore(HttpServletRequest request,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
Long store_user_id = json.optLong("store_user_id");
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
HashMap result = new HashMap<>();
String currentPage =null;
if (json.containsKey("currentPage")) {
currentPage = json.optString("currentPage");
}
Map params2 = queryTools.getParams(currentPage, "a.create_date", "desc");
if (json.containsKey("time_stamp")) {
params2.put("a_add_Time_less_than_equal", json.optString("time_stamp")); //时间戳
}
params2.put("a_status", 1); //已审核
params2.put("userId", user.getId());
params2.put("a_user_id", store_user_id);
Page list = videoService.list(params2);
result.put("list", list.getResult());
return ResponseCode.buildSuccessMap(result);
}
/**
* 某用户的视频列表
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoUser", method = RequestMethod.POST)
public Map videoUser(HttpServletRequest request,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
HashMap result = new HashMap<>();
String currentPage =null;
if (json.containsKey("currentPage")) {
currentPage = json.optString("currentPage");
}
Map params2 = queryTools.getParams(currentPage, "a.create_date", "desc");
if (json.containsKey("time_stamp")) {
params2.put("a_add_Time_less_than_equal", json.optString("time_stamp")); //时间戳
}
String status = json.optString("status");
if (StringUtils.isNoneBlank(status)) {
params2.put("a_status", status); //已审核
}
params2.put("userId", user.getId());
params2.put("a_user_id", user_id);
Page list = videoService.list(params2);
result.put("list", list.getResult());
return ResponseCode.buildSuccessMap(result);
}
/**
* 视频详情
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/updateWatchStatus", method = RequestMethod.POST)
public Map updateWatchStatus(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id != null) {
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
}
String id = json.optString("id");
if (StringUtils.isBlank(id)) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.QUERY_NO_DATA, null);
}
Video video = videoService.selectByPrimaryKey(CommUtil.null2Long(id));
if (video==null) {
return ResponseCode.buildReturnMap(ResponseCode.GOODSCLASS_CODE_NULL, null);
}
if (video.getWatch_status()!=null&&video.getWatch_status()==1) {
video.setWatch_status(0);
}else{
video.setWatch_status(1);
}
videoService.updateById(video);
return ResponseCode.buildSuccessMap(null);
}
/**
* 视频详情
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/delvideo", method = RequestMethod.POST)
public Map delvideo(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id != null) {
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
}
String id = json.optString("id");
if (StringUtils.isBlank(id)) {
// id不存在
return ResponseCode.buildReturnMap(ResponseCode.QUERY_NO_DATA, null);
}
Video video = videoService.selectByPrimaryKey(CommUtil.null2Long(id));
if (video!=null) {
video.setDeleteStatus(1);
videoService.updateById(video);
}
return ResponseCode.buildSuccessMap(null);
}
/**
* 视频详情
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoItems", method = RequestMethod.POST)
public Map videoItems(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id != null) {
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
}
HashMap result = new HashMap<>();
Long id = null;
if (json.containsKey("id")) {
id = json.optLong("id");
}
Video video = videoService.selectByPrimaryKey(id);
if (video != null) {
AccessoryDto selectByPrimaryKey = accessoryFeignClient.selectByPrimaryKey(video.getFile_id());
video.setFile(selectByPrimaryKey);
if (video.getVideo_topic_id()!=null) {
VideoTopic VideoTopic = videoTopicService.selectByPrimaryKey(video.getVideo_topic_id());
video.setTopic_name(VideoTopic!=null?VideoTopic.getName():null);
}
if (video.getUser_id()!=null) {
UserDto UserDto = userFeignClient.selectByPrimaryKey(video.getUser_id());
UserVideoDto userVideoDto = new UserVideoDto();
userVideoDto.setNickName(UserDto.getNickName());
if (UserDto.getPhoto()!=null) {
userVideoDto.setPhoto(UserDto.getPhoto());
}
video.setUser(UserDto!=null?userVideoDto:null);
}
// 用户存在的话
if (user_id!=null) {
VideoLike VideoLike = videoService.selectByUserLike(user_id, video.getId());
if (VideoLike != null) { // 是否点赞
video.setUserlike(1);
}
}
if (video.getGoods_id()!=null) {
GoodsDto goodsDto = goodsFeignClient.selectByPrimaryKey(video.getGoods_id());
video.setGoods(goodsDto);
}
result.put("video", video);
return ResponseCode.buildSuccessMap(result);
}
return ResponseCode.buildFailMap("信息有误", null);
}
/**
* 视频详情
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/add_forward", method = RequestMethod.POST)
public Map add_forward(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
HashMap result = new HashMap<>();
Long id = null;
if (json.containsKey("id")) {
id = json.optLong("id");
}
Video video = videoService.selectByPrimaryKey(id);
if (video != null) {
// 转发数+1
video.setForward_num(video.getForward_num()+1);
videoService.updateById(video);
return ResponseCode.buildSuccessMap(result);
}
return ResponseCode.buildFailMap("信息有误", null);
}
/**
* (发布视频)查看话题
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/addvideoTopic", method = RequestMethod.POST)
public Map addvideoTopic(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String currentPage = "0";
if (json.containsKey("currentPage")) {
currentPage = json.optString("currentPage");
}
HashMap result = new HashMap<>();
Map params = queryTools.getParams(currentPage, "update_date", "desc");
params.put("display", true); // 显示话题
if (json.containsKey("name")) {
params.put("name", json.optString("name"));
}
List queryPageList = videoTopicService.queryPageList(params);
result.put("VideoTopicList", queryPageList);
return ResponseCode.buildSuccessMap(result);
}
/**
* 发布视频,选择商品数据
* @param request
* @param json
* currentPage:当前页数
* pageSize:每页大小
* @return
*/
@RequestMapping("/userGoodsPage")
public Map userGoodsPage(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String type = json.optString("type");
String name = json.optString("name");
HashMap result = new HashMap<>();
Map paraMap = queryTools.getParams(json.optString("currentPage"), null, null);
if (StringUtils.isNotBlank(name)) {
paraMap.put("honghu_goods_name", name); // 搜索商品名
}
// 查询平台商品
if ("1".equals(type)) {
paraMap.put("goods_status", 0); // 商品状态(已上架的商品)
paraMap.put("live_uid", user.getId()); // 中间表(已上架的商品)
if (user.getStore_id()!=null) {
paraMap.put("no_goods_store_id", user.getStore_id()); // 商品状态(已上架的商品)
}
/*paraMap.put("hall_goods", 1); // 大厅商品
List queryPageList = goodsFeignClient.queryPageList(paraMap); // 查询店铺商品列表*/
Map queryPageList = goodsFeignClient.goodsPageList(paraMap);
result.put("queryPageList", queryPageList);
}
// 查询已购
if ("2".equals(type)) {
paraMap.put("user_id", user.getId()); // 购买的商品
List querySnapShotList = orderFormFeignClient.querySnapShotList(paraMap); // 查询店铺商品列表
result.put("queryPageList", querySnapShotList);
}
// 查询店铺商品
if ("3".equals(type) && user.getStore_id() != null) {
StoreDto storeDto = storeFeignClient.selectByPrimaryKey(user.getStore_id());
if (storeDto != null && storeDto.getStore_status() == 15) { // 店铺存在且正常开店
paraMap.put("goods_store_id", user.getStore_id()); // 店铺id
paraMap.put("goods_status", 0); // 商品状态(已上架的商品)
// List queryPageList = goodsFeignClient.queryPageList(paraMap); // 查询店铺商品列表
Map queryPageList = goodsFeignClient.goodsPageList(paraMap);
result.put("queryPageList", queryPageList);
}
}
return ResponseCode.buildSuccessMap(result);
}
/**
* 发布视频保存
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoSave", method = RequestMethod.POST)
public Map videoSave(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
HashMap result = new HashMap<>();
String video_topic_id = json.optString("video_topic_id");
String goods_id = json.optString("goods_id");
String file_id = json.optString("file_id");
String description = json.optString("description");
String file_photo_id = json.optString("file_photo_id");
String lat = json.optString("lat");
String lng = json.optString("lng");
Video video = new Video();
video.setAddTime(new Date());
if (StringUtils.isNotBlank(goods_id)) {
GoodsDto goodsDto = goodsFeignClient.selectByPrimaryKey(CommUtil.null2Long(goods_id));
if (goodsDto==null) {
return ResponseCode.buildFailMap("商品不存在", null);
}
video.setGoods_id(CommUtil.null2Long(goods_id));
if (goodsDto.getGoods_store_id() != null && user.getStore_id() != null
&& user.getStore_id().toString().equals(goodsDto.getGoods_store_id().toString())
&& goodsDto.getGoods_nearby() == 1) { // 为附近配送, 显示店铺
video.setStore_id(goodsDto.getGoods_store_id());
}
}
if (StringUtils.isNotBlank(video_topic_id)) {
video.setVideo_topic_id(CommUtil.null2Long(video_topic_id));
}
if (StringUtils.isNotBlank(video_topic_id)) {
video.setVideo_topic_id(CommUtil.null2Long(video_topic_id));
}
if (StringUtils.isNotBlank(file_id)) {
video.setFile_id(CommUtil.null2Long(file_id));
}
if (StringUtils.isNotBlank(file_photo_id)) {
video.setFile_photo_id(CommUtil.null2Long(file_photo_id));
}
if (StringUtils.isNotBlank(lat)&&StringUtils.isNotBlank(lng)) {
video.setLng(Double.valueOf(lng));
video.setLat(Double.valueOf(lat));
}
video.setDescription(description);
video.setLike_num(0);
video.setStatus(0);
video.setComment_num(0);
video.setUser_id(user.getId());
video.setCreate_date(new Date());
video.setUpdate_date(new Date());
videoService.saveEntity(video);
//通知用户审核
try{
Map params = new HashMap();
params.put("kind", "视频");
params.put("nickname", user.getNickName());
tXTemplateFeignClient.auditNsgNote(params);
}catch(Exception e){
log.error("VideoController >> videoSave >> auditNsgNote " + e.getMessage());
}
return ResponseCode.buildSuccessMap(result);
}
/**
* 视频点赞
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/addVideoUserLike", method = RequestMethod.POST)
public Map addVideoUserLike(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String video_id=null;
if (json.containsKey("video_id")) {
video_id=json.optString("video_id");
}
if (StringUtils.isBlank(video_id)) {
return ResponseCode.buildFailMap("参数信息错误", null);
}
Video video = videoService.selectByPrimaryKey(CommUtil.null2Long(video_id));
if (video==null) {
return ResponseCode.buildFailMap("视频不存在", null);
}
video.setLike_num(video.getLike_num()+1); //喜欢数+1
videoService.updateById(video);
VideoLike videoLike = new VideoLike();
videoLike.setCreate_date(new Date());
videoLike.setUser_id(user.getId());
videoLike.setVideo_id(CommUtil.null2Long(video_id));
videoService.saveVideoLike(videoLike); //保存
return ResponseCode.buildSuccessMap(null);
}
/**
* 视频取消赞
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/delVideoUserLike", method = RequestMethod.POST)
public Map delVideoUserLike(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String video_id=null;
if (json.containsKey("video_id")) {
video_id=json.optString("video_id");
}
if (StringUtils.isBlank(video_id)) {
return ResponseCode.buildFailMap("参数信息错误", null);
}
Video video = videoService.selectByPrimaryKey(CommUtil.null2Long(video_id));
if (video==null) {
return ResponseCode.buildFailMap("视频不存在", null);
}
video.setLike_num(video.getLike_num()-1); //点赞数-1
videoService.updateById(video);
videoService.delVideoLike(user.getId(),CommUtil.null2Long(video_id)); //删除中间表
return ResponseCode.buildSuccessMap(null);
}
/**
* 查看评论
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoComment", method = RequestMethod.POST)
public Map videoComment(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
HashMap result = new HashMap<>();
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
Map params = queryTools.getParams(json.optString("currentPage"), "a.update_date", "desc");
params.put("video_id", json.optString("video_id"));
params.put("userId", user.getId());
Page list = videoCommentService.list(params);
result.put("queryPageList", list.getResult());
return ResponseCode.buildSuccessMap(result);
}
/**
* 查看详细评论(二级页面
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoCommentDetailed", method = RequestMethod.POST)
public Map videoCommentDetailed(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
HashMap result = new HashMap<>();
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
if(!json.containsKey("p_id")){
// p_id不存在
return ResponseCode.buildReturnMap(ResponseCode.PARAMETER_ERROR, null);
}
Map params =Maps.newHashMap();
params.put("a_id", json.optLong("p_id"));
params.put("userId", user.getId()); //查看用户是否点赞
List queryPages = videoCommentService.queryPages(params);
if (queryPages.size()<1) { //改评论不存在
return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
}
result.put("videocomment", queryPages.get(0));
//
params.clear();
params = queryTools.getParams(json.optString("currentPage"), "a.update_date", "desc");
params.put("p_id", json.optString("p_id")); //上级id
params.put("userId", user.getId()); //查看用户是否点赞
Page list = videoCommentService.list(params);
result.put("queryPageList", list.getResult());
return ResponseCode.buildSuccessMap(result);
}
/**
* 发布评论保存
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/videoCommentSave", method = RequestMethod.POST)
public Map videoCommentSave(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if (user_id == null) {
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if (user == null) {
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
HashMap result = new HashMap<>();
String content = json.optString("content");
String video_id = json.optString("video_id");
String p_id = json.optString("p_id");
boolean aliSecurity = AliSmsUtil.aliSecurity(content);
if(!aliSecurity){//内容检测不合法
return ResponseCode.buildReturnMap(ResponseCode.ALISECURITY_ERROR, null);
}
if (StringUtils.isNotBlank(video_id)) {
Video video = videoService.selectByPrimaryKey(CommUtil.null2Long(video_id));
if (video == null) {// 数据不存在
return ResponseCode.buildReturnMap(ResponseCode.GOODSCLASS_CODE_NULL, null);
} /*
* else { video.setComment_num(video.getComment_num()+1);
* //评论数+1 videoService.updateById(video); }
*/
VideoComment videoComment = new VideoComment();
videoComment.setUser_id(user.getId());
if (StringUtils.isNotBlank(p_id)) {
videoComment.setP_id(CommUtil.null2Long(p_id));
}
videoComment.setCreate_date(new Date());
videoComment.setLike_num(0);
videoComment.setVideo_id(CommUtil.null2Long(video_id));
videoComment.setDeleteStatus(0);
videoComment.setUpdate_date(new Date());
if (json.containsKey("reply_user_id")) {
videoComment.setReply_user_id(json.optLong("reply_user_id"));
}
videoComment.setStatus(1);
videoComment.setContent(content);
videoCommentService.saveEntity(videoComment);
video.setComment_num(video.getComment_num() + 1);
videoService.updateById(video);
return ResponseCode.buildSuccessMap(result);
} else { // 参数没传
return ResponseCode.buildReturnMap(ResponseCode.PARAM_ERROR, null);
}
}
/**
* 删除
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/delVideoComment", method = RequestMethod.POST)
public Map delVideoComment(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String id = json.optString("id");
VideoComment videoComment = videoCommentService.selectByPrimaryKey(CommUtil.null2Long(id));
if (videoComment==null||!videoComment.getUser_id().toString().equals(user_id.toString())) {
return ResponseCode.buildReturnMap(ResponseCode.GOODSCLASS_CODE_NULL, null);
}
Video video = videoService.selectByPrimaryKey(videoComment.getVideo_id());
video.setComment_num(video.getComment_num()-1);
videoService.updateById(video);
videoCommentService.deleteById(CommUtil.null2Long(id));
return ResponseCode.buildSuccessMap(null);
}
/**
* 评论点赞
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/addVideoCommentLike", method = RequestMethod.POST)
public Map addVideoCommentLike(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String id=null;
if (json.containsKey("id")) {
id=json.optString("id");
}
if (StringUtils.isBlank(id)) {
return ResponseCode.buildFailMap("参数信息错误", null);
}
VideoComment videoComment = videoCommentService.selectByPrimaryKey(CommUtil.null2Long(id));
if (videoComment==null) {
return ResponseCode.buildFailMap("评论不存在", null);
}
videoComment.setLike_num(videoComment.getLike_num()+1); //喜欢数+1
videoCommentService.updateById(videoComment);
VideoCommentLike videoCommentLike = new VideoCommentLike();
videoCommentLike.setCreate_date(new Date());
videoCommentLike.setUser_id(user.getId());
videoCommentLike.setVideo_comment_id(CommUtil.null2Long(id));
videoCommentService.saveVideoCommentLike(videoCommentLike); //保存
return ResponseCode.buildSuccessMap(null);
}
/**
* 评论取消点赞
* @param order
* @param localPath
* @param buyer
*/
@RequestMapping(value = "/delVideoCommentLike", method = RequestMethod.POST)
public Map delVideoCommentLike(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String id=null;
if (json.containsKey("id")) {
id=json.optString("id");
}
if (StringUtils.isBlank(id)) {
return ResponseCode.buildFailMap("参数信息错误", null);
}
VideoComment videoComment = videoCommentService.selectByPrimaryKey(CommUtil.null2Long(id));
if (videoComment==null) {
return ResponseCode.buildFailMap("评论不存在", null);
}
videoComment.setLike_num(videoComment.getLike_num()-1); //喜欢数-1
videoCommentService.updateById(videoComment);
videoCommentService.delVideoCommentLike(user.getId(),CommUtil.null2Long(id)); //删除中间表
return ResponseCode.buildSuccessMap(null);
}
//推荐视频
@RequestMapping(value = "/recomVideo", method = RequestMethod.POST)
public Map recomVideo(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json){
String currentPage = json.optString("currentPage");
Map params = queryTools.getParams(currentPage, "a.create_date", "desc");
params.put("a_video_class_id", 1);
Page list = videoService.list(params);
return ResponseCode.buildSuccessMap(list);
}
/**
* 我的视频
*/
@RequestMapping(value = "/myVideoList", method = RequestMethod.POST)
public Map myVideoList(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildFailMap("token无效", null);
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
// 用户不存在
return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
}
String currentPage = json.optString("currentPage");
String status = json.optString("status");
HashMap result = new HashMap<>();
Map params = queryTools.getParams(currentPage, "a.create_date", "desc");
if (StringUtils.isNotBlank(status)) {
params.put("a_status",status);
}
params.put("a_user_id",user_id);
Page list = videoService.list(params);
result.put("list", list);
//获取获赞数
Long selectCountUserLike = videoService.selectCountUserLike(user_id);
result.put("UserLike", selectCountUserLike);
return ResponseCode.buildSuccessMap(result);
}
/**
* 主播添加的商品
* @param json
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/myLiveGoodsApp", method = RequestMethod.POST)
public ResponseVO myLiveGoods(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) {
String currentPage = json.optString("currentPage");
Integer pageSize = json.optInt("pageSize"); //数据长度
String orderBy = json.optString("orderBy"); //排序字段(默认添加的时间)
String orderType = json.optString("orderType"); //排序方式(倒序)
String type = json.optString("type"); //hall_goods 大厅商品 store_goods 店铺商品
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_CANNOT_EMPTY, null); //用户userName不能为空
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); //用户不存在
}
if(StringUtils.isEmpty(type)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USER_GOODS_TYPE_ISNULL, null); //用户我的商品类型不能为空
}
Map maps= queryTools.getParams(currentPage, pageSize, orderBy, orderType);
maps.put("goods_status", 0);
if(StringUtils.equals(type, "hall_goods")){
maps.put("live_uid", user.getId());
if(user.getStore_id() != null){
maps.put("no_goods_store_id", user.getStore_id());
}
}
Map resultMap = new HashMap();
if(StringUtils.equals(type, "store_goods")){
maps.put("goods_store_id", user.getStore_id());
if(user.getStore_id() == null){
resultMap.put("currentPage", 0);
resultMap.put("pages", 0);
resultMap.put("pageSize", 12);
List> list = new ArrayList>();
resultMap.put("result", list);
resultMap.put("rowCount", 0);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);
}
}
resultMap = goodsFeignClient.getQueryPageList(maps);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);
}
/**
* 大厅商品
* @param json
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/hallGoodsApp", method = RequestMethod.POST)
public ResponseVO hallGoods(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) {
String currentPage = json.optString("currentPage");
Integer pageSize = json.optInt("pageSize"); //数据长度
String orderBy = json.optString("orderBy"); //排序字段(默认添加的时间)
String orderType = json.optString("orderType"); //排序方式(倒序)
String goods_name = json.optString("goods_name"); //模糊查询商品名称
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_CANNOT_EMPTY, null); //用户userName不能为空
}
UserDto user = userFeignClient.selectByPrimaryKey(user_id);
if(user == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); //用户不存在
}
Map maps= queryTools.getParams(currentPage, pageSize, orderBy, orderType);
maps.put("goods_status", 0);
maps.put("hall_goods", 1);
if (StringUtils.isNotBlank(goods_name)) {
maps.put("honghu_goods_name", goods_name);
}
maps.put("uid", user.getId());
maps.put("liveUserAdd", "yes");
maps.put("is_distribution", "yes");
Map resultMap = goodsFeignClient.getQueryPageList(maps);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);
}
/**
* 添加商品
* @param json
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/userLiveGoodsAddApp", method = RequestMethod.POST)
public ResponseVO user_live_goods_add(@RequestBody JSONObject json, HttpServletRequest request) {
Long goods_id = json.optLong("goods_id"); //商品编号
if(goods_id == null || goods_id <=0){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_ID_ISNULL, null); //商品编号不能为空
}
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_CANNOT_EMPTY, null); //用户userName不能为空
}
Integer count = goodsFeignClient.findUserLiveGoods(user_id, goods_id);
if(count != null && count > 0 ){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_ADD_REPEAT_ISNULL, null); //重复添加数据
}
Map params = new HashMap();
params.put("uid", user_id);
params.put("goods_id", goods_id);
goodsFeignClient.addUserLiveGoods(params);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null);
}
/**
* 移除商品
* @param json
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/userLiveGoodsDelApp", method = RequestMethod.POST)
public ResponseVO user_live_goods_del(@RequestBody JSONObject json, HttpServletRequest request) {
Long goods_id = json.optLong("goods_id"); //商品编号
if(goods_id == null || goods_id <=0){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_ID_ISNULL, null); //商品编号不能为空
}
String tokenStr = request.getHeader("token");
Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
if(user_id == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_CANNOT_EMPTY, null); //用户userName不能为空
}
Map params = new HashMap();
params.put("uid", CommUtil.null2Long(user_id));
params.put("goods_id", CommUtil.null2Long(goods_id));
goodsFeignClient.delUserLiveGoods(params);
return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null);
}
}