use of com.duangframework.mongodb.common.MongoUpdate in project duangframework by tcrct.
the class CurdService method delete.
/**
* 删除记录
*/
public boolean delete(String id) throws ServiceException {
if (!ToolsKit.isValidDuangId(id)) {
throw new ServiceException("it is not ObjectId");
}
MongoQuery<T> mongoQuery = new MongoQuery<>();
mongoQuery.eq(IdEntity.ID_FIELD, id);
MongoUpdate<T> mongoUpdate = new MongoUpdate<>();
mongoUpdate.set(IdEntity.STATUS_FIELD, IdEntity.STATUS_FIELD_DELETE);
try {
long count = getMongoDao().update(mongoQuery, mongoUpdate);
if (count > 0 && (getCacheDao() != null)) {
getCacheDao().delete(entityClass, id);
}
return true;
} catch (Exception e) {
throw new ServiceException("delete id[" + id + "] record is fail: " + e.getMessage(), e);
}
}
use of com.duangframework.mongodb.common.MongoUpdate in project duangframework by tcrct.
the class MongoKit method clear.
private static void clear() {
mongoQuery = new MongoQuery();
mongoUpdate = new MongoUpdate();
}
Aggregations