Commit 1eefdcc0a9e207a8d80b6dfec7ef0bbbe2e5b983
1 parent
c940612a
1.实现开始报名
Showing
3 changed files
with
318 additions
and
0 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.sql.dao; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.database.sqlite.SQLiteDatabase; | ||
| 5 | +import android.database.sqlite.SQLiteDatabase.CursorFactory; | ||
| 6 | +import android.util.Log; | ||
| 7 | + | ||
| 8 | +import org.greenrobot.greendao.AbstractDaoMaster; | ||
| 9 | +import org.greenrobot.greendao.database.StandardDatabase; | ||
| 10 | +import org.greenrobot.greendao.database.Database; | ||
| 11 | +import org.greenrobot.greendao.database.DatabaseOpenHelper; | ||
| 12 | +import org.greenrobot.greendao.identityscope.IdentityScopeType; | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
| 16 | +/** | ||
| 17 | + * Master of DAO (schema version 1): knows all DAOs. | ||
| 18 | + */ | ||
| 19 | +public class DaoMaster extends AbstractDaoMaster { | ||
| 20 | + public static final int SCHEMA_VERSION = 1; | ||
| 21 | + | ||
| 22 | + /** Creates underlying database table using DAOs. */ | ||
| 23 | + public static void createAllTables(Database db, boolean ifNotExists) { | ||
| 24 | + UserStepEntityDao.createTable(db, ifNotExists); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** Drops underlying database table using DAOs. */ | ||
| 28 | + public static void dropAllTables(Database db, boolean ifExists) { | ||
| 29 | + UserStepEntityDao.dropTable(db, ifExists); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * WARNING: Drops all table on Upgrade! Use only during development. | ||
| 34 | + * Convenience method using a {@link DevOpenHelper}. | ||
| 35 | + */ | ||
| 36 | + public static DaoSession newDevSession(Context context, String name) { | ||
| 37 | + Database db = new DevOpenHelper(context, name).getWritableDb(); | ||
| 38 | + DaoMaster daoMaster = new DaoMaster(db); | ||
| 39 | + return daoMaster.newSession(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public DaoMaster(SQLiteDatabase db) { | ||
| 43 | + this(new StandardDatabase(db)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public DaoMaster(Database db) { | ||
| 47 | + super(db, SCHEMA_VERSION); | ||
| 48 | + registerDaoClass(UserStepEntityDao.class); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public DaoSession newSession() { | ||
| 52 | + return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public DaoSession newSession(IdentityScopeType type) { | ||
| 56 | + return new DaoSession(db, type, daoConfigMap); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - | ||
| 61 | + */ | ||
| 62 | + public static abstract class OpenHelper extends DatabaseOpenHelper { | ||
| 63 | + public OpenHelper(Context context, String name) { | ||
| 64 | + super(context, name, SCHEMA_VERSION); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public OpenHelper(Context context, String name, CursorFactory factory) { | ||
| 68 | + super(context, name, factory, SCHEMA_VERSION); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public void onCreate(Database db) { | ||
| 73 | + Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); | ||
| 74 | + createAllTables(db, false); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** WARNING: Drops all table on Upgrade! Use only during development. */ | ||
| 79 | + public static class DevOpenHelper extends OpenHelper { | ||
| 80 | + public DevOpenHelper(Context context, String name) { | ||
| 81 | + super(context, name); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public DevOpenHelper(Context context, String name, CursorFactory factory) { | ||
| 85 | + super(context, name, factory); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @Override | ||
| 89 | + public void onUpgrade(Database db, int oldVersion, int newVersion) { | ||
| 90 | + Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); | ||
| 91 | + dropAllTables(db, true); | ||
| 92 | + onCreate(db); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | +} |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.sql.dao; | ||
| 2 | + | ||
| 3 | +import java.util.Map; | ||
| 4 | + | ||
| 5 | +import org.greenrobot.greendao.AbstractDao; | ||
| 6 | +import org.greenrobot.greendao.AbstractDaoSession; | ||
| 7 | +import org.greenrobot.greendao.database.Database; | ||
| 8 | +import org.greenrobot.greendao.identityscope.IdentityScopeType; | ||
| 9 | +import org.greenrobot.greendao.internal.DaoConfig; | ||
| 10 | + | ||
| 11 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | ||
| 12 | + | ||
| 13 | +import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | ||
| 14 | + | ||
| 15 | +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * {@inheritDoc} | ||
| 19 | + * | ||
| 20 | + * @see org.greenrobot.greendao.AbstractDaoSession | ||
| 21 | + */ | ||
| 22 | +public class DaoSession extends AbstractDaoSession { | ||
| 23 | + | ||
| 24 | + private final DaoConfig userStepEntityDaoConfig; | ||
| 25 | + | ||
| 26 | + private final UserStepEntityDao userStepEntityDao; | ||
| 27 | + | ||
| 28 | + public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> | ||
| 29 | + daoConfigMap) { | ||
| 30 | + super(db); | ||
| 31 | + | ||
| 32 | + userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | ||
| 33 | + userStepEntityDaoConfig.initIdentityScope(type); | ||
| 34 | + | ||
| 35 | + userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | ||
| 36 | + | ||
| 37 | + registerDao(UserStepEntity.class, userStepEntityDao); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public void clear() { | ||
| 41 | + userStepEntityDaoConfig.clearIdentityScope(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public UserStepEntityDao getUserStepEntityDao() { | ||
| 45 | + return userStepEntityDao; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | +} |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/UserStepEntityDao.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.sql.dao; | ||
| 2 | + | ||
| 3 | +import android.database.Cursor; | ||
| 4 | +import android.database.sqlite.SQLiteStatement; | ||
| 5 | + | ||
| 6 | +import org.greenrobot.greendao.AbstractDao; | ||
| 7 | +import org.greenrobot.greendao.Property; | ||
| 8 | +import org.greenrobot.greendao.internal.DaoConfig; | ||
| 9 | +import org.greenrobot.greendao.database.Database; | ||
| 10 | +import org.greenrobot.greendao.database.DatabaseStatement; | ||
| 11 | + | ||
| 12 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | ||
| 13 | + | ||
| 14 | +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
| 15 | +/** | ||
| 16 | + * DAO for table "USER_STEP_ENTITY". | ||
| 17 | +*/ | ||
| 18 | +public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 19 | + | ||
| 20 | + public static final String TABLENAME = "USER_STEP_ENTITY"; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * Properties of entity UserStepEntity.<br/> | ||
| 24 | + * Can be used for QueryBuilder and for referencing column names. | ||
| 25 | + */ | ||
| 26 | + public static class Properties { | ||
| 27 | + public final static Property Uuid = new Property(0, String.class, "uuid", true, "UUID"); | ||
| 28 | + public final static Property UserId = new Property(1, String.class, "userId", false, "USER_ID"); | ||
| 29 | + public final static Property Date = new Property(2, String.class, "date", false, "DATE"); | ||
| 30 | + public final static Property StepCount = new Property(3, String.class, "stepCount", false, "STEP_COUNT"); | ||
| 31 | + public final static Property PauseTimeStamp = new Property(4, long.class, "pauseTimeStamp", false, "PAUSE_TIME_STAMP"); | ||
| 32 | + public final static Property RecordTime = new Property(5, long.class, "recordTime", false, "RECORD_TIME"); | ||
| 33 | + public final static Property CaloriesCount = new Property(6, double.class, "caloriesCount", false, "CALORIES_COUNT"); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + public UserStepEntityDao(DaoConfig config) { | ||
| 38 | + super(config); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public UserStepEntityDao(DaoConfig config, DaoSession daoSession) { | ||
| 42 | + super(config, daoSession); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** Creates the underlying database table. */ | ||
| 46 | + public static void createTable(Database db, boolean ifNotExists) { | ||
| 47 | + String constraint = ifNotExists? "IF NOT EXISTS ": ""; | ||
| 48 | + db.execSQL("CREATE TABLE " + constraint + "\"USER_STEP_ENTITY\" (" + // | ||
| 49 | + "\"UUID\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid | ||
| 50 | + "\"USER_ID\" TEXT," + // 1: userId | ||
| 51 | + "\"DATE\" TEXT," + // 2: date | ||
| 52 | + "\"STEP_COUNT\" TEXT," + // 3: stepCount | ||
| 53 | + "\"PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 4: pauseTimeStamp | ||
| 54 | + "\"RECORD_TIME\" INTEGER NOT NULL ," + // 5: recordTime | ||
| 55 | + "\"CALORIES_COUNT\" REAL NOT NULL );"); // 6: caloriesCount | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** Drops the underlying database table. */ | ||
| 59 | + public static void dropTable(Database db, boolean ifExists) { | ||
| 60 | + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"USER_STEP_ENTITY\""; | ||
| 61 | + db.execSQL(sql); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + protected final void bindValues(DatabaseStatement stmt, UserStepEntity entity) { | ||
| 66 | + stmt.clearBindings(); | ||
| 67 | + | ||
| 68 | + String uuid = entity.getUuid(); | ||
| 69 | + if (uuid != null) { | ||
| 70 | + stmt.bindString(1, uuid); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + String userId = entity.getUserId(); | ||
| 74 | + if (userId != null) { | ||
| 75 | + stmt.bindString(2, userId); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + String date = entity.getDate(); | ||
| 79 | + if (date != null) { | ||
| 80 | + stmt.bindString(3, date); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + String stepCount = entity.getStepCount(); | ||
| 84 | + if (stepCount != null) { | ||
| 85 | + stmt.bindString(4, stepCount); | ||
| 86 | + } | ||
| 87 | + stmt.bindLong(5, entity.getPauseTimeStamp()); | ||
| 88 | + stmt.bindLong(6, entity.getRecordTime()); | ||
| 89 | + stmt.bindDouble(7, entity.getCaloriesCount()); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + protected final void bindValues(SQLiteStatement stmt, UserStepEntity entity) { | ||
| 94 | + stmt.clearBindings(); | ||
| 95 | + | ||
| 96 | + String uuid = entity.getUuid(); | ||
| 97 | + if (uuid != null) { | ||
| 98 | + stmt.bindString(1, uuid); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + String userId = entity.getUserId(); | ||
| 102 | + if (userId != null) { | ||
| 103 | + stmt.bindString(2, userId); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + String date = entity.getDate(); | ||
| 107 | + if (date != null) { | ||
| 108 | + stmt.bindString(3, date); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + String stepCount = entity.getStepCount(); | ||
| 112 | + if (stepCount != null) { | ||
| 113 | + stmt.bindString(4, stepCount); | ||
| 114 | + } | ||
| 115 | + stmt.bindLong(5, entity.getPauseTimeStamp()); | ||
| 116 | + stmt.bindLong(6, entity.getRecordTime()); | ||
| 117 | + stmt.bindDouble(7, entity.getCaloriesCount()); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + @Override | ||
| 121 | + public String readKey(Cursor cursor, int offset) { | ||
| 122 | + return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + @Override | ||
| 126 | + public UserStepEntity readEntity(Cursor cursor, int offset) { | ||
| 127 | + UserStepEntity entity = new UserStepEntity( // | ||
| 128 | + cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // uuid | ||
| 129 | + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userId | ||
| 130 | + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // date | ||
| 131 | + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // stepCount | ||
| 132 | + cursor.getLong(offset + 4), // pauseTimeStamp | ||
| 133 | + cursor.getLong(offset + 5), // recordTime | ||
| 134 | + cursor.getDouble(offset + 6) // caloriesCount | ||
| 135 | + ); | ||
| 136 | + return entity; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + @Override | ||
| 140 | + public void readEntity(Cursor cursor, UserStepEntity entity, int offset) { | ||
| 141 | + entity.setUuid(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); | ||
| 142 | + entity.setUserId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); | ||
| 143 | + entity.setDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); | ||
| 144 | + entity.setStepCount(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); | ||
| 145 | + entity.setPauseTimeStamp(cursor.getLong(offset + 4)); | ||
| 146 | + entity.setRecordTime(cursor.getLong(offset + 5)); | ||
| 147 | + entity.setCaloriesCount(cursor.getDouble(offset + 6)); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @Override | ||
| 151 | + protected final String updateKeyAfterInsert(UserStepEntity entity, long rowId) { | ||
| 152 | + return entity.getUuid(); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public String getKey(UserStepEntity entity) { | ||
| 157 | + if(entity != null) { | ||
| 158 | + return entity.getUuid(); | ||
| 159 | + } else { | ||
| 160 | + return null; | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + @Override | ||
| 165 | + public boolean hasKey(UserStepEntity entity) { | ||
| 166 | + return entity.getUuid() != null; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + @Override | ||
| 170 | + protected final boolean isEntityUpdateable() { | ||
| 171 | + return true; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | +} |