Commit da634c6d by 徐丛奇

wwwwwww

parent ea32ec66
package com.oo.eye.db; package com.oo.eye.db;
import android.content.Context; import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import com.app.baselibrary.commonUtil.CheckUtil;
import com.oo.eye.bean.StudentBean;
import com.oo.eye.gen.DaoMaster; import com.oo.eye.gen.DaoMaster;
import com.oo.eye.gen.DaoSession; import com.oo.eye.gen.DaoSession;
import com.oo.eye.gen.StudentBeanDao;
import java.util.ArrayList;
import java.util.List;
/** /**
*/ */
...@@ -92,5 +99,64 @@ public class DbManager { ...@@ -92,5 +99,64 @@ public class DbManager {
return mDaoMaster; return mDaoMaster;
} }
/**
* 获取班级名称
* @param context
* @return
*/
public List<String> getClasses(Context context){
List<String> classes = new ArrayList<>();
Cursor cursor = DbManager.getWritableDatabase(context)
.rawQuery("select distinct(CLASSES) FROM STUDENT_BEAN GROUP BY CLASSES",null);
if(cursor != null){
for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()) {
String nameColumn = cursor.getString(0);
if(!CheckUtil.isEmpty(nameColumn)){
classes.add(nameColumn);
}
}
}
return classes;
}
/**
* 获取学生
* @param context
* @param className
* @return
*/
public List<StudentBean> getStudents(Context context,String className,boolean isA){
List<StudentBean> studentBeans = new ArrayList<>();
try {
if(!isA) {
if (!CheckUtil.isEmpty(className)) {
studentBeans = DbManager.getDaoSession(context).getStudentBeanDao()
.queryBuilder().where(StudentBeanDao.Properties.Classes.eq(className))
.build().list();
} else {
studentBeans = DbManager.getDaoSession(context).getStudentBeanDao()
.queryBuilder()
.build().list();
}
}else{
if (!CheckUtil.isEmpty(className)) {
studentBeans = DbManager.getDaoSession(context).getStudentBeanDao()
.queryBuilder().where(StudentBeanDao.Properties.Classes.eq(className),
StudentBeanDao.Properties.Left_eye.ge(5.0) ,
StudentBeanDao.Properties.Right_eye.ge(5.0))
.build().list();
} else {
studentBeans = DbManager.getDaoSession(context).getStudentBeanDao()
.queryBuilder().where(
StudentBeanDao.Properties.Left_eye.ge(5.0) ,
StudentBeanDao.Properties.Right_eye.ge(5.0))
.build().list();
}
}
}catch (Exception e){
e.printStackTrace();
}
return studentBeans;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment