1
所以基本上我想要一个人在哪个商店?这是商店的Pojo代码;如何获取用户密钥所在的实体?
@Entity
public class Store{
@Id
Long StoreId;
String Name;
String Address;
@Index List<Key<Person>> Members;
private House() {
}
public Store(Long StoreId ,String Name, String Address) {
StoreId = StoreId;
this.Name = Name;
this.Address = Address;
Members = new ArrayList<Key<Person>>();
}
public Long getId() {
return StoreId;
}
public String getName() {
return Name;
}
public void setName(String name) {
this.Name = name;
}
public String getAddress() {
return Address;
}
public void setAddress(String postcode) {
this.Address = Address;
}
public void AddToStore(Key<Person> person) {
Members.add(person);
}
下面是创建一家商店,在用户签订(谷歌登录)当前添加代码
/**
* Inserts a new {@code Store}.
*/
@ApiMethod(
name = "insert",
path = "Store",
httpMethod = ApiMethod.HttpMethod.POST)
public House insert(User user) throws UnauthorizedException {
if (user == null){
throw new UnauthorizedException("You need to authorisation");
}
String tempName = "cottages";
String tempAddress = "Gogoland";
String userId = user.getUserId();
Key<Person> personKey = Key.create(Person.class, userId);
final Key<Store> storeKey = OfyService.factory().allocateId(Store.class);
final Long StoreId = storeKey.getId();
Store h = new Store(StoreId , tempName,tempAddress);
h.AddToStore(personKey);
ofy().save().entity(h).now();
logger.info("Created Store.");
return ofy().load().entity(h).now();
}
所以对个人商店之间的关系是一对多的,你可以看到。所以我希望能够获得登录用户的当前房屋,并依次检索对象中的其他“人员”/成员实体。此外,我希望还可以检索与当前用户位于同一商店的“人员”实体的“子女”。
此外,如何邀请其他人通过电子邮件加入用户商店?
任何帮助表示赞赏。
修改这个问题让它变得更加清晰。任何帮助是极大的赞赏 :-) – Nbacareerthrowaway