Commit 99ef83c5 by 邓敏

websocket发送班级配置

1 parent f1aff5ff
Showing with 276 additions and 43 deletions
......@@ -3,7 +3,9 @@ package com.subsidy.controller;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.businessScope.AddBusinessScopeDTO;
import com.subsidy.dto.businessScope.BusinessScopeDTO;
import com.subsidy.dto.businessScope.EditBusinessScopeDTO;
import com.subsidy.model.BusinessScopeDictDO;
import com.subsidy.service.BusinessScopeDictService;
import io.swagger.annotations.ApiOperation;
......@@ -31,18 +33,18 @@ public class BusinessScopeDictController {
private BusinessScopeDictService businessScopeDictService;
@PostMapping("addBusinessScope")
@ApiOperation("添加经营范围:businessScopeName/经营范围名称")
@ApiOperation("添加经营范围:businessScopeName/经营范围名称, businessScopeItems[]/经营范围类目")
@LoginRequired
public ResponseVO addBusinessScope(@RequestBody BusinessScopeDictDO businessScopeDictDO) {
businessScopeDictService.save(businessScopeDictDO);
public ResponseVO addBusinessScope(@RequestBody AddBusinessScopeDTO addBusinessScopeDTO) {
businessScopeDictService.addBusinessScope(addBusinessScopeDTO);
return ResponseData.generateCreatedResponse(0);
}
@PostMapping("updateBusinessScope")
@ApiOperation("修改经营范围:id/ID、businessScopeName/经营范围名称")
@ApiOperation("修改经营范围:id/ID、businessScopeName/经营范围名称, businessScopeItems[]/经营范围类目")
@LoginRequired
public ResponseVO updateBusinessScope(@RequestBody BusinessScopeDictDO businessScopeDictDO) {
businessScopeDictService.updateById(businessScopeDictDO);
public ResponseVO updateBusinessScope(@RequestBody EditBusinessScopeDTO editBusinessScopeDTO) {
businessScopeDictService.updateBusinessScope(editBusinessScopeDTO);
return ResponseData.generateCreatedResponse(0);
}
......@@ -50,7 +52,7 @@ public class BusinessScopeDictController {
@ApiOperation("删除经营范围:id/ID")
@LoginRequired
public ResponseVO deleteBusinessScope(@RequestBody BusinessScopeDictDO businessScopeDictDO) {
businessScopeDictService.removeById(businessScopeDictDO.getId());
businessScopeDictService.deleteBusinessScope(businessScopeDictDO.getId());
return ResponseData.generateCreatedResponse(0);
}
......
......@@ -4,7 +4,7 @@ import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.dto.contentVod.AddContentVod;
import com.subsidy.dto.contentVod.AddContentVodDTO;
import com.subsidy.dto.contentVod.ContentVodDTO;
import com.subsidy.dto.vod.ChangeOrdersDTO;
import com.subsidy.service.ContentVodMappingService;
......@@ -40,16 +40,16 @@ public class ContentVodMappingController {
}
@PostMapping("changeContentVodOrders")
@ApiOperation("课程内容视频排序 contentId/内容ID vodIds [] 视频的id")
@ApiOperation("课程内容视频排序 contentId/内容ID vodIds []")
public ResponseVO changeContentVodOrders(@RequestBody ChangeOrdersDTO changeOrdersDTO ){
contentVodMappingService.changeContentVodOrders(changeOrdersDTO);
return ResponseData.generateCreatedResponse(0);
}
@PostMapping("addContentVod")
@ApiOperation("添加课程内容视频:contentId/内容ID、vodIds [] /视频ID")
@ApiOperation("添加课程内容视频:contentId/内容ID、vodIds [vodId, vodAliasName]")
@LoginRequired
public ResponseVO addContentVod(@RequestBody AddContentVod addContentVod) {
public ResponseVO addContentVod(@RequestBody AddContentVodDTO addContentVod) {
contentVodMappingService.addContentVod(addContentVod);
return ResponseData.generateCreatedResponse(0);
}
......
......@@ -3,7 +3,9 @@ package com.subsidy.controller;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.vod.AddVodDictDTO;
import com.subsidy.dto.vod.ChangeOrdersDTO;
import com.subsidy.dto.vod.VodDictPageDTO;
import com.subsidy.model.VodDictDO;
import com.subsidy.service.VodDictService;
import com.subsidy.util.ConstantUtils;
......@@ -46,10 +48,10 @@ public class VodDictController {
}
@PostMapping("addVod")
@ApiOperation("新增视频 labelId vodName vodLength vodType vodSize vodUrl vodCode")
@ApiOperation("新增视频 labelId contentId vodName vodLength vodType vodSize vodUrl vodCode coverPage")
@LoginRequired
public ResponseVO addVod(@RequestBody VodDictDO vodDictDO) {
vodDictService.addVod(vodDictDO);
public ResponseVO addVod(@RequestBody AddVodDictDTO addVodDictDTO) {
vodDictService.addVod(addVodDictDTO);
return ResponseData.generateCreatedResponse(0, ConstantUtils.ADD_SUCCESS);
}
......@@ -68,4 +70,11 @@ public class VodDictController {
return ResponseData.generateCreatedResponse(0,ConstantUtils.SET_SUCCESS);
}
@PostMapping(value = "queryVodPage")
@ApiOperation("根据类目ID查询视频: pageNum, pageSize, labelId/类目ID, vodName/视频名称")
@LoginRequired
public ResponseVO queryVodPage(@RequestBody VodDictPageDTO vodDictPageDTO) {
return ResponseData.generateCreatedResponse(0, vodDictService.queryVodPage(vodDictPageDTO));
}
}
package com.subsidy.dto.businessScope;
import lombok.Data;
import java.util.List;
@Data
public class AddBusinessScopeDTO {
/**
* 经营范围名称
*/
private String businessScopeName;
/**
* 经营范围类目
*/
private List<String> businessScopeItems;
}
package com.subsidy.dto.businessScope;
import lombok.Data;
import java.util.List;
@Data
public class EditBusinessScopeDTO {
private Long id;
/**
* 经营范围名称
*/
private String businessScopeName;
/**
* 经营范围类目
*/
private List<String> businessScopeItems;
}
......@@ -5,9 +5,9 @@ import lombok.Data;
import java.util.List;
@Data
public class AddContentVod {
public class AddContentVodDTO {
private List<Long> vodIds;
private List<ContentVodDTO> vodIds;
private Long contentId;
}
......@@ -8,4 +8,6 @@ public class ContentVodDTO {
private Long contentId;
private Long vodId;
private String vodAliasName;
}
package com.subsidy.dto.vod;
import com.subsidy.model.VodDictDO;
import lombok.Data;
@Data
public class AddVodDictDTO extends VodDictDO {
private Long contentId;
}
package com.subsidy.dto.vod;
import lombok.Data;
@Data
public class VodDictPageDTO {
private Integer pageNum;
private Integer pageSize;
private Long labelId;
private String vodName;
}
package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.model.BusinessScopeDictDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.businessScope.BusinessScopeDictVO;
import org.springframework.stereotype.Repository;
/**
......@@ -15,4 +18,5 @@ import org.springframework.stereotype.Repository;
@Repository
public interface BusinessScopeDictMapper extends BaseMapper<BusinessScopeDictDO> {
IPage<BusinessScopeDictVO> queryBusinessScopePage(Page page, String businessScopeName);
}
......@@ -25,10 +25,11 @@ public class BusinessScopeDictDO extends BaseModel {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long parentId;
/**
* 经营范围名称
*/
private String businessScopeName;
}
......@@ -40,5 +40,10 @@ public class ContentVodMappingDO extends BaseModel {
*/
private Integer orderNo;
/**
* 视频别名
*/
private String vodAliasName;
}
package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.businessScope.AddBusinessScopeDTO;
import com.subsidy.dto.businessScope.BusinessScopeDTO;
import com.subsidy.dto.businessScope.EditBusinessScopeDTO;
import com.subsidy.model.BusinessScopeDictDO;
import com.baomidou.mybatisplus.extension.service.IService;
......@@ -16,4 +18,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface BusinessScopeDictService extends IService<BusinessScopeDictDO> {
IPage queryBusinessScopePage(BusinessScopeDTO businessScopeDictDO);
void addBusinessScope(AddBusinessScopeDTO addBusinessScopeDTO);
void updateBusinessScope(EditBusinessScopeDTO editBusinessScopeDTO);
void deleteBusinessScope(Long id);
}
package com.subsidy.service;
import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.dto.contentVod.AddContentVod;
import com.subsidy.dto.contentVod.AddContentVodDTO;
import com.subsidy.dto.contentVod.ContentVodDTO;
import com.subsidy.dto.vod.ChangeOrdersDTO;
import com.subsidy.model.ContentVodMappingDO;
......@@ -26,5 +26,5 @@ public interface ContentVodMappingService extends IService<ContentVodMappingDO>
void deleteContentVod(ContentVodDTO contentVodDTO);
void addContentVod(AddContentVod addContentVod);
void addContentVod(AddContentVodDTO addContentVod);
}
package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.dto.vod.AddVodDictDTO;
import com.subsidy.dto.vod.ChangeOrdersDTO;
import com.subsidy.dto.vod.VodDictPageDTO;
import com.subsidy.model.VodDictDO;
import com.subsidy.vo.vod.SignatureVO;
......@@ -19,9 +22,11 @@ public interface VodDictService extends IService<VodDictDO> {
void deleteVod(VodDictDO vodDictDO);
void addVod(VodDictDO vodDictDO);
void addVod(AddVodDictDTO addVodDictDTO);
void updateVod(VodDictDO vodDictDO);
void changeOrders(ChangeOrdersDTO changeOrdersDTO);
IPage queryVodPage(VodDictPageDTO vodDictPageDTO);
}
......@@ -3,13 +3,22 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.dto.businessScope.AddBusinessScopeDTO;
import com.subsidy.dto.businessScope.BusinessScopeDTO;
import com.subsidy.dto.businessScope.EditBusinessScopeDTO;
import com.subsidy.model.BusinessScopeDictDO;
import com.subsidy.mapper.BusinessScopeDictMapper;
import com.subsidy.service.BusinessScopeDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.vo.businessScope.BusinessScopeDictVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
......@@ -25,8 +34,74 @@ public class BusinessScopeDictServiceImpl extends ServiceImpl<BusinessScopeDictM
@Override
public IPage queryBusinessScopePage(BusinessScopeDTO businessScopeDictDO) {
Page page = new Page(businessScopeDictDO.getPageNum(), businessScopeDictDO.getPageSize());
return this.baseMapper.selectPage(page, new QueryWrapper<BusinessScopeDictDO>()
IPage<BusinessScopeDictVO> iPage = this.baseMapper.queryBusinessScopePage(page, businessScopeDictDO.getBusinessScopeName());
iPage.getRecords().forEach(businessScopeDictVO -> {
iPage.getRecords().forEach(bs -> {
if(bs.getParentId().equals(businessScopeDictVO.getId())) {
if(businessScopeDictVO.getChildNode() == null) {
businessScopeDictVO.setChildNode(new ArrayList<>());
}
businessScopeDictVO.getChildNode().add(bs);
}
});
});
return iPage;
}
@Override
public void addBusinessScope(AddBusinessScopeDTO addBusinessScopeDTO) {
if(addBusinessScopeDTO != null) {
BusinessScopeDictDO businessScopeDictDO = new BusinessScopeDictDO();
businessScopeDictDO.setBusinessScopeName(addBusinessScopeDTO.getBusinessScopeName());
this.baseMapper.insert(businessScopeDictDO);
if(CollectionUtils.isNotEmpty(addBusinessScopeDTO.getBusinessScopeItems())) {
for (String businessScopeName : addBusinessScopeDTO.getBusinessScopeItems()) {
BusinessScopeDictDO childNode = new BusinessScopeDictDO();
childNode.setParentId(businessScopeDictDO.getId());
childNode.setBusinessScopeName(businessScopeName);
this.baseMapper.insert(childNode);
}
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBusinessScope(EditBusinessScopeDTO editBusinessScopeDTO) {
if(CollectionUtils.isNotEmpty(editBusinessScopeDTO.getBusinessScopeItems())) {
List<BusinessScopeDictDO> list = this.baseMapper.selectList(new QueryWrapper<BusinessScopeDictDO>()
.lambda()
.eq(BusinessScopeDictDO::getParentId, editBusinessScopeDTO.getId()));
if(CollectionUtils.isNotEmpty(list)) {
this.baseMapper.deleteBatchIds(list.stream().map(BusinessScopeDictDO::getId).collect(Collectors.toList()));
}
for (String businessScopeName : editBusinessScopeDTO.getBusinessScopeItems()) {
BusinessScopeDictDO childNode = new BusinessScopeDictDO();
childNode.setParentId(editBusinessScopeDTO.getId());
childNode.setBusinessScopeName(businessScopeName);
this.baseMapper.insert(childNode);
}
}
/* 只更新经营范围名称 */
BusinessScopeDictDO businessScopeDictDO = new BusinessScopeDictDO();
businessScopeDictDO.setBusinessScopeName(editBusinessScopeDTO.getBusinessScopeName());
businessScopeDictDO.setId(editBusinessScopeDTO.getId());
this.baseMapper.updateById(businessScopeDictDO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBusinessScope(Long id) {
List<BusinessScopeDictDO> list = this.baseMapper.selectList(new QueryWrapper<BusinessScopeDictDO>()
.lambda()
.like(StringUtils.isNotBlank(businessScopeDictDO.getBusinessScopeName()), BusinessScopeDictDO::getBusinessScopeName, businessScopeDictDO.getBusinessScopeName()));
.eq(BusinessScopeDictDO::getParentId, id));
if(CollectionUtils.isNotEmpty(list)) {
this.baseMapper.deleteBatchIds(list.stream().map(BusinessScopeDictDO::getId).collect(Collectors.toList()));
}
this.baseMapper.deleteById(id);
}
}
......@@ -3,7 +3,7 @@ package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.dto.contentVod.AddContentVod;
import com.subsidy.dto.contentVod.AddContentVodDTO;
import com.subsidy.dto.contentVod.ContentVodDTO;
import com.subsidy.dto.vod.ChangeOrdersDTO;
import com.subsidy.mapper.VodDictMapper;
......@@ -67,7 +67,7 @@ public class ContentVodMappingServiceImpl extends ServiceImpl<ContentVodMappingM
}
@Override
public void addContentVod(AddContentVod addContentVod) {
public void addContentVod(AddContentVodDTO addContentVod) {
if(CollectionUtils.isNotEmpty(addContentVod.getVodIds())) {
List<ContentVodMappingDO> list = this.baseMapper.selectList(new QueryWrapper<ContentVodMappingDO>()
.lambda()
......@@ -79,7 +79,8 @@ public class ContentVodMappingServiceImpl extends ServiceImpl<ContentVodMappingM
for (int i = 0; i < addContentVod.getVodIds().size(); i++) {
ContentVodMappingDO contentVodMappingDO = new ContentVodMappingDO();
contentVodMappingDO.setContentId(addContentVod.getContentId());
contentVodMappingDO.setVodId(addContentVod.getVodIds().get(i));
contentVodMappingDO.setVodId(addContentVod.getVodIds().get(i).getVodId());
contentVodMappingDO.setVodAliasName(addContentVod.getVodIds().get(i).getVodAliasName());
contentVodMappingDO.setOrderNo(i+1);
this.baseMapper.insert(contentVodMappingDO);
}
......
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.configure.VODConfig;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.content.GetContendVodsDTO;
import com.subsidy.dto.vod.AddVodDictDTO;
import com.subsidy.dto.vod.ChangeOrdersDTO;
import com.subsidy.dto.vod.VodDictPageDTO;
import com.subsidy.mapper.ContentVodMappingMapper;
import com.subsidy.mapper.VodDictMapper;
import com.subsidy.model.ContentVodMappingDO;
import com.subsidy.model.VodDictDO;
import com.subsidy.service.VodDictService;
import com.subsidy.util.Signature;
......@@ -38,6 +45,9 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
@Value("${spring.profiles.active}")
private String env;
@Autowired
private ContentVodMappingMapper contentVodMappingMapper;
@Override
public SignatureVO signature() {
SignatureVO signatureVO = new SignatureVO();
......@@ -67,16 +77,19 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
throw new HttpException(18000);
}
if(vodDictDO.getVodCode() != null) {
VodUtil.deleteMedia(vodConfig, vodDictDO.getVodCode());
}
this.baseMapper.deleteById(vodDictDO.getId());
VodUtil.deleteMedia(vodConfig, vodDictDO.getVodCode());
}
@Override
public void addVod(VodDictDO vodDictDO) {
public void addVod(AddVodDictDTO addVodDictDTO) {
int orderNo = 1;//排序
List<VodDictDO> vodDictDOS = this.baseMapper.selectList(new QueryWrapper<VodDictDO>()
.lambda()
.eq(VodDictDO::getLabelId, vodDictDO.getLabelId())
.eq(VodDictDO::getLabelId, addVodDictDTO.getLabelId())
.orderByDesc(VodDictDO::getOrderNo));
if (CollectionUtils.isNotEmpty(vodDictDOS)){
......@@ -86,12 +99,19 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
}
}
vodDictDO.setOrderNo(orderNo);
this.baseMapper.insert(vodDictDO);
addVodDictDTO.setOrderNo(orderNo);
this.baseMapper.insert(addVodDictDTO);
if(addVodDictDTO.getContentId() != null) {
ContentVodMappingDO contentVodMappingDO = new ContentVodMappingDO();
contentVodMappingDO.setVodId(addVodDictDTO.getId());
contentVodMappingDO.setContentId(addVodDictDTO.getContentId());
contentVodMappingMapper.insert(contentVodMappingDO);
}
//测试环境就不转码了
if (env.equals("prod")){
VodUtil.processMedia(vodConfig, vodDictDO.getVodCode());
VodUtil.processMedia(vodConfig, addVodDictDTO.getVodCode());
}
}
......@@ -109,4 +129,13 @@ public class VodDictServiceImpl extends ServiceImpl<VodDictMapper, VodDictDO> im
}
}
@Override
public IPage<VodDictDO> queryVodPage(VodDictPageDTO vodDictPageDTO) {
Page page = new Page(vodDictPageDTO.getPageNum(), vodDictPageDTO.getPageSize());
return this.baseMapper.selectPage(page, new QueryWrapper<VodDictDO>()
.lambda()
.eq(VodDictDO::getLabelId, vodDictPageDTO.getLabelId())
.like(StringUtils.isNotBlank(vodDictPageDTO.getVodName()), VodDictDO::getVodName, vodDictPageDTO.getVodName()));
}
}
package com.subsidy.util.websocket;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.ResponseData;
import com.subsidy.mapper.ClassDictMapper;
......@@ -99,9 +101,11 @@ public class WebSocketUtil implements WebSocketHandler {
}
webSocketMap.put(id, session);
List<ClassSettingsVO> list = classDictMapper.getClassSettings(id);
if(CollectionUtils.isNotEmpty(list)) {
webSocketMap.get(id).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, list))));
/* 班级配置信息 */
List<ClassSettingsVO> classSettings = classDictMapper.getClassSettings(id);
if(CollectionUtils.isNotEmpty(classSettings)) {
String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, classSettings), SerializerFeature.WriteMapNullValue);
webSocketMap.get(id).sendMessage(new TextMessage(data));
}
String httpSessionId = session.getId();
......
package com.subsidy.vo.businessScope;
import lombok.Data;
import java.util.List;
@Data
public class BusinessScopeDictVO {
private Long id;
private Long parentId;
private String businessScopeName;
private List<BusinessScopeDictVO> childNode;
}
......@@ -5,6 +5,8 @@ import lombok.Data;
@Data
public class ClassSettingsVO {
private Long id;
/**
* 是否按照顺序播放
*/
......@@ -60,13 +62,7 @@ public class ClassSettingsVO {
*/
private Integer playSnap;
/**
*
*/
private Integer ipAddressRecord;
/**
*
*/
private Integer deviceNoRecord;
}
......@@ -8,6 +8,7 @@
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="delete_date" property="deleteDate" />
<result column="parent_id" property="parentId" />
<result column="business_scope_name" property="businessScopeName" />
</resultMap>
......@@ -16,7 +17,17 @@
create_date,
update_date,
delete_date,
id, business_scope_name
id, parent_id, business_scope_name
</sql>
<select id="queryBusinessScopePage" resultType="com.subsidy.vo.businessScope.BusinessScopeDictVO">
select * from business_scope_dict
<where>
<if test="businessScopeName != null">
business_scope_name like concat('%', #{businessScopeName} ,'%')
</if>
delete_date is null
</where>
</select>
</mapper>
......@@ -18,7 +18,7 @@
create_date,
update_date,
delete_date,
id, content_id, vod_id, order_no
id, content_id, vod_id, vod_alias_name, order_no
</sql>
</mapper>
......@@ -47,7 +47,7 @@
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t3.delete_date IS NULL
AND t.content_id = #{contentId}
AND t3.content_id = #{contentId}
<if test="vodName != null and vodName !=''">
and vod_name like concat('%',#{vodName} ,'%')
</if>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!