vona-module-test-rest 5.0.0 → 5.1.2

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.
Files changed (52) hide show
  1. package/LICENSE +0 -0
  2. package/dist/.metadata/index.d.ts +292 -0
  3. package/dist/.metadata/index.d.ts.map +1 -0
  4. package/dist/.metadata/locales.d.ts +33 -0
  5. package/dist/.metadata/locales.d.ts.map +1 -0
  6. package/dist/.metadata/this.d.ts +3 -0
  7. package/dist/.metadata/this.d.ts.map +1 -0
  8. package/dist/bean/meta.version.d.ts +7 -0
  9. package/dist/bean/meta.version.d.ts.map +1 -0
  10. package/dist/bean/ssrMenu.product.d.ts +8 -0
  11. package/dist/bean/ssrMenu.product.d.ts.map +1 -0
  12. package/dist/config/locale/en-us.d.ts +16 -0
  13. package/dist/config/locale/en-us.d.ts.map +1 -0
  14. package/dist/config/locale/zh-cn.d.ts +16 -0
  15. package/dist/config/locale/zh-cn.d.ts.map +1 -0
  16. package/dist/controller/product.d.ts +19 -0
  17. package/dist/controller/product.d.ts.map +1 -0
  18. package/dist/dto/productCreate.d.ts +9 -0
  19. package/dist/dto/productCreate.d.ts.map +1 -0
  20. package/dist/dto/productQuery.d.ts +10 -0
  21. package/dist/dto/productQuery.d.ts.map +1 -0
  22. package/dist/dto/productQueryRes.d.ts +9 -0
  23. package/dist/dto/productQueryRes.d.ts.map +1 -0
  24. package/dist/dto/productUpdate.d.ts +9 -0
  25. package/dist/dto/productUpdate.d.ts.map +1 -0
  26. package/dist/entity/product.d.ts +12 -0
  27. package/dist/entity/product.d.ts.map +1 -0
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +321 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/model/product.d.ts +8 -0
  33. package/dist/model/product.d.ts.map +1 -0
  34. package/dist/service/product.d.ts +16 -0
  35. package/dist/service/product.d.ts.map +1 -0
  36. package/package.json +38 -19
  37. package/src/.metadata/index.ts +361 -0
  38. package/src/.metadata/locales.ts +13 -0
  39. package/src/.metadata/this.ts +2 -0
  40. package/src/bean/meta.version.ts +44 -0
  41. package/src/bean/ssrMenu.product.ts +26 -0
  42. package/src/config/locale/en-us.ts +14 -0
  43. package/src/config/locale/zh-cn.ts +14 -0
  44. package/src/controller/product.tsx +66 -0
  45. package/src/dto/productCreate.ts +22 -0
  46. package/src/dto/productQuery.ts +22 -0
  47. package/src/dto/productQueryRes.ts +11 -0
  48. package/src/dto/productUpdate.ts +15 -0
  49. package/src/entity/product.tsx +97 -0
  50. package/src/index.ts +2 -0
  51. package/src/model/product.ts +10 -0
  52. package/src/service/product.ts +36 -0
@@ -0,0 +1,97 @@
1
+ import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
2
+
3
+ // import { cel } from '@cabloy/utils';
4
+ // import React from 'react';
5
+ import { Api, v } from 'vona-module-a-openapiutils';
6
+ import { Entity, EntityBase } from 'vona-module-a-orm';
7
+
8
+ // import { ZZDemoBasicActionView } from 'zova-rest-cabloy-basic-admin';
9
+ import { $locale } from '../.metadata/locales.ts';
10
+
11
+ export interface IEntityOptionsProduct extends IDecoratorEntityOptions<'_custom'> {}
12
+
13
+ @Entity<IEntityOptionsProduct>('testRestProduct', {
14
+ openapi: { title: $locale('ProductInfo') },
15
+ fields: {
16
+ _custom: {
17
+ title: 'Custom',
18
+ rest: {
19
+ render: 'text',
20
+ },
21
+ },
22
+ },
23
+ })
24
+ export class EntityProduct extends EntityBase {
25
+ @Api.field(
26
+ v.title($locale('Name')),
27
+ v.order(1),
28
+ // v.render(
29
+ // <ZZDemoBasicActionView>
30
+ // <div className="mock">{cel('displayValue')}</div>
31
+ // <div>{cel('get(permissions,"actions.create")')}</div>
32
+ // </ZZDemoBasicActionView>,
33
+ // 'table',
34
+ // ),
35
+ // v.render(
36
+ // <a
37
+ // className="hover:text-blue-500"
38
+ // href="#"
39
+ // onClick={(
40
+ // <action prevent>
41
+ // <ActionView></ActionView>
42
+ // <ActionVar name="var1" value={cel('getValue("id")')}></ActionVar>
43
+ // <ActionLog message={cel('var1+":var1 hello world"')}></ActionLog>
44
+ // <ActionExpr expression={cel('displayValue+"!"')}></ActionExpr>
45
+ // <ActionLog message={cel('res[3]')}></ActionLog>
46
+ // <ActionLog message={cel('getEventProp("x")+":"+getEventProp("y")')}></ActionLog>
47
+ // <action res="resAction">
48
+ // <ActionVar name="var2" value={cel('getValue("id")')}></ActionVar>
49
+ // <ActionLog message={cel('var2+":var2 hello world"')}></ActionLog>
50
+ // <ActionExpr expression={cel('displayValue+"!"')}></ActionExpr>
51
+ // <ActionLog message={cel('res[6]')}></ActionLog>
52
+ // <ActionLog message={cel('res[6][2]')}></ActionLog>
53
+ // <ActionExpr expression={cel('res[6][2]')}></ActionExpr>
54
+ // </action>
55
+ // <ActionLog message={cel('res[6]')}></ActionLog>
56
+ // <ActionLog message={cel('resAction')}></ActionLog>
57
+ // <AAActionsLog message={cel('"log: "+resAction')}></AAActionsLog>
58
+ // </action>
59
+ // )}
60
+ // >
61
+ // {cel('displayValue')}
62
+ // </a>,
63
+ // 'table',
64
+ // ),
65
+ v.render('actionView', 'table'),
66
+ v.min(3, $locale('ZodErrorStringMin')),
67
+ v.required(),
68
+ )
69
+ name: string;
70
+
71
+ @Api.field(v.title($locale('Description')), v.order(2), v.optional())
72
+ description?: string;
73
+
74
+ @Api.field(
75
+ v.title($locale('Price')),
76
+ v.order(3),
77
+ // v.render(<TTCurrency currency={{ exp: 4, fixed: 4 }}></TTCurrency>, 'table'),
78
+ // v.component('currency', { exp: 3, fixed: 3 }),
79
+ // v.render(
80
+ // <ZZDemoBasicTableCellTest showLog={true}>
81
+ // <div>{cel('displayValue')}</div>
82
+ // <div v-slot="header" v-slot-scope="item">{cel('name + ":header:" + item.name')}</div>
83
+ // <div v-slot="footer" v-slot-scope="scope">{cel('name + ":footer:" + scope.name')}</div>
84
+ // </ZZDemoBasicTableCellTest>,
85
+ // ),
86
+ v.component('currency'),
87
+ v.min(0, $locale('ZodErrorNumberMin')),
88
+ v.required(),
89
+ )
90
+ price: number;
91
+
92
+ @Api.field(v.title($locale('Quantity')), v.order(4), v.default(0))
93
+ quantity: number;
94
+
95
+ @Api.field(v.title($locale('Amount')), v.order(5), v.component('currency'), v.required())
96
+ amount: number;
97
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './.metadata/index.ts';
2
+ export * from './.metadata/locales.ts';
@@ -0,0 +1,10 @@
1
+ import type { IDecoratorModelOptions } from 'vona-module-a-orm';
2
+
3
+ import { BeanModelBase, Model } from 'vona-module-a-orm';
4
+
5
+ import { EntityProduct } from '../entity/product.tsx';
6
+
7
+ export interface IModelOptionsProduct extends IDecoratorModelOptions<EntityProduct> {}
8
+
9
+ @Model<IModelOptionsProduct>({ entity: EntityProduct })
10
+ export class ModelProduct extends BeanModelBase<EntityProduct> {}
@@ -0,0 +1,36 @@
1
+ import type { TableIdentity } from 'table-identity';
2
+ import type { IQueryParams } from 'vona-module-a-orm';
3
+
4
+ import { BeanBase } from 'vona';
5
+ import { Service } from 'vona-module-a-bean';
6
+
7
+ import type { DtoProductCreate } from '../dto/productCreate.ts';
8
+ import type { DtoProductQueryRes } from '../dto/productQueryRes.ts';
9
+ import type { DtoProductUpdate } from '../dto/productUpdate.ts';
10
+ import type { EntityProduct } from '../entity/product.tsx';
11
+ import type { ModelProduct } from '../model/product.ts';
12
+
13
+ @Service()
14
+ export class ServiceProduct extends BeanBase {
15
+ async create(product: DtoProductCreate): Promise<EntityProduct> {
16
+ return await this.scope.model.product.insert(product);
17
+ }
18
+
19
+ async select(params?: IQueryParams<ModelProduct>): Promise<DtoProductQueryRes> {
20
+ return await this.scope.model.product.selectAndCount({
21
+ ...params,
22
+ });
23
+ }
24
+
25
+ async view(id: TableIdentity): Promise<EntityProduct | undefined> {
26
+ return await this.scope.model.product.getById(id);
27
+ }
28
+
29
+ async update(id: TableIdentity, product: DtoProductUpdate) {
30
+ return await this.scope.model.product.updateById(id, product);
31
+ }
32
+
33
+ async delete(id: TableIdentity) {
34
+ return await this.scope.model.product.deleteById(id);
35
+ }
36
+ }