فهرست منبع

Merge remote-tracking branch 'origin/master'

liweifan 3 سال پیش
والد
کامیت
68257966c8
17فایلهای تغییر یافته به همراه657 افزوده شده و 30 حذف شده
  1. 1 1
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/AdminFeignService.java
  2. 2 0
      cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/NoRepliedTeacherTask.java
  3. 7 0
      cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/SysConfigController.java
  4. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseHomeworkServiceImpl.java
  5. 4 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImNetworkRoomServiceImpl.java
  6. 22 23
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java
  7. 15 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/EndType.java
  8. 48 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/FlagIndex.java
  9. 249 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordContext.java
  10. 216 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordFilter.java
  11. 15 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordType.java
  12. 14 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/annotation/CheckWord.java
  13. 42 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/annotation/CheckWordAspect.java
  14. 2 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseHomeworkMapper.xml
  15. 3 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  16. 8 0
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/SysConfigController.java
  17. 8 0
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/SysConfigController.java

+ 1 - 1
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/AdminFeignService.java

@@ -39,7 +39,7 @@ public interface AdminFeignService {
     /**
      * 老师作业布置通知
      */
-    @GetMapping("/task/teacherSend")
+    @PostMapping("/task/teacherSend")
     HttpResponseResult<Object> sendTodayNotRepliedAndNotDecorateHomework();
 
     //老师课酬

+ 2 - 0
cooleshow-task/src/main/java/com/yonge/cooleshow/task/jobs/NoRepliedTeacherTask.java

@@ -4,11 +4,13 @@ import com.yonge.cooleshow.api.feign.StudentFeignService;
 import com.yonge.cooleshow.task.core.BaseTask;
 import com.yonge.cooleshow.task.core.TaskException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 /**
  * @Author: cy
  * @Date: 2022/5/6
  */
+@Service
 public class NoRepliedTeacherTask extends BaseTask {
 
     @Autowired

+ 7 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/SysConfigController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.admin.controller;
 
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.utils.http.HttpUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -106,4 +107,10 @@ public class SysConfigController extends BaseController {
 		}
 		return succeed(sysConfigService.findConfigValue(paramName));
 	}
+
+	@ApiOperation(value = "url短链接")
+	@PostMapping("shortURL")
+	public HttpResponseResult<String> shortURL(String orginURL) {
+		return succeed(HttpUtil.getSortUrl(orginURL));
+	}
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseHomeworkServiceImpl.java

@@ -122,7 +122,7 @@ public class CourseHomeworkServiceImpl extends ServiceImpl<CourseHomeworkDao, Co
         }
 
 
-        // 声部信息 群组信息
+        // 声部信息 群组 课程信息
         List<CourseHomeworkVo> subjectList = baseMapper.selectSubjectAndGroupInfoList(recordIdList);
 
         if (CollectionUtils.isEmpty(subjectList)) {

+ 4 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImNetworkRoomServiceImpl.java

@@ -156,11 +156,13 @@ public class ImNetworkRoomServiceImpl extends ServiceImpl<ImNetworkRoomDao, ImNe
         }
         Date now = new Date();
         //获取房间信息
-        this.initRoom(roomId, Long.parseLong(roomId), userRole, userId, now);
+        ImNetworkRoom room = this.initRoom(roomId, Long.parseLong(roomId), userRole, userId, now);
         //获取房间用户信息
         ImNetworkRoomMember roomMember = imNetworkRoomMemberService.initRoomMember(roomId,sysUser,userRole);
         //发送人员变动消息
         publishMemberChangedMessage(roomMember);
+        //sendDisplay
+        this.sendDisplay(userId,room);
     }
 
     //发送人员变动消息
@@ -607,7 +609,7 @@ public class ImNetworkRoomServiceImpl extends ServiceImpl<ImNetworkRoomDao, ImNe
         }else {
             if(userRole == UserRoleEnum.TEACHER){
                 room.setDisplay(display);
-                this.updateDisplay(userId,room);
+                baseMapper.updateById(room);
             }
         }
         return room;

+ 22 - 23
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.beust.jcommander.internal.Lists;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
@@ -35,6 +34,7 @@ import java.time.LocalDate;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -104,7 +104,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     public PageInfo<LiveRoom> queryPageRoom(Map<String, Object> param) {
         String roomType = WrapperUtil.toStr(param, "roomType");
         Integer liveState = WrapperUtil.toInt(param, "liveState");
-        Long userId = getSysUser().getId();
+        Long userId = this.getSysUser().getId();
         Page<LiveRoom> pageInfo = PageUtil.getPageInfo(param);
         IPage<LiveRoom> page = this.page(pageInfo, Wrappers.<LiveRoom>lambdaQuery()
                 .eq(WrapperUtil.StrPredicate.test(roomType), LiveRoom::getType, roomType)
@@ -122,7 +122,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      */
     @Override
     public RoomInfoCache studentCheckRoomInfo(String roomUid) {
-        return checkStudentRoom(roomUid, getSysUser());
+        return this.checkStudentRoom(roomUid, this.getSysUser());
     }
 
     /**
@@ -133,7 +133,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      */
     @Override
     public RoomInfoCache speakerCheckRoomInfo(String roomUid) {
-        Long userId = getSysUser().getId();
+        Long userId = this.getSysUser().getId();
         LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery()
                 .eq(LiveRoom::getRoomUid, roomUid));
         if (Objects.isNull(liveRoom)) {
@@ -224,9 +224,9 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             room.setCreatedTime(now);
             this.save(room);
             //去融云创建房间及创建房间缓存信息
-            createLiveRoomInfo(room);
+            this.createLiveRoomInfo(room);
             //开课提醒
-            pushLiveCreateRoom(room);
+            this.pushLiveCreateRoom(room);
         });
     }
 
@@ -236,7 +236,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     private void pushLiveCreateRoom(LiveRoom room) {
         try {
             //查询老师信息
-            SysUser teacherInfo = getSysUser(room.getSpeakerId());
+            SysUser teacherInfo = this.getSysUser(room.getSpeakerId());
             //极光-消息推送
             Map<Long, String> teacherMap = new HashMap<>();
             teacherMap.put(teacherInfo.getId(), teacherInfo.getPhone());
@@ -257,7 +257,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     @Transactional(rollbackFor = Exception.class)
     public String createTempLiveRoom(Map<String, Object> param) {
         //查询主讲人信息
-        SysUser sysUser = getSysUser();
+        SysUser sysUser = this.getSysUser();
         Long teacherId = sysUser.getId();
         List<LiveRoom> liveRoomList = this.list(Wrappers.<LiveRoom>lambdaQuery()
                 .eq(LiveRoom::getSpeakerId, teacherId)
@@ -307,7 +307,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      */
     private void createLiveRoomInfo(LiveRoom room) {
         //查询主讲人信息
-        SysUser sysUser = getSysUser(room.getSpeakerId());
+        SysUser sysUser = this.getSysUser(room.getSpeakerId());
         this.createLiveRoomInfo(room, sysUser);
     }
 
@@ -445,15 +445,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         String roomUid = room.getRoomUid();
 
         //删除房间全部人员缓存
-        getTotalUserCache(roomUid).deleteAsync();
+        this.getTotalUserCache(roomUid).deleteAsync();
         //获取在线人员信息
-        RMap<Long, String> onlineUserCache = getOnlineUserCache(roomUid);
+        RMap<Long, String> onlineUserCache = this.getOnlineUserCache(roomUid);
         //删除人员对应直播间编号信息
         onlineUserCache.forEach((id, s) -> redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, id.toString())).deleteAsync());
         //删除房间在线人员缓存
         onlineUserCache.deleteAsync();
         //删除房间信息
-        getLiveRoomInfo(room.getRoomUid()).deleteAsync();
+        this.getLiveRoomInfo(room.getRoomUid()).deleteAsync();
         //删除点赞数
         redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, room.getRoomUid())).deleteAsync();
         //删除当前主讲人最后一次进入房间的ip
@@ -485,8 +485,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     private void ImDestroyLiveRoom(String roomId) {
         try {
             //删除服务器房间
-            List<String> deleteRoomIds = Lists.newArrayList(roomId);
-            IMApiResultInfo resultInfo = imHelper.deleteChrm(deleteRoomIds);
+            IMApiResultInfo resultInfo = imHelper.deleteChrm(Collections.singletonList(roomId));
             if (!resultInfo.isSuccess()) {
                 log.error("destroyLiveRoom error" + resultInfo.getErrorMessage());
             }
@@ -532,7 +531,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             }
             String roomUid = userRoom.get();
             //根据房间号获取房间信息
-            RBucket<RoomInfoCache> roomInfoCache = getLiveRoomInfo(roomUid);
+            RBucket<RoomInfoCache> roomInfoCache = this.getLiveRoomInfo(roomUid);
             if (!roomInfoCache.isExists()) {
                 return;
             }
@@ -549,7 +548,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             //用户id
             Long userId = Long.valueOf(userIdStr);
             //从房间累计用户信息中查询该用户的信息
-            RMap<Long, String> roomTotalUser = getTotalUserCache(roomUid);
+            RMap<Long, String> roomTotalUser = this.getTotalUserCache(roomUid);
             //该房间未查询到用户数据则不处理
             if (!roomTotalUser.isExists() && !roomTotalUser.containsKey(userId)) {
                 return;
@@ -560,7 +559,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             String userJsonStr = JSONObject.toJSONString(userInfo);
             roomTotalUser.fastPut(userId, userJsonStr);
             //查询在线人员列表
-            RMap<Long, String> onlineUserInfo = getOnlineUserCache(roomUid);
+            RMap<Long, String> onlineUserInfo = this.getOnlineUserCache(roomUid);
             if (!onlineUserInfo.isExists()) {
                 return;
             }
@@ -635,7 +634,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             }
         }
         //如果退出时间大于进入时间就无需再次退出-直接返回
-        if (compareDate.apply(roomInfo.getExitRoomTime(), roomInfo.getJoinRoomTime())) {
+        if (compareDate.test(roomInfo.getExitRoomTime(), roomInfo.getJoinRoomTime())) {
             return;
         }
 
@@ -666,7 +665,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      * <p>- date1 时间1
      * <p>- date2 时间2
      */
-    private final BiFunction<Date, Date, Boolean> compareDate = (date1, date2) -> {
+    private final BiPredicate<Date, Date> compareDate = (date1, date2) -> {
         if (Objects.nonNull(date1) && Objects.nonNull(date2)) {
             return date1.getTime() > date2.getTime();
         } else {
@@ -753,7 +752,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     //校验学生与房间的关系
     private RoomInfoCache checkStudentRoom(String roomUid, SysUser sysUser) {
         //校验房间是否存在
-        RBucket<RoomInfoCache> roomInfoCache = getLiveRoomInfo(roomUid);
+        RBucket<RoomInfoCache> roomInfoCache = this.getLiveRoomInfo(roomUid);
         if (!roomInfoCache.isExists()) {
             throw new BizException("直播还未开始!");
         }
@@ -987,7 +986,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         //result
         Map<String, Object> result = new HashMap<>();
         //获取房间信息
-        RBucket<RoomInfoCache> speakerCache = getLiveRoomInfo(roomUid);
+        RBucket<RoomInfoCache> speakerCache = this.getLiveRoomInfo(roomUid);
         if (speakerCache.isExists()) {
             result.put("房间信息信息", speakerCache.get());
         } else {
@@ -1013,7 +1012,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         int look = 0;
 
         //累计总观看的用户数量
-        List<RoomUserInfoCache> totalUserInfo = getTotalUserInfo(roomUid);
+        List<RoomUserInfoCache> totalUserInfo = this.getTotalUserInfo(roomUid);
         if (CollectionUtils.isNotEmpty(totalUserInfo)) {
             totalLook = totalUserInfo.size();
             result.put("总人员数据", totalUserInfo);
@@ -1022,7 +1021,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         }
         result.put("总观看人数", totalLook);
         //正在房间观看的用户数据
-        List<RoomUserInfoCache> onlineUserInfo = getOnlineUserInfo(roomUid);
+        List<RoomUserInfoCache> onlineUserInfo = this.getOnlineUserInfo(roomUid);
         if (CollectionUtils.isNotEmpty(onlineUserInfo)) {
             look = onlineUserInfo.size();
             result.put("正在观看的人员信息", onlineUserInfo);

+ 15 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/EndType.java

@@ -0,0 +1,15 @@
+package com.yonge.cooleshow.biz.dal.wordfilter;
+
+/**
+ * 结束类型定义
+ *
+ * @author minghu.zhang
+ * @date 11:37 2020/11/11
+ **/
+public enum EndType {
+
+    /**
+     * 有下一个,结束
+     */
+    HAS_NEXT, IS_END
+}

+ 48 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/FlagIndex.java

@@ -0,0 +1,48 @@
+package com.yonge.cooleshow.biz.dal.wordfilter;
+
+import java.util.List;
+
+/**
+ * 敏感词标记
+ *
+ * @author minghu.zhang
+ */
+public class FlagIndex {
+
+    /**
+     * 标记结果
+     */
+    private boolean flag;
+    /**
+     * 是否黑名单词汇
+     */
+    private boolean isWhiteWord;
+    /**
+     * 标记索引
+     */
+    private List<Integer> index;
+
+    public boolean isFlag() {
+        return flag;
+    }
+
+    public void setFlag(boolean flag) {
+        this.flag = flag;
+    }
+
+    public List<Integer> getIndex() {
+        return index;
+    }
+
+    public void setIndex(List<Integer> index) {
+        this.index = index;
+    }
+
+    public boolean isWhiteWord() {
+        return isWhiteWord;
+    }
+
+    public void setWhiteWord(boolean whiteWord) {
+        isWhiteWord = whiteWord;
+    }
+}

+ 249 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordContext.java

@@ -0,0 +1,249 @@
+package com.yonge.cooleshow.biz.dal.wordfilter;
+
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
+import com.yonge.toolset.base.exception.BizException;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.PostConstruct;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.*;
+
+/**
+ * 词库上下文环境
+ * <p>
+ * 初始化敏感词库,将敏感词加入到HashMap中,构建DFA算法模型
+ *
+ * @author minghu.zhang
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+@Configuration
+public class WordContext {
+    private final static Logger log = LoggerFactory.getLogger(WordContext.class);
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    /**
+     * 敏感词字典
+     */
+    private final Map wordMap = new HashMap(1024);
+
+    /**
+     * 是否已初始化
+     */
+    private boolean init;
+    /**
+     * 黑名单列表
+     */
+    private String blackList;
+    /**
+     * 白名单列表
+     */
+    private String whiteList;
+
+    @PostConstruct
+    public void init() {
+        this.blackList = sysConfigService.findConfigValue(SysConfigConstant.BLACK_LIST);
+        this.whiteList = sysConfigService.findConfigValue(SysConfigConstant.WHITE_LIST);
+        initKeyWord();
+    }
+
+    /**
+     * 获取初始化的敏感词列表
+     *
+     * @return 敏感词列表
+     */
+    public Map getWordMap() {
+        return wordMap;
+    }
+
+    /**
+     * 初始化
+     */
+    private synchronized void initKeyWord() {
+        try {
+            if (!init) {
+                // 将敏感词库加入到HashMap中
+                addWord(strToSet(blackList), WordType.BLACK);
+                // 将非敏感词库也加入到HashMap中
+                addWord(strToSet(whiteList), WordType.WHITE);
+            }
+            init = true;
+        } catch (Exception e) {
+            log.error("初始化失败:" + e);
+            throw new BizException("敏感词列表初始化失败");
+        }
+    }
+
+    /**
+     * 读取敏感词库,将敏感词放入HashSet中,构建一个DFA算法模型:<br>
+     * 中 = { isEnd = 0 国 = {<br>
+     * isEnd = 1 人 = {isEnd = 0 民 = {isEnd = 1} } 男 = { isEnd = 0 人 = { isEnd = 1 }
+     * } } } 五 = { isEnd = 0 星 = { isEnd = 0 红 = { isEnd = 0 旗 = { isEnd = 1 } } } }
+     */
+    public void addWord(Iterable<String> wordList, WordType wordType) {
+        Map nowMap;
+        Map<String, String> newWorMap;
+        // 迭代keyWordSet
+        for (String key : wordList) {
+            nowMap = wordMap;
+            for (int i = 0; i < key.length(); i++) {
+                // 转换成char型
+                char keyChar = key.charAt(i);
+                // 获取
+                Object wordMap = nowMap.get(keyChar);
+                // 如果存在该key,直接赋值
+                if (wordMap != null) {
+                    nowMap = (Map) wordMap;
+                } else {
+                    // 不存在则构建一个map,同时将isEnd设置为0,因为他不是最后一个
+                    newWorMap = new HashMap<>(4);
+                    // 不是最后一个
+                    newWorMap.put("isEnd", String.valueOf(EndType.HAS_NEXT.ordinal()));
+                    nowMap.put(keyChar, newWorMap);
+                    nowMap = newWorMap;
+                }
+
+                if (i == key.length() - 1) {
+                    // 最后一个
+                    nowMap.put("isEnd", String.valueOf(EndType.IS_END.ordinal()));
+                    nowMap.put("isWhiteWord", String.valueOf(wordType.ordinal()));
+                }
+            }
+        }
+    }
+
+    /**
+     * 修改敏感词后初始化
+     */
+    public void mapInit() {
+        init = false;
+        this.blackList = sysConfigService.findConfigValue(SysConfigConstant.BLACK_LIST);
+        this.whiteList = sysConfigService.findConfigValue(SysConfigConstant.WHITE_LIST);
+        wordMap.clear();
+        initKeyWord();
+        /*Map nowMap;
+        for (String key : wordList) {
+            List<Map> cacheList = new ArrayList<>();
+            nowMap = wordMap;
+            for (int i = 0; i < key.length(); i++) {
+                char keyChar = key.charAt(i);
+
+                Object map = nowMap.get(keyChar);
+                if (map != null) {
+                    nowMap = (Map) map;
+                    cacheList.add(nowMap);
+                } else {
+                    return;
+                }
+
+                if (i == key.length() - 1) {
+                    char[] keys = key.toCharArray();
+                    boolean cleanable = false;
+                    char lastChar = 0;
+                    for (int j = cacheList.size() - 1; j >= 0; j--) {
+                        Map cacheMap = cacheList.get(j);
+                        if (j == cacheList.size() - 1) {
+                            if (String.valueOf(WordType.BLACK.ordinal()).equals(cacheMap.get("isWhiteWord"))) {
+                                if (wordType == WordType.WHITE) {
+                                    return;
+                                }
+                            }
+                            if (String.valueOf(WordType.WHITE.ordinal()).equals(cacheMap.get("isWhiteWord"))) {
+                                if (wordType == WordType.BLACK) {
+                                    return;
+                                }
+                            }
+                            cacheMap.remove("isWhiteWord");
+                            cacheMap.remove("isEnd");
+                            if (cacheMap.size() == 0) {
+                                cleanable = true;
+                                continue;
+                            }
+                        }
+                        if (cleanable) {
+                            Object isEnd = cacheMap.get("isEnd");
+                            if (String.valueOf(EndType.IS_END.ordinal()).equals(isEnd)) {
+                                cleanable = false;
+                            }
+                            cacheMap.remove(lastChar);
+                        }
+                        lastChar = keys[j];
+                    }
+
+                    if (cleanable) {
+                        wordMap.remove(lastChar);
+                    }
+                }
+            }
+        }*/
+    }
+
+    /**
+     * 删除敏感词
+     * @param paramName 黑/白名单(black_list/white_list)
+     * @param word 敏感词
+     */
+    public void removeWord(String paramName, String word) {
+        if (!paramName.equals(SysConfigConstant.BLACK_LIST) && !paramName.equals(SysConfigConstant.WHITE_LIST)) {
+            throw new BizException("paramName不合法");
+        }
+        Set<String> list = strToSet(sysConfigService.findConfigValue(paramName));
+        list.removeIf(s -> s.equals(word));
+        sysConfigService.updateByName(paramName, list.toString().replaceAll("(?:\\[|null|\\]| +)", ""));
+        mapInit();
+    }
+
+    /**
+     * 添加敏感词
+     * @param paramName 黑/白名单(black_list/white_list)
+     * @param word 敏感词
+     */
+    public void addWord(String paramName, String word) {
+        if (!paramName.equals(SysConfigConstant.BLACK_LIST) && !paramName.equals(SysConfigConstant.WHITE_LIST)) {
+            throw new BizException("paramName不合法");
+        }
+        Set<String> list = strToSet(sysConfigService.findConfigValue(paramName));
+        list.add(word);
+        sysConfigService.updateByName(paramName, list.toString().replaceAll("(?:\\[|null|\\]| +)", ""));
+        mapInit();
+    }
+
+    /**
+     * 读取敏感词库中的内容,将内容添加到set集合中
+     */
+    private Set<String> readWordFile(String file) throws Exception {
+        Set<String> set;
+        // 字符编码
+        String encoding = "UTF-8";
+        try (InputStreamReader read = new InputStreamReader(
+                this.getClass().getResourceAsStream(file), encoding)) {
+            set = new HashSet<>();
+            BufferedReader bufferedReader = new BufferedReader(read);
+            String txt;
+            // 读取文件,将文件内容放入到set中
+            while ((txt = bufferedReader.readLine()) != null) {
+                set.add(txt);
+            }
+        }
+        // 关闭文件流
+        return set;
+    }
+
+    /**
+     * 字符串转set
+     */
+    private Set<String> strToSet(String str) {
+        if (StringUtils.isNotBlank(str)){
+            String[] split = str.split(",");
+            return new HashSet<>(Arrays.asList(split));
+        }
+        return new HashSet<>();
+    }
+}

+ 216 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordFilter.java

@@ -0,0 +1,216 @@
+package com.yonge.cooleshow.biz.dal.wordfilter;
+
+import org.springframework.context.annotation.Configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 敏感词过滤器
+ *
+ * @author minghu.zhang
+ */
+@SuppressWarnings("rawtypes")
+@Configuration
+public class WordFilter {
+    /**
+     * 敏感词表
+     */
+    private final Map wordMap;
+
+    /**
+     * 构造函数
+     */
+    public WordFilter(WordContext context) {
+        this.wordMap = context.getWordMap();
+    }
+
+    /**
+     * 替换敏感词
+     *
+     * @param text 输入文本
+     */
+    public String replace(final String text) {
+        return replace(text, 0, '*');
+    }
+
+    /**
+     * 替换敏感词
+     *
+     * @param text   输入文本
+     * @param symbol 替换符号
+     */
+    public String replace(final String text, final char symbol) {
+        return replace(text, 0, symbol);
+    }
+
+    /**
+     * 替换敏感词
+     *
+     * @param text   输入文本
+     * @param skip   文本距离
+     * @param symbol 替换符号
+     */
+    public String replace(final String text, final int skip, final char symbol) {
+        char[] charset = text.toCharArray();
+        for (int i = 0; i < charset.length; i++) {
+            FlagIndex fi = getFlagIndex(charset, i, skip);
+            if (fi.isFlag()) {
+                if (!fi.isWhiteWord()) {
+                    for (int j : fi.getIndex()) {
+                        charset[j] = symbol;
+                    }
+                } else {
+                    i += fi.getIndex().size() - 1;
+                }
+            }
+        }
+        return new String(charset);
+    }
+
+    /**
+     * 是否包含敏感词
+     *
+     * @param text 输入文本
+     */
+    public boolean include(final String text) {
+        return include(text, 0);
+    }
+
+    /**
+     * 是否包含敏感词
+     *
+     * @param text 输入文本
+     * @param skip 文本距离
+     */
+    public boolean include(final String text, final int skip) {
+        boolean include = false;
+        char[] charset = text.toCharArray();
+        for (int i = 0; i < charset.length; i++) {
+            FlagIndex fi = getFlagIndex(charset, i, skip);
+            if (fi.isFlag()) {
+                if (fi.isWhiteWord()) {
+                    i += fi.getIndex().size() - 1;
+                } else {
+                    include = true;
+                    break;
+                }
+            }
+        }
+        return include;
+    }
+
+    /**
+     * 获取敏感词数量
+     *
+     * @param text 输入文本
+     */
+    public int wordCount(final String text) {
+        return wordCount(text, 0);
+    }
+
+    /**
+     * 获取敏感词数量
+     *
+     * @param text 输入文本
+     * @param skip 文本距离
+     */
+    public int wordCount(final String text, final int skip) {
+        int count = 0;
+        char[] charset = text.toCharArray();
+        for (int i = 0; i < charset.length; i++) {
+            FlagIndex fi = getFlagIndex(charset, i, skip);
+            if (fi.isFlag()) {
+                if (fi.isWhiteWord()) {
+                    i += fi.getIndex().size() - 1;
+                } else {
+                    count++;
+                }
+            }
+        }
+        return count;
+    }
+
+    /**
+     * 获取敏感词列表
+     *
+     * @param text 输入文本
+     */
+    public List<String> wordList(final String text) {
+        return wordList(text, 0);
+    }
+
+    /**
+     * 获取敏感词列表
+     *
+     * @param text 输入文本
+     * @param skip 文本距离
+     */
+    public List<String> wordList(final String text, final int skip) {
+        List<String> wordList = new ArrayList<>();
+        char[] charset = text.toCharArray();
+        for (int i = 0; i < charset.length; i++) {
+            FlagIndex fi = getFlagIndex(charset, i, skip);
+            if (fi.isFlag()) {
+                if (fi.isWhiteWord()) {
+                    i += fi.getIndex().size() - 1;
+                } else {
+                    StringBuilder builder = new StringBuilder();
+                    for (int j : fi.getIndex()) {
+                        char word = text.charAt(j);
+                        builder.append(word);
+                    }
+                    wordList.add(builder.toString());
+                }
+            }
+        }
+        return wordList;
+    }
+
+    /**
+     * 获取标记索引
+     *
+     * @param charset 输入文本
+     * @param begin   检测起始
+     * @param skip    文本距离
+     */
+    private FlagIndex getFlagIndex(final char[] charset, final int begin, final int skip) {
+        FlagIndex fi = new FlagIndex();
+
+        Map current = wordMap;
+        boolean flag = false;
+        int count = 0;
+        List<Integer> index = new ArrayList<>();
+        for (int i = begin; i < charset.length; i++) {
+            char word = charset[i];
+            Map mapTree = (Map) current.get(word);
+            if (count > skip || (i == begin && Objects.isNull(mapTree))) {
+                break;
+            }
+            if (Objects.nonNull(mapTree)) {
+                current = mapTree;
+                count = 0;
+                index.add(i);
+            } else {
+                count++;
+                if (flag && count > skip) {
+                    break;
+                }
+            }
+            if ("1".equals(current.get("isEnd"))) {
+                flag = true;
+            }
+            if ("1".equals(current.get("isWhiteWord"))) {
+                fi.setWhiteWord(true);
+                break;
+            }
+        }
+
+        fi.setFlag(flag);
+        fi.setIndex(index);
+
+        return fi;
+    }
+}

+ 15 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordType.java

@@ -0,0 +1,15 @@
+package com.yonge.cooleshow.biz.dal.wordfilter;
+
+/**
+ * 词汇类型
+ *
+ * @author minghu.zhang
+ * @date 11:37 2020/11/11
+ **/
+public enum WordType {
+
+    /**
+     * 黑名单/白名单
+     */
+    BLACK, WHITE
+}

+ 14 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/annotation/CheckWord.java

@@ -0,0 +1,14 @@
+package com.yonge.cooleshow.biz.dal.wordfilter.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @Description: 敏感词校验/过滤
+ * @Author: cy
+ * @Date: 2022/7/6
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface CheckWord {
+}

+ 42 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/annotation/CheckWordAspect.java

@@ -0,0 +1,42 @@
+package com.yonge.cooleshow.biz.dal.wordfilter.annotation;
+
+import com.alibaba.fastjson.JSON;
+import com.yonge.cooleshow.biz.dal.wordfilter.WordFilter;
+import com.yonge.toolset.base.exception.BizException;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description: 敏感词过滤切面
+ * @Author: cy
+ * @Date: 2022/7/6
+ */
+@Aspect
+@Order(1)
+@Component
+public class CheckWordAspect {
+    @Autowired
+    private WordFilter wordFilter;
+    @Autowired
+    RedissonClient redissonClient;
+
+    @Pointcut("@annotation(com.yonge.cooleshow.biz.dal.wordfilter.annotation.CheckWord)")
+    private void checkWord() {
+    }
+
+    @Around("checkWord()")
+    public Object checkWord(ProceedingJoinPoint joinPoint) throws Throwable {
+        Object[] args = joinPoint.getArgs();
+        String text = JSON.toJSONString(args);
+        if (wordFilter.include(text, 3)) {
+            throw new BizException("文本包含敏感信息:{}", wordFilter.wordList(text));
+        }
+        return joinPoint.proceed();
+    }
+}

+ 2 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseHomeworkMapper.xml

@@ -194,7 +194,7 @@
         ,sch.attachments_ as studentAttachments
         ,sch.teacher_replied_ as teacherReplied
         ,cg.id_ as courseGroupId
-        ,cg.name_ as courseGroupName
+        ,concat(cg.name_,'-第',cs.class_num_,'课') as courseGroupName
         ,cs.class_num_ as classNum
         ,sch.submit_time_ as submitTime
         ,sch.id_ as studentHomeworkId
@@ -282,7 +282,7 @@
         select
         cs.id_ as courseId,
         s.name_ as subjectName
-        ,cg.name_ as courseGroupName
+        ,concat(cg.name_,'-第',cs.class_num_,'课') as courseGroupName
         ,cg.background_pic_ as backgroundPic
         ,cs.class_num_ as classNum
         ,ig.id_ as imGroupId

+ 3 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -343,6 +343,7 @@
         LEFT JOIN im_group i ON g.id_ = i.course_group_id_
         WHERE cs.lock_=0
         AND cs.status_ IN ('ING','COMPLETE','NOT_START')
+        AND g.status_ IN ('ING', 'COMPLETE')
         AND cs.type_ IN ('LIVE','PIANO_ROOM_CLASS')
         AND cs.teacher_id_=#{param.teacherId}
         AND cs.class_date_=#{param.classDate}
@@ -508,6 +509,7 @@
         LEFT JOIN (SELECT course_id_,COUNT(1) AS payCount FROM course_schedule_student_payment GROUP BY course_id_) a ON s.id_=a.course_id_
         WHERE s.lock_=0
         AND s.status_ IN ('ING','NOT_START','COMPLETE')
+        AND g.status_ IN ('ING', 'COMPLETE')
         AND s.id_ IN
         (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ IN ('LIVE','PIANO_ROOM_CLASS'))
         AND s.class_date_ = #{param.classDate}
@@ -734,7 +736,7 @@
     <select id="selectTypeCount" resultType="com.yonge.cooleshow.biz.dal.vo.CountVo">
         SELECT
             s.type_ AS type,
-            COUNT(1) AS count
+            COUNT(1) AS `count`
         FROM course_schedule s
         LEFT JOIN course_group g ON s.course_group_id_=g.id_
         WHERE s.lock_=0

+ 8 - 0
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/SysConfigController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.student.controller;
 
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.utils.http.HttpUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -12,6 +13,7 @@ import java.util.Map;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -73,4 +75,10 @@ public class SysConfigController extends BaseController {
 		List<String> paramNameList = Arrays.asList(paramNames.split(","));
 		return succeed(sysConfigService.findByParamName(paramNameList));
 	}
+
+	@ApiOperation(value = "url短链接")
+	@PostMapping("shortURL")
+	public HttpResponseResult<String> shortURL(String orginURL) {
+		return succeed(HttpUtil.getSortUrl(orginURL));
+	}
 }

+ 8 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/SysConfigController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.teacher.controller;
 
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.utils.http.HttpUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -12,6 +13,7 @@ import java.util.Map;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -73,4 +75,10 @@ public class SysConfigController extends BaseController {
 		List<String> paramNameList = Arrays.asList(paramNames.split(","));
 		return succeed(sysConfigService.findByParamName(paramNameList));
 	}
+
+	@ApiOperation(value = "url短链接")
+	@PostMapping("shortURL")
+	public HttpResponseResult<String> shortURL(String orginURL) {
+		return succeed(HttpUtil.getSortUrl(orginURL));
+	}
 }