xuhy
2025-12-05 a8f2080d05242914158e4fa57635ee53e89b38c7
小鹅通
2个文件已添加
9个文件已修改
527 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TRegionController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/XiaoeLiveDTO.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TRegion.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TRegionService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmSupplierServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRegionServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/utils/util/XiaoeUtils.java 356 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TRegionController.java
@@ -50,6 +50,12 @@
    public R<List<TRegion>> getProvince() {
        return R.ok(regionService.list(Wrappers.lambdaQuery(TRegion.class).eq(TRegion::getParentId,0)));
    }
    @ApiOperation(value = "查询省市区管理")
    @GetMapping(value = "/getRegionList")
    public R<List<TRegion>> getRegionList() {
        return R.ok(regionService.getRegionList());
    }
//    @ApiOperation(value = "发送测试")
//    @PostMapping(value = "/sendTest")
//    public R<String> sendTest() {
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java
@@ -8,13 +8,16 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.XiaoeLiveDTO;
import com.ruoyi.system.model.TSysEducationalInfo;
import com.ruoyi.system.model.TSysLive;
import com.ruoyi.system.model.TSysProductIntroduction;
import com.ruoyi.system.query.TSysLiveQuery;
import com.ruoyi.system.service.TSysLiveService;
import com.ruoyi.system.utils.util.XiaoeUtils;
import com.ruoyi.system.vo.TSysLiveVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -43,11 +46,13 @@
    private final TSysLiveService sysLiveService;
    private final TokenService tokenService;
    private final RedisCache redisCache;
    private final XiaoeUtils xiaoeUtils;
    @Autowired
    public TSysLiveController(TSysLiveService sysLiveService, TokenService tokenService, RedisCache redisCache) {
    public TSysLiveController(TSysLiveService sysLiveService, TokenService tokenService, RedisCache redisCache, XiaoeUtils xiaoeUtils) {
        this.sysLiveService = sysLiveService;
        this.tokenService = tokenService;
        this.redisCache = redisCache;
        this.xiaoeUtils = xiaoeUtils;
    }
    /**
@@ -96,6 +101,22 @@
        }
        // 计算结束时间
        dto.setEndTime(dto.getStartTime().plusMinutes(dto.getExpectedDuration()));
        // 创建小鹅通直播
        XiaoeLiveDTO xiaoeLiveDTO = new XiaoeLiveDTO();
        xiaoeLiveDTO.setTitle(dto.getLiveTitle());
        xiaoeLiveDTO.setSummary(dto.getLiveIntroduction());
        xiaoeLiveDTO.setZbStartAt(DateUtils.localDateTimeToString(dto.getStartTime()));
        xiaoeLiveDTO.setZbStopAt(dto.getExpectedDuration());
        // 直播类型 0-语音,1-录播直播,2-推流直播,默认为0-语音直播
        xiaoeLiveDTO.setAliveType(2);
        xiaoeLiveDTO.setAliveMode(dto.getLiveMode()==1?0:1);
        xiaoeLiveDTO.setUserId(dto.getLiveLecturer());
        xiaoeLiveDTO.setPaymentType(dto.getLiveType()==1?1:3);
        xiaoeLiveDTO.setResourcePassword(dto.getResourcePassword());
        xiaoeLiveDTO.setDescrb(dto.getLiveDetail());
        xiaoeUtils.addLive(xiaoeLiveDTO);
        return R.ok(sysLiveService.save(dto));
    }
@@ -112,6 +133,22 @@
//        }
        // 计算结束时间
        dto.setEndTime(dto.getStartTime().plusMinutes(dto.getExpectedDuration()));
        // 编辑小鹅通直播
        XiaoeLiveDTO xiaoeLiveDTO = new XiaoeLiveDTO();
        xiaoeLiveDTO.setTitle(dto.getLiveTitle());
        xiaoeLiveDTO.setSummary(dto.getLiveIntroduction());
        xiaoeLiveDTO.setZbStartAt(DateUtils.localDateTimeToString(dto.getStartTime()));
        xiaoeLiveDTO.setZbStopAt(dto.getExpectedDuration());
        // 直播类型 0-语音,1-录播直播,2-推流直播,默认为0-语音直播
        xiaoeLiveDTO.setAliveType(2);
        xiaoeLiveDTO.setAliveMode(dto.getLiveMode()==1?0:1);
        xiaoeLiveDTO.setUserId(dto.getLiveLecturer());
        xiaoeLiveDTO.setPaymentType(dto.getLiveType()==1?1:3);
        xiaoeLiveDTO.setResourcePassword(dto.getResourcePassword());
        xiaoeLiveDTO.setDescrb(dto.getLiveDetail());
        xiaoeUtils.editLive(xiaoeLiveDTO);
        return R.ok(sysLiveService.updateById(dto));
    }
@@ -144,6 +181,11 @@
    @DeleteMapping(value = "/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        redisCache.deleteObject(Constants.SYS_LIVE_CLICK_COUNT+id);
        // 删除直播
        TSysLive sysLive = sysLiveService.getById(id);
        xiaoeUtils.deleteLive(sysLive.getGoslingLiveId());
        return R.ok(sysLiveService.removeById(id));
    }
ruoyi-system/src/main/java/com/ruoyi/system/dto/XiaoeLiveDTO.java
New file
@@ -0,0 +1,71 @@
package com.ruoyi.system.dto;
import com.alibaba.fastjson2.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
@ApiModel(value = "小鹅通直播XiaoeLiveDTO")
public class XiaoeLiveDTO implements Serializable {
    @ApiModelProperty(value = "直播id",notes = "添加不传,编辑必传")
    @JSONField(name = "id")
    private String id;
    @ApiModelProperty(value = "直播标题", required = true, notes = "字符长度必须小于45")
    @NotBlank(message = "直播标题不能为空")
    @JSONField(name = "title")
    private String title;
    @ApiModelProperty(value = "直播简介", notes = "字符长度必须小于256,默认为空")
    @NotBlank(message = "直播简介不能为空")
    @Length(max = 256, message = "直播简介长度不能超过256")
    @JSONField(name = "summary")
    private String summary;
    @ApiModelProperty(value = "预设直播开始时间", required = true, notes = "距离当前时间不能超过五年", example = "2023-05-31 18:00:00")
    @NotBlank(message = "预设直播开始时间不能为空")
    @JSONField(name = "zb_start_at")
    private String zbStartAt;
    @ApiModelProperty(value = "预设直播时长,单位:秒", required = true, notes = "距离预设直播开始时间不能超过十年")
    @JSONField(name = "zb_stop_at")
    private Integer zbStopAt;
    @ApiModelProperty(value = "直播类型 0-语音,1-录播直播,2-推流直播,默认为0-语音直播")
    @NotNull(message = "直播类型不能为空")
    @JSONField(name = "alive_type")
    private Integer aliveType;
    @ApiModelProperty(value = "直播模式:0-横屏直播,1-竖屏直播(默认为0-横屏直播)", example = "0")
    @NotNull(message = "直播模式不能为空")
    @JSONField(name = "alive_mode")
    private Integer aliveMode;
    @ApiModelProperty(value = "讲师用户id")
    @NotBlank(message = "讲师用户id不能为空")
    @JSONField(name = "user_id")
    private String userId;
    @ApiModelProperty(value = "支付类型:1-免费,3-加密,仅当goods_info.sale_type=2时才可用", example = "1")
    @NotNull(message = "直播类型不能为空")
    @JSONField(name = "payment_type")
    private Integer paymentType;
    @ApiModelProperty(value = "密码(paymentType为3时必填,否则该字段无效)")
    @JSONField(name = "resource_password")
    private String resourcePassword;
    @ApiModelProperty(value = "直播详情", notes = "仅允许纯文本,不得超过5000个字符,默认为空")
    @NotBlank(message = "直播详情不能为空")
    @Length(max = 5000, message = "直播详情长度不能超过5000")
    @JSONField(name = "descrb")
    private String descrb;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TRegion.java
@@ -51,10 +51,6 @@
    @TableField("english")
    private String english;
    @ApiModelProperty(value = "首字母")
    @TableField("initial")
    private String initial;
    @ApiModelProperty(value = "子项")
    @TableField(exist = false)
    private List<TRegion> children;
ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java
@@ -75,6 +75,10 @@
    @TableField("live_type")
    private Integer liveType;
    @ApiModelProperty(value = "直播密码")
    @TableField("resource_password")
    private String resourcePassword;
    @ApiModelProperty(value = "直播地址")
    @TableField("live_url")
    private String liveUrl;
@@ -90,4 +94,9 @@
    @ApiModelProperty(value = "点击次数")
    @TableField("click_count")
    private Integer clickCount;
    @ApiModelProperty(value = "小鹅通直播id")
    @TableField("gosling_live_id")
    private String goslingLiveId;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TRegionService.java
@@ -20,4 +20,11 @@
     * @return
     */
    List<TRegion> getRegion();
    /**
     * 查询省市区管理
     * @return
     */
    List<TRegion> getRegionList();
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmSupplierServiceImpl.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.CodeGenerateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.TCrmSupplierDTO;
@@ -70,6 +71,7 @@
        if(Objects.nonNull(sysUser)){
            return R.fail(dto.getAccount()+"-账号已存在");
        }
        dto.setUniqueIdentifierId(CodeGenerateUtils.generateOrderSn());
        this.save(dto);
        // 添加供应商和仓库关联关系
//        TCrmSupplierToWarehouse crmSupplierToWarehouse = new TCrmSupplierToWarehouse();
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
@@ -922,12 +922,18 @@
            crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class)
                    .eq(TCrmBranchArea::getCityCode, query.getCityCode())
                    .eq(TCrmBranchArea::getAreaType, 2));
            if(CollectionUtils.isEmpty(crmBranchAreas)){
                return new PageInfo<>();
            }
        }
        if(StringUtils.isNotEmpty(query.getProvinceCode())){
            crmBranchAreas = crmBranchAreaMapper.selectList(Wrappers.lambdaQuery(TCrmBranchArea.class)
                    .eq(TCrmBranchArea::getProvinceCode, query.getProvinceCode())
                    .eq(TCrmBranchArea::getAreaType, 2));
            if(CollectionUtils.isEmpty(crmBranchAreas)){
                return new PageInfo<>();
            }
        }
        if(!CollectionUtils.isEmpty(crmBranchAreas)){
            List<String> branchIds = crmBranchAreas.stream().map(TCrmBranchArea::getBranchId).collect(Collectors.toList());
@@ -938,8 +944,6 @@
            }
            List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
            clinicIds.addAll(ids);
        }else {
            return new PageInfo<>();
        }
        if(StringUtils.isNotBlank(query.getBranchName())){
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRegionServiceImpl.java
@@ -32,4 +32,19 @@
        }
        return parent;
    }
    @Override
    public List<TRegion> getRegionList() {
        List<TRegion> tRegions = this.baseMapper.selectList(Wrappers.lambdaQuery(TRegion.class));
        List<TRegion> parent = tRegions.stream().filter(e -> e.getParentId().equals(0L)).collect(Collectors.toList());
        for (TRegion region : parent) {
            List<TRegion> children = tRegions.stream().filter(e -> e.getParentId().equals(region.getId())).collect(Collectors.toList());
            for (TRegion child : children) {
                List<TRegion> children1 = tRegions.stream().filter(e -> e.getParentId().equals(child.getId())).collect(Collectors.toList());
                child.setChildren(children1);
            }
            region.setChildren(children);
        }
        return parent;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/utils/util/XiaoeUtils.java
New file
@@ -0,0 +1,356 @@
package com.ruoyi.system.utils.util;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.XiaoeLiveDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
 * 小鹅通工具类
 * @author mitao
 * @date 2025/1/8
 */
@Slf4j
@Component
public class XiaoeUtils {
    @Resource
    private RedisService redisService;
    private static final String BASE_URL = "https://api.xiaoe-tech.com/token";
    //店铺的业务id
    private  String app_id = "";
    //应用的唯一标识,通过 client_id 来鉴别应用的身份
    private  String client_id = "";
    //应用的凭证秘钥,即client_secret,用来保证应用来源的可靠性,防止被伪造
    private  String secret_key = "";
    //固定填写client_credential
    private  String grant_type = "client_credential";
    //获取直播列表
    private static final String LIVE_PAGE_LIST = "https://api.xiaoe-tech.com/xe.alive.list.get/1.0.0";
    private static final String LIVE_PAGE_LIST_V2 = "https://api.xiaoe-tech.com/xe.alive.list.get/2.0.0";
    //获取直播详情
    private static final String LIVE_DETAIL = "https://api.xiaoe-tech.com/xe.alive.detail.get/1.0.0";
    private static final String LIVE_DETAIL_V2 = "https://api.xiaoe-tech.com/xe.alive.detail.get/2.0.0";
    //创建直播
    private static final String LIVE_ADD = "https://api.xiaoe-tech.com/xe.alive.live.create/1.0.0";
    //编辑直播
    private static final String LIVE_EDIT = "https://api.xiaoe-tech.com/xe.alive.live.update/1.0.0";
    //删除直播
    private static final String LIVE_DELETE = "https://api.xiaoe-tech.com/xe.alive.live.delete/1.0.0";
    /**
     * 获取小鹅通access_token
     * @return
     */
    private String getAccessToken() {
        Boolean flag = redisService.hasKey("xiaoe:access_token");
        String accessToken = "";
        if (flag) {
            accessToken = redisService.getCacheObject("xiaoe:access_token");
        } else {
            String urlString = BASE_URL +
                    "?app_id=" + this.app_id +
                    "&client_id=" + this.client_id +
                    "&secret_key=" + this.secret_key +
                    "&grant_type=" + this.grant_type;
            String result = null;
            try {
                URL reqURL = new URL(urlString);
                HttpURLConnection httpURLConnection = (HttpURLConnection) reqURL.openConnection();
                InputStreamReader isr = new InputStreamReader(httpURLConnection.getInputStream());
                char[] chars = new char[1024];
                result = "";
                int len;
                while ((len = isr.read(chars)) != -1) {
                    result += new String(chars, 0, len);
                }
                isr.close();
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject jsonObject = JSONObject.parseObject(result);
            log.info("获取access_token返回结果:{}", result);
            Map data = (Map) jsonObject.get("data");
            accessToken = (String)data.get("access_token");
            Integer expiresIn = (int) data.get("expires_in");
            redisService.setCacheObject("xiaoe:access_token", accessToken,Long.parseLong(expiresIn.toString()), TimeUnit.SECONDS);
        }
        return accessToken;
    }
    /**
     * 获取直播列表
     * @param dto
     * @return
     */
//    public Page<XiaoeLiveVo> getLivePageList(XiaoeLiveQueryDto dto) {
//        Map<String,Object> postParams = new HashMap<>();
//        postParams.put("search_content", dto.getSearchContent());
//        postParams.put("create_mode", dto.getCreateMode());
//        postParams.put("state", 0);
//        postParams.put("search_alive_type", dto.getSearchAliveType());
//        postParams.put("alive_play_state", dto.getAlivePlayState());
//        postParams.put("page", dto.getPage());
//        postParams.put("page_size", dto.getPageSize());
//        postParams.put("access_token", getAccessToken());
//        String post = HttpUtil.post(LIVE_PAGE_LIST, JSONObject.toJSONString(postParams));
//        Page<XiaoeLiveVo> xiaoeLiveVOPage = new Page<>();
//        if (StringUtils.isNotBlank(post)) {
//            log.info("获取直播列表返回结果:{}", post);
//            JSONObject jsonObject = JSONObject.parseObject(post);
//            if (jsonObject.get("code").equals(0) ) {
//                JSONObject data = jsonObject.getJSONObject("data");
//                JSONArray list = data.getJSONArray("list");
//                if (CollectionUtil.isNotEmpty(list)) {
//                    List<XiaoeLiveVo> xiaoeLiveVos = JSONArray.parseArray(list.toJSONString(), XiaoeLiveVo.class);
//                    xiaoeLiveVOPage.setRecords(xiaoeLiveVos);
//                    xiaoeLiveVOPage.setCurrent(dto.getPage());
//                    xiaoeLiveVOPage.setPages(data.getLong("page_count"));
//                }
//            }
//        }
//        return xiaoeLiveVOPage;
//    }
    /**
     *获取直播详情
     * @param id 直播ID
     * @return
     */
//    public XiaoeLiveVo getLiveDetail(String id) {
//        Map<String, Object> postParams = new HashMap<>();
//        postParams.put("id", id);
//        postParams.put("access_token", getAccessToken());
//        String post = HttpUtil.post(LIVE_DETAIL, JSONObject.toJSONString(postParams));
//        XiaoeLiveVo xiaoeLiveVO = null;
//        if (StringUtils.isNotBlank(post)) {
//            JSONObject jsonObject = JSONObject.parseObject(post);
//            if (jsonObject.get("code").equals(0)) {
//                JSONObject data = jsonObject.getJSONObject("data");
//                xiaoeLiveVO = JSONObject.parseObject(data.toJSONString(), XiaoeLiveVo.class);
//            }
//        }
//        return xiaoeLiveVO;
//    }
    /**
     * 获取直播列表2.0
     * @param dto
     * @return
     */
//    public Page<XiaoeLiveVoV2> getLivePageListV2(XiaoeLiveQueryDto dto) {
//        Map<String,Object> postParams = new HashMap<>();
//        postParams.put("search_content", dto.getSearchContent());
//        postParams.put("create_mode", dto.getCreateMode());
//        postParams.put("state", 0);
//        postParams.put("search_alive_type", dto.getSearchAliveType());
//        postParams.put("alive_play_state", dto.getAlivePlayState());
//        postParams.put("page", dto.getPage());
//        postParams.put("page_size", dto.getPageSize());
//        postParams.put("access_token", getAccessToken());
//        postParams.put("zb_start_at_min", DateUtil.format(DateUtils.getTodayStartTime(), DatePattern.NORM_DATETIME_PATTERN));
//        String post = HttpUtil.post(LIVE_PAGE_LIST_V2, JSONObject.toJSONString(postParams));
//        Page<XiaoeLiveVoV2> xiaoeLiveVOPage = new Page<>();
//        if (StringUtils.isNotBlank(post)) {
//            log.info("获取直播详情2.0返回结果:{}", post);
//            JSONObject jsonObject = JSONObject.parseObject(post);
//            if (jsonObject.get("code").equals(0)) {
//                JSONObject data = jsonObject.getJSONObject("data");
//                JSONArray list = data.getJSONArray("live_list");
//                if (!list.isEmpty()){
//                    List<XiaoeLiveVoV2> xiaoeLiveVos = JSONArray.parseArray(list.toJSONString(), XiaoeLiveVoV2.class);
//                    xiaoeLiveVOPage.setRecords(xiaoeLiveVos);
//                    xiaoeLiveVOPage.setCurrent(dto.getPage());
//                    xiaoeLiveVOPage.setTotal(data.getLong("total_count"));
//                }
//            }
//        }
//        return xiaoeLiveVOPage;
//    }
    /**
     *获取直播详情
     * @param id 直播ID
     * @return
     */
//    public XiaoeLiveDetailVOV2 getLiveDetailV2(String id) {
//        Map<String, Object> postParams = new HashMap<>();
//        postParams.put("id", id);
//        postParams.put("access_token", getAccessToken());
//        String post = HttpUtil.post(LIVE_DETAIL_V2, JSONObject.toJSONString(postParams));
//        XiaoeLiveDetailVOV2 vo = null;
//        if (StringUtils.isNotBlank(post)) {
//            JSONObject jsonObject = JSONObject.parseObject(post);
//            if (jsonObject.get("code").equals(0)) {
//                JSONObject data = jsonObject.getJSONObject("data");
//                vo = JSONObject.parseObject(data.toJSONString(), XiaoeLiveDetailVOV2.class);
//            }
//        }
//        return vo;
//    }
    /**
     * 创建直播
     * @param dto
     * @return
     */
    public String addLive(XiaoeLiveDTO dto) {
        Map<String, Object> requestParams = new HashMap<>();
        Map<String, Object> resourceInfoMap = new HashMap<>();
        resourceInfoMap.put("title", dto.getTitle());
        resourceInfoMap.put("summary", dto.getSummary());
        resourceInfoMap.put("zb_start_at", dto.getZbStartAt());
        resourceInfoMap.put("zb_stop_at", dto.getZbStopAt());
        resourceInfoMap.put("alive_type", dto.getAliveType());
        resourceInfoMap.put("descrb", dto.getDescrb());
        requestParams.put("resource_info", resourceInfoMap);
        //    配置信息
        Map<String, Object> moudleInfoMap = new HashMap<>();
        moudleInfoMap.put("alive_mode", dto.getAliveMode());
        requestParams.put("module_info", moudleInfoMap);
        //讲师信息
        List<Map<String, Object>> roleList = new ArrayList<>();
        Map<String, Object> roleInfoMap = new HashMap<>();
        roleInfoMap.put("role_name", "讲师");
        roleInfoMap.put("user_id", dto.getUserId());
        roleList.add(roleInfoMap);
        requestParams.put("role_info", roleList);
        //商品信息
        Map<String, Object> goodsInfoMap = new HashMap<>();
        goodsInfoMap.put("sale_type", 1);//售卖类型:1-单独售卖、2-关联售卖
        goodsInfoMap.put("payment_type", dto.getPaymentType());
        if (dto.getPaymentType().equals(3)) {
            goodsInfoMap.put("resource_password", dto.getResourcePassword());
        }
        requestParams.put("goods_info", goodsInfoMap);
        requestParams.put("access_token", getAccessToken());
        log.info("创建直播参数:{}" ,JSONObject.toJSONString(requestParams));
        String post = HttpUtil.post(LIVE_ADD, JSONObject.toJSONString(requestParams));
        if (StringUtils.isNotBlank(post)) {
            JSONObject jsonObject = JSONObject.parseObject(post);
            log.info("创建直播返回结果:{}" ,post);
            if (jsonObject.get("code").equals(0)) {
                JSONObject data = jsonObject.getJSONObject("data");
                return data.getString("id");
            }
        }
        return null;
    }
    /**
     * 编辑直播
     * @param dto
     * @return
     */
    public Boolean editLive(XiaoeLiveDTO dto) {
        boolean flag = false;
        Map<String, Object> requestParams = new HashMap<>();
        Map<String, Object> resourceInfoMap = new HashMap<>();
        resourceInfoMap.put("id", dto.getId());
        resourceInfoMap.put("title", dto.getTitle());
        resourceInfoMap.put("summary", dto.getSummary());
        resourceInfoMap.put("zb_start_at", dto.getZbStartAt());
        resourceInfoMap.put("zb_stop_at", dto.getZbStopAt());
        resourceInfoMap.put("alive_type", dto.getAliveType());
        resourceInfoMap.put("descrb", dto.getDescrb());
        requestParams.put("resource_info", resourceInfoMap);
        //    配置信息
        Map<String, Object> moudleInfoMap = new HashMap<>();
        moudleInfoMap.put("alive_mode", dto.getAliveMode());
        requestParams.put("module_info", moudleInfoMap);
        //讲师信息
        List<Map<String, Object>> roleList = new ArrayList<>();
        Map<String, Object> roleInfoMap = new HashMap<>();
        roleInfoMap.put("role_name", "讲师");
        roleInfoMap.put("user_id", dto.getUserId());
        roleList.add(roleInfoMap);
        requestParams.put("role_info", roleList);
        //商品信息
        Map<String, Object> goodsInfoMap = new HashMap<>();
        goodsInfoMap.put("sale_type", 1);//售卖类型:1-单独售卖、2-关联售卖
        goodsInfoMap.put("payment_type", dto.getPaymentType());
        if (dto.getPaymentType().equals(3)) {
            goodsInfoMap.put("resource_password", dto.getResourcePassword());
        }
        requestParams.put("goods_info", goodsInfoMap);
        requestParams.put("access_token", getAccessToken());
        log.info("编辑直播参数:{}" ,JSONObject.toJSONString(requestParams));
        String post = HttpUtil.post(LIVE_EDIT, JSONObject.toJSONString(requestParams));
        if (StringUtils.isNotBlank(post)) {
            JSONObject jsonObject = JSONObject.parseObject(post);
            log.info("编辑直播返回结果:{}" ,post);
            if (jsonObject.get("code").equals(0)) {
                flag = true;
            }
        }
        return flag;
    }
    /**
     * 删除直播
     * @param id
     * @return
     */
    public Boolean deleteLive(String id) {
        boolean flag = false;
        Map<String, Object> requestParams = new HashMap<>();
        requestParams.put("id", id);
        requestParams.put("access_token", getAccessToken());
        String post = HttpUtil.post(LIVE_DELETE, JSONObject.toJSONString(requestParams));
        if (StringUtils.isNotBlank(post)) {
            JSONObject jsonObject = JSONObject.parseObject(post);
            log.info("删除直播返回结果:{}" ,post);
            if (jsonObject.get("code").equals(0)) {
                flag = true;
            }
        }
        return flag;
    }
    public static void main(String[] args) {
        String urlString = BASE_URL +
                "?app_id=appwmuwNWD48082" +
                "&client_id=xopYwOAqNI36444"+
                "&secret_key=qKFxbGR0OlKX85PVyfCvkRF1P6fLRBEu" +
                "&grant_type=client_credential";
        String result = null;
        try {
            URL reqURL = new URL(urlString);
            HttpURLConnection httpURLConnection = (HttpURLConnection) reqURL.openConnection();
            InputStreamReader isr = new InputStreamReader(httpURLConnection.getInputStream());
            char[] chars = new char[1024];
            result = "";
            int len;
            while ((len = isr.read(chars)) != -1) {
                result += new String(chars, 0, len);
            }
            isr.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONObject jsonObject = JSONObject.parseObject(result);
        System.out.println(jsonObject);
        Map data = (Map) jsonObject.get("data");
      String accessToken = (String) data.get("access_token");
        System.out.println(accessToken);
    }
}
ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml
@@ -19,6 +19,8 @@
        <result column="live_detail" property="liveDetail" />
        <result column="push_type" property="pushType" />
        <result column="click_count" property="clickCount" />
        <result column="gosling_live_id" property="goslingLiveId" />
        <result column="resource_password" property="resourcePassword" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_by" property="createBy" />
@@ -29,7 +31,8 @@
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, live_title, live_cover, live_introduction, start_time,end_time, expected_duration, live_way, live_mode,live_url,
          live_lecturer, live_type, live_detail, push_type,click_count, create_time, update_time, create_by, update_by, disabled
          live_lecturer, live_type, live_detail, push_type,click_count, create_time, update_time, create_by, update_by, disabled,
          gosling_live_id,resource_password
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TSysLiveVO">
        SELECT