我有父级(产品)和子级(书籍、家具),并且希望将产品实体映射到产品 DTO。如您所见,产品被映射并存储在数据库中的单个表中。如何映射具有子项额外详细信息的父项产品?
实体
@Entity
@Table(name = "product")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Product {
@Id
private long id;
private String productName;
}
@Entity
@DiscriminatorValue("Book")
public class Book extends Product {
private String author;
...
}
@Entity
@DiscriminatorValue("Furniture")
public class Furniture extends Product {
String color;
...
}
Run Code Online (Sandbox Code Playgroud)
数据传输组织
public class ProductDto {
private long id;
private String productName;
...
}
public class BookDto extends ProductDto {
private String author;
...
}
public class …Run Code Online (Sandbox Code Playgroud) 我想通过调用具有不同数量参数的构造函数来创建不同的对象。我怎样才能在 Dart 中实现这一目标?
class A{
String b,c,d;
A(this.b,this.c)
A(this.b,this.c,this.d)
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用local_auth包包含生物识别身份验证。这在应用程序启动时使用。指纹用于确定用户是否为手机的所有者。如果确认,他们将被带到主页。下面的代码有效,但我想在下面的代码中应用的是MVCor design pattern。有人可以指导我吗?
class LoginOptionState extends State<LoginOption> {
final LocalAuthentication auth = LocalAuthentication();
String _authorized = 'Not Authorized';
@override
Widget build(BuildContext context) {
return Scaffold(
body: new Container(
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Column(
children: <Widget>[
Text("Touch ID"),
SizedBox(height: 10),
GestureDetector(
child: Image.asset(
"assets/",
),
onTap: _authenticate),
],
),
],
),
)));
}
Future<void> _authenticate() async {
bool authenticated = false;
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Scan your fingerprint …Run Code Online (Sandbox Code Playgroud)