123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package com.quansu.heifengwuliu.model;
- import com.github.promeg.pinyinhelper.Pinyin;
- import com.litesuits.orm.LiteOrm;
- import com.litesuits.orm.db.annotation.Table;
- import com.litesuits.orm.db.assit.QueryBuilder;
- import com.quansu.heifengwuliu.App;
- import java.util.ArrayList;
- @Table("Contact")
- public class Contact {
- private String id;
- private String name;
- private String num;
- private String pinyin;
- private String pinyinSimple;
- private Long taskId;
- public void save() {
- App.getLiteOrm().save(this);
- }
- public static void clear() {
- App.getLiteOrm().delete(Contact.class);
- }
- public static ArrayList<Contact> findContactsByName(String name) {
- LiteOrm liteOrm = App.getLiteOrm();
- ArrayList<Contact> res = null;
- if (Pinyin.isChinese(name.charAt(0))) {
- res = liteOrm.query(new QueryBuilder<>(Contact.class).where("name LIKE ?", "%" + name + "%"));
- } else {
- res = liteOrm.query(new QueryBuilder<>(Contact.class).where("pinyin LIKE ?", "%" + name + "%"));
- }
- return res;
- }
- public void setTaskId(Long l) {
- this.taskId = l;
- }
- // public static void sync(long j) {
- // try {
- // GreenDbManger.getInstance().getWritableDatabase().execSQL("delete from contact where _taskId < " + j);
- // } catch (Exception e) {
- // ApplicationDao.createTable(getDao().getDatabase(), true);
- // }
- // }
- // private static ContactDao getDao() {
- // return new DaoMaster(GreenDbManger.getInstance().getWritableDatabase()).newSession().getContactDao();
- // }
- public String getId() {
- return this.id;
- }
- public void setId(String str) {
- this.id = str;
- }
- public String getNum() {
- return this.num;
- }
- public void setNum(String str) {
- this.num = str;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String str) {
- this.name = str;
- }
- public String getPinyin() {
- return this.pinyin;
- }
- public void setPinyin(String str) {
- this.pinyin = str;
- }
- public String getPinyinSimple() {
- return this.pinyinSimple;
- }
- public void setPinyinSimple(String str) {
- this.pinyinSimple = str;
- }
- public Long getTaskId() {
- return this.taskId;
- }
- public Contact() {
- }
- public Contact(String name, String num, String id, Long taskId, String pinyinSimple, String pinyin) {
- this.name = name;
- this.num = num;
- this.id = id;
- this.taskId = taskId;
- this.pinyinSimple = pinyinSimple;
- this.pinyin = pinyin;
- }
- // public static List<Contact> findWithLimit(String str, int i) {
- // return getDao().queryBuilder().getPinyin(Properties.Name.getPinyin("%" + str + "%"), Properties.Pinyin.getPinyin("%" + str + "%"), Properties.PinyinSimple.getPinyin("%" + str + "%")).getPinyin(i).getPinyinSimple();
- // }
- // public static List<Contact> find(String str) {
- // return getDao().queryBuilder().getPinyin(Properties.Name.getPinyin("%" + str + "%"), Properties.Pinyin.getPinyin("%" + str + "%"), Properties.PinyinSimple.getPinyin("%" + str + "%")).getPinyinSimple();
- // }
- }
|