| | |
| | | */ |
| | | @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); |
| | |
| | | * @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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存对象 |
| | | */ |
| | |
| | | */ |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | @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(",")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * 考试 |
| | | * |
| | | * |
| | | * @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()); |
| | | } |
| | |
| | | @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"; |
| | | |
| | |
| | | * @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("微信登录") |
| | | @ApiOperation("微信小程序登录") |
| | | @ResponseBody |
| | | public Result wechatLogin(String code,String number) { |
| | | JSONObject sessionKeyOrOpenId = wechatService.getSessionKeyOrOpenId(code); |
| | |
| | | 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({ |
| | |
| | | import com.qxueyou.scc.teach.live.model.MediaVideoLive; |
| | | |
| | | public interface IMediaLiveService { |
| | | |
| | | |
| | | /** |
| | | * 新增直播 |
| | | * @param name 直播名称 |
| | |
| | | * @return |
| | | */ |
| | | 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; |
| | |
| | | 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 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) { |
| | |
| | | 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); |
| | |
| | | |
| | | 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(); |
| | |
| | | wx.appId=wx953bf2ed18e7836b |
| | | wx.secret=1d8b00beaddf5c8f36d1fedc14ef7973 |
| | | |
| | | |
| | | wx.app.appId=wx5a7c0d4798fbfdc2 |
| | | wx.app.secret=95c5470a52a2c4e037741f82246f4d86 |
| | | |
| | | logging.config=classpath:log4j2.xml |