/******************************************************************************
|
* Copyright (C) 2015 Shenzhen Penguin Network Technology Co., Ltd
|
* All Rights Reserved.
|
* 本软件为深圳市企鹅网络科技有限公司开发研制。未经本公司正式书面同意,其他任何个人、团体
|
* 不得使用、复制、修改或发布本软件.
|
*****************************************************************************/
|
|
package com.qxueyou.scc.org.dao;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import org.springframework.stereotype.Repository;
|
|
import com.qxueyou.scc.admin.classes.model.ClsClass;
|
import com.qxueyou.scc.base.dao.BaseDAO;
|
import com.qxueyou.scc.base.model.Pager;
|
import com.qxueyou.scc.org.model.OrgCollegeCourse;
|
import com.qxueyou.scc.org.model.OrgCourseCategory;
|
|
@Repository(value="orgDAO")
|
/**
|
* 自动注入sessionFactory
|
*
|
* @author 夏德虎
|
* @since JDK1.6
|
* @history 2010-07-28 夏德虎 新建
|
*/
|
public class OrgDAO extends BaseDAO {
|
|
/**
|
* 根据hql查询,并返回执行类型的列表结果
|
*
|
* @param hql 查询语句
|
* @param args 参数
|
* @param cls 返回类型
|
* @return
|
*/
|
public List<OrgCollegeCourse> queryOrgCourseList(String hql, List<Object> args) {
|
return this.queryOrgCourseListNew(hql, args);
|
}
|
|
/**
|
* 根据hql查询,并返回执行类型的列表结果
|
*
|
* @param hql 查询语句
|
* @param args 参数
|
* @param cls 返回类型
|
* @return
|
*/
|
@SuppressWarnings("unchecked")
|
public List<OrgCollegeCourse> queryOrgCourseListNew(String hql, List<Object> args) {
|
List<OrgCollegeCourse> lstCourse = new ArrayList<OrgCollegeCourse>();
|
// 添加不限
|
OrgCollegeCourse course = null;
|
List<Object[]> lst = (List<Object[]>) this.getHibernateTemplate().find(hql, args.toArray());
|
for (Object[] obj : lst) {
|
course = new OrgCollegeCourse();
|
course.setCourseId(String.valueOf(obj[0]));
|
course.setName(String.valueOf(obj[1]));
|
course.setPrice(new BigDecimal(String.valueOf(obj[2])));
|
course.setImgPath(String.valueOf(obj[3]));
|
course.setCourseCategoryId(String.valueOf(obj[4]));
|
lstCourse.add(course);
|
}
|
|
return lstCourse;
|
}
|
|
|
/**
|
* 根据hql查询,并返回执行类型的列表结果
|
*
|
* @param hql 查询语句
|
* @param args 参数
|
* @param cls 返回类型
|
* @return
|
*/
|
@SuppressWarnings("unchecked")
|
public List<OrgCourseCategory> queryOrgCourseCategoryList(String hql,
|
List<Object> args) {
|
List<OrgCourseCategory> lstCategory = new ArrayList<OrgCourseCategory>();
|
OrgCourseCategory category = null;
|
|
List<Object[]> lst = (List<Object[]>) this.getHibernateTemplate().find(hql, args.toArray());
|
for (Object[] obj : lst) {
|
category = new OrgCourseCategory();
|
category.setCategoryId(String.valueOf(obj[0]));
|
category.setCategoryName(String.valueOf(obj[1]));
|
lstCategory.add(category);
|
}
|
|
return lstCategory;
|
}
|
|
/**
|
* 组装查询班级
|
* @param hql
|
* @param page
|
* @param args
|
* @return
|
*/
|
public List<ClsClass> queryRegClassList(final String hql, final Pager page, final List<Object> args) {
|
|
List<ClsClass> lstitems = new ArrayList<ClsClass>(20);
|
ClsClass item;
|
List<Object[]> lst = this.findList(hql, page, args, Object[].class);
|
|
for (Object obj : lst) {
|
item = (ClsClass) obj;
|
lstitems.add(item);
|
}
|
return lstitems;
|
|
}
|
}
|