vona-cli-set-api 1.0.218 → 1.0.220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,9 +16,9 @@ export interface IControllerOptions<%=argv.resourceNameCapitalize%> extends IDec
|
|
|
16
16
|
@Controller<IControllerOptions<%=argv.resourceNameCapitalize%>>('<%=argv.resourceName%>')
|
|
17
17
|
export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
18
18
|
@Web.post()
|
|
19
|
-
@Api.body(v.
|
|
20
|
-
async create(@Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<
|
|
21
|
-
return await this.scope.service.<%=argv.resourceName%>.create(<%=argv.resourceName%>);
|
|
19
|
+
@Api.body(v.tableIdentity())
|
|
20
|
+
async create(@Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<TableIdentity> {
|
|
21
|
+
return (await this.scope.service.<%=argv.resourceName%>.create(<%=argv.resourceName%>)).id;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
@Web.get()
|
|
@@ -19,24 +19,24 @@ describe('<%=argv.resourceName%>.test.ts', () => {
|
|
|
19
19
|
// login
|
|
20
20
|
await app.bean.passport.signinMock();
|
|
21
21
|
// create
|
|
22
|
-
const <%=argv.resourceName
|
|
23
|
-
assert.equal(
|
|
22
|
+
const <%=argv.resourceName%>Id = await app.bean.executor.performAction('post', '<%=argv.moduleActionPathRaw%>', { body: data });
|
|
23
|
+
assert.equal(!!<%=argv.resourceName%>Id, true);
|
|
24
24
|
// findMany
|
|
25
25
|
const queryRes: Dto<%=argv.resourceNameCapitalize%>QueryRes = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>');
|
|
26
26
|
assert.equal(queryRes.list.findIndex(item => item.name === data.name) > -1, true);
|
|
27
27
|
// update
|
|
28
28
|
await app.bean.executor.performAction('patch', '<%=argv.moduleActionPathRaw%>/:id', {
|
|
29
|
-
params: { id: <%=argv.resourceName
|
|
29
|
+
params: { id: <%=argv.resourceName%>Id },
|
|
30
30
|
body: dataUpdate,
|
|
31
31
|
});
|
|
32
32
|
// findOne
|
|
33
|
-
const <%=argv.resourceName
|
|
34
|
-
assert.equal(<%=argv.resourceName
|
|
33
|
+
const <%=argv.resourceName%>: Entity<%=argv.resourceNameCapitalize%> = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>Id } });
|
|
34
|
+
assert.equal(<%=argv.resourceName%>.name, dataUpdate.name);
|
|
35
35
|
// delete
|
|
36
|
-
await app.bean.executor.performAction('delete', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName
|
|
36
|
+
await app.bean.executor.performAction('delete', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>.id } });
|
|
37
37
|
// findOne
|
|
38
38
|
const [_, err] = await catchError(() => {
|
|
39
|
-
return app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName
|
|
39
|
+
return app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>.id } });
|
|
40
40
|
});
|
|
41
41
|
assert.equal(err?.code, 404);
|
|
42
42
|
// logout
|