@fastcar/core 0.3.5 → 0.3.6

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.
package/annotation.d.ts CHANGED
@@ -134,6 +134,9 @@ export function Field(name: string): PMRet;
134
134
  //是否为主键
135
135
  export function PrimaryKey(target: any, propertyKey: string): void;
136
136
 
137
+ //是否为自增的
138
+ export function IsSerial(target: any, propertyKey: string): void;
139
+
137
140
  //标记表名
138
141
  export function Table(name: string): Ret;
139
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastcar/core",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -0,0 +1,7 @@
1
+ import "reflect-metadata";
2
+ import { DesignMeta } from "../../db";
3
+
4
+ //是否为主键
5
+ export default function IsSerial(target: any, propertyKey: string) {
6
+ Reflect.defineMetadata(DesignMeta.isSerial, true, target, propertyKey);
7
+ }
@@ -16,6 +16,7 @@ export default function Table(name: string) {
16
16
  let field = Reflect.getOwnMetadata(DesignMeta.field, proto, c) || c;
17
17
  let dbType = Reflect.getOwnMetadata(DesignMeta.dbType, proto, c) || "varchar";
18
18
  let primaryKey = !!Reflect.getOwnMetadata(DesignMeta.primaryKey, proto, c);
19
+ let isSerial = Reflect.getOwnMetadata(DesignMeta.isSerial, proto, c);
19
20
 
20
21
  let tsName: string = tsType.name;
21
22
  let customeType = Reflect.getOwnMetadata(FastCarMetaData.CustomType, proto, c);
@@ -26,6 +27,7 @@ export default function Table(name: string) {
26
27
  field, //数据库列名
27
28
  dbType: dbType, //数据类型
28
29
  primaryKey, //是否为主键 默认为false
30
+ isSerial: isSerial || false,
29
31
  };
30
32
  dbFields.set(field, c);
31
33
  mappingMap.set(c, m);
package/src/annotation.ts CHANGED
@@ -54,6 +54,7 @@ import DemandInjection from "./annotation/bind/DemandInjection";
54
54
  import Value from "./annotation/bind/Value";
55
55
  import AppEnv from "./annotation/bind/AppEnv";
56
56
  import HotterCallBack from "./annotation/scan/HotterCallBack";
57
+ import IsSerial from "./annotation/data/IsSerial";
57
58
 
58
59
  //注解暴露出去
59
60
  export {
@@ -111,6 +112,7 @@ export {
111
112
  Entity, //表和对应编程内的类型映射
112
113
  SqlSession, //连接会话 如果需要使用同一连接或者使用事务是传递
113
114
  Transactional, //事务管理
115
+ IsSerial, //自增管理
114
116
  };
115
117
 
116
118
  export { ENV, BaseFilePath, BasePath, BaseName, ApplicationSetting };
package/src/db.ts CHANGED
@@ -160,6 +160,7 @@ export type MapperType = {
160
160
  dbType: string; //数据类型
161
161
  primaryKey?: boolean; //是否为主键 默认为false
162
162
  serialize?: Function; //序列化对象方法
163
+ isSerial?: boolean; //是否递增
163
164
  };
164
165
 
165
166
  export enum DesignMeta {
@@ -171,7 +172,8 @@ export enum DesignMeta {
171
172
  entity = "db:entity", //实例化的数据库类
172
173
  mapping = "db:mapping", //映射描述
173
174
  dbFields = "db:fields", //数据库名-ts名
174
- sqlSession = "SqlSession", //sql会话
175
+ sqlSession = "SqlSession",
176
+ isSerial = "isSerial", //sql会话
175
177
  }
176
178
 
177
179
  export interface DataSourceManager {
@@ -8,4 +8,5 @@ export enum DesignMeta {
8
8
  mapping = "db:mapping", //映射描述
9
9
  dbFields = "db:fields", //数据库名-ts名
10
10
  sqlSession = "SqlSession", //sql会话
11
+ isSerial = "db:isSerial", //是否递增
11
12
  }
@@ -5,4 +5,5 @@ export type MapperType = {
5
5
  dbType: string; //数据类型
6
6
  primaryKey?: boolean; //是否为主键 默认为false
7
7
  serialize?: Function; //序列化对象方法
8
+ isSerial: boolean; //是否为自增的
8
9
  };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = IsSerial;
4
+ require("reflect-metadata");
5
+ const db_1 = require("../../db");
6
+ //是否为主键
7
+ function IsSerial(target, propertyKey) {
8
+ Reflect.defineMetadata(db_1.DesignMeta.isSerial, true, target, propertyKey);
9
+ }
@@ -16,6 +16,7 @@ function Table(name) {
16
16
  let field = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.field, proto, c) || c;
17
17
  let dbType = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.dbType, proto, c) || "varchar";
18
18
  let primaryKey = !!Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.primaryKey, proto, c);
19
+ let isSerial = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.isSerial, proto, c);
19
20
  let tsName = tsType.name;
20
21
  let customeType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.CustomType, proto, c);
21
22
  const m = {
@@ -24,6 +25,7 @@ function Table(name) {
24
25
  field, //数据库列名
25
26
  dbType: dbType, //数据类型
26
27
  primaryKey, //是否为主键 默认为false
28
+ isSerial: isSerial || false,
27
29
  };
28
30
  dbFields.set(field, c);
29
31
  mappingMap.set(c, m);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.AppEnv = exports.Value = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.DemandInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.HotterCallBack = exports.Hotter = exports.ComponentScanMust = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
4
- exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = exports.Transactional = void 0;
4
+ exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = exports.IsSerial = exports.Transactional = void 0;
5
5
  const Application_1 = require("./annotation/Application");
6
6
  exports.Application = Application_1.default;
7
7
  const Autowired_1 = require("./annotation/bind/Autowired");
@@ -114,3 +114,5 @@ const AppEnv_1 = require("./annotation/bind/AppEnv");
114
114
  exports.AppEnv = AppEnv_1.default;
115
115
  const HotterCallBack_1 = require("./annotation/scan/HotterCallBack");
116
116
  exports.HotterCallBack = HotterCallBack_1.default;
117
+ const IsSerial_1 = require("./annotation/data/IsSerial");
118
+ exports.IsSerial = IsSerial_1.default;
package/target/db.js CHANGED
@@ -46,4 +46,5 @@ var DesignMeta;
46
46
  DesignMeta["mapping"] = "db:mapping";
47
47
  DesignMeta["dbFields"] = "db:fields";
48
48
  DesignMeta["sqlSession"] = "SqlSession";
49
+ DesignMeta["isSerial"] = "isSerial";
49
50
  })(DesignMeta || (exports.DesignMeta = DesignMeta = {}));
@@ -12,4 +12,5 @@ var DesignMeta;
12
12
  DesignMeta["mapping"] = "db:mapping";
13
13
  DesignMeta["dbFields"] = "db:fields";
14
14
  DesignMeta["sqlSession"] = "SqlSession";
15
+ DesignMeta["isSerial"] = "db:isSerial";
15
16
  })(DesignMeta || (exports.DesignMeta = DesignMeta = {}));