78 lines
2.2 KiB
Java
78 lines
2.2 KiB
Java
package com.ubt.jimu.base.db.user;
|
|
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.db.DatabaseUtils;
|
|
import com.ubt.jimu.base.entities.User;
|
|
import com.ubt.jimu.gen.UserDao;
|
|
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
|
import java.util.List;
|
|
import org.greenrobot.greendao.query.QueryBuilder;
|
|
import org.greenrobot.greendao.query.WhereCondition;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class UserDbHandler {
|
|
public static void clearUser() {
|
|
JimuAnalytics.b().a("0", "google_play");
|
|
try {
|
|
DatabaseUtils.getDaoSession(true).w().b();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static User getUser() {
|
|
try {
|
|
List<User> j = DatabaseUtils.getDaoSession(false).w().j();
|
|
if (j != null && j.size() != 0) {
|
|
return j.get(0);
|
|
}
|
|
return null;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static boolean isLogin() {
|
|
User user = getUser();
|
|
return user != null && user.getUserId() > 0;
|
|
}
|
|
|
|
public static void save(User user) {
|
|
if (user != null) {
|
|
JimuAnalytics.b().a(String.valueOf(user.getUserId()), "google_play");
|
|
}
|
|
try {
|
|
DatabaseUtils.getDaoSession(true).w().g(user);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static void updateUser(long j) {
|
|
}
|
|
|
|
public static void updateUserInfo(User user) {
|
|
try {
|
|
DatabaseUtils.getDaoSession(true).w().j(user);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static void updateUserToken(String str) {
|
|
try {
|
|
UserDao w = DatabaseUtils.getDaoSession(false).w();
|
|
QueryBuilder<User> k = w.k();
|
|
k.a(UserDao.Properties.UserId.a(Long.valueOf(Cache.getInstance().getLoginUserIntId())), new WhereCondition[0]);
|
|
User c = k.c();
|
|
if (c != null) {
|
|
c.setToken(str);
|
|
}
|
|
w.j(c);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|