微信小程序直播V0.2
This commit is contained in:
parent
0173ba814e
commit
02827a2f8b
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@ -15,10 +14,10 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author liushuai(liushuai711 @ gmail.com)
|
* 直播商品
|
||||||
* @version v4.1
|
*
|
||||||
* @Description:
|
* @author Bulbasaur
|
||||||
* @since 2021/5/17 3:10 下午
|
* @date: 2021/5/18 5:42 下午
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package cn.lili.modules.broadcast.entity.dto;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author liushuai(liushuai711 @ gmail.com)
|
|
||||||
* @version v4.1
|
|
||||||
* @Description:
|
|
||||||
* @since 2021/5/17 11:34 上午
|
|
||||||
*/
|
|
||||||
public enum CommodityAuditStatusEnum {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 未审核
|
|
||||||
*/
|
|
||||||
WAIT_AUDIT("0"),
|
|
||||||
/**
|
|
||||||
* 审核中
|
|
||||||
*/
|
|
||||||
AUDITING("1"),
|
|
||||||
/**
|
|
||||||
* 审核通过
|
|
||||||
*/
|
|
||||||
AUDIT_PASS("2"),
|
|
||||||
/**
|
|
||||||
* 审核失败
|
|
||||||
*/
|
|
||||||
AUDIT_REJECTION("3");
|
|
||||||
|
|
||||||
private final String status;
|
|
||||||
|
|
||||||
CommodityAuditStatusEnum(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +1,6 @@
|
|||||||
package cn.lili.modules.broadcast.util;
|
package cn.lili.modules.broadcast.util;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.http.HttpRequest;
|
|
||||||
import cn.hutool.http.HttpResponse;
|
|
||||||
import cn.hutool.http.Method;
|
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
||||||
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||||
@ -15,16 +12,15 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序直播工具类
|
* 微信小程序直播工具类
|
||||||
|
*
|
||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 10:16 上午
|
* @date: 2021/5/17 10:16 上午
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ -33,31 +29,19 @@ public class WechatLivePlayerUtil {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private WechatAccessTokenUtil wechatAccessTokenUtil;
|
private WechatAccessTokenUtil wechatAccessTokenUtil;
|
||||||
|
|
||||||
private void test(Studio studio){
|
|
||||||
HttpRequest httpRequest = new HttpRequest("https://api.weixin.qq.com/cgi-bin/media/upload");
|
|
||||||
httpRequest.setMethod(Method.POST);
|
|
||||||
File logoFile = new File(studio.getMediaUrl());
|
|
||||||
httpRequest.setConnectionTimeout(30000);
|
|
||||||
httpRequest.form("access_token",wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP));
|
|
||||||
httpRequest.form("type", "image");
|
|
||||||
httpRequest.form("media", logoFile);
|
|
||||||
HttpResponse reqResult = httpRequest.execute();
|
|
||||||
System.out.println(reqResult.body());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建小程序直播间
|
* 创建小程序直播间
|
||||||
|
*
|
||||||
* @param studio 小程序直播
|
* @param studio 小程序直播
|
||||||
* @return 房间ID
|
* @return 房间ID
|
||||||
*/
|
*/
|
||||||
public Integer create(Studio studio) {
|
public Integer create(Studio studio) {
|
||||||
test(studio);
|
|
||||||
//获取token
|
//获取token
|
||||||
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP);
|
||||||
//发送url
|
//发送url
|
||||||
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=" + token;
|
String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=" + token;
|
||||||
Map<String, String> map = new HashMap<>();
|
|
||||||
|
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
// 背景图
|
// 背景图
|
||||||
map.put("coverImg", studio.getCoverImg());
|
map.put("coverImg", studio.getCoverImg());
|
||||||
// 分享图
|
// 分享图
|
||||||
@ -94,6 +78,7 @@ public class WechatLivePlayerUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取直播间回放
|
* 获取直播间回放
|
||||||
|
*
|
||||||
* @param roomId 房间ID
|
* @param roomId 房间ID
|
||||||
* @return 回放地址
|
* @return 回放地址
|
||||||
*/
|
*/
|
||||||
@ -121,6 +106,7 @@ public class WechatLivePlayerUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送直播间商品
|
* 推送直播间商品
|
||||||
|
*
|
||||||
* @param roomId 房间ID
|
* @param roomId 房间ID
|
||||||
* @param goodsId 商品ID
|
* @param goodsId 商品ID
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
@ -143,6 +129,7 @@ public class WechatLivePlayerUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除直播间商品
|
* 删除直播间商品
|
||||||
|
*
|
||||||
* @param roomId 房间ID
|
* @param roomId 房间ID
|
||||||
* @param goodsId 商品ID
|
* @param goodsId 商品ID
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
@ -165,6 +152,7 @@ public class WechatLivePlayerUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加直播商品
|
* 添加直播商品
|
||||||
|
*
|
||||||
* @param commodity 直播商品
|
* @param commodity 直播商品
|
||||||
* @return 添加结果
|
* @return 添加结果
|
||||||
*/
|
*/
|
||||||
@ -182,6 +170,7 @@ public class WechatLivePlayerUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除直播商品
|
* 删除直播商品
|
||||||
|
*
|
||||||
* @param goodsId 商品ID
|
* @param goodsId 商品ID
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
@ -198,6 +187,7 @@ public class WechatLivePlayerUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询直播商品状态
|
* 查询直播商品状态
|
||||||
|
*
|
||||||
* @param goodsIdList 商品ID列表
|
* @param goodsIdList 商品ID列表
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
|
@ -162,7 +162,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
|||||||
private Member findMember(String userName) {
|
private Member findMember(String userName) {
|
||||||
QueryWrapper<Member> queryWrapper = new QueryWrapper();
|
QueryWrapper<Member> queryWrapper = new QueryWrapper();
|
||||||
queryWrapper.eq("username", userName).or().eq("mobile", userName);
|
queryWrapper.eq("username", userName).or().eq("mobile", userName);
|
||||||
return memberMapper.selectOne(queryWrapper);
|
return this.getOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.lili.controller.member;
|
package cn.lili.controller.member;
|
||||||
|
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.utils.PageUtil;
|
import cn.lili.common.utils.PageUtil;
|
||||||
import cn.lili.common.utils.ResultUtil;
|
import cn.lili.common.utils.ResultUtil;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
@ -53,7 +54,7 @@ public class MemberGradeManagerController {
|
|||||||
if (memberGradeService.updateById(memberGrade)) {
|
if (memberGradeService.updateById(memberGrade)) {
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除会员等级")
|
@ApiOperation(value = "删除会员等级")
|
||||||
@ -61,10 +62,10 @@ public class MemberGradeManagerController {
|
|||||||
@PutMapping(value = "/delete/{id}")
|
@PutMapping(value = "/delete/{id}")
|
||||||
public ResultMessage<IPage<Object>> delete(@PathVariable String id) {
|
public ResultMessage<IPage<Object>> delete(@PathVariable String id) {
|
||||||
if(memberGradeService.getById(id).getIsDefault()){
|
if(memberGradeService.getById(id).getIsDefault()){
|
||||||
return ResultUtil.error(ResultCode.USER_GRADE_IS_DEFAULT);
|
throw new ServiceException(ResultCode.USER_GRADE_IS_DEFAULT);
|
||||||
}else if(memberGradeService.removeById(id)){
|
}else if(memberGradeService.removeById(id)){
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.lili.controller.other.broadcast;
|
package cn.lili.controller.other.broadcast;
|
||||||
|
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.utils.PageUtil;
|
import cn.lili.common.utils.PageUtil;
|
||||||
import cn.lili.common.utils.ResultUtil;
|
import cn.lili.common.utils.ResultUtil;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
@ -16,9 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺端,直播商品接口
|
* 店铺端,直播商品接口
|
||||||
|
*
|
||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 2:05 下午
|
* @date: 2021/5/17 2:05 下午
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Api(tags = "店铺端,直播商品接口")
|
@Api(tags = "店铺端,直播商品接口")
|
||||||
@ -40,7 +41,7 @@ public class CommodityController {
|
|||||||
if (commodityService.addCommodity(commodity)) {
|
if (commodityService.addCommodity(commodity)) {
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除店铺直播商品")
|
@ApiOperation(value = "删除店铺直播商品")
|
||||||
@ -49,6 +50,6 @@ public class CommodityController {
|
|||||||
if (commodityService.deleteCommodity(goodsId)) {
|
if (commodityService.deleteCommodity(goodsId)) {
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package cn.lili.controller.other.broadcast;
|
package cn.lili.controller.other.broadcast;
|
||||||
|
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.utils.PageUtil;
|
import cn.lili.common.utils.PageUtil;
|
||||||
import cn.lili.common.utils.ResultUtil;
|
import cn.lili.common.utils.ResultUtil;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
|
import cn.lili.modules.base.entity.enums.ClientTypeEnum;
|
||||||
import cn.lili.modules.broadcast.entity.dos.Studio;
|
import cn.lili.modules.broadcast.entity.dos.Studio;
|
||||||
import cn.lili.modules.broadcast.service.StudioService;
|
import cn.lili.modules.broadcast.service.StudioService;
|
||||||
|
import cn.lili.modules.message.util.WechatAccessTokenUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
@ -19,9 +22,9 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺端,直播间接口
|
* 店铺端,直播间接口
|
||||||
|
*
|
||||||
* @author Bulbasaur
|
* @author Bulbasaur
|
||||||
* @date: 2021/5/17 2:05 下午
|
* @date: 2021/5/17 2:05 下午
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Api(tags = "店铺端,直播间接口")
|
@Api(tags = "店铺端,直播间接口")
|
||||||
@ -30,6 +33,8 @@ public class StudioController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StudioService studioService;
|
private StudioService studioService;
|
||||||
|
@Autowired
|
||||||
|
private WechatAccessTokenUtil wechatAccessTokenUtil;
|
||||||
|
|
||||||
@ApiOperation(value = "获取店铺直播间列表")
|
@ApiOperation(value = "获取店铺直播间列表")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ -50,7 +55,7 @@ public class StudioController {
|
|||||||
if (studioService.create(studio)) {
|
if (studioService.create(studio)) {
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "店铺直播间添加商品")
|
@ApiOperation(value = "店铺直播间添加商品")
|
||||||
@ -63,7 +68,7 @@ public class StudioController {
|
|||||||
if (studioService.push(roomId, liveGoodsId)) {
|
if (studioService.push(roomId, liveGoodsId)) {
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "店铺直播间删除商品")
|
@ApiOperation(value = "店铺直播间删除商品")
|
||||||
@ -76,6 +81,12 @@ public class StudioController {
|
|||||||
if (studioService.goodsDeleteInRoom(roomId, liveGoodsId)) {
|
if (studioService.goodsDeleteInRoom(roomId, liveGoodsId)) {
|
||||||
return ResultUtil.success(ResultCode.SUCCESS);
|
return ResultUtil.success(ResultCode.SUCCESS);
|
||||||
}
|
}
|
||||||
return ResultUtil.error(ResultCode.ERROR);
|
throw new ServiceException(ResultCode.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取素材,调用接口凭证")
|
||||||
|
@PutMapping(value = "/getCgiAccessToken")
|
||||||
|
public ResultMessage<Object> getCgiAccessToken() {
|
||||||
|
return ResultUtil.data(wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user