Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haihang
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐丛奇
haihang
Commits
da634c6d
Commit
da634c6d
authored
Sep 07, 2018
by
徐丛奇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wwwwwww
parent
ea32ec66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
DbManager.java
app/src/main/java/com/oo/eye/db/DbManager.java
+66
-0
No files found.
app/src/main/java/com/oo/eye/db/DbManager.java
View file @
da634c6d
package
com
.
oo
.
eye
.
db
;
import
android.content.Context
;
import
android.database.Cursor
;
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.DaoSession
;
import
com.oo.eye.gen.StudentBeanDao
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
*/
...
...
@@ -92,5 +99,64 @@ public class DbManager {
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment