|
Post by Mitu46544 on Nov 8, 2023 15:11:46 GMT 8
首先您需要创建一个将实例化对象的构造函数。复制构造函数接受一个对象并使用该方法将属性从对象复制到实例。的类型是这意味着该对象可以包含类中定义的属性的任何子集。接下来更新路由处理程序以返回而不是对象复制现在响应对象中应该省略密码。不会泄露密码连同文章一起返回作者在第一章中您实现了用于检索单篇文章的端点。目前此端点不返回文章的仅返回为了获取您必须向端点发出额外的请求。如果您同时需要文章及其作者那么这。 求您可以通过将与对象一起返回 捷克共和国手机号码列表 来改进这一点。数据访问逻辑在更新方法以返回和对象复制如果您测试端点您会注意到文章的作者如果存在包含在响应对象中。然而有一个问题。田野又暴露了。显示密码这个问题的原因和上次很相似。目前返回生成类型的实例而与类一起使用。要解决此问题您将更新该类的实现并确保它使用的实例初始化该属性。复制您再次使用该方法将属性从对象复制到实例。该属性如果存在将。 被初始化为的实例。现在更新以返回对象的实例复制现在返回不带字段的对象不会泄露密码总结和最后评论在本章中您学习了如何使用在应用程序中对关系数据进行建模。您还了解了以及如何使用实体类来控制返回到客户端的数据。您可以在存储库的分支中找到本教程的完成代码。如果您发现问题请随时在存储库中提出问题或提交。您也可以直接在上与我联系。教育不要错过下一篇文章使用和构建处理关系数据系列我不明白塔辛伊斯玛姆分。
|
|