Merge remote-tracking branch 'origin/master'
| | |
| | | <scope>runtime</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-beanutils</groupId> |
| | | <artifactId>commons-beanutils</artifactId> |
| | | <version>1.7.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-codec</groupId> |
| | | <artifactId>commons-codec</artifactId> |
| | | <version>1.4</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-collections</groupId> |
| | | <artifactId>commons-collections</artifactId> |
| | | <version>3.2.1</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-httpclient</groupId> |
| | | <artifactId>commons-httpclient</artifactId> |
| | | <version>3.0.1</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-beanutils</groupId> |
| | | <artifactId>commons-beanutils</artifactId> |
| | | <version>1.9.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-collections</groupId> |
| | | <artifactId>commons-collections</artifactId> |
| | | <version>3.2.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-lang</groupId> |
| | | <artifactId>commons-lang</artifactId> |
| | | <version>2.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-logging</groupId> |
| | | <artifactId>commons-logging</artifactId> |
| | | <version>1.1.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.sf.ezmorph</groupId> |
| | | <artifactId>ezmorph</artifactId> |
| | | <version>1.0.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.sf.json-lib</groupId> |
| | | <artifactId>json-lib</artifactId> |
| | | <version>2.2.3</version> |
| | | <classifier>jdk15</classifier><!-- 指定jdk版本 --> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.httpcomponents</groupId> |
| | | <artifactId>httpclient</artifactId> |
| | | <version>4.5.2</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | <build> |
| | | <plugins> |
New file |
| | |
| | | package com.qxueyou.scc.Sensitive; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | public class List extends ArrayList<Word> { |
| | | public Word get(char c){ |
| | | for(Word w :this){ |
| | | if(w.c == c) return w; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 二分查找,必须先升序排序 |
| | | * @param c 需要查找的字符 |
| | | * @return Word对象:如果找到 null:如果没找到 |
| | | */ |
| | | public Word binaryGet(char c){ |
| | | int left,right,key; |
| | | Word word; |
| | | left = 0;right = this.size()-1; |
| | | while (left <= right){ |
| | | key = (left + right) / 2; |
| | | word = get(key); |
| | | if(word.c == c){ |
| | | return word; |
| | | }else if(word.c > c){ |
| | | right = key - 1; |
| | | }else { |
| | | left = key + 1; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public Word add(char c){ |
| | | Word word = new Word(c); |
| | | super.add(word); |
| | | return word; |
| | | } |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.Sensitive; |
| | | |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | |
| | | |
| | | public final class SensitiveWordFilter { |
| | | public static List wordList; |
| | | private final static char replace = '*'; // 替代字符 |
| | | private final static char[] skip = new char[]{ // 遇到这些字符就会跳过,例如,如果"AB"是敏感词,那么"A B","A=B"也会被屏蔽 |
| | | '!','*','-','+','_','=',',','.','@' |
| | | }; |
| | | |
| | | /** |
| | | * 敏感词替换 |
| | | * @param text 待替换文本 |
| | | * @return 替换后的文本 |
| | | */ |
| | | public static String Filter(String text){ |
| | | if(wordList == null || wordList.size() == 0) return text; |
| | | char[] __char__ = text.toCharArray(); // 把String转化成char数组,便于遍历 |
| | | int i,j; |
| | | Word word; |
| | | boolean flag; // 是否需要替换 |
| | | for(i=0;i<__char__.length;i++){ // 遍历所有字符 |
| | | char c = __char__[i]; |
| | | word = wordList.binaryGet(c); // 使用二分查找来寻找字符,提高效率 |
| | | if(word != null){ // word != null说明找到了 |
| | | flag = false; |
| | | j = i+1; |
| | | while (j < __char__.length){ // 开始逐个比较后面的字符 |
| | | if(skip(__char__[j])) { // 跳过空格之类的无关字符 |
| | | j++; |
| | | continue; |
| | | } |
| | | if(word.next != null){ // 字符串尚未结束,不确定是否存在敏感词 |
| | | /* |
| | | 以下代码并没有使用二分查找,因为以同一个字符开头的敏感词较少 |
| | | 例如,wordList中记录了所有敏感词的开头第一个字,它的数量通常会有上千个 |
| | | 假如现在锁定了字符“T”开头的敏感词,而“T”开头的敏感词只有10个,这时使用二分查找的效率反而低于顺序查找 |
| | | */ |
| | | word = word.next.get(__char__[j]); |
| | | if(word == null){ |
| | | break; |
| | | } |
| | | j++; |
| | | }else { // 字符串已结束,存在敏感词汇 |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | if(word != null && word.next == null){ |
| | | flag = true; |
| | | } |
| | | if(flag){ // 如果flag==true,说明检测出敏感粗,需要替换 |
| | | while (i<j){ |
| | | if(skip(__char__[i])){ // 跳过空格之类的无关字符,如果要把空格也替换成'*',则删除这个if语句 |
| | | i++; |
| | | continue; |
| | | } |
| | | __char__[i] = replace; |
| | | i++; |
| | | } |
| | | i--; |
| | | } |
| | | } |
| | | } |
| | | return new String(__char__); |
| | | } |
| | | |
| | | /** |
| | | * 加载敏感词列表 |
| | | * @param words 敏感词数组 |
| | | */ |
| | | public static void loadWord(ArrayList<String> words){ |
| | | if(words == null) return; |
| | | char[] chars; |
| | | List now; |
| | | Word word; |
| | | wordList = new List(); |
| | | for(String __word__:words){ |
| | | if(__word__ == null) continue; |
| | | chars = __word__.toCharArray(); |
| | | now = wordList; |
| | | word = null; |
| | | for(char c:chars){ |
| | | if(word != null) { |
| | | if(word.next == null) word.next = new List(); |
| | | now = word.next; |
| | | } |
| | | word = now.get(c); |
| | | if(word == null) word = now.add(c); |
| | | } |
| | | } |
| | | sort(wordList); |
| | | } |
| | | |
| | | /** |
| | | * 加载敏感词txt文件,每个敏感词独占一行,不可出现空格,空行,逗号等非文字内容,必须使用UTF-8编码 |
| | | * @param path txt文件的绝对地址 |
| | | */ |
| | | public static void loadWordFromFile(String path){ |
| | | String encoding = "UTF-8"; |
| | | File file = new File(path); |
| | | try{ |
| | | if(file.isFile() && file.exists()){ |
| | | InputStreamReader inputStreamReader = new InputStreamReader( |
| | | new FileInputStream(file),encoding |
| | | ); |
| | | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); |
| | | String line; |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | while ((line = bufferedReader.readLine()) != null){ |
| | | list.add(line); |
| | | } |
| | | bufferedReader.close(); |
| | | inputStreamReader.close(); |
| | | loadWord(list); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 对敏感词多叉树递增排序 |
| | | * @param list 待排序List |
| | | */ |
| | | private static void sort(List list){ |
| | | if(list == null) return; |
| | | Collections.sort(list); // 递增排序 |
| | | for(Word word:list){ |
| | | sort(word.next); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断是否跳过当前字符 |
| | | * @param c 待检测字符 |
| | | * @return true:需要跳过 false:不需要跳过 |
| | | */ |
| | | private static boolean skip(char c){ |
| | | for(char c1:skip){ |
| | | if(c1 == c) return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.Sensitive; |
| | | |
| | | public class Word implements Comparable<Word>{ |
| | | public char c; |
| | | public List next = null; |
| | | |
| | | public Word(char c){ |
| | | this.c = c; |
| | | } |
| | | |
| | | @Override |
| | | public int compareTo(Word word) { |
| | | return c - word.c; |
| | | } |
| | | |
| | | public String toString(){ |
| | | return c + "(" + (next == null ? null : next.size()) + ")"; |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public Result insertReClass(String className, String classNumber, Date startTime, Date endTime, String subjectId, |
| | | String teacherId,String classTypes) { |
| | | String teacherId,String classTypes) { |
| | | |
| | | ClsClass cls = new ClsClass(); |
| | | |
| | |
| | | save(cls); |
| | | return new Result(true, "success",CollectionUtils.newStringMap("classId",cls.getClassId())); |
| | | } |
| | | @Override |
| | | public ClsClass getReClass(String classTypes) { |
| | | String hql = "select c from ClsClass c where c.deleteFlag is false and c.classTypes=? "; |
| | | @Override |
| | | public ClsClass getReClass(String classTypes) { |
| | | String hql = "select c from ClsClass c where c.deleteFlag is false and c.classTypes=? "; |
| | | |
| | | ClsClass cls = findUnique(hql, CollectionUtils.newList(classTypes), |
| | | ClsClass.class); |
| | | return cls; |
| | | } |
| | | ClsClass cls = findUnique(hql, CollectionUtils.newList(classTypes), |
| | | ClsClass.class); |
| | | return cls; |
| | | } |
| | | |
| | | @Override |
| | | public Result updateClass(String classId, String className, String classNumber, Date startTime, Date endTime, |
| | |
| | | hql.append(" and c.endTime < sysdate() "); |
| | | } |
| | | // System.out.println("vvvvv"+ClientUtils.getOrgId()+"333333333"+ClientUtils.getUserId()); |
| | | List<Object> args = CollectionUtils.newList(ClientUtils.getOrgId(),keyword_ + "%","40288a1261d106ba0161d1072e260000"); |
| | | List<Object> args = CollectionUtils.newList(ClientUtils.getOrgId(),keyword_ + "%",ClientUtils.getUserId()); |
| | | // System.out.println(args); |
| | | if (!StringUtils.isEmpty(teacherId)) { |
| | | hql.append(" and exists( select 1 from ClsClassReSubject r,Subject t where r.subjectId=t.subjectId and c.classId= r.classId and t.teacherId=? and r.deleteFlag is false and t.deleteFlag is false)"); |
| | |
| | | if (pageType == 1) { |
| | | hql.append(" and c.endTime >= sysdate() "); |
| | | }else if(pageType == 2) { |
| | | hql.append(" and c.endTime < sysdate() "); |
| | | hql.append(" and c.endTime < sysdate() "); |
| | | } |
| | | |
| | | List<Object> args = CollectionUtils.newList(ClientUtils.getOrgId(),keyword + "%"); |
| | | |
| | | if (!StringUtils.isEmpty(teacherId)) { |
| | | hql.append(" and exists( select 1 from ClsClassReSubject r,Subject t where r.subjectId=t.subjectId and c.classId= r.classId and t.teacherId=? and r.deleteFlag is false and t.deleteFlag is false)"); |
| | | hql.append(" and exists( select 1 from ClsClassReSubject r,Subject t where r.subjectId=t.subjectId and c.classId= r.classId and t.teacherId=? and r.deleteFlag is false and t.deleteFlag is false)"); |
| | | args.add(teacherId); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<Map<String,Object>> queryAvailableClassIdAndName(String teacherId,String subjectId) { |
| | | StringBuffer hql = new StringBuffer(1000); |
| | | // and c.endTime>=sysdate() 增加条件过滤掉历史班级 |
| | | hql.append("select c.classId as classId ,c.name as className from ClsClass c where c.deleteFlag is false and c.orgId=:orgId and c.createId=:createId " ); |
| | | Map<String,Object> queryParam = new HashMap<String,Object>(); |
| | | queryParam.put("orgId", ClientUtils.getOrgId()); |
| | | queryParam.put("createId", ClientUtils.getUserId()); |
| | | StringBuffer hql = new StringBuffer(1000); |
| | | // and c.endTime>=sysdate() 增加条件过滤掉历史班级 |
| | | hql.append("select c.classId as classId ,c.name as className from ClsClass c where c.deleteFlag is false and c.orgId=:orgId and c.createId=:createId " ); |
| | | Map<String,Object> queryParam = new HashMap<String,Object>(); |
| | | queryParam.put("orgId", ClientUtils.getOrgId()); |
| | | queryParam.put("createId", ClientUtils.getUserId()); |
| | | |
| | | if(StringUtils.isNotEmpty(teacherId)||StringUtils.isNotEmpty(subjectId)){ |
| | | hql.append(" and exists (select 1 from ClsClassReSubject r ,Subject s where r.subjectId=s.subjectId and r.classId =c.classId and r.deleteFlag is false "); |
| | | } |
| | | if(StringUtils.isNotEmpty(teacherId)||StringUtils.isNotEmpty(subjectId)){ |
| | | hql.append(" and exists (select 1 from ClsClassReSubject r ,Subject s where r.subjectId=s.subjectId and r.classId =c.classId and r.deleteFlag is false "); |
| | | } |
| | | |
| | | if(!StringUtils.isEmpty(teacherId)){ |
| | | hql.append(" and s.teacherId=:teacherId "); |
| | | queryParam.put("teacherId", teacherId); |
| | | } |
| | | if(!StringUtils.isEmpty(teacherId)){ |
| | | hql.append(" and s.teacherId=:teacherId "); |
| | | queryParam.put("teacherId", teacherId); |
| | | } |
| | | |
| | | if(!StringUtils.isEmpty(subjectId)){ |
| | | hql.append(" and s.origSubjectId=:subjectId "); |
| | | queryParam.put("subjectId", subjectId); |
| | | } |
| | | if(!StringUtils.isEmpty(subjectId)){ |
| | | hql.append(" and s.origSubjectId=:subjectId "); |
| | | queryParam.put("subjectId", subjectId); |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(teacherId)||StringUtils.isNotEmpty(subjectId)){ |
| | | hql.append(")"); |
| | | } |
| | | if(StringUtils.isNotEmpty(teacherId)||StringUtils.isNotEmpty(subjectId)){ |
| | | hql.append(")"); |
| | | } |
| | | |
| | | return this.findListWithMapByHql(hql.toString(), queryParam); |
| | | return this.findListWithMapByHql(hql.toString(), queryParam); |
| | | } |
| | | |
| | | @Override |
| | | @Override |
| | | public List<Map<String,Object>> queryAllClassIdAndName() { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | StringBuffer hql = new StringBuffer(500); |
| | | // c.deleteFlag is false and |
| | | hql.append("select c.classId as classId ,c.name as className from ClsClass c where c.endTime>=:endTime and c.orgId=:orgId " ); |
| | | |
| | | return this.findListWithMapByHql(hql.toString(), CollectionUtils.newObjectMap("endTime",new Date(),"orgId",ClientUtils.getOrgId())); |
| | | return this.findListWithMapByHql(hql.toString(), CollectionUtils.newObjectMap("endTime",new Date(),"orgId",ClientUtils.getOrgId())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询班级 |
| | | * |
| | | * type 1正常班級,2历史班級 |
| | | */ |
| | | public Result classList(String keyword, Pager pager, int type) { |
| | | //获取老师id |
| | | String teacherId = teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | if (StringUtils.isEmpty(teacherId)) { |
| | | return new Result(false, "非老师角色无法查看班级"); |
| | | } |
| | | QClsClass qClsClass = QClsClass.clsClass; |
| | | QSubject qSubject = QSubject.subject; |
| | | QClsClassReSubject qClsClassReSubject = QClsClassReSubject.clsClassReSubject; |
| | | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; |
| | | /** |
| | | * 查询班级 |
| | | * |
| | | * type 1正常班級,2历史班級 |
| | | */ |
| | | public Result classList(String keyword, Pager pager, int type) { |
| | | //获取老师id |
| | | String teacherId = teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | if (StringUtils.isEmpty(teacherId)) { |
| | | return new Result(false, "非老师角色无法查看班级"); |
| | | } |
| | | QClsClass qClsClass = QClsClass.clsClass; |
| | | QSubject qSubject = QSubject.subject; |
| | | QClsClassReSubject qClsClassReSubject = QClsClassReSubject.clsClassReSubject; |
| | | QSubjectProgressTreeV qSubjectProgressTreeV = QSubjectProgressTreeV.subjectProgressTreeV; |
| | | |
| | | //查询脚本 |
| | | JPAQuery<Tuple> queryDsl = this.getQueryFactory() |
| | | .select(qClsClass.name, qClsClass.classId, qClsClass.classNumber, qClsClass.studentCount, |
| | | qClsClass.createTime, qClsClass.startTime, qClsClass.endTime, qSubject) |
| | | .from(qClsClass, qSubject, qClsClassReSubject) |
| | | .where(qClsClass.deleteFlag.isFalse().and((type == 2 ? qClsClass.endTime.lt(new Date()) : qClsClass.endTime.gt(new Date()))).and(qClsClass.name.like("%" + keyword + "%")) |
| | | .and(qSubject.teacherId.eq(teacherId)).and(qSubject.deleteFlag.isFalse()) |
| | | .and(qClsClassReSubject.deleteFlag.isFalse()) |
| | | .and(qClsClassReSubject.classId.eq(qClsClass.classId)) |
| | | .and(qClsClassReSubject.subjectId.eq(qSubject.subjectId))) |
| | | .groupBy(qClsClass.classId); |
| | | //查询脚本 |
| | | JPAQuery<Tuple> queryDsl = this.getQueryFactory() |
| | | .select(qClsClass.name, qClsClass.classId, qClsClass.classNumber, qClsClass.studentCount, |
| | | qClsClass.createTime, qClsClass.startTime, qClsClass.endTime, qSubject) |
| | | .from(qClsClass, qSubject, qClsClassReSubject) |
| | | .where(qClsClass.deleteFlag.isFalse().and((type == 2 ? qClsClass.endTime.lt(new Date()) : qClsClass.endTime.gt(new Date()))).and(qClsClass.name.like("%" + keyword + "%")) |
| | | .and(qSubject.teacherId.eq(teacherId)).and(qSubject.deleteFlag.isFalse()) |
| | | .and(qClsClassReSubject.deleteFlag.isFalse()) |
| | | .and(qClsClassReSubject.classId.eq(qClsClass.classId)) |
| | | .and(qClsClassReSubject.subjectId.eq(qSubject.subjectId))) |
| | | .groupBy(qClsClass.classId); |
| | | |
| | | //总数 |
| | | long count = queryDsl.fetchCount(); |
| | | //总数 |
| | | long count = queryDsl.fetchCount(); |
| | | |
| | | //listData |
| | | List<Map<String, Object>> listData = queryDsl.limit(pager.getPageSize()).offset(pager.getOffset()) |
| | | .orderBy(qClsClass.createTime.desc(), qSubject.createTime.desc()).fetch().stream().map(tuple -> { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Subject subject = tuple.get(qSubject); |
| | | //listData |
| | | List<Map<String, Object>> listData = queryDsl.limit(pager.getPageSize()).offset(pager.getOffset()) |
| | | .orderBy(qClsClass.createTime.desc(), qSubject.createTime.desc()).fetch().stream().map(tuple -> { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Subject subject = tuple.get(qSubject); |
| | | |
| | | map.put("className", tuple.get(qClsClass.name)); |
| | | map.put("classId", tuple.get(qClsClass.classId)); |
| | | map.put("classNumber", tuple.get(qClsClass.classNumber)); |
| | | map.put("studentCount", tuple.get(qClsClass.studentCount)); |
| | | map.put("createTime", tuple.get(qClsClass.createTime)); |
| | | map.put("startTime", tuple.get(qClsClass.startTime)); |
| | | map.put("endTime", tuple.get(qClsClass.endTime)); |
| | | if (subject != null) { |
| | | map.put("subjectName", subject.getName()); |
| | | map.put("progressPercent", |
| | | this.getQueryFactory().select(qSubjectProgressTreeV.percent.avg()) |
| | | .from(qSubjectProgressTreeV) |
| | | .where(qSubjectProgressTreeV.id.nodeId.eq(subject.getSubjectId()) |
| | | .and(qSubjectProgressTreeV.nodeType.eq(Progress.PROGRESS_TYPE_SUBJECT))) |
| | | .groupBy(qSubjectProgressTreeV.id.nodeId).fetchOne()); |
| | | } else { |
| | | map.put("subjectName", "暂无开班课程"); |
| | | map.put("progressPercent", 0); |
| | | } |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | map.put("className", tuple.get(qClsClass.name)); |
| | | map.put("classId", tuple.get(qClsClass.classId)); |
| | | map.put("classNumber", tuple.get(qClsClass.classNumber)); |
| | | map.put("studentCount", tuple.get(qClsClass.studentCount)); |
| | | map.put("createTime", tuple.get(qClsClass.createTime)); |
| | | map.put("startTime", tuple.get(qClsClass.startTime)); |
| | | map.put("endTime", tuple.get(qClsClass.endTime)); |
| | | if (subject != null) { |
| | | map.put("subjectName", subject.getName()); |
| | | map.put("progressPercent", |
| | | this.getQueryFactory().select(qSubjectProgressTreeV.percent.avg()) |
| | | .from(qSubjectProgressTreeV) |
| | | .where(qSubjectProgressTreeV.id.nodeId.eq(subject.getSubjectId()) |
| | | .and(qSubjectProgressTreeV.nodeType.eq(Progress.PROGRESS_TYPE_SUBJECT))) |
| | | .groupBy(qSubjectProgressTreeV.id.nodeId).fetchOne()); |
| | | } else { |
| | | map.put("subjectName", "暂无开班课程"); |
| | | map.put("progressPercent", 0); |
| | | } |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("count", count, "listData", listData)); |
| | | } |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("count", count, "listData", listData)); |
| | | } |
| | | |
| | | @Override |
| | | public String [] queryClassNamesByIds(String[] classIds){ |
| | | if(classIds!=null && classIds.length==0){ |
| | | return null; |
| | | } |
| | | if(classIds!=null && classIds.length==0){ |
| | | return null; |
| | | } |
| | | |
| | | String [] classNames = null; |
| | | String [] classNames = null; |
| | | |
| | | List<Map<String,Object>> lstResult= this.findListWithMapByHql("select c.classId as classId ,c.name as className from ClsClass c where c.classId in (:classIds) ", |
| | | CollectionUtils.newObjectMap("classIds",classIds)); |
| | | List<Map<String,Object>> lstResult= this.findListWithMapByHql("select c.classId as classId ,c.name as className from ClsClass c where c.classId in (:classIds) ", |
| | | CollectionUtils.newObjectMap("classIds",classIds)); |
| | | |
| | | if(lstResult!=null && lstResult.size()==classIds.length){ |
| | | Map<String,String> map= new HashMap<String,String>(lstResult.size()); |
| | | classNames =new String [classIds.length]; |
| | | if(lstResult!=null && lstResult.size()==classIds.length){ |
| | | Map<String,String> map= new HashMap<String,String>(lstResult.size()); |
| | | classNames =new String [classIds.length]; |
| | | |
| | | for(Map<String,Object> item:lstResult){ |
| | | map.put((String)item.get("classId"), (String)item.get("className")); |
| | | } |
| | | for(Map<String,Object> item:lstResult){ |
| | | map.put((String)item.get("classId"), (String)item.get("className")); |
| | | } |
| | | |
| | | for(int i=0;i<classIds.length;i++){ |
| | | classNames[i]= map.get(classIds[i]); |
| | | } |
| | | } |
| | | for(int i=0;i<classIds.length;i++){ |
| | | classNames[i]= map.get(classIds[i]); |
| | | } |
| | | } |
| | | |
| | | return classNames; |
| | | return classNames; |
| | | } |
| | | |
| | | @Override |
| | | public List<ClsClass> queryStudentClassesByUserId(String userId) { |
| | | return this.find("from ClsClass c where c.deleteFlag is false and exists( select 1 from StuStudent t where t.classId = c.classId and t.userId=? and t.status=? ) ", |
| | | CollectionUtils.newList(userId,StuStudent.STATUS_ACTIVE),ClsClass.class); |
| | | return this.find("from ClsClass c where c.deleteFlag is false and exists( select 1 from StuStudent t where t.classId = c.classId and t.userId=? and t.status=? ) ", |
| | | CollectionUtils.newList(userId,StuStudent.STATUS_ACTIVE),ClsClass.class); |
| | | } |
| | | |
| | | |
| | |
| | | StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class); |
| | | |
| | | if(stuStudent!=null && classId!=null){ |
| | | StringBuffer ClaHql=new StringBuffer("from ClsClass where classId=? and deleteFlag is false"); |
| | | |
| | | List<Object> claArgs = CollectionUtils.newList(classId); |
| | | |
| | | ClsClass cLaClass = findUnique(ClaHql.toString(), claArgs, ClsClass.class); |
| | | |
| | | cLaClass.setStudentCount(cLaClass.getStudentCount()+1); |
| | | |
| | | stuStudent.setClassId(classId); |
| | | |
| | | save(stuStudent); |
| | | }else { |
| | | return new Result(false,"班级不存在或学生不存在"); |
| | | } |
| | | } |
| | | |
| | | return new Result(true); |
| | | return new Result(true,"分班成功"); |
| | | |
| | | } |
| | | |
| | |
| | | String[] headers = { "姓名", "性别" ,"手机号" ,"身份证"}; |
| | | List<StuStudent> dataset = new ArrayList<StuStudent>(); |
| | | for (StuStudent stuStudent: |
| | | stuStudents) { |
| | | stuStudents) { |
| | | StuStudent u = new StuStudent(); |
| | | u.setName(stuStudent.getName()); |
| | | u.setSex(stuStudent.getSex()); |
| | |
| | | @Override |
| | | public Result loopStudentIds(String[] studentIds) { |
| | | for (String studentId: |
| | | studentIds) { |
| | | studentIds) { |
| | | auditStudent(studentId); |
| | | } |
| | | return new Result(true); |
New file |
| | |
| | | package com.qxueyou.scc.admin.studentFiles.Impl; |
| | | |
| | | import com.qxueyou.scc.admin.studentFiles.StudentFilesService; |
| | | import com.qxueyou.scc.base.model.Pager; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.base.service.impl.CommonAppService; |
| | | import com.qxueyou.scc.base.util.CollectionUtils; |
| | | import com.qxueyou.scc.teach.student.model.QStuStudent; |
| | | import com.qxueyou.scc.teach.student.model.StuStudent; |
| | | import com.qxueyou.scc.user.model.QUser; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class StudentFilesServiceImpl extends CommonAppService implements StudentFilesService { |
| | | @Override |
| | | public List<Map<String, Object>> getStudentLst(String classId, String keyword, Pager pager) { |
| | | QUser qUser = QUser.user; |
| | | QStuStudent qStuStudent = QStuStudent.stuStudent; |
| | | return this.getQueryFactory() |
| | | .select(qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex, |
| | | qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score,qStuStudent.attendanceStatus, qStuStudent.graduationText,qStuStudent.comment, |
| | | qUser.imgPath) |
| | | .from(qUser, qStuStudent) |
| | | .where(qUser.deleteFlag.isFalse().and(qUser.userId.eq(qStuStudent.userId)) |
| | | .and(qStuStudent.classId.eq(classId)).and(qStuStudent.name.like("%" + keyword + "%")).and(qStuStudent.deleteFlag.isFalse())) |
| | | .limit(pager.getPageSize()).offset(pager.getOffset()).orderBy(qStuStudent.createTime.desc()).fetch().stream().map(tuple -> { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("studentId", tuple.get(qStuStudent.studentId)); |
| | | map.put("name", tuple.get(qStuStudent.name)); |
| | | map.put("studentNo", tuple.get(qStuStudent.studentNo)); |
| | | map.put("studentNumber", tuple.get(qStuStudent.studentNo)); |
| | | map.put("sex", tuple.get(qStuStudent.sex)); |
| | | map.put("mobilePhone", tuple.get(qStuStudent.mobilePhone)); |
| | | map.put("status", tuple.get(qStuStudent.status)); |
| | | map.put("studyDuration", tuple.get(qStuStudent.studyDuration)); |
| | | map.put("tenantId", tuple.get(qStuStudent.tenantId)); |
| | | map.put("score", tuple.get(qStuStudent.score)); |
| | | map.put("graduationText", tuple.get(qStuStudent.graduationText)); |
| | | map.put("attendanceStatus", tuple.get(qStuStudent.attendanceStatus)); |
| | | map.put("comment", tuple.get(qStuStudent.comment)); |
| | | map.put("imgPath", tuple.get(qUser.imgPath)); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | @Override |
| | | public int getStudentsCount(String classId, String keyword) { |
| | | // //TODO 判断是否为补考分组 |
| | | // ClsClass cls = clsService.read(classId); |
| | | // String hql=null; |
| | | // if(cls!=null && cls.getClassTypes()!=null && "1".equals(cls.getClassTypes())){ |
| | | // //TODO 补考分组需要另一种查询学员 stu.tenantId = class.classId |
| | | // hql = "from StuStudent where tenantId=:classId and name like :keyword and deleteFlag is false"; |
| | | // }else { |
| | | String hql = "from StuStudent where classId=:classId and name like :keyword and deleteFlag is false"; |
| | | // } |
| | | return findCountByComplexHql(hql, CollectionUtils.newObjectMap("classId", classId, "keyword", "%" + keyword + "%" )); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public String studentCommentAddAndUp(String[] studentIds,String comment) { |
| | | StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false"); |
| | | |
| | | List<Object> args = CollectionUtils.newList(studentIds); |
| | | |
| | | StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class); |
| | | |
| | | stuStudent.setComment(comment); |
| | | |
| | | save(stuStudent); |
| | | return ""; |
| | | } |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.admin.studentFiles; |
| | | |
| | | import com.qxueyou.scc.base.model.Pager; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.teach.student.model.StuStudent; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 学生档案管理 |
| | | */ |
| | | public interface StudentFilesService { |
| | | /** |
| | | * 学生档案查询 |
| | | * @param classId |
| | | * @param keyword |
| | | * @param pager |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> getStudentLst(String classId, String keyword, Pager pager); |
| | | |
| | | /** |
| | | * 获取学员数量 |
| | | * @param classId 班级id |
| | | * @param keyword 关键词 |
| | | * @return |
| | | */ |
| | | int getStudentsCount(String classId,String keyword); |
| | | /** |
| | | * 评语 |
| | | * @param studentIds |
| | | * @param comment |
| | | * @return |
| | | */ |
| | | String studentCommentAddAndUp(String[] studentIds,String comment); |
| | | } |
| | |
| | | |
| | | package com.qxueyou.scc.base.dao; |
| | | |
| | | import java.beans.Transient; |
| | | import java.io.Serializable; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | import com.qxueyou.scc.base.model.Pager; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * 基础DAO类,自动注入sessionFactory |
| | |
| | | * @since JDK1.6 |
| | | * @history 2010-07-28 夏德虎 新建 |
| | | */ |
| | | @Transactional(readOnly=false) |
| | | public class BaseDAO extends HibernateDaoSupport { |
| | | |
| | | /** 注释 rawtypes */ |
| | | private static final String RAW_TYPES = "rawtypes"; |
| | | |
| | | |
| | | /** 注释 rawtypes */ |
| | | private static final String RAW_TYPES = "rawtypes"; |
| | | |
| | | /** |
| | | * 注入sessionFactory |
| | | * |
| | |
| | | * @return 查找到的结果,如果没找到,返回null |
| | | */ |
| | | public <T> T read(Class<T> clz, Serializable key) { |
| | | if(key==null){ |
| | | return null; |
| | | } |
| | | if(key==null){ |
| | | return null; |
| | | } |
| | | return clz.cast(this.getHibernateTemplate().get(clz, key)); |
| | | } |
| | | |
| | |
| | | public void update(Object obj) { |
| | | this.getHibernateTemplate().update(obj); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存对象 |
| | | */ |
| | |
| | | /** |
| | | * 保存或更新对象 |
| | | */ |
| | | @Transactional(readOnly = false) |
| | | public void saveOrUpdate(Object obj) { |
| | | this.getHibernateTemplate().saveOrUpdate(obj); |
| | | } |
| | |
| | | */ |
| | | public void saveOrUpdateAll(@SuppressWarnings(RAW_TYPES) Collection collection) { |
| | | for(Object obj:collection){ |
| | | this.getHibernateTemplate().saveOrUpdate(obj); |
| | | this.getHibernateTemplate().saveOrUpdate(obj); |
| | | } |
| | | } |
| | | |
| | |
| | | public void deleteAll(@SuppressWarnings(RAW_TYPES) Collection col) { |
| | | this.getHibernateTemplate().deleteAll(col); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public <T> List<T> find(String hql, Class<T> cls) { |
| | | public <T> List<T> find(String hql, Class<T> cls) { |
| | | return find(hql,Collections.EMPTY_LIST,cls); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | * @param cls 返回类型 |
| | | * @return |
| | | */ |
| | | public <T> List<T> find(final String hql,final List<Object> args,final Class<T> cls) { |
| | | return this.getHibernateTemplate().execute(new HibernateCallback<List<T>>() { |
| | | public <T> List<T> find(final String hql,final List<Object> args,final Class<T> cls) { |
| | | return this.getHibernateTemplate().execute(new HibernateCallback<List<T>>() { |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public List<T> doInHibernate(Session session) { |
| | | public List<T> doInHibernate(Session session) { |
| | | Query query = session.createQuery(hql); |
| | | int i = 0; |
| | | for (Object arg : args) { |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表 |
| | | * |
| | |
| | | * @param cls 返回类型 |
| | | * @return |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public List<Object[]> findwithRawResult(String hql, List<Object> args) { |
| | | @SuppressWarnings("unchecked") |
| | | public List<Object[]> findwithRawResult(String hql, List<Object> args) { |
| | | return (List<Object[]>) this.getHibernateTemplate().find(hql, args.toArray()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,返回列表数据总数 |
| | | * |
| | |
| | | * @param cls 返回类型 |
| | | * @return |
| | | */ |
| | | public int findCount(final String hql, final List<Object> args) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | public int findCount(final String hql, final List<Object> args) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session){ |
| | | |
| | | Query query = session.createQuery(hql.trim().startsWith("from")?"select count(1) ".concat(hql):hql); |
| | | int i = 0; |
| | | for (Object arg : args) { |
| | | |
| | | Query query = session.createQuery(hql.trim().startsWith("from")?"select count(1) ".concat(hql):hql); |
| | | int i = 0; |
| | | for (Object arg : args) { |
| | | query.setParameter(i++, arg); |
| | | } |
| | | |
| | | if(null != query.uniqueResult()){ |
| | | return ((Long)query.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | |
| | | if(null != query.uniqueResult()){ |
| | | return ((Long)query.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | |
| | | /** |
| | | * 根据hql查询,返回列表数据总数 |
| | | * |
| | | * @param hql 查询语句 |
| | |
| | | * @param cls 返回类型 |
| | | * @return |
| | | */ |
| | | public int findCountBySql(final String sql, final List<Object> args) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | public int findCountBySql(final String sql, final List<Object> args) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session){ |
| | | |
| | | Query query = session.createSQLQuery(sql.trim().startsWith("from")?"select count(1) ".concat(sql):sql); |
| | | int i = 0; |
| | | for (Object arg : args) { |
| | | |
| | | Query query = session.createSQLQuery(sql.trim().startsWith("from")?"select count(1) ".concat(sql):sql); |
| | | int i = 0; |
| | | for (Object arg : args) { |
| | | query.setParameter(i++, arg); |
| | | } |
| | | |
| | | if(null != query.uniqueResult()){ |
| | | return ((BigInteger)query.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | |
| | | if(null != query.uniqueResult()){ |
| | | return ((BigInteger)query.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,返回列表分页数据 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @SuppressWarnings({ "unchecked" }) |
| | | public <T> List<T> findList(final String hql, final Pager page, final List<Object> args,Class<T> cls) { |
| | | public <T> List<T> findList(final String hql, final Pager page, final List<Object> args,Class<T> cls) { |
| | | return this.getHibernateTemplate().execute(new HibernateCallback<List<T>>() { |
| | | |
| | | public List<T> doInHibernate(Session session) { |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,返回唯一的数据 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @SuppressWarnings({ RAW_TYPES, "unchecked" }) |
| | | public <T> T findUnique(final String hql, final List<Object> args,Class<T> cls) { |
| | | public <T> T findUnique(final String hql, final List<Object> args,Class<T> cls) { |
| | | return (T)this.getHibernateTemplate().execute(new HibernateCallback() { |
| | | |
| | | public Object doInHibernate(Session session) { |
| | |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | query.setParameter(i++, arg); |
| | | } |
| | | query.setFirstResult(pager.getPageSize()*(pager.getPageNum()-1)); |
| | | query.setMaxResults(pager.getPageSize()); |
| | | query.setMaxResults(pager.getPageSize()); |
| | | return query.list(); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * hql只含单一参数 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public Result bulkUpdateInLoop(String hql, Object args[]) { |
| | | int iCount = 0; |
| | | int iCount = 0; |
| | | for(Object arg:args){ |
| | | iCount += getHibernateTemplate().bulkUpdate(hql, arg); |
| | | iCount += getHibernateTemplate().bulkUpdate(hql, arg); |
| | | } |
| | | Map<String,Object> attrs = new HashMap<String,Object>(1); |
| | | attrs.put("doCount", iCount); |
| | | Result result = new Result(true); |
| | | result.setData(attrs); |
| | | return result; |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * hql只含单一参数 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public Result bulkUpdate(String hql, Object args[]) { |
| | | int count = getHibernateTemplate().bulkUpdate(hql, args); |
| | | int count = getHibernateTemplate().bulkUpdate(hql, args); |
| | | Map<String,Object> attrs = new HashMap<String,Object>(1); |
| | | attrs.put("doCount", count); |
| | | Result result = new Result(true); |
| | | result.setData(attrs); |
| | | return result; |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 存储过程语句 |
| | | * |
| | |
| | | * @param args 参数数组 |
| | | * @return |
| | | */ |
| | | public Result executeProduce(final String sql, final Object args[]) { |
| | | |
| | | Integer result = getHibernateTemplate().execute(new HibernateCallback<Integer>(){ |
| | | public Result executeProduce(final String sql, final Object args[]) { |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session) |
| | | throws HibernateException { |
| | | |
| | | Query query = session.createSQLQuery("{ "+sql+" }"); |
| | | for(int i=0;i<args.length;i++){ |
| | | query.setParameter(i, args[i]); |
| | | } |
| | | Integer result = getHibernateTemplate().execute(new HibernateCallback<Integer>(){ |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session) |
| | | throws HibernateException { |
| | | |
| | | Query query = session.createSQLQuery("{ "+sql+" }"); |
| | | for(int i=0;i<args.length;i++){ |
| | | query.setParameter(i, args[i]); |
| | | } |
| | | return query.executeUpdate(); |
| | | } |
| | | |
| | | } |
| | | |
| | | }); |
| | | return new Result(true,String.valueOf(result)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 执行sql删除 |
| | | * |
| | |
| | | * @param args 参数数组 |
| | | * @return |
| | | */ |
| | | public int executeSqlDelete(final String sql, final Object args[]) { |
| | | |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>(){ |
| | | public int executeSqlDelete(final String sql, final Object args[]) { |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session) |
| | | throws HibernateException { |
| | | |
| | | Query query = session.createSQLQuery(sql); |
| | | for(int i=0;i<args.length;i++){ |
| | | query.setParameter(i, args[i]); |
| | | } |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>(){ |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session) |
| | | throws HibernateException { |
| | | |
| | | Query query = session.createSQLQuery(sql); |
| | | for(int i=0;i<args.length;i++){ |
| | | query.setParameter(i, args[i]); |
| | | } |
| | | return query.executeUpdate(); |
| | | } |
| | | |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | */ |
| | | @SuppressWarnings({RAW_TYPES, "unchecked" }) |
| | | public List<Object[]> findRawByComplexHql(final String hql, final Map<String, Object> map) { |
| | | // 查询结果 |
| | | // 查询结果 |
| | | return (List<Object[]>)this.getHibernateTemplate().execute(new HibernateCallback<List>() { |
| | | public List doInHibernate(Session session) { |
| | | Query query = session.createQuery(hql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | return query.list(); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据hql查询,返回列表数据总数 |
| | | * |
| | |
| | | * @param cls 返回类型 |
| | | * @return |
| | | */ |
| | | public int findCountByComplexHql(final String hql, final Map<String, Object> map) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | public int findCountByComplexHql(final String hql, final Map<String, Object> map) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session){ |
| | | |
| | | Query queryHql = session.createQuery(hql.trim().startsWith("from")?"select count(1) ".concat(hql):hql); |
| | | |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | |
| | | Query queryHql = session.createQuery(hql.trim().startsWith("from")?"select count(1) ".concat(hql):hql); |
| | | |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | queryHql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | queryHql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | queryHql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != queryHql.uniqueResult()){ |
| | | return ((Long)queryHql.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | queryHql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | queryHql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | queryHql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != queryHql.uniqueResult()){ |
| | | return ((Long)queryHql.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | |
| | | /** |
| | | * 根据sql查询,返回列表数据总数 |
| | | * |
| | | * @param hql 查询语句 |
| | |
| | | * @param cls 返回类型 |
| | | * @return |
| | | */ |
| | | public int findCountByComplexSql(final String hql, final Map<String, Object> map) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | public int findCountByComplexSql(final String hql, final Map<String, Object> map) { |
| | | return getHibernateTemplate().execute(new HibernateCallback<Integer>() { |
| | | |
| | | @Override |
| | | public Integer doInHibernate(Session session){ |
| | | |
| | | Query querySql = session.createSQLQuery(hql.trim().startsWith("from")?"select count(1) ".concat(hql):hql); |
| | | |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | |
| | | Query querySql = session.createSQLQuery(hql.trim().startsWith("from")?"select count(1) ".concat(hql):hql); |
| | | |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | querySql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | querySql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | querySql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != querySql.uniqueResult()){ |
| | | return ((BigInteger)querySql.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | querySql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | querySql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | querySql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(null != querySql.uniqueResult()){ |
| | | return ((BigInteger)querySql.uniqueResult()).intValue(); |
| | | }else{ |
| | | return 0 ; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public <T> List<T> findByComplexHql(final String hql, final Map<String, Object> map, Class<T> cls) { |
| | | Pager page = new Pager(); |
| | | page.setPageSize(Integer.MAX_VALUE); |
| | | page.setPageNum(1); |
| | | Pager page = new Pager(); |
| | | page.setPageSize(Integer.MAX_VALUE); |
| | | page.setPageNum(1); |
| | | return findByComplexHql(hql, page, map, cls); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 复杂hql |
| | | * @param sql |
| | |
| | | * @return |
| | | */ |
| | | public <T> T findUniqueByHql(final String hql, final Map<String, Object> map){ |
| | | // 查询结果 |
| | | // 查询结果 |
| | | List<T> lst = this.getHibernateTemplate().execute(new HibernateCallback<List<T>>() { |
| | | |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public List<T> doInHibernate(Session session) { |
| | | public List<T> doInHibernate(Session session) { |
| | | Query queryHql = session.createQuery(hql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | queryHql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | queryHql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | queryHql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | queryHql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | queryHql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | queryHql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | queryHql.setFirstResult(0); |
| | | queryHql.setMaxResults(1); |
| | | |
| | | |
| | | List<?> r = queryHql.list(); |
| | | |
| | | |
| | | List<T> lst = new ArrayList<T>(r.size()); |
| | | for(Object o:r) { |
| | | lst.add((T)o); |
| | | lst.add((T)o); |
| | | } |
| | | return lst; |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | return lst.isEmpty()?null:lst.get(0); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果,列表数据为Map |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public List<Map<String,Object>> findListWithMapByHql(final String hql, final Map<String, Object> map) { |
| | | Pager page = new Pager(); |
| | | page.setPageNum(1); |
| | | page.setPageSize(Integer.MAX_VALUE); |
| | | |
| | | Pager page = new Pager(); |
| | | page.setPageNum(1); |
| | | page.setPageSize(Integer.MAX_VALUE); |
| | | |
| | | return findListWithMapByHql(hql,map,page); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果,列表数据为Map |
| | | * |
| | |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public List<Map<String,Object>> findListWithMapByHql(final String hql, final Map<String, Object> map,final Pager page) { |
| | | // 查询结果 |
| | | // 查询结果 |
| | | List<Map<String,Object>> lst = getHibernateTemplate().execute(new HibernateCallback<List<Map<String,Object>>>() { |
| | | public List<Map<String,Object>> doInHibernate(Session session) { |
| | | public List<Map<String,Object>> doInHibernate(Session session) { |
| | | Query query = session.createQuery(hql).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | query.setFirstResult(page.getPageSize()*(page.getPageNum()-1)); |
| | | query.setMaxResults(page.getPageSize()); |
| | | return query.list(); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | return lst; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回唯一一条结果 |
| | | * |
| | |
| | | */ |
| | | @SuppressWarnings({RAW_TYPES }) |
| | | public <T> T findUniqueByComplexHql(final String hql, final Map<String, Object> map, Class<T> cls) { |
| | | // 查询结果 |
| | | // 查询结果 |
| | | List<T> lst = this.getHibernateTemplate().execute(new HibernateCallback<List<T>>() { |
| | | public List doInHibernate(Session session) { |
| | | Query query = session.createQuery(hql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | query.setFirstResult(0); |
| | | query.setMaxResults(1); |
| | | return query.list(); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | return lst.isEmpty()?null:cls.cast(lst.get(0)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据Sql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public <T> List<T> findByComplexSql(final String sql, final Map<String, Object> map, Class<T> cls) { |
| | | Pager page = new Pager(); |
| | | page.setPageSize(Integer.MAX_VALUE); |
| | | page.setPageNum(1); |
| | | Pager page = new Pager(); |
| | | page.setPageSize(Integer.MAX_VALUE); |
| | | page.setPageNum(1); |
| | | return findByComplexSql(sql, page, map, cls); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据Sql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | */ |
| | | @SuppressWarnings({RAW_TYPES, "unchecked" }) |
| | | public List<Object[]> findRawByComplexSql(final String sql, final Map<String, Object> map) { |
| | | // 查询结果 |
| | | // 查询结果 |
| | | return (List<Object[]>)this.getHibernateTemplate().execute(new HibernateCallback<List>() { |
| | | public List doInHibernate(Session session) { |
| | | SQLQuery query = session.createSQLQuery(sql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | query.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | query.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | query.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | return query.list(); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据hql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | */ |
| | | @SuppressWarnings({RAW_TYPES }) |
| | | public <T> List<T> findByComplexHql(final String hql,final Pager page, final Map<String, Object> map, Class<T> cls) { |
| | | // 查询结果 |
| | | // 查询结果 |
| | | List lst = this.getHibernateTemplate().execute(new HibernateCallback<List>() { |
| | | public List doInHibernate(Session session) { |
| | | Query queryHql = session.createQuery(hql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | queryHql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | queryHql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | queryHql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | queryHql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | queryHql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | queryHql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | queryHql.setFirstResult(page.getPageSize()*(page.getPageNum()-1)); |
| | | queryHql.setMaxResults(page.getPageSize()); |
| | | return queryHql.list(); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | // 组装结果 |
| | | List<T> result = new ArrayList<T>(); |
| | | for (Object obj : lst) { |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据Sql查询,并返回执行类型的列表结果 |
| | | * |
| | |
| | | */ |
| | | @SuppressWarnings({RAW_TYPES }) |
| | | public <T> List<T> findByComplexSql(final String sql,final Pager page, final Map<String, Object> map, Class<T> cls) { |
| | | // 查询结果 |
| | | // 查询结果 |
| | | List lst = this.getHibernateTemplate().execute(new HibernateCallback<List>() { |
| | | public List doInHibernate(Session session) { |
| | | SQLQuery querySql = session.createSQLQuery(sql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | SQLQuery querySql = session.createSQLQuery(sql); |
| | | if (map != null) { |
| | | Set<String> keySet = map.keySet(); |
| | | for (String string : keySet) { |
| | | Object obj = map.get(string); |
| | | //这里考虑传入的参数是什么类型,不同类型使用的方法不同 |
| | | if(obj instanceof Collection<?>){ |
| | | querySql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | querySql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | querySql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | if(obj instanceof Collection<?>){ |
| | | querySql.setParameterList(string, (Collection<?>)obj); |
| | | }else if(obj instanceof Object[]){ |
| | | querySql.setParameterList(string, (Object[])obj); |
| | | }else{ |
| | | querySql.setParameter(string, obj); |
| | | } |
| | | } |
| | | } |
| | | querySql.setFirstResult(page.getPageSize()*(page.getPageNum()-1)); |
| | | querySql.setMaxResults(page.getPageSize()); |
| | | return querySql.list(); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | // 组装结果 |
| | | List<T> result = new ArrayList<T>(); |
| | | for (Object obj : lst) { |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | this.success = success; |
| | | } |
| | | |
| | | public Boolean getSuccess() { |
| | | return success; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | |
| | | |
| | | /** 得到classId*/ |
| | | public static String getClassId(){ |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | HttpSession session = request.getSession(); |
| | | String info = getUserInfo().getInfo(UserInfoWrapper.INF_CLASS_ID); |
| | | // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | // HttpSession session = request.getSession(); |
| | | // String info = getUserInfo().getInfo(UserInfoWrapper.INF_CLASS_ID); |
| | | // if(info!=null){ |
| | | // info= (String) session.getAttribute(UserInfoWrapper.INF_CLASS_ID); |
| | | // } |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import com.qxueyou.scc.admin.classes.model.ClsClass; |
| | | import com.qxueyou.scc.admin.classroom.service.IClassRoomService; |
| | |
| | | */ |
| | | @Api(tags="课表接口") |
| | | @Controller |
| | | @CrossOrigin(origins="*",maxAge=3600) |
| | | @RequestMapping("/admin/schedule") |
| | | public class CourseScheduleController { |
| | | |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | * @author chenjunliang |
| | | */ |
| | | @Api(tags = "资源管理接口") |
| | | @CrossOrigin |
| | | @RestController |
| | | @RequestMapping(value = "/teach/res") |
| | | public class ResController { |
| | |
| | | * @param id 资源id |
| | | */ |
| | | @GetMapping(value = "getResDetail") |
| | | public Result getResDetail(String id) { |
| | | |
| | | public Result getResDetail(String id,HttpServletResponse response) { |
| | | Res res = resService.read(id); |
| | | Result pathResult = resService.readAccessPath(id, null); |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("type", res.getType(), "name", res.getName(), |
| | | "coverUrl", res.getCoverPageUrl(), "remark", res.getRemark(), "fullPath", pathResult.getDataT("path"))); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | * @param pageNum |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "获取正学籍列表", notes = "") |
| | | @ApiOperation(value = "获取学籍列表", notes = "") |
| | | @GetMapping(value = "/schoolList") |
| | | public Result schoolList(@RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "1") Integer pageNum,String keyword,String status) { |
| | | |
New file |
| | |
| | | package com.qxueyou.scc.controller; |
| | | |
| | | import com.qxueyou.scc.admin.studentFiles.StudentFilesService; |
| | | import com.qxueyou.scc.base.model.Pager; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.base.util.CollectionUtils; |
| | | import com.qxueyou.scc.base.util.QBeanUtils; |
| | | import com.qxueyou.scc.teach.student.model.StuStudent; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Api(tags="学生档案管理接口") |
| | | @RestController |
| | | @RequestMapping("/admin/StudentFiles") |
| | | public class StudentFilesController { |
| | | |
| | | @Autowired |
| | | private StudentFilesService studentFilesService; |
| | | @ApiOperation(value = "学生档案", notes = "") |
| | | @GetMapping(value = "/studentFilesList") |
| | | public Result studentFilesList(String classId, @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "") String keyword) { |
| | | |
| | | List<Map<String, Object>> students = studentFilesService.getStudentLst(classId, keyword, new Pager(limit, pageNum)); |
| | | int studentCount = studentFilesService.getStudentsCount(classId, keyword); |
| | | |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("studentCount", studentCount, "studentLst", students)); |
| | | } |
| | | |
| | | @ApiOperation(value = "学生评语", notes = "") |
| | | @PostMapping(value = "/studentCommentAddAndUp") |
| | | public String studentCommentAddAndUp(String[] studentIds, String comment) { |
| | | return studentFilesService.studentCommentAddAndUp(studentIds,comment); |
| | | } |
| | | } |
| | |
| | | package com.qxueyou.scc.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hankcs.hanlp.corpus.tag.Nature; |
| | | import com.qxueyou.scc.sdk.MTCloud; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import springfox.documentation.spring.web.json.Json; |
| | | |
| | | import static com.hankcs.hanlp.corpus.tag.Nature.r; |
| | | import static com.hankcs.hanlp.corpus.tag.Nature.s; |
| | | |
| | | @Api(tags="直播管理接口") |
| | | @RestController |
| | |
| | | |
| | | List<MediaVideoLive> data = liveService.listOfMine(keyword, pageNum, pageSize); |
| | | int count = liveService.listCountOfMine(keyword); |
| | | |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap("videoLiveCount", count, |
| | | "videoLiveLst",QBeanUtils.listBean2ListMap(data, CollectionUtils.newStringMap( |
| | | "creator","creator", |
| | |
| | | "status","status", |
| | | "pushUrl","rtmpPushUrl", |
| | | "hlsPullUrl","hlsPullUrl", |
| | | "previewImgUrl","previewImgUrl" |
| | | "previewImgUrl","previewImgUrl", |
| | | "courseId","courseId" |
| | | )))); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "创建编辑直播") |
| | | @PostMapping(value = "addOrUpdate") |
| | | public Result addOrUpdate(String videoLiveId, String name, String content,String teacherId,String teacherName,String subjectId, |
| | | String subjectName,String definition,String imgPath, long startTime,long endTime, boolean isPlayBack, String classIds) { |
| | | if(StringUtils.isEmpty(videoLiveId)) { |
| | | return liveService.add(name, content,teacherId,teacherName,subjectId,subjectName,definition,imgPath, new Date(startTime), new Date(endTime), isPlayBack, StringUtils.isEmpty(classIds)?null:CollectionUtils.newList(String.class,classIds.split(","))); |
| | | }else { |
| | | return liveService.update(videoLiveId,name, content,teacherId,teacherName,subjectId,subjectName,definition,imgPath, new Date(startTime), new Date(endTime), isPlayBack, StringUtils.isEmpty(classIds)?null:CollectionUtils.newList(String.class,classIds.split(","))); |
| | | String subjectName,String definition,String imgPath, long startTime,long endTime, boolean isPlayBack, String classIds) throws Exception { |
| | | MTCloud client = new MTCloud(); |
| | | HashMap<Object,Object> options = new HashMap<Object,Object>(); |
| | | options.put("barrage", 1); |
| | | options.put("isPublic", 1); |
| | | options.put("robotNumber", 1); |
| | | options.put("robotType", 1); |
| | | options.put("pptDisplay", 1); |
| | | options.put("modetype", 6); |
| | | //将long类型转换为String类型 |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+00:00")); |
| | | String startTime1 = simpleDateFormat.format(new Date(startTime)); |
| | | String endTime1 = simpleDateFormat.format(new Date(endTime)); |
| | | //调用第三方直播接口 |
| | | String s = client.courseAdd(name, ClientUtils.getUserId(), startTime1, endTime1, ClientUtils.getUserName(), "222", options); |
| | | //json转换拿到courseId |
| | | JSONObject jsonObject = JSON.parseObject(s); |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | String course_id = (String) data.get("course_id"); |
| | | // System.out.println(Integer.parseInt(course_id)); |
| | | if(Nature.s !=null) { |
| | | liveService.add(name, content,teacherId,teacherName,subjectId,subjectName,definition,imgPath, new Date(startTime), new Date(endTime),Integer.parseInt(course_id), isPlayBack, StringUtils.isEmpty(classIds)?null:CollectionUtils.newList(String.class,classIds.split(","))); |
| | | return new Result(true, "成功", s); |
| | | } |
| | | return new Result(false); |
| | | } |
| | | |
| | | @ApiOperation(value = "开启直播") |
| | | @GetMapping(value = "OpenLive") |
| | | public Result OpenLive(int courseId) throws Exception { |
| | | MTCloud client = new MTCloud(); |
| | | |
| | | HashMap<Object,Object> options = new HashMap<Object, Object>(); |
| | | options.put("ssl", false); |
| | | |
| | | String res = client.courseLogin(ClientUtils.getUserId(),MTCloud.ACCOUNT_TYPE_THIRD, options); |
| | | System.out.println(res); |
| | | JSONObject jsonObject = JSON.parseObject(res); |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | String protocol = (String) data.get("url"); |
| | | return new Result(true,"开启成功",protocol); |
| | | } |
| | | |
| | | @ApiOperation(value = "在线时长") |
| | | @GetMapping(value = "onlineCommunication") |
| | | public Result onlineCommunication(String courseId,Integer page, Integer size) throws Exception { |
| | | MTCloud client = new MTCloud(); |
| | | HashMap<Object,Object> options = new HashMap<Object, Object>(); |
| | | options.put("ssl", false); |
| | | String res = client.courseVisitorList("3360573",10,1,options); |
| | | return new Result(true,"开启成功",res); |
| | | } |
| | | /** |
| | | * 查询直播详情 |
| | | * |
| | |
| | | /** |
| | | * 删除/多个以逗号隔开 |
| | | * |
| | | * @param videoLiveId |
| | | * @param videoLiveIds |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除创建的直播") |
| | | @PostMapping(value = "delete") |
| | | public Result delete(String videoLiveIds) { |
| | | return liveService.delete(videoLiveIds.split(",")); |
| | | public Result delete(String videoLiveIds,String courseIds) throws Exception { |
| | | return liveService.delete(videoLiveIds.split(","),courseIds.split(",")); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * 直播结束 |
| | | * |
| | | * @param videoLiveId |
| | | * @param videoLiveIds |
| | | * 直播id |
| | | */ |
| | | @ApiOperation(value = "直播结束") |
| | |
| | | "status","status", |
| | | "pushUrl","rtmpPushUrl", |
| | | "hlsPullUrl","hlsPullUrl", |
| | | "previewImgUrl","previewImgUrl" |
| | | "previewImgUrl","previewImgUrl", |
| | | "courseId","courseId" |
| | | )))); |
| | | } |
| | | |
| | |
| | | public @ResponseBody Result queryStudentExamList(String keyword, String classId, String subjectId, Integer status, Integer pageSize, Integer pageNum) { |
| | | pageSize = pageSize != null && pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE; |
| | | pageNum = pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM; |
| | | classId=ClientUtils.getClassId(); |
| | | if(classId==null){ |
| | | classId=ClientUtils.getClassId(); |
| | | } |
| | | System.out.println("avcd"+ClientUtils.getUserId()); |
| | | // System.out.println(ClientUtils.getUserId()+"--cla"+classId+"--sub"+subjectId+"--sta"+status+"--key"+keyword+"--pag"+pageNum+"---siz"+pageSize); |
| | | String [] classIds= null; |
| | |
| | | |
| | | /** |
| | | * 考试 |
| | | * |
| | | * |
| | | * @author lihanqi |
| | | * |
| | | */ |
| | |
| | | |
| | | @Autowired |
| | | IHandoutService handoutService; |
| | | |
| | | |
| | | @Autowired |
| | | IMsgInfoService msgInfoService; |
| | | |
| | | |
| | | @Autowired |
| | | IExerciseCompleteService exerciseCompleteService; |
| | | |
| | | |
| | | @Autowired |
| | | IExerciseGroupService exerciseGroupService; |
| | | |
| | | |
| | | @Override |
| | | public List<ExerciseInfo> list(String keyword,String classId,Short status,Integer pageSize,Integer pageNum) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseInfo e where e.name like ? and e.createId =? "); |
| | | List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%',ClientUtils.getUserId()); |
| | | |
| | | |
| | | if(status!=null){ |
| | | hql.append(" and e.status = ? "); |
| | | params.add(status); |
| | | } |
| | | |
| | | |
| | | if(StringUtils.isNotEmpty(classId)){ |
| | | hql.append(" and exists(select 1 from ExerciseExamReClass r where e.exerciseInfoId=r.examId and r.classId = ? and r.deleteFlag is false)"); |
| | | params.add(classId); |
| | | } |
| | | |
| | | |
| | | hql.append(" and e.deleteFlag is false order by e.createTime desc"); |
| | | return findList(hql.toString(),new Pager(pageSize, pageNum),params, ExerciseInfo.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int listCount(String keyword,String classId, Short status) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseInfo e where e.name like ? and e.createId =? "); |
| | | List<Object> params = CollectionUtils.newList('%' + keyword.trim() + '%',ClientUtils.getUserId()); |
| | | |
| | | |
| | | if(status!=null){ |
| | | hql.append(" and e.status = ? "); |
| | | params.add(status); |
| | | } |
| | | |
| | | |
| | | if(StringUtils.isNotEmpty(classId)){ |
| | | hql.append(" and exists(select 1 from ExerciseExamReClass r where e.exerciseInfoId=r.examId and r.classId = ? and r.deleteFlag is false)"); |
| | | params.add(classId); |
| | | } |
| | | |
| | | |
| | | hql.append(" and e.deleteFlag is false "); |
| | | return findCount(hql.toString(),params); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存作业 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public Result insertExerciseInfo(ExerciseInfo exerciseInfo) { |
| | | String[] classIds = QBeanUtils.listPropertyVal(exerciseInfo.getReClasses(), "classId").toArray(new String[exerciseInfo.getReClasses().size()]); |
| | | |
| | | |
| | | String exerciseInfoId = UUIDUtils.generateUUID().replace("-", ""); |
| | | exerciseInfo.setExerciseInfoId(exerciseInfoId); |
| | | exerciseInfo.setOrgId(ClientUtils.getOrgId()); |
| | |
| | | // 保存题目类型 |
| | | List<ExerciseItemSet> lstExerciseItemSet = exerciseInfo.getExerciseItemSets(); |
| | | this.saveExerciseItemSet(exerciseInfoId,lstExerciseItemSet); |
| | | |
| | | |
| | | //生成作业题目信息 |
| | | String[] sourceGroupIds = QBeanUtils.listPropertyVal(exerciseInfo.getReGroups(), "groupId").toArray(new String[exerciseInfo.getReGroups().size()]); |
| | | |
| | | |
| | | String newGroupId = this.exerciseGroupService.doCreateRandomExerciseGroup( |
| | | exerciseInfo.getName() + "-作业",ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,sourceGroupIds,lstExerciseItemSet); |
| | | |
| | | |
| | | if(StringUtils.isEmpty(newGroupId)){ |
| | | return new Result(false, "题目数据不够,请增加题库的题目或者减少试卷的题数",exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | this.saveExerciseExamReGroup(exerciseInfoId,new String[]{newGroupId},EXAM_TYPES[0],ExerciseExamReGroup.GROUP_TYPE_EXAM); |
| | | |
| | | |
| | | // 保存关联题库信息 |
| | | this.saveExerciseExamReGroup(exerciseInfoId,sourceGroupIds,null,ExerciseExamReGroup.GROUP_TYPE_SOURCE); |
| | | } |
| | | |
| | | |
| | | // 保存关联班级 |
| | | this.saveExerciseExamReClass(exerciseInfoId, classIds); |
| | | |
| | | |
| | | return new Result(true, "", exerciseInfoId); |
| | | } |
| | | |
| | | /** |
| | | * 修改练习 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public Result updateExerciseInfo(ExerciseInfo exerciseInfo) { |
| | | String[] classIds = QBeanUtils.listPropertyVal(exerciseInfo.getReClasses(), "classId").toArray(new String[exerciseInfo.getReClasses().size()]); |
| | | |
| | | |
| | | String exerciseInfoId = exerciseInfo.getExerciseInfoId(); |
| | | |
| | | |
| | | ExerciseInfo newExerciseInfo = this.read(ExerciseInfo.class, exerciseInfoId); |
| | | newExerciseInfo.setScore(exerciseInfo.getScore()); |
| | | newExerciseInfo.setClassCount(classIds == null ? 0 : classIds.length); |
| | |
| | | newExerciseInfo.setCommitUploadType(exerciseInfo.getCommitUploadType()); |
| | | TraceUtils.setUpdateTrace(newExerciseInfo); |
| | | this.save(newExerciseInfo); |
| | | |
| | | |
| | | //清理旧关系数据 |
| | | this.doClearExerciseExamReData(exerciseInfoId); |
| | | |
| | | |
| | | // 答题作业默认按照统一卷生成作业题目 |
| | | |
| | | |
| | | if (newExerciseInfo.getType() == ExerciseInfo.EXERCISE_TYPE_ANSWER) { |
| | | |
| | | |
| | | // 保存题目类型 |
| | | List<ExerciseItemSet> lstExerciseItemSet = exerciseInfo.getExerciseItemSets(); |
| | | |
| | | |
| | | saveExerciseItemSet(exerciseInfoId,lstExerciseItemSet); |
| | | |
| | | |
| | | //生成作业题目信息 |
| | | String[] groupIds = QBeanUtils.listPropertyVal(exerciseInfo.getReGroups(), "groupId").toArray(new String[exerciseInfo.getReGroups().size()]); |
| | | String newGroupId = this.exerciseGroupService.doCreateRandomExerciseGroup( |
| | | exerciseInfo.getName() + "-作业",ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,groupIds, lstExerciseItemSet); |
| | | |
| | | exerciseInfo.getName() + "-作业",ExerciseGroup.TYPE_EXERCISE_EXAM_ITEM,groupIds, lstExerciseItemSet); |
| | | |
| | | if(StringUtils.isEmpty(newGroupId)){ |
| | | return new Result(false, "题目数据不够,请增加题库的题目或者减少试卷的题数"); |
| | | } |
| | | |
| | | |
| | | this.saveExerciseExamReGroup(exerciseInfoId,new String[]{newGroupId},EXAM_TYPES[0],ExerciseExamReGroup.GROUP_TYPE_EXAM); |
| | | |
| | | |
| | | // 保存关联题库信息 |
| | | this.saveExerciseExamReGroup(exerciseInfoId,groupIds,null,ExerciseExamReGroup.GROUP_TYPE_SOURCE); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | // 保存关联班级 |
| | | this.saveExerciseExamReClass(exerciseInfoId, classIds); |
| | | |
| | | |
| | | return new Result(true, "", exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | //清除之前的练习关联关系数据 |
| | | private void doClearExerciseExamReData(String exerciseInfoId){ |
| | | this.bulkUpdate("update ExerciseExamReGroup set deleteFlag = 1 where examId = ?",new Object[]{exerciseInfoId}); |
| | | this.bulkUpdate("update ExerciseExamReClass set deleteFlag = 1 where examId = ?",new Object[] {exerciseInfoId}); |
| | | this.bulkUpdate("update ExerciseItemSet set deleteFlag = 1 where exerciseInfoId = ?",new Object[]{exerciseInfoId}); |
| | | } |
| | | |
| | | |
| | | private void saveExerciseExamReClass(String exerciseInfoId,String[] classIds){ |
| | | ExerciseExamReClass reClass = null; |
| | | for (String classId : classIds) { |
| | |
| | | reClass.setDeleteFlag(false); |
| | | reClass.setExamId(exerciseInfoId); |
| | | TraceUtils.setCreateTrace(reClass); |
| | | this.save(reClass); |
| | | this.save(reClass); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void saveExerciseExamReGroup(String exerciseInfoId, String [] groupIds,String examType,short reType){ |
| | | ExerciseExamReGroup reGroup = null; |
| | | for (String groupId : groupIds) { |
| | |
| | | reGroup.setExamId(exerciseInfoId); |
| | | TraceUtils.setCreateTrace(reGroup); |
| | | this.save(reGroup); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void saveExerciseItemSet(String exerciseInfoId,List<ExerciseItemSet> lstExerciseItemSet){ |
| | | for (ExerciseItemSet itemSet : lstExerciseItemSet) { |
| | | itemSet.setExerciseInfoId(exerciseInfoId); |
| | |
| | | |
| | | /** |
| | | * 删除作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | @Override |
| | | public String queryExerciseInfoRelatedGroupId(String exerciseInfoId) { |
| | | return this.findUnique("select groupId from ExerciseExamReGroup where examId=? and type=? and deleteFlag is false ", |
| | | CollectionUtils.newList(exerciseInfoId, ExerciseExamReGroup.GROUP_TYPE_EXAM),String.class); |
| | | return this.findUnique("select groupId from ExerciseExamReGroup where examId=? and type=? and deleteFlag is false ", |
| | | CollectionUtils.newList(exerciseInfoId, ExerciseExamReGroup.GROUP_TYPE_EXAM),String.class); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<ExerciseItemSet> queryExerciseItemSet(String exerciseInfoId){ |
| | | return this.find("from ExerciseItemSet where exerciseInfoId=? and deleteFlag is false order by itemType ASC", |
| | | return this.find("from ExerciseItemSet where exerciseInfoId=? and deleteFlag is false order by itemType ASC", |
| | | CollectionUtils.newList(exerciseInfoId), ExerciseItemSet.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ExerciseResultV> queryStuExerciselist(String keyword,String exerciseInfoId,String userId,String subjectId,Short status,Integer pageSize,Integer pageNum) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseResultV where exerciseStatus=?"); |
| | | List<Object> params = CollectionUtils.newList(ExerciseInfo.EXERCISE_STATUS_PUBLISHED); |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(userId)){ |
| | | hql.append(" and userId=? "); |
| | | params.add(userId); |
| | | params.add(userId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(exerciseInfoId)){ |
| | | hql.append(" and id.exerciseInfoId=?"); |
| | | params.add(exerciseInfoId); |
| | | params.add(exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(keyword)){ |
| | | hql.append(" and studentName like ?"); |
| | | params.add("%" + keyword.trim() + "%"); |
| | | params.add("%" + keyword.trim() + "%"); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(subjectId)){ |
| | | hql.append(" and subjectId=?"); |
| | | params.add(subjectId); |
| | | } |
| | | |
| | | |
| | | //默认全部,0待完成,1已提交 ,2:已批阅,3需重写,4:逾期未交 |
| | | if(status!=null){ |
| | | Date nowTime = new Date(); |
| | |
| | | params.add(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | } |
| | | } |
| | | |
| | | |
| | | hql.append(" order by startTime desc"); |
| | | |
| | | |
| | | return this.findList(hql.toString(),new Pager(pageSize, pageNum),params, ExerciseResultV.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int queryStuExerciseListCount(String keyword,String exerciseInfoId,String userId,String subjectId,Short status) { |
| | | StringBuffer hql = new StringBuffer(500); |
| | | hql.append("from ExerciseResultV where exerciseStatus=?"); |
| | | List<Object> params = CollectionUtils.newList(ExerciseInfo.EXERCISE_STATUS_PUBLISHED); |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(userId)){ |
| | | hql.append(" and userId=? "); |
| | | params.add(userId); |
| | | params.add(userId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(exerciseInfoId)){ |
| | | hql.append(" and id.exerciseInfoId=?"); |
| | | params.add(exerciseInfoId); |
| | | params.add(exerciseInfoId); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(keyword)){ |
| | | hql.append(" and studentName like ?"); |
| | | params.add("%" + keyword.trim() + "%"); |
| | | } |
| | | |
| | | |
| | | if(!StringUtils.isEmpty(subjectId)){ |
| | | hql.append(" and subjectId=?"); |
| | | params.add(subjectId); |
| | | } |
| | | |
| | | |
| | | //默认全部,0待完成,1已提交 ,2:已批阅,3需重写,4:逾期未交 |
| | | if(status!=null){ |
| | | Date nowTime = new Date(); |
| | |
| | | params.add(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | } |
| | | } |
| | | |
| | | return this.findCount(hql.toString(), params); |
| | | |
| | | return this.findCount(hql.toString(), params); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 初始化平均成绩和最高成绩 |
| | | * |
| | | * |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 题目得分详情 |
| | | * |
| | | * |
| | | * @param groupId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开始题目作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | this.doStartAnswerExercise(exerciseInfo, clsClass, studentUserId) |
| | | : |
| | | this.doStartOtherExercise(exerciseInfo, clsClass, studentUserId); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 开始题目作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | // 查询学生考试总分 |
| | | result.addData("studentScore", record.getScore()); |
| | | result.addData("objStudentScore", record.getObjScore()==null?BigDecimal.ZERO:record.getObjScore()); |
| | | |
| | | |
| | | ExerciseCompleteInfo completeInfo = doGetOrCreateExerciseCompleteInfo(exerciseInfo.getExerciseInfoId(),clsClass.getClassId() , studentUserId); |
| | | |
| | | |
| | | if(completeInfo!=null){ |
| | | result.addData("exerciseCompleteId", completeInfo.getExerciseCompleteId()); |
| | | } |
| | | |
| | | |
| | | result.addData("itemSet", exerciseInfo.getExerciseItemSets()); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | private ExerciseCompleteInfo doGetOrCreateExerciseCompleteInfo(String exerciseInfoId,String classId,String studentUserId){ |
| | | // 判断是否已经初始化 |
| | | ExerciseCompleteInfo completeInfo = exerciseCompleteService.queryCompleteInfo(exerciseInfoId,classId , studentUserId); |
| | | |
| | | if(completeInfo==null){ |
| | | String hql = " select s.studentId as studentId,s.studentNo as studentNo,s.userId as studentUserId,s.name as studentName," |
| | | + " c.classId as classId,c.name as className from StuStudent s ,ClsClass c,ExerciseExamReClass r " |
| | | + " where r.examId=:exerciseInfoId and r.classId =c.classId and c.classId= s.classId and s.userId=:userId" |
| | | + " and s.classId=:classId and r.examId=:exerciseInfoId and r.deleteFlag is false and s.deleteFlag is false and c.deleteFlag is false"; |
| | | |
| | | List<Map<String, Object>> resultMap = this.findListWithMapByHql(hql, |
| | | // 判断是否已经初始化 |
| | | ExerciseCompleteInfo completeInfo = exerciseCompleteService.queryCompleteInfo(exerciseInfoId,classId , studentUserId); |
| | | |
| | | if(completeInfo==null){ |
| | | String hql = " select s.studentId as studentId,s.studentNo as studentNo,s.userId as studentUserId,s.name as studentName," |
| | | + " c.classId as classId,c.name as className from StuStudent s ,ClsClass c,ExerciseExamReClass r " |
| | | + " where r.examId=:exerciseInfoId and r.classId =c.classId and c.classId= s.classId and s.userId=:userId" |
| | | + " and s.classId=:classId and r.examId=:exerciseInfoId and r.deleteFlag is false and s.deleteFlag is false and c.deleteFlag is false"; |
| | | |
| | | List<Map<String, Object>> resultMap = this.findListWithMapByHql(hql, |
| | | CollectionUtils.newObjectMap("userId",studentUserId,"classId",classId,"exerciseInfoId",exerciseInfoId)); |
| | | |
| | | if(resultMap!=null && resultMap.get(0)!=null){ |
| | | Map<String, Object> map = resultMap.get(0); |
| | | |
| | | completeInfo = new ExerciseCompleteInfo(); |
| | | TraceUtils.setCreateTrace(completeInfo); |
| | | completeInfo.setStudentId((String) map.get("studentId")); |
| | | completeInfo.setStudentNo((String) map.get("studentNo")); |
| | | completeInfo.setStudentUserId((String) map.get("studentUserId")); |
| | | completeInfo.setStudentUserName((String) map.get("studentName")); |
| | | completeInfo.setClassId((String) map.get("classId")); |
| | | completeInfo.setClassName((String) map.get("className")); |
| | | completeInfo.setExerciseInfoId(exerciseInfoId); |
| | | completeInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | this.save(completeInfo); |
| | | } |
| | | |
| | | if(resultMap!=null && resultMap.get(0)!=null){ |
| | | Map<String, Object> map = resultMap.get(0); |
| | | |
| | | completeInfo = new ExerciseCompleteInfo(); |
| | | TraceUtils.setCreateTrace(completeInfo); |
| | | completeInfo.setStudentId((String) map.get("studentId")); |
| | | completeInfo.setStudentNo((String) map.get("studentNo")); |
| | | completeInfo.setStudentUserId((String) map.get("studentUserId")); |
| | | completeInfo.setStudentUserName((String) map.get("studentName")); |
| | | completeInfo.setClassId((String) map.get("classId")); |
| | | completeInfo.setClassName((String) map.get("className")); |
| | | completeInfo.setExerciseInfoId(exerciseInfoId); |
| | | completeInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_DRAFT); |
| | | this.save(completeInfo); |
| | | } |
| | | |
| | | return completeInfo; |
| | | } |
| | | |
| | | return completeInfo; |
| | | } |
| | | |
| | | |
| | | private Map<String,Object> insertExerRecord(ExerciseInfo exerciseInfo,String groupId) { |
| | | ExerciseRecord record = new ExerciseRecord(); |
| | | record.setDeleteFlag(false); |
| | |
| | | record.setUserId(ClientUtils.getUserId()); |
| | | record.setOrgId(ClientUtils.getOrgId()); |
| | | TraceUtils.setCreateTrace(record); |
| | | |
| | | |
| | | //获取考试题目统计信息,并保存 |
| | | Map<String,Object> result = this.queryItemStatics(exerciseInfo.getExerciseItemSets()); |
| | | record.setTotalScore(new BigDecimal(exerciseInfo.getScore())); |
| | |
| | | record.setObjTotalScore((BigDecimal)result.get("objTotalScore")); |
| | | record.setSubItemCount((int)result.get("subItemCount")); |
| | | record.setObjItemCount((int)result.get("objItemCount")); |
| | | |
| | | |
| | | TraceUtils.setCreateTrace(record); |
| | | this.save(record); |
| | | |
| | | |
| | | Map<String,Object> resultMap = new HashMap<String, Object>(3); |
| | | resultMap.put("exerciseRecordId", record.getRecordId()); |
| | | resultMap.put("updateTime", DateTimeUtils.getCurrDateTime(record.getUpdateTime())); |
| | | resultMap.put("exerciseGroupId", groupId); |
| | | resultMap.put("record", record); |
| | | |
| | | |
| | | return resultMap; |
| | | } |
| | | |
| | | |
| | | private Map<String,Object> queryItemStatics(List<ExerciseItemSet> itemSets){ |
| | | float subTotalScore = 0,objTotalScore=0; |
| | | int subItemCount=0,objItemCount=0; |
| | | |
| | | |
| | | //如果是随机组卷 |
| | | if(itemSets!=null && itemSets.size()>0){ |
| | | for(ExerciseItemSet s:itemSets){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Map<String,Object> result = new HashMap<String,Object>(); |
| | | result.put("subTotalScore", new BigDecimal(subTotalScore)); |
| | | result.put("objTotalScore", new BigDecimal(objTotalScore)); |
| | | result.put("subItemCount", subItemCount); |
| | | result.put("objItemCount", objItemCount); |
| | | |
| | | |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 开始文件和写作作业 |
| | | * |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | |
| | | // 查询是否已经存在做题记录,如果不存在需要新建 |
| | | ExerciseCompleteInfo exerciseCompleteInfo = exerciseCompleteService.doCheckAndCreateExerciseCompleteInfo( |
| | | exerciseInfo.getExerciseInfoId(), clsClass.getClassId(), studentUserId); |
| | | |
| | | |
| | | exerciseCompleteInfo.setCommitUploadType(exerciseInfo.getCommitUploadType()); |
| | | exerciseCompleteInfo.setRemind(exerciseInfo.getRemind()); |
| | | exerciseCompleteInfo.setExerciseType(exerciseInfo.getType()); |
| | |
| | | exerciseCompleteInfo |
| | | .setPreviewPath(StringUtils.isNotEmpty(video.getAndroidHD()) ? video.getAndroidHD() |
| | | : StringUtils.isNotEmpty(video.getAndroidSD()) ? video.getAndroidSD() |
| | | : video.getAndroidLD()); |
| | | : video.getAndroidLD()); |
| | | } else { |
| | | exerciseCompleteInfo.setTransStatus(ExerciseCompleteInfo.PREVIEW_STATUS_NO); |
| | | } |
| | |
| | | .getOrgText(exerciseCompleteInfo.getExerciseCompleteId(), OrgText.TABLE_WRITING_EXERCISE) |
| | | .getContent()); |
| | | } |
| | | |
| | | |
| | | exerciseCompleteInfo.setTotalScore(exerciseInfo.getScore()); |
| | | |
| | | return new Result(true,"",CollectionUtils.newObjectMap("exerciseCompleteInfo", exerciseCompleteInfo)); |
| | |
| | | |
| | | @Override |
| | | public Result doSubmitOtherExerciseInfo(String exerciseCompleteInfoId, String content, String fileId, |
| | | String filePath, short submitType) { |
| | | String filePath, short submitType) { |
| | | Result result = new Result(true); |
| | | ExerciseCompleteInfo exerciseCompleteInfo = this.read(ExerciseCompleteInfo.class, exerciseCompleteInfoId); |
| | | ExerciseInfo exerciseInfo = this.read(ExerciseInfo.class, exerciseCompleteInfo.getExerciseInfoId()); |
| | | |
| | | |
| | | if (exerciseInfo.getType() == ExerciseInfo.EXERCISE_TYPE_WRITING) { |
| | | result = this.doSubmitWritingExerciseInfo(exerciseCompleteInfoId, content, submitType); |
| | | } else if (exerciseInfo.getType() == ExerciseInfo.EXERCISE_TYPE_FILE) { |
| | |
| | | |
| | | /** |
| | | * 提交写作作业 |
| | | * |
| | | * |
| | | * @param exerciseInfoId |
| | | * @param content |
| | | * @param submitType |
| | |
| | | exerciseCompleteInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_COMMIT); |
| | | exerciseCompleteInfo.setCreator(ClientUtils.getUserName()); |
| | | } |
| | | |
| | | |
| | | this.save(exerciseCompleteInfo); |
| | | return new Result(true); |
| | | } |
| | | |
| | | /** |
| | | * 提交文件作业 |
| | | * |
| | | * |
| | | * @param exerciseCompleteInfoId |
| | | * @param content |
| | | * @param fileId |
| | |
| | | * @return |
| | | */ |
| | | private Result doSubmitFileExerciseInfo(String exerciseCompleteInfoId, String content, String fileId, |
| | | String filePath, short submitType) { |
| | | String filePath, short submitType) { |
| | | ExerciseCompleteInfo exerciseCompleteInfo = this.read(ExerciseCompleteInfo.class, exerciseCompleteInfoId); |
| | | ExerciseInfo exerciseInfo = this.read(ExerciseInfo.class, exerciseCompleteInfo.getExerciseInfoId()); |
| | | |
| | |
| | | ResFile resFile = this.read(ResFile.class, fileId); |
| | | exerciseCompleteInfo.setFileId(fileId); |
| | | exerciseCompleteInfo.setFilePath(filePath); |
| | | exerciseCompleteInfo.setOrgiFileName(resFile.getFileName()); |
| | | exerciseCompleteInfo.setOrgiFileName(ClientUtils.getUserName()+"的作业"); |
| | | } |
| | | |
| | | exerciseCompleteInfo.setUploadDesc(content); |
| | |
| | | |
| | | return new Result(false, "提交数据异常"); |
| | | } |
| | | |
| | | |
| | | ExerciseRecord record = this.read(ExerciseRecord.class, initRecordId); |
| | | |
| | | //计算得分 |
| | | double studentScore = this.doCalculateExerciseScores(answerData, exerciseInfo.getExerciseItemSets()); |
| | | |
| | | |
| | | // 提交试卷答案 |
| | | answerData.setScore(new BigDecimal(studentScore)); |
| | | Map<String, Object> resultMap = exerciseVerService.doOperExerciseAnswerData(answerData); |
| | |
| | | // 更新得分记录及状态 |
| | | exerciseCompleteInfo = this.read(ExerciseCompleteInfo.class, exerciseCompleteId); |
| | | resultMap.put("studentScore", studentScore); |
| | | |
| | | |
| | | |
| | | |
| | | // 更新完成得分 |
| | | if (ExerciseRecord.STATUS_SUBMIT.equals(answerData.getStatus())) { |
| | | resultMap.put("objScore", studentScore); |
| | | exerciseCompleteInfo.setSubmitTime(new Date()); |
| | | |
| | | |
| | | if(record.getSubItemCount()==0){ |
| | | exerciseCompleteInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_CHECKED); |
| | | }else{ |
| | | exerciseCompleteInfo.setCompleteStatus(ExerciseCompleteInfo.STATUS_COMMIT); |
| | | } |
| | | |
| | | |
| | | this.bulkUpdate( |
| | | "update ExerciseRecord set status=1 , score=" + studentScore + ",objScore=" + studentScore |
| | | + " where deleteFlag is false and recordId=?", |
| | |
| | | + " where deleteFlag is false and recordId=? ", |
| | | new Object[] { resultMap.get("recordId") }); |
| | | } |
| | | exerciseCompleteInfo.setStudentScore(new BigDecimal(studentScore)); |
| | | |
| | | exerciseCompleteInfo.setStudentScore(new BigDecimal(studentScore)); |
| | | |
| | | this.save(exerciseCompleteInfo); |
| | | |
| | | |
| | | // 记录提交的数据日志 |
| | | exerciseVerService.doSaveExerciseDataSubmitLog(JSON.toJSONString(answerData), initRecordId, |
| | | ExerciseDataSubmitLog.TYPE_SUBMIT_ANSWER, ExerciseDataSubmitLog.STATUS_SUCCESS, |
| | |
| | | private double doCalculateExerciseScores(ExerciseSubmitAnswerData answerData, List<ExerciseItemSet> lstItemSet) { |
| | | //获取填空题答案信息 |
| | | Map<String,String> exerciseFillItemMap= null; |
| | | List<Object[]> lstObj = this.find("select i.exerciseId,i.answer from ExerciseGroupItemRe r, ExerciseItem i where r.exerciseItemId=i.exerciseId and r.exerciseGroupId=? and r.deleteFlag is false and i.type=? and i.deleteFlag is false", |
| | | List<Object[]> lstObj = this.find("select i.exerciseId,i.answer from ExerciseGroupItemRe r, ExerciseItem i where r.exerciseItemId=i.exerciseId and r.exerciseGroupId=? and r.deleteFlag is false and i.type=? and i.deleteFlag is false", |
| | | CollectionUtils.newList(answerData.getExerciseGroupId(),ExerciseItem.TYPE_FILL_BLANKS), Object[].class); |
| | | if(lstObj!=null && lstObj.size()>0){ |
| | | exerciseFillItemMap = new HashMap<String,String>(lstObj.size()); |
| | | for(Object[] arrObj : lstObj){ |
| | | exerciseFillItemMap.put((String)arrObj[0],(String)arrObj[1]); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Map<String, Double> scoreMap = new HashMap<String, Double>(); |
| | | for (int i = 0; i < lstItemSet.size(); i++) { |
| | | if (lstItemSet.get(i).getItemType() == ExerciseItem.TYPE_SINGLE_SELECT) { |
| | |
| | | scoreMap.put("fill_right", lstItemSet.get(i).getRightScore()); |
| | | scoreMap.put("fill_wrong", lstItemSet.get(i).getWrongScore()); |
| | | scoreMap.put("fill_noanswer", lstItemSet.get(i).getBlankScore()); |
| | | } |
| | | } |
| | | } |
| | | double totalScore = 0.00; |
| | | String tempRightAnswer =null; |
| | |
| | | |
| | | return totalScore; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result doPublishExercise(String[] exerciseIds) { |
| | | // 更新作业状态 |
| | |
| | | for (String exerciseId : exerciseIds) { |
| | | // 判断是否已经初始化,如果已经初始化则继续 -> TODO:需要处理新加入班级学生 |
| | | int count = this.findCount("from ExerciseCompleteInfo f where f.deleteFlag is false and f.exerciseInfoId=?",CollectionUtils.newList(exerciseId)); |
| | | |
| | | |
| | | if (count == 0) { |
| | | hql = " select s.studentId as studentId,s.studentNo as studentNo,s.userId as studentUserId,s.name as studentName,c.classId as classId,c.name as className " |
| | | + " from StuStudent s ,ClsClass c,ExerciseExamReClass r where r.examId=:exerciseInfoId " |
| | |
| | | this.saveOrUpdateAll(lstCompleteInfos); |
| | | } |
| | | } |
| | | |
| | | |
| | | //发布作业消息 |
| | | this.doExercisePublishMsg(exerciseId); |
| | | } |
| | | |
| | | |
| | | return new Result(true); |
| | | } |
| | | |
| | | |
| | | private void doExercisePublishMsg(String exerciseInfoId){ |
| | | ExerciseInfo exerciseInfo= this.read(ExerciseInfo.class, exerciseInfoId); |
| | | |
| | | List<String> lstUserIds = this.find("select userId from ExerciseResultV where id.exerciseInfoId=?", |
| | | CollectionUtils.newList(exerciseInfoId), String.class); |
| | | |
| | | |
| | | List<String> lstUserIds = this.find("select userId from ExerciseResultV where id.exerciseInfoId=?", |
| | | CollectionUtils.newList(exerciseInfoId), String.class); |
| | | |
| | | if(lstUserIds!=null && lstUserIds.size()>0){ |
| | | Map<String,String> attrs = CollectionUtils.newStringMap("exerciseInfoId",exerciseInfoId,"exerciseName",exerciseInfo.getName(), |
| | | "subjectId",exerciseInfo.getSubjectId(),"subjectName",exerciseInfo.getSubject().getName()); |
| | | |
| | | msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]), |
| | | MsgInfo.TYPE_EXERCISE," 发布了作业 ", attrs); |
| | | "subjectId",exerciseInfo.getSubjectId(),"subjectName",exerciseInfo.getSubject().getName()); |
| | | |
| | | msgInfoService.doSendTextMsgToUsers(lstUserIds.toArray(new String[lstUserIds.size()]), |
| | | MsgInfo.TYPE_EXERCISE," 发布了作业 ", attrs); |
| | | } |
| | | } |
| | | |
| | |
| | | this.bulkUpdateInLoop("update ExerciseInfo set status=" + ExerciseInfo.EXERCISE_STATUS_DRAFT + " WHERE exerciseInfoId=?",exerciseIds); |
| | | // 清除作业完成情况 |
| | | this.bulkUpdateInLoop("update ExerciseCompleteInfo set deleteFlag= true WHERE exerciseInfoId=?", exerciseIds); |
| | | |
| | | |
| | | return new Result(true); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取完成的作业个数 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @param userId |
| | | * @return |
| | |
| | | CollectionUtils.newObjectMap("classId", classId, "status", ExerciseInfo.EXERCISE_STATUS_PUBLISHED)); |
| | | return exerciseCount; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询作业列表-教师端 |
| | | * |
| | | * |
| | | * @param pageSize |
| | | * @param keyword |
| | | * @param classId |
| | |
| | | public List<Map<String, Object>> teacherExerciseInfoList(Integer pageSize,String keyword,String classId,Integer pageNum) { |
| | | QHomeworkScoreV qHomeworkScoreV = QHomeworkScoreV.homeworkScoreV; |
| | | QExerciseInfo qExerciseInfo = QExerciseInfo.exerciseInfo; |
| | | |
| | | |
| | | Expression<Integer> cases = new CaseBuilder() |
| | | .when(qHomeworkScoreV.completeStatus.isNull()).then(1) |
| | | .otherwise(0).sum().as("homeworkNoSubmitCount"); |
| | | |
| | | .when(qHomeworkScoreV.completeStatus.isNull()).then(1) |
| | | .otherwise(0).sum().as("homeworkNoSubmitCount"); |
| | | |
| | | Expression<Integer> cases2 = new CaseBuilder() |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_CHECKED))).then(1) |
| | | .otherwise(0).sum().as("homeworkToAuditCount"); |
| | | |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_CHECKED))).then(1) |
| | | .otherwise(0).sum().as("homeworkToAuditCount"); |
| | | |
| | | Expression<Integer> cases3 = new CaseBuilder() |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_COMMIT))).then(1) |
| | | .otherwise(0).sum().as("homeworkHasAuditCount"); |
| | | |
| | | .when(qHomeworkScoreV.completeStatus.eq(String.valueOf(ExerciseCompleteInfo.STATUS_COMMIT))).then(1) |
| | | .otherwise(0).sum().as("homeworkHasAuditCount"); |
| | | |
| | | return this.getQueryFactory().select(cases,cases2,cases3, qExerciseInfo.name.max(), |
| | | qExerciseInfo.startTime.max(), qExerciseInfo.endTime.max(), qExerciseInfo.type.max()).from(qHomeworkScoreV, qExerciseInfo) |
| | | .where(qHomeworkScoreV.classId.eq(classId) |
| | |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<String,Integer> queryResultStatusCount(List<String> lstExerciseIds) { |
| | | if(lstExerciseIds== null || lstExerciseIds.size()==0){ |
| | | return null; |
| | | } |
| | | |
| | | |
| | | String hql = "select id.exerciseInfoId||'-'||completeStatus ,count(1) from ExerciseResultV " |
| | | + "where id.exerciseInfoId in(:exerciseIds) group by id.exerciseInfoId,completeStatus"; |
| | | |
| | | List<Object[]> lstResult = this.findByComplexHql(hql, |
| | | + "where id.exerciseInfoId in(:exerciseIds) group by id.exerciseInfoId,completeStatus"; |
| | | |
| | | List<Object[]> lstResult = this.findByComplexHql(hql, |
| | | CollectionUtils.newObjectMap("exerciseIds",lstExerciseIds.toArray(new String[lstExerciseIds.size()])), Object[].class); |
| | | |
| | | Map<String,Integer> resultMap = new HashMap<String,Integer>(lstResult.size()); |
| | | |
| | | |
| | | Map<String,Integer> resultMap = new HashMap<String,Integer>(lstResult.size()); |
| | | |
| | | for(Object[] o:lstResult){ |
| | | resultMap.put((String)o[0],((Long)o[1]).intValue()); |
| | | } |
| | |
| | | |
| | | package com.qxueyou.scc.operation.topic.action; |
| | | |
| | | import com.qxueyou.scc.Sensitive.SensitiveWordFilter; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @GetMapping(value = "addComment") |
| | | public Result addComment(String content, String commentObjectId, String commentParentId, String commentedId, |
| | | String commentedName) { |
| | | return topicService.addComment(content, commentObjectId, commentParentId, commentedId, commentedName); |
| | | SensitiveWordFilter.loadWordFromFile("D:\\工作\\SensitiveWord\\SensitiveWordList.txt"); |
| | | String filter = SensitiveWordFilter.Filter(content); |
| | | return topicService.addComment(filter, commentObjectId, commentParentId, commentedId, commentedName); |
| | | } |
| | | |
| | | /** |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | * @author ZERO 2021-03-03 09:06 |
| | | */ |
| | | @RestController |
| | | @CrossOrigin |
| | | @RequestMapping("/homepage") |
| | | @Api(tags = "首页相关接口") |
| | | public class HomepageController { |
| | |
| | | return new Result(true, "tab",homepageService.getTabs()); |
| | | } |
| | | |
| | | // @GetMapping |
| | | // @ApiOperation("获取列表") |
| | | // public Result getIndexDetail() { |
| | | //// System.err.println("=====>获取列表"); |
| | | // return new Result(true,"", homepageService.getIndexDetail()); |
| | | // } |
| | | @GetMapping(value = "/home") |
| | | @ApiOperation("获取列表") |
| | | public Result getIndexDetail() { |
| | | // System.err.println("=====>获取列表"); |
| | | return new Result(true,"", homepageService.getIndexDetail()); |
| | | } |
| | | |
| | | @GetMapping(value = "/getExcellentTeaching") |
| | | @ApiOperation("获取精品教学") |
| | | public Result getExcellentTeaching() { |
| | | // System.err.println("=====>获取列表"); |
| | | return new Result(true,"", homepageService.getExcellentTeaching()); |
| | | } |
| | | |
| | | @GetMapping("/article") |
| | | @ApiOperation("获取文章列表") |
| | |
| | | /** |
| | | * 获取首页数据 |
| | | // */ |
| | | // Map<String, Object> getIndexDetail(); |
| | | Map<String, Object> getIndexDetail(); |
| | | |
| | | /** |
| | | * 获取首页标签 |
| | |
| | | |
| | | Map<String,Object> getVideo(String type,String subColumn,int page, int size); |
| | | |
| | | Map<String,Object> getExcellentTeaching(); |
| | | } |
| | |
| | | //import com.qxueyou.appraisal.web.homepage.serivce.IHomepageService; |
| | | //import com.qxueyou.entity.article.ArticleDO; |
| | | //import com.qxueyou.util.CollectionUtils; |
| | | |
| | | import com.querydsl.jpa.impl.JPAQuery; |
| | | import com.qxueyou.scc.admin.classes.service.IClassLectureService; |
| | | import com.qxueyou.scc.admin.progress.dao.ProgressDAO; |
| | | import com.qxueyou.scc.base.service.impl.CommonAppService; |
| | | import com.qxueyou.scc.base.util.CollectionUtils; |
| | | import com.qxueyou.scc.evaluate.service.IEvaluateService; |
| | | import com.qxueyou.scc.operation.topic.service.ITopicService; |
| | | import com.qxueyou.scc.portal.homepage.dao.ArticleDao; |
| | | import com.qxueyou.scc.portal.homepage.serivce.IHomepageService; |
| | | import com.qxueyou.scc.portal.information.model.Information; |
| | | import com.qxueyou.scc.teach.res.model.Res; |
| | | import com.qxueyou.scc.teach.res.model.ResLib; |
| | | import com.qxueyou.scc.teach.res.service.IResAudioService; |
| | | import com.qxueyou.scc.teach.subject.model.QSubjectLecture; |
| | | import com.qxueyou.scc.teach.subject.model.SubjectLecture; |
| | | import com.qxueyou.scc.teach.subject.model.view.OpenSubjectV; |
| | | import com.qxueyou.scc.teach.subject.service.ILectureService; |
| | | import com.qxueyou.scc.teach.subject.service.ISubjectService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import static java.util.stream.Collectors.toList; |
| | | |
| | | /** |
| | | * @author ZERO 2021-03-03 09:16 |
| | | */ |
| | | @Service |
| | | public class HomepageService implements IHomepageService { |
| | | public class HomepageService extends CommonAppService implements IHomepageService { |
| | | |
| | | @Autowired |
| | | private ArticleDao articleDao; |
| | | |
| | | // @Autowired |
| | | // private AppraisalBatchDao batchDao; |
| | | @Autowired |
| | | ISubjectService subjectService; |
| | | |
| | | // @Autowired |
| | | // private ContestsBatchDao batchDao; |
| | | @Autowired |
| | | ILectureService lectureService; |
| | | |
| | | // @Autowired |
| | | // private OccupationDao occupationDao; |
| | | @Autowired |
| | | IClassLectureService clsLectureService; |
| | | |
| | | @Autowired |
| | | IResAudioService audioService; |
| | | |
| | | @Autowired |
| | | ProgressDAO progressDao; |
| | | |
| | | @Autowired |
| | | ITopicService topicService; |
| | | |
| | | @Autowired |
| | | IEvaluateService evaluateService; |
| | | |
| | | |
| | | /** |
| | | * 获取首页数据 |
| | | */ |
| | | // @Override |
| | | // public Map<String, Object> getIndexDetail() { |
| | | // |
| | | // List<OpenSubjectV> openSubjectVS = subjectService.listOpenSubjectV(); |
| | | // //华文课堂 |
| | | //// List<String> chineseLanguageClassId= openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("华文课堂")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | // //文化中国 |
| | | // List<String> culturalChinaId = openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("文化中国")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | // //文化课堂 |
| | | // List<String> culturalClassroomId = openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("文化课堂")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | // //实景课堂 |
| | | // List<String> realClassId = openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("实景课堂")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | // //中文+职业教育课程 |
| | | // List<String> chineseCourseId = openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("中文职业教育课程")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | // |
| | | // StringBuffer hql = new StringBuffer("from SubjectLecture p where deleteFlag is false and status=?"); |
| | | // List<Object> args = CollectionUtils.newList(SubjectLecture.STATUS_DRAFT); |
| | | // List<SubjectLecture> subjectLectureList = find(hql.toString(), args, SubjectLecture.class); |
| | | // |
| | | // //华文课堂 |
| | | //// List<String> shineseLanguageClassResId= subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getSubjectId().equals(chineseLanguageClassId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | // //文化中国 |
| | | // List<String> culturalChinaResId = subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getName().equals(culturalChinaId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | // //文化课堂 |
| | | // List<String> culturalClassroomResId = subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getName().equals(culturalClassroomId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | // //实景课堂 |
| | | // List<String> realClassResId = subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getName().equals(realClassId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | // //中文+职业教育课程 |
| | | // List<String> chineseCourseResId = subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getName().equals(chineseCourseId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | // StringBuffer hqlRes = new StringBuffer("from Res p where deleteFlag is false and status=?"); |
| | | // List<Res> resList = find(hqlRes.toString(), args, Res.class); |
| | | // ArrayList<Res> shineseLanguageClassRes = new ArrayList<>(); |
| | | // ArrayList<Res> culturalChinaRes = new ArrayList<>(); |
| | | // ArrayList<Res> culturalClassroomRes = new ArrayList<>(); |
| | | // ArrayList<Res> realClassRes = new ArrayList<>(); |
| | | // for (Res res : resList) { |
| | | //// for (String resItemId : shineseLanguageClassResId) { |
| | | //// if (res.getResId().equals(resItemId)) { |
| | | //// shineseLanguageClassRes.add(res); |
| | | //// } |
| | | //// } |
| | | // for (String resItemId : culturalChinaResId) { |
| | | // if (res.getResId().equals(resItemId)) { |
| | | // culturalChinaRes.add(res); |
| | | // } |
| | | // } |
| | | // for (String resItemId : culturalClassroomResId) { |
| | | // if (res.getResId().equals(resItemId)) { |
| | | // culturalClassroomRes.add(res); |
| | | // } |
| | | // } |
| | | // for (String resItemId : realClassResId) { |
| | | // if (res.getResId().equals(resItemId)) { |
| | | // realClassRes.add(res); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | //// System.err.println("================>获取首页数据"); |
| | | // return CollectionUtils.newObjectMap( |
| | | // "appraisalBatchInfo", batchDao.findBatches(1, 24, null).get("data"), // createTime browseCount dateTime |
| | | // "occupationInfo", articleDao.findPage(CollectionUtils.newObjectMap("type", "qualifiedSet", "status", ArticleDO.UP_STATUS), 1, 8, "dateTime", Sort.Direction.DESC).get("data"), |
| | | // "news", articleDao.findPage(CollectionUtils.newObjectMap("type", "policiesRegulations", "status", ArticleDO.UP_STATUS), 1, 8, "dateTime", Sort.Direction.DESC).get("data")); |
| | | // "华文课堂", shineseLanguageClassRes, |
| | | // "文化中国", culturalChinaRes, |
| | | // "实景课堂", culturalClassroomRes, |
| | | // "中文+职业教育课程", realClassRes); |
| | | // } |
| | | @Override |
| | | public Map<String, Object> getIndexDetail() { |
| | | |
| | | List<OpenSubjectV> openSubjectVS = subjectService.listOpenSubjectV(); |
| | | //文化中国 |
| | | List<String> culturalChinaId = openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("文化中国")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | //文化课堂 |
| | | // List<String> culturalClassroomId = openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("文化课堂")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | //华文课堂 |
| | | List<String> chineseLanguageClassId= openSubjectVS.stream().filter(openSubjectV -> openSubjectV.getSubjectName().equals("华文课堂")).map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | |
| | | StringBuffer hql = new StringBuffer("from SubjectLecture p where deleteFlag is false and status=?"); |
| | | List<Object> args = CollectionUtils.newList(SubjectLecture.STATUS_DRAFT); |
| | | List<SubjectLecture> subjectLectureList = find(hql.toString(), args, SubjectLecture.class); |
| | | //文化中国 |
| | | List<String> culturalChinaResId = culturalChinaId.size() == 0 ? null : subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getSubjectId().equals(culturalChinaId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | //文化课堂 |
| | | List<String> chineseLanguageClassResId = chineseLanguageClassId.size() == 0 ? null : subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getSubjectId().equals(chineseLanguageClassId.get(0))).map(SubjectLecture::getResItemId).collect(toList()); |
| | | StringBuffer hqlRes = new StringBuffer("from Res p where deleteFlag is false and status=?"); |
| | | List<Res> resList = find(hqlRes.toString(), args, Res.class); |
| | | List<Res> culturalChinaRes = new ArrayList<>(); |
| | | List<Res> chineseLanguageClassRes = new ArrayList<>(); |
| | | if (culturalChinaResId != null) { |
| | | for (Res res : resList) { |
| | | for (String resItemId : culturalChinaResId) { |
| | | if (res.getResId().equals(resItemId)) { |
| | | culturalChinaRes.add(res); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (chineseLanguageClassResId != null) { |
| | | for (Res res : resList) { |
| | | for (String resItemId : chineseLanguageClassResId) { |
| | | if (res.getResId().equals(resItemId)) { |
| | | chineseLanguageClassRes.add(res); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // return CollectionUtils.newObjectMap( |
| | | // "culturalClassroomRes", chineseLanguageClassRes, |
| | | // "culturalChinaRes", culturalChinaRes); |
| | | return CollectionUtils.newObjectMap( |
| | | "culturalClassroomRes",CollectionUtils.newObjectMap("data",chineseLanguageClassRes), |
| | | "culturalChinaRes",CollectionUtils.newObjectMap("data", culturalChinaRes) |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getExcellentTeaching() { |
| | | |
| | | List<OpenSubjectV> openSubjectVS = subjectService.listOpenSubjectV(); |
| | | //文化课堂 |
| | | List<String> culturalClassroomId = openSubjectVS.stream() |
| | | .filter(openSubjectV -> openSubjectV.getSubjectName().equals("华文课堂")) |
| | | .map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | //实景课堂 |
| | | List<String> realClassId = openSubjectVS.stream() |
| | | .filter(openSubjectV -> openSubjectV.getSubjectName().equals("实景课堂")) |
| | | .map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | //中文+职业教育课程 |
| | | List<String> chineseCourseId = openSubjectVS.stream() |
| | | .filter(openSubjectV -> openSubjectV.getSubjectName().equals("中文+职业教育课程")) |
| | | .map(OpenSubjectV::getSubjectId).collect(toList()); |
| | | |
| | | StringBuffer hql = new StringBuffer("from SubjectLecture p where deleteFlag is false and status=?"); |
| | | List<Object> args = CollectionUtils.newList(SubjectLecture.STATUS_DRAFT); |
| | | List<SubjectLecture> subjectLectureList = find(hql.toString(), args, SubjectLecture.class); |
| | | |
| | | //华文课堂 |
| | | List<String> culturalClassroomResId = culturalClassroomId.size() == 0 ? null : subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getSubjectId().equals(culturalClassroomId.get(0))) |
| | | .sorted(Comparator.comparing(SubjectLecture::getCreateTime) |
| | | .reversed()).map(SubjectLecture::getResItemId).limit(8).collect(toList()); |
| | | //实景课堂 |
| | | List<String> realClassResId = realClassId.size() == 0 ? null : subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getSubjectId().equals(realClassId.get(0))) |
| | | .sorted(Comparator.comparing(SubjectLecture::getCreateTime) |
| | | .reversed()).map(SubjectLecture::getResItemId).limit(8).collect(toList()); |
| | | //中文+职业教育课程 |
| | | List<String> chineseCourseResId = chineseCourseId.size() == 0 ? null : subjectLectureList.stream().filter(subjectLecture -> subjectLecture.getSubjectId().equals(chineseCourseId.get(0))) |
| | | .sorted(Comparator.comparing(SubjectLecture::getCreateTime) |
| | | .reversed()).map(SubjectLecture::getResItemId).limit(8).collect(toList()); |
| | | StringBuffer hqlRes = new StringBuffer("from Res p where deleteFlag is false and status=?"); |
| | | List<Res> resList = find(hqlRes.toString(), args, Res.class); |
| | | ArrayList<Res> chineseCourseRes = new ArrayList<>(); |
| | | ArrayList<Res> culturalClassroomRes = new ArrayList<>();//文化课堂 |
| | | ArrayList<Res> realClassRes = new ArrayList<>(); |
| | | |
| | | if (culturalClassroomResId != null) { |
| | | for (String resItemId : culturalClassroomResId) { |
| | | for (Res res : resList) { |
| | | if (res.getResId().equals(resItemId)) { |
| | | culturalClassroomRes.add(res); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (realClassResId != null) { |
| | | for (String resItemId : realClassResId) { |
| | | for (Res res : resList) { |
| | | if (res.getResId().equals(resItemId)) { |
| | | realClassRes.add(res); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (chineseCourseResId != null) { |
| | | for (String resItemId : chineseCourseResId) { |
| | | for (Res res : resList) { |
| | | if (res.getResId().equals(resItemId)) { |
| | | chineseCourseRes.add(res); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return CollectionUtils.newObjectMap( |
| | | "chineseCourseRes",CollectionUtils.newObjectMap("subjectId",culturalClassroomId.size() == 0 ? null : culturalClassroomId.get(0),"data",chineseCourseRes), |
| | | "culturalClassroomRes",CollectionUtils.newObjectMap("subjectId",realClassId.size() == 0 ? null : realClassId.get(0),"data",culturalClassroomRes), |
| | | "realClassRes", CollectionUtils.newObjectMap("subjectId",chineseCourseId.size() == 0 ? null :chineseCourseId.get(0),"data",realClassRes)); |
| | | } |
| | | |
| | | /** |
| | | * 获取首页标签 |
| | |
| | | boolean exist; |
| | | List<Map<String, Object>> tabs = new ArrayList<>(); |
| | | |
| | | List<Map<String,String>> sub=new ArrayList<>(); |
| | | List<Map<String, String>> sub = new ArrayList<>(); |
| | | |
| | | |
| | | exist = articleDao.exist("examBriefing"); |
| | | if (exist) tabs.add(CollectionUtils.newObjectMap("name", "媒体聚焦", "type", "examBriefing","list",sub)); |
| | | if (exist) tabs.add(CollectionUtils.newObjectMap("name", "媒体聚焦", "type", "examBriefing", "list", sub)); |
| | | |
| | | exist = articleDao.exist("qualifiedSet"); |
| | | if (exist) tabs.add(CollectionUtils.newObjectMap("name", "华教新鲜事", "type", "qualifiedSet")); |
| | |
| | | exist = articleDao.exist("popularInformation"); |
| | | if (exist) tabs.add(CollectionUtils.newObjectMap("name", "联系我们", "type", "popularInformation")); |
| | | |
| | | exist =articleDao.existsubColumn("examBriefing","introduce"); |
| | | if(exist) sub.add(CollectionUtils.newStringMap("name", "海外资讯", "subColumn", "introduce") ); |
| | | exist = articleDao.existsubColumn("examBriefing", "introduce"); |
| | | if (exist) sub.add(CollectionUtils.newStringMap("name", "海外资讯", "subColumn", "introduce")); |
| | | |
| | | exist =articleDao.existsubColumn("examBriefing","contestFile"); |
| | | if(exist) sub.add(CollectionUtils.newStringMap("name", "海外资讯", "subColumn", "contestFile")); |
| | | exist = articleDao.existsubColumn("examBriefing", "contestFile"); |
| | | if (exist) sub.add(CollectionUtils.newStringMap("name", "海外资讯", "subColumn", "contestFile")); |
| | | |
| | | exist =articleDao.existsubColumn("examBriefing","previousContest"); |
| | | if(exist) sub.add(CollectionUtils.newStringMap("name", "往届大赛", "subColumn", "previousContest")); |
| | | exist = articleDao.existsubColumn("examBriefing", "previousContest"); |
| | | if (exist) sub.add(CollectionUtils.newStringMap("name", "往届大赛", "subColumn", "previousContest")); |
| | | |
| | | return tabs; |
| | | } |
| | |
| | | * 获取文章列表 |
| | | */ |
| | | @Override |
| | | public Map<String, Object> getArticle(String type,String subColumn,String numbers,int page, int size, String keyword) { |
| | | return articleDao.moreOccupation(type,subColumn,numbers,page, size, keyword); |
| | | public Map<String, Object> getArticle(String type, String subColumn, String numbers, int page, int size, String |
| | | keyword) { |
| | | return articleDao.moreOccupation(type, subColumn, numbers, page, size, keyword); |
| | | } |
| | | |
| | | |
| | |
| | | //inc浏览数 |
| | | articleDao.incBrowseCount(id); |
| | | |
| | | Information article = articleDao.read(Information.class,id); |
| | | Information article = articleDao.read(Information.class, id); |
| | | |
| | | Map<String, Object> data = CollectionUtils.newObjectMap( |
| | | "title", article.getTitle(), |
| | |
| | | return data; |
| | | } |
| | | |
| | | public Information getArticlesType(String type,String subColumn) { |
| | | Information articleDO=articleDao.getArticle(type,subColumn); |
| | | public Information getArticlesType(String type, String subColumn) { |
| | | Information articleDO = articleDao.getArticle(type, subColumn); |
| | | return articleDO; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getVideo(String type, String subColumn, int page, int size) { |
| | | return articleDao.getVideoList(type,subColumn,page, size); |
| | | return articleDao.getVideoList(type, subColumn, page, size); |
| | | } |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.sdk; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class CommonResult<T> implements Serializable { |
| | | private static final long serialVersionUID = 7917345507074842804L; |
| | | private String code; |
| | | private String msg; |
| | | private T data; |
| | | private String format = "json"; |
| | | |
| | | public static class Builder { |
| | | public static com.qxueyou.scc.sdk.CommonResult SUCC() { |
| | | com.qxueyou.scc.sdk.CommonResult vo = new com.qxueyou.scc.sdk.CommonResult(); |
| | | vo.setCode("0"); |
| | | vo.setmsg("suc"); |
| | | return vo; |
| | | } |
| | | |
| | | public static com.qxueyou.scc.sdk.CommonResult FAIL() { |
| | | com.qxueyou.scc.sdk.CommonResult vo = new com.qxueyou.scc.sdk.CommonResult(); |
| | | return vo; |
| | | } |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initErrCodeAndMsg(String code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initErrCodeAndMsg(int code, String msg) { |
| | | this.code = Integer.toString(code); |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initSuccCodeAndMsg(String code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public com.qxueyou.scc.sdk.CommonResult initSuccData(T data) { |
| | | this.data = data; |
| | | return this; |
| | | } |
| | | |
| | | public static long getSerialVersionUID() { |
| | | return serialVersionUID; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getmsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setmsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public T getData() { |
| | | return data; |
| | | } |
| | | |
| | | public void setData(T data) { |
| | | this.data = data; |
| | | } |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.sdk.utils; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.nio.MappedByteBuffer; |
| | | import java.nio.channels.FileChannel; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | public class MD5Util { |
| | | |
| | | protected static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','a', 'b', 'c', 'd', 'e', 'f' }; |
| | | protected static MessageDigest messagedigest = null; |
| | | static{ |
| | | try{ |
| | | messagedigest = MessageDigest.getInstance("MD5"); |
| | | }catch(NoSuchAlgorithmException nsaex){ |
| | | System.err.println(MD5Util.class.getName()+"初始化失败,MessageDigest不支持MD5Util。"); |
| | | nsaex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static String getFileMD5String(File file) throws IOException { |
| | | FileInputStream in = new FileInputStream(file); |
| | | FileChannel ch = in.getChannel(); |
| | | MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); |
| | | messagedigest.update(byteBuffer); |
| | | return bufferToHex(messagedigest.digest()); |
| | | } |
| | | |
| | | public static String getMD5String(String s) { |
| | | return getMD5String(s.getBytes()); |
| | | } |
| | | |
| | | public static String getMD5String(byte[] bytes) { |
| | | messagedigest.update(bytes); |
| | | return bufferToHex(messagedigest.digest()); |
| | | } |
| | | |
| | | private static String bufferToHex(byte bytes[]) { |
| | | return bufferToHex(bytes, 0, bytes.length); |
| | | } |
| | | |
| | | private static String bufferToHex(byte bytes[], int m, int n) { |
| | | StringBuffer stringbuffer = new StringBuffer(2 * n); |
| | | int k = m + n; |
| | | for (int l = m; l < k; l++) { |
| | | appendHexPair(bytes[l], stringbuffer); |
| | | } |
| | | return stringbuffer.toString(); |
| | | } |
| | | |
| | | |
| | | private static void appendHexPair(byte bt, StringBuffer stringbuffer) { |
| | | char c0 = hexDigits[(bt & 0xf0) >> 4]; |
| | | char c1 = hexDigits[bt & 0xf]; |
| | | stringbuffer.append(c0); |
| | | stringbuffer.append(c1); |
| | | } |
| | | |
| | | public static boolean checkPassword(String password, String md5PwdStr) { |
| | | String s = getMD5String(password); |
| | | return s.equals(md5PwdStr); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.qxueyou.scc.base.util.ClientUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | * |
| | | */ |
| | | @RestController |
| | | @CrossOrigin |
| | | @RequestMapping(value = "/stu/homepage") |
| | | public class HomePageController { |
| | | |
| | |
| | | package com.qxueyou.scc.stucontroller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qxueyou.scc.sdk.MTCloud; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | |
| | | /** |
| | | * 查看直播明细 |
| | | * @param liveId 直播id |
| | | * @param couresId 直播id |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "view") |
| | | public Result view(String liveId) { |
| | | |
| | | MediaVideoLive live = liveService.read(liveId); |
| | | |
| | | return new Result(true, "success", CollectionUtils.newObjectMap( |
| | | "startTime",live.getStartTime(), |
| | | "endTime",live.getEndTime(), |
| | | "name",live.getName(), |
| | | "hlsPullUrl",live.getHlsPullUrl(), |
| | | "imgPath",live.getPreviewImgUrl(), |
| | | "chatroomId",dao.getChatRoomId(liveId), |
| | | "remark",live.getRemark() |
| | | )); |
| | | public Result view(String couresId) throws Exception { |
| | | |
| | | |
| | | MTCloud client = new MTCloud(); |
| | | |
| | | HashMap<Object,Object> options = new HashMap<Object, Object>(); |
| | | |
| | | String res = client.courseAccess(couresId, ClientUtils.getUserId(), ClientUtils.getUserName(), MTCloud.ROLE_USER, 10000, options); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(res); |
| | | |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | |
| | | String liveUrl = (String) data.get("liveUrl"); |
| | | |
| | | System.out.println(liveUrl); |
| | | |
| | | return new Result(true, "success",liveUrl); |
| | | } |
| | | } |
| | |
| | | subjectUtils.setStudyTime(new BigDecimal(progressValue)); |
| | | } |
| | | mySubjectV.setSubjectName(openSubjectV.getSubjectName()); |
| | | mySubjectV.setCoverPageUrl(openSubjectV.getCoverPageUrl()); |
| | | mySubjectV.getId().setSubjectId(openSubjectV.getSubjectId()); |
| | | result.add(mySubjectV); |
| | | lecurelist.add(subjectUtils); |
| | | } |
| | | for (MySubjectV mySubjectV: |
| | | result) { |
| | | System.out.println(mySubjectV); |
| | | } |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("subjectList", |
| | |
| | | if (percentAvg.isNaN()) { |
| | | percentAvg = 0.0; |
| | | } |
| | | subject.setCoverPageUrl(subject1.getCoverPageUrl()); |
| | | subject.setPercent(percentAvg); |
| | | subject.setProgressValue(new BigDecimal(progressValue)); |
| | | progressLst.get(0).put("percent", subject.getPercent()); |
| | |
| | | if (percentAvg.isNaN()) { |
| | | percentAvg = 0.0; |
| | | } |
| | | subject.setCoverPageUrl(subject1.getCoverPageUrl()); |
| | | subject.setPercent(percentAvg); |
| | | subject.setProgressValue(new BigDecimal(progressValue)); |
| | | subject.setSubjectName(subject1.getName()); |
| | |
| | | package com.qxueyou.scc.sys.action; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qxueyou.scc.base.util.*; |
| | | import com.qxueyou.scc.wx.service.IWechatService; |
| | | import freemarker.template.utility.StringUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.kafka.common.network.LoginType; |
| | | import org.apache.tomcat.util.net.openssl.ciphers.Authentication; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import com.qxueyou.scc.admin.teacher.service.ITeacherService; |
| | |
| | | @Autowired |
| | | private IOrganizationService organizationService; |
| | | |
| | | public static String UUNUMBER="QXYUUNUMBER"; |
| | | /** |
| | | * 小程序appID |
| | | */ |
| | | @Value("${wx.appId}") |
| | | private String appId; |
| | | |
| | | |
| | | /** |
| | | * 小程序secret |
| | | */ |
| | | @Value("${wx.secret}") |
| | | private String secret; |
| | | |
| | | /** |
| | | * 公众号appID |
| | | */ |
| | | @Value("${wx.app.appId}") |
| | | private String wxappId; |
| | | |
| | | |
| | | /** |
| | | * 公众号secret |
| | | */ |
| | | @Value("${wx.app.secret}") |
| | | private String wxsecret; |
| | | |
| | | public static String UUNUMBER="QXYUUNUMBER"; |
| | | |
| | | @Autowired |
| | | IWechatService wechatService; |
| | | |
| | | /** |
| | | * 微信登录 |
| | | * |
| | | * @param uid |
| | | * @throws IOException |
| | | */ |
| | | |
| | | @PostMapping("/wxAccountsLogin") |
| | | @ApiOperation("微信公众号登录") |
| | | @ResponseBody |
| | | public Result wxAccountsLogin(String code) { |
| | | JSONObject gettoken = wechatService.gettoken(wxappId, wxsecret); |
| | | JSONObject OpenId = wechatService.getSessionKeyOrOpenId(code); |
| | | JSONObject user = wechatService.getUser(gettoken.get("access_token").toString(), OpenId.get("openid").toString()); |
| | | return new Result(true,"成功",user); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/wxlogin") |
| | | @ApiOperation("微信小程序登录") |
| | | @ResponseBody |
| | | public Result wechatLogin(String code,String number) { |
| | | JSONObject sessionKeyOrOpenId = wechatService.getSessionKeyOrOpenId(code); |
| | | JSONObject gettoken = wechatService.gettoken(appId, secret); |
| | | Result phone = wechatService.getNumber(gettoken.get("access_token").toString(), number); |
| | | if(phone.getSuccess()){ |
| | | String hql = "from User where deleteFlag is false and mobilePhone = ? "; |
| | | System.out.println(phone.getData()); |
| | | List<Object> params = CollectionUtils.newList(phone.getData()); |
| | | User user = commonDAO.findUnique(hql,params, User.class); |
| | | if(user==null){ |
| | | //新增用户 |
| | | User user1=new User(); |
| | | user1.setMobilePhone(phone.getData().toString()); |
| | | user1.setOpenId(sessionKeyOrOpenId.get("openid").toString()); |
| | | commonDAO.save(user1); |
| | | //新增关联学员 |
| | | String addUserSql = "from User where deleteFlag is false and mobilePhone = ? "; |
| | | List<Object> newParams = CollectionUtils.newList(phone.getData()); |
| | | User newUser = commonDAO.findUnique(addUserSql,newParams, User.class); |
| | | StuStudent stuStudent=new StuStudent(); |
| | | stuStudent.setStatus(StuStudent.STATUS_REGISTER); |
| | | stuStudent.setUserId(newUser.getUserId()); |
| | | stuStudent.setMobilePhone(newUser.getMobilePhone()); |
| | | commonDAO.save(stuStudent); |
| | | } |
| | | if(StringUtils.isEmpty(user.getOpenId())){ |
| | | user.setOpenId(sessionKeyOrOpenId.get("openid").toString()); |
| | | commonDAO.saveOrUpdate(user); |
| | | } |
| | | String studentSql = "from StuStudent where deleteFlag is false and userId = ? "; |
| | | List<Object> stuParams = CollectionUtils.newList(user.getUserId()); |
| | | StuStudent stuStudent = commonDAO.findUnique(studentSql, stuParams, StuStudent.class); |
| | | CacheParamters param = new CacheParamters(); |
| | | param.setUserId(user.getUserId()); |
| | | param.setCustomRoleValue(user.getEmail()); |
| | | param.setCustomOrgId(user.getImei()); |
| | | param.setCacheIpFlag(true); |
| | | // 缓存到请求线程 |
| | | UserInfoWrapper wrapper = cacheUserInfo(param, null); |
| | | // 存到redis |
| | | redisTemplate.opsForValue().set(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper); |
| | | return new Result(true,"授权成功",CollectionUtils.newObjectMap("user",user,"ClassId",stuStudent.getClassId())); |
| | | } |
| | | return phone; |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "登入接口", notes = "") |
| | | @ApiImplicitParams({ |
| | |
| | | // 查询用户信息 |
| | | String uuNumber=null; |
| | | String uuReNumber=null; |
| | | String hql = "from User where deleteFlag is false and account = ? and password = ? "; |
| | | List<Object> params = CollectionUtils.newList(account,password); |
| | | String hql = "from User where deleteFlag is false and account = ?"; |
| | | List<Object> params = CollectionUtils.newList(account); |
| | | User user = commonDAO.findUnique(hql,params, User.class); |
| | | if (user == null ) { |
| | | return new Result(false, "用户账户、密码错误"); |
| | |
| | | } |
| | | // 插入日志 |
| | | insertLoginLog(request, user, account, "SYS-LOGIN"); |
| | | String salt = user.getSalt(); |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | //比较用户输入的密码加密后的字符串是否跟注册时填写的加密密码相同 |
| | | if (!newPassword.equals(user.getPassword())) { |
| | | return new Result(false, "用户账户、密码错误或缺少凭证"); |
| | | } |
| | | // 返回 |
| | | return new Result(true, "验证成功",CollectionUtils.newObjectMap("uuNumber",uuNumber,"uuReNumber",uuReNumber)); |
| | | } |
| | |
| | | public Result platformLogin(@RequestParam("account") String account, @RequestParam("password") String password,String uuNumber,String uuReNumber, |
| | | HttpServletRequest request, HttpServletResponse response, String logType,String organizationId, String platForm) { |
| | | // response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | if(StringUtils.isEmpty(account)) { |
| | | return new Result(false, "用户账号不能为空"); |
| | | } |
| | | if (StringUtils.isEmpty(account)) { |
| | | return new Result(false, "用户账号不能为空"); |
| | | } |
| | | // System.out.println(account+password); |
| | | // System.out.println("-------------------------"+organizationId+"--------------"+platForm+"-----------"+logType); |
| | | String hql = null; |
| | | List<Object> params = null; |
| | | String hql = null; |
| | | List<Object> params = null; |
| | | // boolean flag=true; |
| | | if("study".equals(logType)){ |
| | | hql = "from User where deleteFlag is false and account = ? and password = ? "; |
| | | params = CollectionUtils.newList(account,password); |
| | | }else{ |
| | | if ("study".equals(logType)) { |
| | | hql = "from User where deleteFlag is false and account = ?"; |
| | | params = CollectionUtils.newList(account); |
| | | }else if("portal".equals(logType)){ |
| | | hql = "from User where deleteFlag is false and mobilePhone = ?"; |
| | | params = CollectionUtils.newList(account); |
| | | }else{ |
| | | if(StringUtils.isEmpty(password)) { |
| | | return new Result(false, "用户密码不能为空"); |
| | | } |
| | | hql = "from User where deleteFlag is false and account = ? and password = ? "; |
| | | params = CollectionUtils.newList(account,password); |
| | | hql = "from User where deleteFlag is false and account = ?"; |
| | | params = CollectionUtils.newList(account); |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(organizationId)){ |
| | |
| | | // request.getSession().removeAttribute("uuReNumber"); |
| | | // } |
| | | |
| | | if (user == null) { |
| | | return new Result(false, "用户账户不存在"); |
| | | } |
| | | // 插入日志 |
| | | insertLoginLog(request, user, account, "SYS-LOGIN"); |
| | | |
| | | //考试登录会控制flag变量 其他登录不会 默认true |
| | | if (user == null) { |
| | | return new Result(false, "用户账户、密码错误或缺少凭证"); |
| | | } |
| | | String salt = user.getSalt(); |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | //比较用户输入的密码加密后的字符串是否跟注册时填写的加密密码相同 |
| | | if("study".equals(logType) || "portal".equals(logType) || "adminis".equals(logType)){ |
| | | if (!newPassword.equals(user.getPassword())) { |
| | | return new Result(false, "用户账户、密码错误或缺少凭证"); |
| | | } |
| | | } |
| | | |
| | | // 返回用户基本信息 |
| | | return this.loginValidate(user, 1, request, response, logType, platForm, organizationId); |
| | |
| | | // 存到redis |
| | | redisTemplate.opsForValue().set(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper); |
| | | request.getSession().setAttribute(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper); |
| | | if ("study".equals(logType)) { |
| | | if ("study".equals(logType) || "portal".equals(logType)) { |
| | | /*if (StringUtils.isEmpty(ClientUtils.getClassId()) && user.getRoles() == null) { |
| | | return new Result(false, "该用户未加入任何班级或未激活,请联系班主任"); |
| | | }*/ |
| | |
| | | @ApiOperation(value = "修改密码", notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "usedPass", value = "老密码", required = false, paramType="query", dataType = "String"), |
| | | @ApiImplicitParam(name = "pass", value = "新密码", required = false, paramType="query", dataType = "String"), |
| | | @ApiImplicitParam(name = "pass", value = "新密码", required = false, paramType=" query", dataType = "String"), |
| | | }) |
| | | @RequestMapping(value = "updatePassword", method = RequestMethod.POST) |
| | | @ResponseBody |
| | |
| | | /** 唐桥加入课堂密码 */ |
| | | @Column(name="TQ_MEETING_PWD", length=32) |
| | | private String meetingPwd; |
| | | |
| | | /** 第三方直播入口 */ |
| | | @Column(name="COURSE_ID", length=32) |
| | | private int courseId; |
| | | |
| | | @OneToMany(fetch = FetchType.LAZY, mappedBy = "videoLive") |
| | | @JsonIgnore |
| | |
| | | return subject; |
| | | } |
| | | |
| | | public int getCourseId() { |
| | | return courseId; |
| | | } |
| | | |
| | | public void setCourseId(int courseId) { |
| | | this.courseId = courseId; |
| | | } |
| | | |
| | | public void setSubject(Subject subject) { |
| | | this.subject = subject; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | import com.qxueyou.scc.teach.live.model.MediaVideoLive; |
| | | |
| | | public interface IMediaLiveService { |
| | | |
| | | |
| | | /** |
| | | * 新增直播 |
| | | * @param name 直播名称 |
| | |
| | | * @param classId 班级ids |
| | | * @return |
| | | */ |
| | | Result add(String name,String content,String teacherId,String teacherName,String subjectId,String subjectName,String definition,String imgPath,Date startTime,Date endTime,boolean record,List<String> classIds); |
| | | |
| | | Result add(String name,String content,String teacherId,String teacherName,String subjectId,String subjectName,String definition,String imgPath,Date startTime,Date endTime,Integer courseId,boolean record,List<String> classIds); |
| | | |
| | | /** |
| | | * 查询直播 |
| | | * @param liveId 直播Id |
| | | * @return |
| | | */ |
| | | MediaVideoLive read(String liveId); |
| | | |
| | | |
| | | MediaVideoLive revamp(int courseId); |
| | | |
| | | /** |
| | | * 查询直播 |
| | | * @param noticeId 直播Id |
| | | * @return |
| | | */ |
| | | List<MediaVideoLive> readByStatus(List<String> liveIdLst,short[] status); |
| | | |
| | | |
| | | /** |
| | | * 查询直播 |
| | | * @param keyword 查询关键字 |
| | |
| | | * @return |
| | | */ |
| | | List<MediaVideoLive> listOfMine(String keyword,Integer pageNum, Integer pageSize); |
| | | |
| | | |
| | | /** |
| | | * 查询直播总数 |
| | | * @param keyword 查询关键字 |
| | | * @return |
| | | */ |
| | | int listCountOfMine(String keyword); |
| | | |
| | | |
| | | /** |
| | | * 查询直播 |
| | | * @param keyword 查询关键字 |
| | |
| | | * @return |
| | | */ |
| | | List<MediaVideoLive> list(String keyword,String[] classIds,String subjectId,Short status,Integer pageNum, Integer pageSize); |
| | | |
| | | |
| | | /** |
| | | * 查询直播总数 |
| | | * @param keyword 查询关键字 |
| | | * @return |
| | | */ |
| | | int listCount(String keyword,String [] classIds,String subjectId,Short status); |
| | | |
| | | |
| | | /** |
| | | * 修改直播 |
| | | * @param liveId 直播ID |
| | |
| | | * @return |
| | | */ |
| | | Result update(String liveId,String name,String content,String teacherId,String teacherName,String subjectId,String subjectName,String definition,String imgPath,Date startTime,Date endTime,boolean record,List<String> classIds); |
| | | |
| | | |
| | | /** |
| | | * 删除直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result delete(String liveId); |
| | | |
| | | |
| | | /** |
| | | * 删除直播 |
| | | * @param liveId 直播ID数组 |
| | | * @return |
| | | */ |
| | | Result delete(String[] liveIds); |
| | | |
| | | Result delete(String[] liveIds,String [] courseIds) throws Exception; |
| | | |
| | | /** |
| | | * 发布直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result doIssue(String liveId); |
| | | |
| | | |
| | | /** |
| | | * 取消直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result doCancel(String liveId); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 发布直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result doStart(String liveId); |
| | | |
| | | |
| | | /** |
| | | * 取消直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result doPause(String liveId); |
| | | |
| | | |
| | | /** |
| | | * 取消直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result doStop(String liveId); |
| | | |
| | | |
| | | /** |
| | | * 读取直播班级 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | List<String> getLiveClasses(String liveId); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 点赞直播 |
| | | * @param liveId 直播ID |
| | | * @return |
| | | */ |
| | | Result doPraise(String liveId); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.qxueyou.scc.sdk.MTCloud; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | |
| | | |
| | | @Override |
| | | public Result add(String name, String content, String teacherId,String teacherName ,String subjectId,String subjectName, |
| | | String definition,String imgPath, Date startTime, Date endTime, boolean record,List<String> classIds) { |
| | | public Result add(String name, String content, String teacherId, String teacherName , String subjectId, String subjectName, |
| | | String definition, String imgPath, Date startTime, Date endTime, Integer courseId, boolean record, List<String> classIds) { |
| | | |
| | | UserTeacher teacher = teacherService.getTeacherByUserId(ClientUtils.getUserId()); |
| | | |
| | | MediaVideoLive live = new MediaVideoLive(); |
| | | TraceUtils.setCreateTrace(live); |
| | | |
| | | |
| | | live.setCourseId(courseId); |
| | | live.setName(name); |
| | | live.setRemark(content); |
| | | live.setPreviewImgUrl(imgPath); |
| | |
| | | save(live); |
| | | return Result.SUCCESS; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result delete(String[] liveIds) { |
| | | public Result delete(String[] liveIds,String [] courseIds) throws Exception { |
| | | for(String liveId:liveIds) { |
| | | delete(liveId); |
| | | for(String courseId:courseIds) { |
| | | MTCloud client = new MTCloud(); |
| | | String s = client.courseDelete(courseId); |
| | | } |
| | | } |
| | | return Result.SUCCESS; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result doIssue(String liveId) { |
| | |
| | | public List<MediaVideoLive> list(String keyword, String [] classIds,String subjectId,Short status,Integer pageNum, Integer pageSize) { |
| | | StringBuffer hql = new StringBuffer(1000); |
| | | Map<String,Object> params = new HashMap<String,Object>(); |
| | | hql.append("from MediaVideoLive m left join fetch m.classes c left join fetch m.subject s where m.deleteFlag is false and m.name like :name "); |
| | | hql.append("from MediaVideoLive m left join fetch m.classes c left join fetch m.subject s where m.deleteFlag is false and m.name like :name "); |
| | | |
| | | params.put("name",keyword + "%"); |
| | | |
| | | if(classIds!=null && classIds.length>0){ |
| | | hql.append(" and (c.classId in(:classIds) or s.type=:subjectType)"); |
| | | hql.append(" and (c.classId in(:classIds) or s.type=:Type)"); |
| | | params.put("classIds", classIds); |
| | | params.put("subjectType", Subject.TYPE_PUBLIC_SUBJECT); |
| | | params.put("Type", Subject.TYPE_PUBLIC_SUBJECT); |
| | | }else{ |
| | | hql.append(" and s.type=:subjectType"); |
| | | params.put("subjectType", Subject.TYPE_PUBLIC_SUBJECT); |
| | |
| | | public MediaVideoLive read(String liveId) { |
| | | return read(MediaVideoLive.class,liveId); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public MediaVideoLive revamp(int courseId) { |
| | | String hql = "from MediaVideoLive where deleteFlag is false and courseId=?"; |
| | | MediaVideoLive unique = findUnique(hql, CollectionUtils.newList(courseId), MediaVideoLive.class); |
| | | return unique ; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public List<MediaVideoLive> readByStatus(List<String> liveIdLst,short[] status) { |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<FileMeta> fileUpload(MultipartFile uploadFile, String objectKey) { |
| | | ObsClient obsClient = null; |
| | |
| | | } |
| | | InputStream inputStream = uploadFile.getInputStream(); |
| | | long available = inputStream.available(); |
| | | // PutObjectRequest request = new PutObjectRequest(bucketName,objectKey,inputStream); |
| | | PutObjectRequest request = new PutObjectRequest(bucketName,destPath,inputStream); |
| | | ObjectMetadata objectMetadata = new ObjectMetadata(); |
| | | objectMetadata.setContentLength(available); |
| | | request.setMetadata(objectMetadata); |
| | | // request. |
| | | // 设置对象访问权限为公共读 |
| | | request.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ); |
| | | PutObjectResult result = obsClient.putObject(request); |
| | | fileMeta = new FileMeta(); |
| | | ResFile file = fileService.insertFileToDBTwo(objectKey, uploadFile.getSize(), result.getObjectUrl(), uploadFile.getContentType()); |
| | | // SetObjectMetadataRequest ObjectMetadataRequest = new SetObjectMetadataRequest(bucketName, destPath); |
| | | // ObjectMetadataRequest.setContentDisposition("inline"); |
| | | // obsClient.setObjectMetadata(ObjectMetadataRequest); |
| | | |
| | | fileMeta.setFileId(file.getFileId()); |
| | | fileMeta.setPath(result.getObjectUrl()); |
| | | fileMeta.setFileSize(uploadFile.getSize() / 1024 + "kb"); |
| | |
| | | |
| | | Res res = read(Res.class, resId); |
| | | |
| | | resItemServiceMap.get(res.getType()).update(res.getItemDestId(), name); |
| | | // resItemServiceMap.get(res.getType()).update(res.getItemDestId(), name); |
| | | |
| | | TraceUtils.setUpdateTrace(res); |
| | | res.setName(name); |
| | |
| | | public Result readAccessPath(String resId, String attribute) { |
| | | |
| | | Res res = read(Res.class, resId); |
| | | |
| | | String type="0"; |
| | | // Object path = Res.FILE_TYPE_VIDEO.equals(res.getType())? JSONObject.parse(resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute)):CollectionUtils.newObjectMap("path", resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute)); |
| | | Object path = Res.FILE_TYPE_VIDEO.equals(res.getType())? resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute):resItemServiceMap.get(res.getType()).readAccessPath(res.getItemDestId(), attribute); |
| | | Object path = Res.FILE_TYPE_VIDEO.equals(type)? resItemServiceMap.get(type).readAccessPath(res.getItemDestId(), attribute):resItemServiceMap.get(type).readAccessPath(res.getItemDestId(), attribute); |
| | | if(Res.FILE_TYPE_DOC.equals(res.getType())) { |
| | | return new Result(true, "success", |
| | | CollectionUtils.newObjectMap("path", path, "name", res.getName(), "coverPageUrl", res.getCoverPageUrl(), "size", |
| | |
| | | |
| | | ResItemDoc doc = read(ResItemDoc.class, id); |
| | | |
| | | TraceUtils.setUpdateTrace(doc); |
| | | // TraceUtils.setUpdateTrace(doc); |
| | | |
| | | doc.setName(name); |
| | | |
| | |
| | | private static final long serialVersionUID = 7504161189427721559L; |
| | | |
| | | /* |
| | | * 状态: 已报名 |
| | | * 状态: 已报名,未激活,已毕业 |
| | | */ |
| | | public static final String STATUS_REGISTER = "register"; |
| | | public static final String STATUS_ACTIVE = "active"; |
| | |
| | | private String studentNumber; |
| | | private String attendanceStatus; |
| | | private String graduationText; |
| | | private String comment; |
| | | |
| | | public StuStudent() { |
| | | } |
| | |
| | | |
| | | public StuStudent(String studentId, Date createTime, Date updateTime, String creator, String createId, |
| | | String updator, String updateId, boolean deleteFlag, String userId, String name, String classId, |
| | | String tenantId, String status, String attendanceStatus, String graduationText,String studentNumber) { |
| | | String tenantId, String status, String attendanceStatus, String graduationText,String comment,String studentNumber) { |
| | | this.studentId = studentId; |
| | | this.createTime = createTime; |
| | | this.updateTime = updateTime; |
| | |
| | | this.status = status; |
| | | this.attendanceStatus = attendanceStatus; |
| | | this.graduationText = graduationText; |
| | | this.comment = comment; |
| | | this.studentNumber=studentNumber; |
| | | } |
| | | |
| | |
| | | this.graduationText = graduationText; |
| | | } |
| | | |
| | | @Column(name = "COMMENT", length = 200) |
| | | public String getComment() { |
| | | return this.comment; |
| | | } |
| | | public void setComment(String comment) { |
| | | this.comment = comment; |
| | | } |
| | | |
| | | @Column(name = "STUDENT_NO", length = 32) |
| | | public String getStudentNo() { |
| | | return studentNo; |
| | |
| | | import cn.hutool.core.date.LocalDateTimeUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import com.qxueyou.scc.admin.classes.model.ClsClass; |
| | | import com.qxueyou.scc.base.dao.CommonDAO; |
| | | import com.qxueyou.scc.exam.model.ExamResultV; |
| | | import com.qxueyou.scc.exercise.model.ExerciseCompleteInfo; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | StudentDAO dao; |
| | | |
| | | @Autowired |
| | | CommonDAO commonDAO; |
| | | |
| | | @Override |
| | | public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId) { |
| | |
| | | public Result doActivateStudent(String[] studentIds) { |
| | | for (String studentId : studentIds) { |
| | | activateStudent(studentId, StuStudent.STATUS_ACTIVE); |
| | | ModeUpdate(studentId,StuStudent.STATUS_ACTIVE); |
| | | } |
| | | return new Result(true); |
| | | } |
| | |
| | | public Result doDeActivateStudent(String[] studentIds) { |
| | | for (String studentId : studentIds) { |
| | | activateStudent(studentId, StuStudent.STATUS_DEACTIVE); |
| | | ModeUpdate(studentId,StuStudent.STATUS_DEACTIVE); |
| | | } |
| | | return new Result(true); |
| | | } |
| | | |
| | | private Result ModeUpdate(String studentId,String status){ |
| | | if(status.equals(StuStudent.STATUS_ACTIVE)){ |
| | | String hql = "from ExerciseCompleteInfo where studentId=? and deleteFlag is false"; |
| | | List<Object> Params = CollectionUtils.newList(studentId); |
| | | ExerciseCompleteInfo unique = findUnique(hql, Params, ExerciseCompleteInfo.class); |
| | | unique.setDeleteFlag(false); |
| | | commonDAO.update(unique); |
| | | }else { |
| | | String hql = "from ExerciseCompleteInfo where studentId=? and deleteFlag is false"; |
| | | List<Object> Params = CollectionUtils.newList(studentId); |
| | | ExerciseCompleteInfo unique = findUnique(hql, Params, ExerciseCompleteInfo.class); |
| | | unique.setDeleteFlag(true); |
| | | commonDAO.update(unique); |
| | | } |
| | | return new Result(true); |
| | | } |
| | |
| | | } |
| | | |
| | | TraceUtils.setUpdateTrace(student); |
| | | String currentTime = LocalDateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmmssSSS"); |
| | | |
| | | String examCardNo = currentTime.concat(RandomUtil.randomNumbers(1)); |
| | | |
| | | student.setStudentNumber(examCardNo); |
| | | // String currentTime = LocalDateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmmssSSS"); |
| | | // |
| | | // String examCardNo = currentTime.concat(RandomUtil.randomNumbers(1)); |
| | | // |
| | | // student.setStudentNumber(examCardNo); |
| | | student.setStatus(status); |
| | | save(student); |
| | | commonDAO.update(student); |
| | | |
| | | clsService.addStudent(student.getClassId(), StuStudent.STATUS_DEACTIVE.equals(status) ? -1 : 1); |
| | | |
| | |
| | | } |
| | | subject.put("percent", new BigDecimal(percentAvg)); |
| | | subject.put("progressValue", new BigDecimal(progressValue)); |
| | | |
| | | subject.put("lectureParentId", map.get("lectureParentId")); |
| | | subject.put("lectureId", map.get("lectureId")); |
| | | subject.put("unCommitExerciseCount", exerciseInfoService.getUnCommitExerciseCount(classId, userId)); |
| | |
| | | String className = "公开课"; |
| | | subjectMap.put("subjectName",subject.getSubjectName()); |
| | | subjectMap.put("subjectId",subject.getSubjectId()); |
| | | |
| | | subjectMap.put("coverPageUrl",subject.getCoverPageUrl()); |
| | | subjectMap.put("percent", new BigDecimal(percentAvg)); |
| | | subjectMap.put("progressValue", new BigDecimal(progressValue)); |
| | | subjectMap.put("className",className); |
| | |
| | | @JsonIgnore |
| | | private String createId; |
| | | |
| | | |
| | | @Column(name = "SALT", nullable = false, length = 200) |
| | | @JsonIgnore |
| | | private String salt; |
| | | |
| | | public String getSalt() { |
| | | return salt; |
| | | } |
| | | |
| | | public void setSalt(String salt) { |
| | | this.salt = salt; |
| | | } |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | |
| | | @Column(name = "IMEI", length = 255) |
| | | private String imei; |
| | | |
| | | /** |
| | | * 绑定账号ID |
| | | */ |
| | | @Column(name = "OPENID", length = 255) |
| | | private String openId; |
| | | |
| | | public String getOpenId() { |
| | | return openId; |
| | | } |
| | | |
| | | public void setOpenId(String openId) { |
| | | this.openId = openId; |
| | | } |
| | | |
| | | @ManyToMany(fetch = FetchType.LAZY, mappedBy = "users") |
| | | @JsonIgnore |
| | | private List<UserRole> roles; |
| | |
| | | package com.qxueyou.scc.user.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.qxueyou.scc.user.model.User; |
| | | import com.qxueyou.scc.user.model.UserReRoleUser; |
| | | import com.qxueyou.scc.user.service.IUserService; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | // System.out.println(user.getUserId()); |
| | | // System.out.println(user.getOrganizationId()); |
| | | // System.out.println(StuStudent.STATUS_ACTIVE); |
| | | System.out.println(user.getOrganizationId()); |
| | | System.out.println(user.getUserId()); |
| | | |
| | | ClsClass objClsClass = this.findUnique("select c from StuStudent t," |
| | | + " ClsClass c where c.classId = t.classId " |
| | | + " and c.orgId = ? and t.userId = ? and t.status = ? order by t.createTime desc", CollectionUtils.newList(user.getOrganizationId(), user.getUserId(), StuStudent.STATUS_ACTIVE), ClsClass.class); |
| | |
| | | wrapper.setOrg(org); |
| | | wrapper.setClass(objClsClass); |
| | | wrapper.setLoginInfo(param.getCacheIpFlag(), param.getIp(), param.getPlatForm()); |
| | | System.out.println("aaa"+user.getUserId()); |
| | | session.setAttribute(UserInfoWrapper.INF_USER_ID,user.getUserId()); |
| | | session.setAttribute(UserInfoWrapper.INF_USER_NAME,user.getName()); |
| | | if(objClsClass!=null){ |
| | |
| | | } |
| | | |
| | | private User newUser(String name, String account, String mobilePhone, String password, Boolean sex, String orgId) { |
| | | |
| | | //随机字符串 |
| | | String salt= UUID.randomUUID().toString(); |
| | | User user = new User(); |
| | | TraceUtils.setCreateTrace(user); |
| | | user.setAccount(account); |
| | | user.setName(name); |
| | | //盐值 |
| | | user.setSalt(salt); |
| | | //对密码进行加密处理 |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | user.setPassword(newPassword); |
| | | user.setMobilePhone(mobilePhone); |
| | | user.setPassword(password); |
| | | user.setSex(sex); |
| | | user.setOrganizationId(orgId); |
| | | save(user); |
| | |
| | | @Override |
| | | public Result updatePassword(String userId, String usedPass, String pass) { |
| | | User user = read(User.class, userId); |
| | | //随机字符串 |
| | | String salt= UUID.randomUUID().toString(); |
| | | //盐值 |
| | | user.setSalt(salt); |
| | | //对密码进行加密处理 |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+pass).getBytes()); |
| | | String newPasswords= DigestUtils.md5DigestAsHex((salt+usedPass).getBytes()); |
| | | if (StringUtils.isNotBlank(usedPass) && StringUtils.isNotBlank(pass)) { |
| | | if (!user.getPassword().equals(usedPass)) { |
| | | if (!user.getPassword().equals(newPasswords)) { |
| | | return new Result(false, "输入的旧密码错误"); |
| | | } |
| | | user.setPassword(pass); |
| | | user.setPassword(newPassword); |
| | | } |
| | | TraceUtils.setUpdateTrace(user); |
| | | save(user); |
| | |
| | | public Result updatePassword(String userId, String password) { |
| | | User user = read(User.class, userId); |
| | | |
| | | //随机字符串 |
| | | String salt= UUID.randomUUID().toString(); |
| | | //盐值 |
| | | user.setSalt(salt); |
| | | //对密码进行加密处理 |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | TraceUtils.setUpdateTrace(user); |
| | | user.setPassword(password); |
| | | user.setPassword(newPassword); |
| | | |
| | | save(user); |
| | | |
| | |
| | | Boolean sex) { |
| | | |
| | | User dbUser = read(User.class, userId); |
| | | |
| | | String salt = dbUser.getSalt(); |
| | | String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); |
| | | if (dbUser.getAccount().equals(account)) { |
| | | dbUser.setName(name); |
| | | dbUser.setMobilePhone(mobilePhone); |
| | | dbUser.setPassword(password); |
| | | dbUser.setPassword(newPassword); |
| | | TraceUtils.setCreateTrace(dbUser); |
| | | save(dbUser); |
| | | return new Result(true, "success"); |
| | |
| | | dbUser.setAccount(account); |
| | | dbUser.setName(name); |
| | | dbUser.setMobilePhone(mobilePhone); |
| | | dbUser.setPassword(password); |
| | | dbUser.setPassword(newPassword); |
| | | TraceUtils.setCreateTrace(dbUser); |
| | | save(dbUser); |
| | | return new Result(true, "success"); |
| | |
| | | //是否合法 |
| | | // if(!licenseService.isValid()) { |
| | | // log.debug("license invalid"); |
| | | // forbiddenAsLicense(httpResponse); |
| | | // return; |
| | | // } |
| | | //// forbiddenAsLicense(httpResponse); |
| | | //// return; |
| | | //// } |
| | | |
| | | if (!addClientInfo(httpRequest)) { |
| | | log.debug("非法请求:" + httpRequest.getRequestURI()); |
New file |
| | |
| | | package com.qxueyou.scc.wx.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.teach.student.model.StuStudent; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public interface IWechatService { |
| | | |
| | | /** |
| | | * 查询用户 |
| | | * @param code |
| | | * @param type |
| | | * @return |
| | | * |
| | | * @author 李岩龙 |
| | | * @date 2021年4月2日 下午3:31:05 |
| | | */ |
| | | |
| | | JSONObject getSessionKeyOrOpenId(String code); |
| | | |
| | | Result getNumber(String tonken, String number); |
| | | |
| | | JSONObject gettoken(String appid,String secret); |
| | | |
| | | JSONObject getUser(String token,String openId); |
| | | // Result isBindWx(String userId); |
| | | |
| | | // Result getSignature(String url); |
| | | |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.wx.service.impl; |
| | | |
| | | import com.alibaba.druid.util.HttpClientUtils; |
| | | import com.alibaba.druid.util.StringUtils; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.base.service.ICacheService; |
| | | import com.qxueyou.scc.teach.student.model.StuStudent; |
| | | import com.qxueyou.scc.wx.service.IWechatService; |
| | | import com.qxueyou.scc.wx.utils.HttpClientUtil; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URI; |
| | | import java.time.LocalDateTime; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Service |
| | | public class WechatService implements IWechatService { |
| | | |
| | | // @Autowired |
| | | // IUserService userService; |
| | | |
| | | /** |
| | | * 小程序appID |
| | | */ |
| | | @Value("${wx.appId}") |
| | | private String appId; |
| | | |
| | | |
| | | /** |
| | | * 小程序secret |
| | | */ |
| | | @Value("${wx.secret}") |
| | | private String secret; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private ICacheService cacheService; |
| | | |
| | | private final Logger logger = LogManager.getLogger(); |
| | | |
| | | |
| | | @Override |
| | | public JSONObject getSessionKeyOrOpenId(String code) { |
| | | String requestUrl = "https://api.weixin.qq.com/sns/jscode2session"; |
| | | Map<String, String> requestUrlParam = new HashMap<>(); |
| | | // https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN |
| | | //小程序appId |
| | | requestUrlParam.put("appid", appId); |
| | | //小程序secret |
| | | requestUrlParam.put("secret", secret); |
| | | //小程序端返回的code |
| | | requestUrlParam.put("js_code", code); |
| | | //默认参数 |
| | | requestUrlParam.put("grant_type", "authorization_code"); |
| | | //发送post请求读取调用微信接口获取openid用户唯一标识 |
| | | JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doPost(requestUrl, requestUrlParam)); |
| | | return jsonObject; |
| | | } |
| | | |
| | | @Override |
| | | public Result getNumber(String tonken, String number) { |
| | | JSONObject jsonCode = new JSONObject(); |
| | | |
| | | jsonCode.put("code",number); |
| | | |
| | | |
| | | String resPhone = HttpClientUtil.doPostUrl("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + tonken, jsonCode); |
| | | |
| | | if(StringUtils.isEmpty(resPhone) || !resPhone.contains("phone_info") || !resPhone.contains("phoneNumber")){ |
| | | return new Result(false,"微信官方修改了小程序获取用户手机号码相关接口!"); |
| | | } |
| | | JSONObject resPhoneInfo = JSON.parseObject(resPhone); |
| | | JSONObject phoneInfo=resPhoneInfo.getJSONObject("phone_info"); |
| | | System.out.println(resPhoneInfo); |
| | | System.out.println(phoneInfo); |
| | | String phoneNumber = phoneInfo.get("phoneNumber").toString(); |
| | | |
| | | return new Result(true,"获取手机号成功",phoneNumber); |
| | | // String requestUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="+tonken+jsonObject.toJSONString(); |
| | | |
| | | // Map<String, String> requestUrlParam = new HashMap<>(); |
| | | |
| | | |
| | | |
| | | // requestUrlParam.put("code", number); |
| | | |
| | | // JSONObject s =JSON.parseObject(HttpClientUtil.doPost(requestUrl)); |
| | | |
| | | // return s; |
| | | } |
| | | |
| | | @Override |
| | | public JSONObject gettoken(String appid, String secret) { |
| | | String requestUrl = "https://api.weixin.qq.com/cgi-bin/token"; |
| | | |
| | | Map<String, String> requestUrlParam = new HashMap<>(); |
| | | |
| | | requestUrlParam.put("grant_type", "client_credential"); |
| | | |
| | | requestUrlParam.put("appid", appid); |
| | | |
| | | requestUrlParam.put("secret", secret); |
| | | |
| | | JSONObject s = JSON.parseObject(HttpClientUtil.doGet(requestUrl, requestUrlParam)); |
| | | |
| | | return s; |
| | | } |
| | | @Override |
| | | public JSONObject getUser(String token, String openId) { |
| | | String requestUrl = "https://api.weixin.qq.com/sns/userinfo"; |
| | | |
| | | Map<String, String> requestUrlParam = new HashMap<>(); |
| | | |
| | | requestUrlParam.put("access_token", token); |
| | | |
| | | requestUrlParam.put("openid", openId); |
| | | |
| | | requestUrlParam.put("lang", "zh_CN"); |
| | | |
| | | JSONObject s = JSON.parseObject(HttpClientUtil.doGet(requestUrl, requestUrlParam)); |
| | | |
| | | return s; |
| | | } |
| | | // private String getWechatHeadImgUrl(String unionId) { |
| | | // WechatUserDO wxUser = this.template.findOne(Query.query(condition().and("unionId").is(unionId)), WechatUserDO.class); |
| | | // return wxUser.getHeadImgUrl(); |
| | | // } |
| | | |
| | | // @Override |
| | | // public Result isBindWx(String userId) { |
| | | // UserStudentDO studentDO = read(UserStudentDO.class, userId); |
| | | // boolean status = false; |
| | | // if (StringUtils.isNotBlank(studentDO.getUnionId())) { |
| | | // status = true; |
| | | // } |
| | | // String url = ""; |
| | | // if (status) { |
| | | // url = getWechatHeadImgUrl(studentDO.getUnionId()); |
| | | // } |
| | | // return new Result(true, "status", status, "url", url); |
| | | // } |
| | | // |
| | | // public Result getSignature(String url) { |
| | | // try { |
| | | // long timestamp = System.currentTimeMillis() / 1000; |
| | | // String randomStr = RandomUtils.getRandomStr(); |
| | | // //远程调用获取ticket |
| | | //// String jsapiTicket ="";//getJsapiTicket(false); |
| | | // RestTemplate restTemplate = new RestTemplate(); |
| | | // |
| | | // String jsapiTicket = restTemplate.getForObject("http://192.168.1.111/job/ticket", String.class); |
| | | // |
| | | // String signature = SHA1.genWithAmple("jsapi_ticket=" + jsapiTicket, |
| | | // "noncestr=" + randomStr, "timestamp=" + timestamp, "url=" + url); |
| | | // WxJsapiSignature jsapiSignature = new WxJsapiSignature(); |
| | | // jsapiSignature.setAppId(wxProperties.getAppId()); |
| | | // jsapiSignature.setTimestamp(timestamp); |
| | | // jsapiSignature.setNonceStr(randomStr); |
| | | // jsapiSignature.setUrl(url); |
| | | // jsapiSignature.setSignature(signature); |
| | | // return new Result(true, jsapiSignature); |
| | | // } catch (Exception e) { |
| | | // log.error(e, e); |
| | | // return new Result(false, "获取签名失败"); |
| | | // } |
| | | // } |
| | | |
| | | // @Override |
| | | // public String getOpenId(String userId) { |
| | | // UserStudentDO user = read(UserStudentDO.class, userId); |
| | | // |
| | | // return user.getOpenId(); |
| | | // } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.qxueyou.scc.wx.utils; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * <p> |
| | | * 调用微信接口 返回授权信息~ |
| | | * </p> |
| | | * @author echo lovely |
| | | * @date 2020/12/4 21:56 |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class Code2Session { |
| | | |
| | | //用户唯一标识 |
| | | private String openid; |
| | | // 会话密钥 |
| | | private String session_key; |
| | | // 用户在开放平台的唯一标识符 |
| | | private String unionid; |
| | | // 错误码 |
| | | private Integer errcode; |
| | | // 错误信息 |
| | | private String errmsg; |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.qxueyou.scc.wx.utils; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import net.sf.json.JSONString; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.utils.URIBuilder; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.message.BasicNameValuePair; |
| | | import org.apache.http.util.EntityUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URI; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class HttpClientUtil { |
| | | |
| | | public static String doGet(String url, Map<String, String> param) { |
| | | |
| | | // 创建Httpclient对象 |
| | | CloseableHttpClient httpclient = HttpClients.createDefault(); |
| | | |
| | | String resultString = ""; |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | // 创建uri |
| | | URIBuilder builder = new URIBuilder(url); |
| | | if (param != null) { |
| | | for (String key : param.keySet()) { |
| | | builder.addParameter(key, param.get(key)); |
| | | } |
| | | } |
| | | URI uri = builder.build(); |
| | | |
| | | // 创建http GET请求 |
| | | HttpGet httpGet = new HttpGet(uri); |
| | | |
| | | // 执行请求 |
| | | response = httpclient.execute(httpGet); |
| | | // 判断返回状态是否为200 |
| | | if (response.getStatusLine().getStatusCode() == 200) { |
| | | resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (response != null) { |
| | | response.close(); |
| | | } |
| | | httpclient.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return resultString; |
| | | } |
| | | |
| | | public static String doGet(String url) { |
| | | return doGet(url, null); |
| | | } |
| | | |
| | | public static String doPost(String url, Map<String, String> param) { |
| | | // 创建Httpclient对象 |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | CloseableHttpResponse response = null; |
| | | String resultString = ""; |
| | | try { |
| | | // 创建Http Post请求 |
| | | HttpPost httpPost = new HttpPost(url); |
| | | // 创建参数列表 |
| | | if (param != null) { |
| | | List<NameValuePair> paramList = new ArrayList<>(); |
| | | for (String key : param.keySet()) { |
| | | System.out.println(key); |
| | | System.out.println(param.get(key)); |
| | | paramList.add(new BasicNameValuePair(key, param.get(key))); |
| | | } |
| | | // 模拟表单 |
| | | UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList); |
| | | httpPost.setEntity(entity); |
| | | } |
| | | // 执行http请求 |
| | | response = httpClient.execute(httpPost); |
| | | resultString = EntityUtils.toString(response.getEntity(), "utf-8"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | response.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return resultString; |
| | | } |
| | | |
| | | public static String doPostUrl(String url, JSONObject jsonCode) { |
| | | // 创建Httpclient对象 |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | CloseableHttpResponse response = null; |
| | | String resultString = ""; |
| | | try { |
| | | // 创建Http Post请求 |
| | | HttpPost httpPost = new HttpPost(url); |
| | | |
| | | String s = jsonCode.toJSONString(jsonCode); |
| | | |
| | | StringEntity entity=new StringEntity(s); |
| | | |
| | | httpPost.setEntity(entity); |
| | | // 执行http请求 |
| | | response = httpClient.execute(httpPost); |
| | | resultString = EntityUtils.toString(response.getEntity(), "utf-8"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | response.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return resultString; |
| | | } |
| | | |
| | | public static String doPost(String url) { |
| | | return doPost(url, null); |
| | | } |
| | | |
| | | public static String doPostJson(String url, String json) { |
| | | // 创建Httpclient对象 |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | CloseableHttpResponse response = null; |
| | | String resultString = ""; |
| | | try { |
| | | // 创建Http Post请求 |
| | | HttpPost httpPost = new HttpPost(url); |
| | | // 创建请求内容 |
| | | StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); |
| | | httpPost.setEntity(entity); |
| | | // 执行http请求 |
| | | response = httpClient.execute(httpPost); |
| | | resultString = EntityUtils.toString(response.getEntity(), "utf-8"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | response.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return resultString; |
| | | } |
| | | } |
| | |
| | | spring.http.multipart.maxRequestSize=3000Mb |
| | | #mysqldb.datasource.url=jdbc:mysql://rds88t2of1fi184y4s5wo.mysql.rds.aliyuncs.com:3306/scc?useUnicode=true&characterEncoding=GBK&characterSetResults=GBK&zeroDateTimeBehavior=convertToNull |
| | | #mysqldb.datasource.url=jdbc:mysql://10.1.80.52:3306/rsdb?useUnicode=true&characterEncoding=GBK&characterSetResults=GBK&zeroDateTimeBehavior=convertToNull |
| | | mysqldb.datasource.url=jdbc:mysql://localhost:3306/scc?useUnicode=true&characterEncoding=GBK&characterSetResults=GBK&zeroDateTimeBehavior=convertToNull |
| | | mysqldb.datasource.url=jdbc:mysql://110.41.147.200:3306/scc?useUnicode=true&characterEncoding=GBK&characterSetResults=GBK&zeroDateTimeBehavior=convertToNull |
| | | mysqldb.datasource.username=root |
| | | #mysqldb.datasource.username=rs |
| | | #######\uFFFD\uFFFD\uFFFD\uFFFD\u03AA\uFFFD\uFFFD\u05F0\uFFFD\uFFFD\u03F5\u0373\uFFFD\uFFFD\u012C\uFFFD\uFFFD\uFFFD\u00FB\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u02FF\uFFFD############# |
| | |
| | | #mysqldb.datasource.password=fwefwefWEFefewf$ # |
| | | # port:3370 # |
| | | ################################################# |
| | | mysqldb.datasource.password=12345678 |
| | | mysqldb.datasource.password=123456 |
| | | #mysqldb.datasource.password=QQTec@2019 |
| | | #mysqldb.datasource.url=jdbc:mysql://rds88t2of1fi184y4s5wo.mysql.rds.aliyuncs.com:3306/scc_sr?useUnicode=true&characterEncoding=GBK&characterSetResults=GBK&zeroDateTimeBehavior=convertToNull |
| | | #mysqldb.datasource.url=jdbc:mysql://rds88t2of1fi184y4s5wo.mysql.rds .aliyuncs.com:3306/scc_sr?useUnicode=true&characterEncoding=GBK&characterSetResults=GBK&zeroDateTimeBehavior=convertToNull |
| | | #mysqldb.datasource.username=ssc_sr |
| | | #mysqldb.datasource.password=fsefWEF23@#! |
| | | mysqldb.datasource.driverClassName= com.mysql.jdbc.Driver |
| | |
| | | # default DefaultExpiration time : 30 minutes(600 seconds) |
| | | spring.redis.default.ttl=600 |
| | | |
| | | wx.appId=wx953bf2ed18e7836b |
| | | wx.secret=1d8b00beaddf5c8f36d1fedc14ef7973 |
| | | |
| | | |
| | | wx.app.appId=wx5a7c0d4798fbfdc2 |
| | | wx.app.secret=95c5470a52a2c4e037741f82246f4d86 |
| | | |
| | | logging.config=classpath:log4j2.xml |
| | |
| | | </Console> |
| | | |
| | | <RollingRandomAccessFile name="File" |
| | | fileName="D:/log/qxueyou.log" append="true" |
| | | filePattern="D:/log/qxueyou-%d{yyyyMMdd}-%i.log"> |
| | | fileName="C:/log/qxueyou.log" append="true" |
| | | filePattern="C:/log/qxueyou-%d{yyyyMMdd}-%i.log"> |
| | | <PatternLayout> |
| | | <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</Pattern> |
| | | </PatternLayout> |
| | |
| | | </RollingRandomAccessFile> |
| | | |
| | | <RollingRandomAccessFile name="error_file" |
| | | fileName="D:/log/qxueyou_err.log" append="true" |
| | | filePattern="D:/log/qxueyou_err-%d{yyyyMMdd}-%i.log"> |
| | | fileName="C:/log/qxueyou_err.log" append="true" |
| | | filePattern="C:/log/qxueyou_err-%d{yyyyMMdd}-%i.log"> |
| | | <PatternLayout> |
| | | <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</Pattern> |
| | | </PatternLayout> |
| | |
| | | </RollingRandomAccessFile> |
| | | |
| | | <RollingRandomAccessFile name="OnsFile" |
| | | fileName="D:/logOns/qxueyouOns.log" append="true" |
| | | filePattern="D:/logOns/qxueyouOns-%d{yyyyMMdd}-%i.log"> |
| | | fileName="C:/logOns/qxueyouOns.log" append="true" |
| | | filePattern="C:/logOns/qxueyouOns-%d{yyyyMMdd}-%i.log"> |
| | | <PatternLayout> |
| | | <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</Pattern> |
| | | </PatternLayout> |