@源码地址来源: https://minglisoft.cn/honghu2/business.html
package com.honghu.cloud.controller;
import java.util.ArrayList;
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.lang.StringUtils;
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.RestController;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.code.ResponseVO;
import com.honghu.cloud.dto.ModularClassDto;
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.tools.QueryTools;
import com.honghu.cloud.util.CommUtil;
import net.sf.json.JSONObject;
/**
* 商品控制器
* @author Administrator
*
*/
@SuppressWarnings({"rawtypes","unchecked"})
@RestController
@RequestMapping(value = "/liveUserGoods")
/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST,RequestMethod.OPTIONS ,RequestMethod.DELETE,
RequestMethod.PUT })*/
public class UserLiveGoodsController{
@Autowired
private GoodsFeignClient goodsFeignClient;
@Autowired
private QueryTools queryTools;
@Autowired
private UserFeignClient userFeignClient;
@Autowired
private SysConfigFeignClient sysConfigFeignClient;
@Autowired
private ModularClassFeignClient modularClassFeignClient;
/**
* 主播添加的商品
* @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 userName = json.optString("userName"); //用户userName
if(StringUtils.isEmpty(userName)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null); //用户userName不能为空
}
if(StringUtils.isEmpty(type)){
return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USER_GOODS_TYPE_ISNULL, null); //用户我的商品类型不能为空
}
UserDto user = userFeignClient.selectByUserName(userName); //用户
if(user==null){
return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null); //用户不存在
}
Map maps= queryTools.getParams(currentPage, pageSize, orderBy, orderType);
maps.put("goods_status", 0);
if(StringUtils.equals(type, "hall_goods")){
maps.put("live_uid", user.getId());
if(user.getStore_id() != null){
maps.put("no_goods_store_id", user.getStore_id());
}
}
Map resultMap = new HashMap();
if(StringUtils.equals(type, "store_goods")){
maps.put("goods_store_id", user.getStore_id());
//查询是否是附近店面
if(user.getStore_id() == null){
resultMap.put("currentPage", 0);
resultMap.put("pages", 0);
resultMap.put("pageSize", 12);
List

可搜索体验小程序: 海哇