javascript
七十七、java版商城之直播短视频带货Spring Cloud+SpringBoot+mybatis+uniapp b2b2c o2o 多商家入驻商城 直播带货商城 电子商务
一個好的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);@Autowiredprivate LiveService liveService;@Autowiredprivate LiveFollowService liveFollowService;@Autowiredprivate AccessoryFeignClient accessoryFeignClient;@Autowiredprivate SysConfigFeignClient sysConfigFeignClient;@Autowiredprivate LiveBabyService liveBabyService;@Autowiredprivate UserFeignClient userFeignClient;@Autowiredprivate MessageFeignClient messageFeignClient;@Autowiredprivate GoodsShareFeignClient shareFeignClient;@Autowiredprivate IUserSearchLogService userSearchLogService;@Autowiredprivate GoodsCartFeignClient goodsCartFeignClient;@Autowiredprivate 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<String, Object> params = new HashMap<String, Object>();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<Live> 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<String, Object> params = new HashMap<String, Object>();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<Live> 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<String, Object> params = new HashMap<String, Object>();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<Live> list = liveService.queryPages(params);HashMap<Object, Object> 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<String, Object> params = new HashMap<String, Object>();String currentPage = json.optString("currentPage"); // 當前頁數String pageSize = json.optString("pageSize"); // 數據長度String type = json.optString("type"); // 排序方式String store_id = json.optString("store_id"); // 店鋪idHashMap<Object, Object> 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<Live> list = new Page<>();results.put("list", list);return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, results);}params.put("a_user_id", UserDto.getId());}Page<Live> 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<String, Object> 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; // 商品idif (json.containsKey("goods_id")) {mulitId = json.optString("goods_id");}String live_id = json.optString("live_id"); // 直播idString userName = json.optString("userName"); // 用戶userNameString 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"); // 直播間預播時間// 直播間idif (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)); // 直播間idliveBaby.setDeleteStatus(0); // 刪除標識liveBabyService.addLiveBaby(liveBaby); // 添加直播間寶貝信息}}try {UserDto liveUser = userFeignClient.selectByUserName(userName);Map<String, Object> maps = new HashMap<String, Object>();maps.put("to_concern", liveUser.getId());List<LiveFollow> list = liveFollowService.queryPages(maps);List<MessageDto> msgs = new ArrayList<MessageDto>();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; // 商品idif (json.containsKey("goods_id")) {mulitId = json.optString("goods_id");}// String live_id = json.optString("live_id"); //直播idString 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<String, Object> maps = new HashMap<String, Object>();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<Live> 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())); // 直播間idliveBaby.setDeleteStatus(0); // 刪除標識liveBabyService.addLiveBaby(liveBaby); // 添加直播間寶貝信息}}}try {// UserDto liveUser = userFeignClient.selectByUserName(userName);maps.clear();maps.put("to_concern", user.getId());List<LiveFollow> list = liveFollowService.queryPages(maps);List<MessageDto> msgs = new ArrayList<MessageDto>();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<Object, Object> 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<String, Object> maps = new HashMap<String, Object>();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<String, Object> maps = new HashMap<String, Object>();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<String, Object> params = new HashMap<String, Object>();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<String, Object> params = new HashMap<String, Object>();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<Map<String, Object>> result = new LinkedList<Map<String, Object>>();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<String, Object> params = new HashMap<String, Object>();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<UserDto> 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<String, Object> us = new HashMap<String, Object>();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<Map<String, Object>> result = new LinkedList<Map<String, Object>>();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<String, Object> params = new HashMap<String, Object>();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<UserDto> 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<String, Object> us = new HashMap<String, Object>();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"); // 關注者userNameif (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<String, Object> result = new HashMap<String, Object>();AccessoryDto acc = null;if (userDto.getPhoto_id() != null) {acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id());}Map<String, Object> params = new HashMap<String, Object>();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"); // 關注者userNameif (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<String, Object> result = new HashMap<String, Object>();AccessoryDto acc = null;if (userDto.getPhoto_id() != null) {acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id());}Map<String, Object> params = new HashMap<String, Object>();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<String, Object> 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<Map<String, Object>> 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<String, Object> user = new HashMap<String, Object>();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<String, Object> params = new HashMap<String, Object>();params.put("anchor_id", userDto.getId()); // 當前用戶List<LiveFollow> liveFollows = liveFollowService.queryPages(params);user.put("fans", liveFollows.size()); // 粉絲數量result.add(user);}}return ResponseCode.buildSuccessMap(result);}/*** 個人直播中心*/@RequestMapping("/liveCenter_new")public Map<String, Object> 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<Map<String, Object>> result = new ArrayList<>();if (null != userDto.getPhoto_id()) {AccessoryDto acc = accessoryFeignClient.selectByPrimaryKey(userDto.getPhoto_id()); // 獲取頭像信息Map<String, Object> user = new HashMap<String, Object>();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<String, Object> params = new HashMap<String, Object>();params.put("anchor_id", userDto.getId()); // 當前用戶List<LiveFollow> 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<String, Object> 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<String, String> paraMap = new HashMap<String, String>();paraMap.put("userName", userName);paraMap.put("password", password);Long user_id = userFeignClient.checkingAccount(paraMap);if (user_id == null) {return ResponseCode.buildCodeMap("10002", "你未開通主播", null);}// 根據用戶id獲取登錄tokenString token = SecurityUserHolder.getCurrentUser(user_id);return ResponseCode.buildSuccessMap(token);}/*** 直播賬戶驗證(用戶)* * @param params*/@RequestMapping(value = "/checking/username", method = RequestMethod.POST)public Map<String, Object> checkingUsername(@RequestBody JSONObject json, HttpServletRequest request) {String userName = json.optString("userName");if (StringUtils.isEmpty(userName)) {ResponseCode.buildCodeMap("10001", "用戶名不能為空", null);}Map<String, String> paraMap = new HashMap<String, String>();paraMap.put("userName", userName);Long user_id = userFeignClient.checkingUserName(paraMap);if (user_id == null) {return ResponseCode.buildCodeMap("10002", "你未開通主播", null);}// 根據用戶id獲取登錄tokenString 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<String, Object> maps = new HashMap<String, Object>();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"); // 直播間IDString 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<String, Object> maps = new HashMap<String, Object>();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<String, Object> params = new HashMap<String, Object>();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<String, Object> result = shareFeignClient.liveSharePicture(params);return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);}/*** 查詢用戶搜索記錄*/@RequestMapping(value = "/userSearchLogList", method = RequestMethod.POST)public Map<String, Object> 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<String, Object> result = new HashMap<>();SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();String[] split = sysConfig.getHotSearch().split(",");ArrayList<Object> arrayList = new ArrayList<>();for (int a = 0; a < split.length - 1; a++) {arrayList.add(split[a]);}result.put("hot_search", arrayList);Map<String, Object> params = QueryTools.getParams(null, 6, null, null);params.put("user_id", user.getId());Page<UserSearchLog> list = userSearchLogService.list(params);result.put("search_log", list.getResult());return ResponseCode.buildSuccessMap(result);}/*** 清除用戶搜索記錄*/@RequestMapping(value = "/delUserSearchLog", method = RequestMethod.POST)public Map<String, Object> 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<String, Object> 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<String, Object> params = QueryTools.getParams(null, 3, null, null);params.put("user_id", user.getId());params.put("search_name", json.optString("search_name"));Page<UserSearchLog> 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")); // 商品idInteger 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<Object, Object> result = new HashMap<>();result.put("map", addGoodsCart);return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);}/*** 生成直播間推流地址*/@RequestMapping(value = "/add_live_url", method = RequestMethod.POST)public Map<String, Object> 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<String, Object> maps = new HashMap<>();SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();live.setImgroup_id(imgroup_id); // 聊天室idlive.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"); // 直播間idString 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<String, Object> getFollowNum(@RequestBody JSONObject json) {String live_id = json.optString("live_id"); // 直播間idif (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<String, Object> 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<String, Object> endLive(@RequestBody JSONObject json, HttpServletRequest request) {String tokenStr = request.getHeader("token");String live_id = json.optString("live_id"); // 直播間idString pralis_num = json.optString("pralis_num"); // 點贊數String duration = json.optString("duration"); // 直播間idLong 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<String, Object> 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<String, Object> 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<String, Object> 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 {@Autowiredprivate IVideoService videoService;@Autowiredprivate IVideoClassService videoClassService;@Autowiredprivate AccessoryFeignClient accessoryFeignClient;@Autowiredprivate IVideoTopicService videoTopicService;@Autowiredprivate QueryTools queryTools;@Autowiredprivate UserFeignClient userFeignClient;@Autowiredprivate IVideoCommentService videoCommentService;@Autowiredprivate GoodsFeignClient goodsFeignClient;@Autowiredprivate StoreFeignClient storeFeignClient;@Autowiredprivate OrderFormFeignClient orderFormFeignClient;@Autowiredprivate ModularClassFeignClient modularClassFeignClient;@Autowiredprivate 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<String, Object> params) {return videoService.selectCount(params);}/*** 視頻首頁* @param order* @param localPath* @param buyer*/@RequestMapping(value = "/videoIndex", method = RequestMethod.POST)public Map<String, Object> 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<String, Object> result = new HashMap<>();HashMap<String, Object> 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<String, Object> 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<Video> 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> VideoClass = videoClassService.queryPageList(params);result.put("VideoClass", VideoClass);if (VideoClass.size()>0) {Map<String, Object> 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<Video> 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<String, Object> 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<String, Object> result = new HashMap<>();String currentPage =null;if (json.containsKey("currentPage")) {currentPage = json.optString("currentPage");} Map<String, Object> 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<Video> 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<String, Object> 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<String, Object> result = new HashMap<>();String currentPage =null;if (json.containsKey("currentPage")) {currentPage = json.optString("currentPage");} Map<String, Object> 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<Video> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> result = new HashMap<>();Long id = null;if (json.containsKey("id")) {id = json.optLong("id");}Video video = videoService.selectByPrimaryKey(id);if (video != null) {// 轉發數+1video.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<String, Object> addvideoTopic(HttpServletRequest request, HttpServletResponse response,@RequestBody JSONObject json) {String currentPage = "0";if (json.containsKey("currentPage")) {currentPage = json.optString("currentPage");}HashMap<String, Object> result = new HashMap<>();Map<String, Object> params = queryTools.getParams(currentPage, "update_date", "desc");params.put("display", true); // 顯示話題if (json.containsKey("name")) {params.put("name", json.optString("name"));}List<VideoTopic> queryPageList = videoTopicService.queryPageList(params);result.put("VideoTopicList", queryPageList);return ResponseCode.buildSuccessMap(result);}/*** 發布視頻,選擇商品數據* @param request* @param json * currentPage:當前頁數* pageSize:每頁大小* @return*/@RequestMapping("/userGoodsPage")public Map<String, Object> 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<Object, Object> result = new HashMap<>();Map<String, Object> 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<GoodsDto> queryPageList = goodsFeignClient.queryPageList(paraMap); // 查詢店鋪商品列表*/ Map<String, Object> queryPageList = goodsFeignClient.goodsPageList(paraMap);result.put("queryPageList", queryPageList);}// 查詢已購if ("2".equals(type)) {paraMap.put("user_id", user.getId()); // 購買的商品List<SnapshotDto> 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()); // 店鋪idparaMap.put("goods_status", 0); // 商品狀態(已上架的商品)// List<GoodsDto> queryPageList = goodsFeignClient.queryPageList(paraMap); // 查詢店鋪商品列表Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> params = new HashMap<String, Object>();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<String, Object> 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); //喜歡數+1videoService.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<String, Object> 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); //點贊數-1videoService.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<String, Object> 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<String, Object> result = new HashMap<>();UserDto user = userFeignClient.selectByPrimaryKey(user_id);if(user == null){// 用戶不存在return ResponseCode.buildReturnMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);}Map<String, Object> params = queryTools.getParams(json.optString("currentPage"), "a.update_date", "desc");params.put("video_id", json.optString("video_id"));params.put("userId", user.getId());Page<VideoComment> 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<String, Object> videoCommentDetailed(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json) {HashMap<String, Object> 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<String, Object> params =Maps.newHashMap();params.put("a_id", json.optLong("p_id"));params.put("userId", user.getId()); //查看用戶是否點贊List<VideoComment> 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")); //上級idparams.put("userId", user.getId()); //查看用戶是否點贊Page<VideoComment> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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); //喜歡數+1videoCommentService.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<String, Object> 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); //喜歡數-1videoCommentService.updateById(videoComment);videoCommentService.delVideoCommentLike(user.getId(),CommUtil.null2Long(id)); //刪除中間表return ResponseCode.buildSuccessMap(null);}//推薦視頻@RequestMapping(value = "/recomVideo", method = RequestMethod.POST)public Map<String, Object> recomVideo(HttpServletRequest request,HttpServletResponse response,@RequestBody JSONObject json){String currentPage = json.optString("currentPage");Map<String, Object> params = queryTools.getParams(currentPage, "a.create_date", "desc");params.put("a_video_class_id", 1);Page<Video> list = videoService.list(params);return ResponseCode.buildSuccessMap(list);}/*** 我的視頻*/@RequestMapping(value = "/myVideoList", method = RequestMethod.POST)public Map<String, Object> 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<String, Object> result = new HashMap<>();Map<String, Object> 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<Video> 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<String,Object> 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<String, Object> resultMap = new HashMap<String, Object>();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<Map<String,Object>> list = new ArrayList<Map<String,Object>>();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<String,Object> 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<String, Object> 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<String, Object> params = new HashMap<String,Object>();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<String, Object> params = new HashMap<String,Object>();params.put("uid", CommUtil.null2Long(user_id));params.put("goods_id", CommUtil.null2Long(goods_id));goodsFeignClient.delUserLiveGoods(params);return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null);}}總結
以上是生活随笔為你收集整理的七十七、java版商城之直播短视频带货Spring Cloud+SpringBoot+mybatis+uniapp b2b2c o2o 多商家入驻商城 直播带货商城 电子商务的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言实现url的编码和解码
- 下一篇: bootloader学习笔记---第二篇