package com.honghu.cloud.controller;
import java.util.ArrayList;import java.util.HashMap;import java.util.LinkedList;import java.util.List;import java.util.Map;
import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.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.RestController;
import com.honghu.cloud.bean.LiveBaby;import com.honghu.cloud.code.ResponseCode;import com.honghu.cloud.code.ResponseVO;import com.honghu.cloud.common.page.Page;import com.honghu.cloud.dto.GoodsDto;import com.honghu.cloud.dto.ModularClassDto;import com.honghu.cloud.dto.SysConfigDto;import com.honghu.cloud.dto.UserDto;import com.honghu.cloud.feign.GoodsFeignClient;import com.honghu.cloud.feign.ModularClassFeignClient;import com.honghu.cloud.feign.SysConfigFeignClient;import com.honghu.cloud.feign.UserFeignClient;import com.honghu.cloud.service.LiveBabyService;import com.honghu.cloud.tools.QueryTools;import com.honghu.cloud.tools.SecurityUserHolder;
import net.sf.json.JSONObject;
/**
* 直播间宝贝控制器
*
* @author Administrator
*
*/@RestController@RequestMapping(value="/liveBaby")public class LiveBabyController {
@源码地址来源: https://minglisoft.cn/honghu2/business.html @Autowired private LiveBabyService liveBabyService;
@Autowired private GoodsFeignClient goodsFeignClient;
@Autowired private SysConfigFeignClient sysConfigFeignClient;
@Autowired private UserFeignClient userFeignClient;
@Autowired private ModularClassFeignClient modularClassFeignClient;
/**
* 直播宝贝列表数据查询
* @param request
* @param json
* currentPage:当前页数
* pageSize:每页大小
* type: 查询类【all-全部,yes-已播,not-未播 pay-已购】
* @return */ @RequestMapping("/getLiveBabyAll_bak") public ResponseVO getLiveBabyAll_bak(@RequestBody JSONObject json) {
String currentPage = json.optString("currentPage"); //当前页数 String pageSize = json.optString("pageSize"); //每页大小 String type = json.optString("type"); //查询方式 String userName = json.optString("userName"); //用户名 if(StringUtils.isEmpty(userName)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); //用户userName不能为空 }
if(StringUtils.isEmpty(type)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null); //直播间宝贝类型不能为空 }
UserDto user = userFeignClient.selectByUserName(userName);
if(user == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); //用户不存在 }
if(user.getStore_id() == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null); //你未开通店铺 }
Map paraMap = new HashMap();
paraMap.put("currentPage", currentPage);
paraMap.put("pageSize", pageSize);
paraMap.put("goods_store_id", user.getStore_id()); //商品所属店铺编号 paraMap.put("goods_status", 0); //商品状态标识 if(type.equals("not")){
paraMap.put("live_user_id", user.getUserName()); //主播用户编号 }
if(type.equals("yes")){
paraMap.put("live_creater_id", user.getUserName()); //主播用户编号 }
if(type.equals("pay")){
paraMap.put("pay_status", 1); //是否已购,0为未购买,1为已购 paraMap.put("live_creater_id", user.getUserName()); //主播用户编号 }
Map resultMap = goodsFeignClient.getQueryPageList(paraMap); //查询店铺商品列表 return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap); //请求成功、结果处理成功 }
/**
* 直播宝贝列表数据查询
* @param request
* @param json
* currentPage:当前页数
* pageSize:每页大小
* type: 查询类【all-全部,yes-已播,not-未播 pay-已购】
* @return */ @RequestMapping("/getLiveBabyAll_bak_new") public ResponseVO getLiveBabyAll_bak_new(@RequestBody JSONObject json,HttpServletRequest request) {
String currentPage = json.optString("currentPage"); //当前页数 String pageSize = json.optString("pageSize"); //每页大小 String type = json.optString("type"); //查询方式 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(type)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null); //直播间宝贝类型不能为空 }
if(user.getStore_id() == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null); //你未开通店铺 }
Map paraMap = new HashMap();
paraMap.put("currentPage", currentPage);
paraMap.put("pageSize", pageSize);
paraMap.put("goods_store_id", user.getStore_id()); //商品所属店铺编号 paraMap.put("goods_status", 0); //商品状态标识 if(type.equals("not")){
paraMap.put("live_user_id", user.getUserName()); //主播用户编号 }
if(type.equals("yes")){
paraMap.put("live_creater_id", user.getUserName()); //主播用户编号 }
if(type.equals("pay")){
paraMap.put("pay_status", 1); //是否已购,0为未购买,1为已购 paraMap.put("live_creater_id", user.getUserName()); //主播用户编号 }
Map resultMap = goodsFeignClient.getQueryPageList(paraMap); //查询店铺商品列表 return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap); //请求成功、结果处理成功 }
/**
* 直播宝贝列表数据查询
* @param request
* @param json
* currentPage:当前页数
* pageSize:每页大小
* type: 查询类【all-全部,yes-已播,not-未播 pay-已购】
* @return */ @RequestMapping("/getLiveBabyAll") public ResponseVO getLiveBabyAll(@RequestBody JSONObject json) {
String currentPage = json.optString("currentPage"); //当前页数 String pageSize = json.optString("pageSize"); //每页大小 String type = json.optString("type"); //查询方式 String userName = json.optString("userName"); //用户名 if(StringUtils.isEmpty(userName)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); //用户userName不能为空 }
if(StringUtils.isEmpty(type)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null); //直播间宝贝类型不能为空 }
UserDto user = userFeignClient.selectByUserName(userName);
if(user == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); //用户不存在 }
if(user.getStore_id() == null){
return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null); //你未开通店铺 }
Map paraMap = new HashMap();
paraMap.put("currentPage", currentPage);
paraMap.put("pageSize", pageSize);
paraMap.put("goods_status", 0); //商品状态标识 paraMap.put("live_uid", user.getId());
if(type.equals("not")){
}
if(type.equals("yes")){
}
if(type.equals("pay")){
paraMap.put("pay_status", 1);
//是否已购,0为未购买,1为已购
}
Map resultMap = goodsFeignClient.getQueryPageList(paraMap); //查询店铺商品列表 return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap); //请求成功、结果处理成功 }
/**
* 直播宝贝列表数据查询
* @param request
* @param json
* currentPage:当前页数
* pageSize:每页大小
* type: 查询类【all-全部,yes-已播,not-未播 pay-已购】
* @return */ @RequestMapping("/getLiveBabyAll_new") public ResponseVO getLiveBabyAll_new(@RequestBody JSONObject json, HttpServletRequest request) {
String currentPage = json.optString("currentPage"); // 当前页数 String pageSize = json.optString("pageSize"); // 每页大小 String type = json.optString("type"); // 查询方式 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(type)) {
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null); // 直播间宝贝类型不能为空 }
Map paraMap = new HashMap();
paraMap.put("currentPage", currentPage);
paraMap.put("pageSize", pageSize);
paraMap.put("goods_status", 0); // 商品状态标识
boolean seleteStore = false;
if (user.getStore_id() != null) { // 查询是否是特殊行业的店, ModularClassDto modularClassDto = modularClassFeignClient.selectByStoreId(user.getStore_id());
if (modularClassDto != null && !modularClassDto.isTimely()) {
seleteStore = true;
}
}
if (type.equals("yes") && seleteStore) {
if (user.getStore_id() == null) {
return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null); // 你未开通店铺 }
paraMap.put("and_store_goods", user.getId()); // 店铺商品 } else if (type.equals("all") && seleteStore) {
paraMap.put("or_store_goods", user.getId()); // 查全部 paraMap.put("live_uid", user.getId());
} else if (type.equals("all") && !seleteStore) {
paraMap.put("live_uid", user.getId()); // 查询中间表 , 但是店铺为特殊行业 ,不查店铺 } else if (type.equals("yes") && !seleteStore) {
return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNEARBY, null); // 店铺为特殊行业暂无法添加 }
Map resultMap = goodsFeignClient.getQueryPageList(paraMap); // 查询店铺商品列表 return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap); // 请求成功、结果处理成功 }
/**
* 直播间宝贝列表数据查询
* @param params
*/ @RequestMapping("/getLiveGoodsList")
public ResponseVO getLiveGoodsList(@RequestBody JSONObject json) {
String currentPage = json.optString("currentPage"); //当前页数 String pageSize = json.optString("pageSize"); // 每页大小 String live_id = json.optString("live_id"); //主播间编号 if(StringUtils.isEmpty(live_id)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null); //直播间ID不能为空 }
Map params = new HashMap();
params.put("currentPage",currentPage);
params.put("pageSize",pageSize);
params.put("live_id",live_id);
Page page = liveBabyService.getLiveGoodsList(params);
List
直播间管理代码:
获取源码可搜索体验小程序: 海哇