В бэкэнде я использую springboot, и у Empoyee есть отношение oneToOne. java с логином. java и отношение ManyToMany с пользователем. java. По этому коду значения в базе данных обнуляются, поэтому, пожалуйста, помогите мне.
Employee.model.ts
import { Feedback } from './Feedback.model';
import { Query } from './Query.model';
import { Login } from './Login.model';
import { User } from './User.model';
export class Employee{
empid:number;
empname:String;
currentaddress:String;
permanentaddress:String;
mobileno:number;
birthdate:String;
email:String;
pincode:number; //long
pancard:String;
aadharcard:number; //long
login:Login;
user:User[];
query:Query[];
feedbacks:Feedback[];
}
Здесь создается только объект Employee.model.ts
component.ts
import { Login } from './../Model/Login.model';
import { EmployeeService } from './../employee.service';
import { Component, OnInit } from '@angular/core';
import { Employee } from '../Model/Employee.model';
@Component({
selector: 'app-employee-details',
templateUrl: './employee-details.component.html',
styleUrls: ['./employee-details.component.css']
})
export class EmployeeDetailsComponent implements OnInit {
constructor(private EmployeeService:EmployeeService) { }
ngOnInit() :void{
}
emp=new Employee();
addEmpMethod()
{
console.log(this.emp);
this.EmployeeService.addEmployee(this.emp).subscribe(rs=>this.emp.empid);
}
}
Здесь я пробую только для login.model .ts и employee.model.ts, но также я хочу добавить user.model.ts feedback.model.ts и query.model.ts
<code>component.html
<h2 style="font-family: 'Times New Roman', Times, serif; color: black;">Registration Form</h2>
<div>
<pre>
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">username</label>
<input type="text" name="login.username" placeholder="Enter User name" [(ngModel)]="emp.login.username">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">password</label>
<input type="text" name="login.password" placeholder="Enter User name" [(ngModel)]="emp.login.password">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">type</label>
<input type="text" name="login.type" placeholder="Enter User name" [(ngModel)]="emp.login.type">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">User_Name</label>
<input type="text" name="empname" placeholder="Enter User name" [(ngModel)]="emp.empname">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">currentaddress</label>
<input type="text" name="currentaddress" placeholder="Enter Password" [(ngModel)]="emp.currentaddress">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">permanentaddress</label>
<input type="text" name="permanentaddress" placeholder="Enter employee nme" [(ngModel)]="emp.permanentaddress">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">mobileno</label>
<input type="text" name="mobileno" placeholder="Enter Address" [(ngModel)]="emp.mobileno">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">birthdate</label>
<input type="text" name="birthdate" placeholder="Enter Address" [(ngModel)]="emp.birthdate">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">email</label>
<input type="text" name="email" placeholder="Enter Address" [(ngModel)]="emp.email">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">pincode</label>
<input type="text" name="pincode" placeholder="Enter Address" [(ngModel)]="emp.pincode">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">pancard</label>
<input type="text" name="pancard" placeholder="Enter Address" [(ngModel)]="emp.pancard">
<label style="font-family: 'Times New Roman', Times, serif; color:blue ;">aadharcard</label>
<input type="text" name="aadharcard" placeholder="Enter Address" [(ngModel)]="emp.aadharcard">
<input class="btn btn-primary" (click)="addEmpMethod()" input type="submit" value="add-employee">
<!--<a routerLink="/login"></a> -->
<!-- <input routerLink='/login' type="submit" (click)="addEmpMethod()" value="Register"> -->