public void insertData(float percent, int calorie, int courseID) { CourseBean bean = CourseDaoImp.getInstance(this).queryCourseData(getUserID(), getDate(), courseID); if (bean == null) { int category = 0; bean = new CourseBean(); bean.setUserID(getUserID()); bean.setCourseID(courseID); bean.setDate(getDate()); bean.setPercent(percent); bean.setCalorie(calorie); bean.setCourseUUID(StringUtils.getUUID()); bean.setUpload(0); category = CourseDaoImp.getInstance(this).getCategoryByUserID(getUserID()); if (category == 0) { bean.setCategory(DateUtil.getTimeStamp()); } else { bean.setCategory(category); } CourseDaoImp.getInstance(this).insertCourseData(bean); } else { bean.setPercent(bean.getPercent() + percent); bean.setCalorie(bean.getCalorie() + calorie); bean.setUpload(0); CourseDaoImp.getInstance(this).updateCourseData(bean); } }
private float getRatting(int courseID) { return CourseDaoImp.getInstance(this).queryDataByID(getUserID(), courseID); }