我有以下表单,它从用户获取一些值并生成解密密钥:
<mat-toolbar color="primary">
<span class="align-center">License Generator</span>
</mat-toolbar>
<br>
<mat-card>
<table class="generate-full-width" >
</table>
<br> <br>
<mat-card-content>
<form [formGroup]="form" (submit)="onSubmit()" autocomplete="off" novalidate>
<table class="generate-full-width">
<tr>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<input matInput placeholder="Hardware Key" formControlName="hardwareKey" name="hardwareKey">
<mat-error *ngIf="submitted && hasError('hardwareKey', 'required')">hardwareKey is required</mat-error>
</mat-form-field>
</td>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<input matInput placeholder="CustomerID" formControlName="customerID" name="customerID">
<mat-error *ngIf="submitted && hasError('customerID', 'required')">CustomerID is required</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<mat-select placeholder="Product" formControlName="product" name="product" (selectionChange)="getDefaultValues()">
<mat-option *ngFor="let product of products" [value]="product.value">
{{product.viewValue}}
</mat-option>
</mat-select>
<mat-error *ngIf="submitted && hasError('product', 'required')">Product is required</mat-error>
</mat-form-field>
</td>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<mat-select placeholder="Version" formControlName="Version" name="Version">
<mat-option *ngFor="let version of Versions" [value]="version.value">
{{version.viewValue}}
</mat-option>
</mat-select>
<mat-error *ngIf="submitted && hasError('Version', 'required')">Version is required</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<input type="text" matInput placeholder="Max User Sessions" formControlName="userSessions" name="userSessions" pattern="[0-9]*"
numbersOnly>
<mat-error *ngIf="submitted && hasError('userSessions', 'required')">User Sessions is required</mat-error>
</mat-form-field>
</td>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<input matInput placeholder="Max Service Connections" formControlName="serviceConnections" name="serviceConnections" numbersOnly>
<mat-error *ngIf="submitted && hasError('serviceConnections', 'required')">Service Connections is required</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<input matInput placeholder="Max MSANs" formControlName="msan" name="msan" numbersOnly>
<mat-error *ngIf="submitted && hasError('msan', 'required')">MSAN is required</mat-error>
</mat-form-field>
</td>
<td colspan="2" width="100%">
<mat-form-field class="generate-full-width">
<input matInput placeholder="Max CPE" formControlName="cpe" name="cpe" numbersOnly>
<mat-error *ngIf="submitted && hasError('cpe', 'required')">CPE is required</mat-error>
</mat-form-field>
</td>
</tr>
<br>
<tr>
<td colspan="5" width="100%">
<strong>* Default Expiration Date for all licenses is 01/01/2100 *</strong>
</td>
</tr>
<br>
<br>
<tr>
<td colspan="2">
<button mat-raised-button color="primary">GENERATE</button>
</td>
<td>
<button mat-raised-button color="warn" style='margin-left:115px' type="reset" >RESET</button>
</td>
<br>
</tr>
</table>
<br>
<br>
<mat-form-field class="generate-full-width">
<input matInput [readonly]="!editable" placeholder="License Key" style="font-weight: bold;" value={{licenseKey}}>
</mat-form-field>
</form>
</mat-card-content>
</mat-card>
单击generate按钮后,密钥在后端使用密码生成并显示。以下html将显示所有这些键:
<h1 mat-dialog-title color="primary">
License Details
</h1>
<mat-dialog-content >
<div style="width:100%;display: flex;flex-direction: column;">
</div>
</mat-dialog-content>
<mat-dialog-content>
<div class="example-container mat-elevation-z8">
<table mat-table [dataSource]="customerList" class="a">
<ng-container matColumnDef="Customer ID" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef class="customtd" style="font-size:15px;"><strong>Customer Id*</strong></th>
<td mat-cell *matCellDef="let element" class="customtd"> {{element.customerId}} </td>
</ng-container>
<ng-container matColumnDef="Hardware Key" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef class="customtd" style="font-size:15px;"><strong>Hardware Key</strong></th>
<td mat-cell *matCellDef="let element" class="customtd"> <textarea rows="2" cols="20" wrap="hard">{{element.hardwareKey}}</textarea> </td>
</ng-container>
<ng-container matColumnDef="Product" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef style="font-size:15px;" class="customtd"><strong>Product</strong></th>
<td mat-cell *matCellDef="let element"> {{element.product}} </td>
</ng-container>
<ng-container matColumnDef="MSAN" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef style="font-size:15px;" class="customtd"><strong>MSAN</strong></th>
<td mat-cell *matCellDef="let element"> {{element.msan}} </td>
</ng-container>
<ng-container matColumnDef="CPE" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef style="font-size:15px;" class="customtd"><strong>CPE</strong></th>
<td mat-cell *matCellDef="let element"> {{element.cpe}} </td>
</ng-container>
<ng-container matColumnDef="Service Connections" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef style="font-size:15px;" class="customtd"><strong>Service Connections</strong></th>
<td mat-cell *matCellDef="let element"> {{element.serviceConnections}} </td>
</ng-container>
<ng-container matColumnDef="License Key" margin-right:10px margin-left:5px>
<th mat-header-cell *matHeaderCellDef style="font-weight: bold;" style="font-size:15px;" class="customtd"><strong>License Key</strong></th>
<td mat-cell *matCellDef="let element"> <textarea rows="2" cols="20" wrap="hard" [readonly]="!editable">{{element.licenseKey}} </textarea></td>
</ng-container>
<ng-container matColumnDef="Actions" margin-right:10px margin-left:10px>
<th mat-header-cell *matHeaderCellDef style="font-weight: bold;" style="font-size:15px;" class="customtd"><strong>Actions</strong></th>
<td mat-cell *matCellDef="let element">
<button type="button" style="margin-left:5px" (click)="deleteLicense(element.id)">Delete</button>
<button type="button" style="margin-left:5px" (click)="openMxkLicenseDetailsDialog()">Update</button>
<button type="button" style="margin-left:5px" (click)="copyLicenseToClipboard(element.licenseKey)" class='btn btn-primary'>Copy License Key</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky:true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
</mat-dialog-content>
<br>
<br>
<br>
<strong>* Customer ID might not be present for some products.</strong>
<mat-dialog-actions align="end">
<button mat-button mat-raised-button mat-dialog-close cdkFocusInitial color="warn">Close</button>
</mat-dialog-actions>
在update按钮中,我想在上面的弹出窗口上打开一个弹出窗口,它只从要更新的用户那里获取msan和cpe。问题是如果这些值被更改,那么键也会更改。我想保持所有其他值如customer id相同,更改msan和cpe并生成一个新的密钥,然后在数据库中更新。
我不能打开另一个弹出窗口在此之上,而且我想更新许可证密钥和msan和cpe与一个单一的按钮。
在后端,我尝试了以下方法:
@PostMapping("updateLicense/{license_id}")
public boolean updateLicense(@RequestBody License license,@PathVariable("license_id") long license_id) {
license.setLicense_id(license_id);
return licenseService.updateLicense(license);
}
@Override
public boolean updateLicense(License license) {
boolean status=false;
try {
sessionFactory.getCurrentSession().update(license);
status=true;
} catch (Exception e) {
e.printStackTrace();
}
return status;
}
但是这并没有起作用,并且极大地改变了代码部分,因为它涉及到hibernate以及配置文件和服务文件的添加。现在,我只使用dao和repository。当前代码如下:
@GetMapping("/licenses")
public List<License> getAllLicense() {
return licenseDao.getAllLicenses();
}
@DeleteMapping("/deleteLicense/{id}")
public void deleteLicense(@PathVariable("id") Long id,License license) {
license.setId(id);;
//mxkLicenseService.deleteMxkLicense(mxkLicense);
licenseDao.deleteLicense(license);
}
在crud存储库和jpa存储库中,生成值之后,我找不到任何要更新的函数。上面的更新函数非常适合我尝试的更新,但是在生成值之后更新会给我带来问题。请帮忙。坚持了好几天。从以下示例应用程序获取帮助:https://www.javatpoint.com/angular-spring-crud-example
暂无答案!
目前还没有任何答案,快来回答吧!