chyz 1.0.13-rc.4 → 1.0.13-rc.5
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/BaseChyz.ts +384 -0
- package/Chyz.ts +11 -0
- package/Examples/Controllers/ApiController.ts +140 -0
- package/Examples/Controllers/KeyCloakController.ts +100 -0
- package/Examples/Controllers/PublicController.ts +42 -0
- package/Examples/Controllers/SiteController.ts +139 -0
- package/Examples/Models/Categories.ts +48 -0
- package/Examples/Models/Customer.ts +115 -0
- package/Examples/Models/KeycloakUser.ts +66 -0
- package/Examples/Models/Order.ts +64 -0
- package/Examples/Models/OrderItem.ts +27 -0
- package/Examples/Models/ProductModels.ts +49 -0
- package/Examples/Models/ProductToCategories.ts +46 -0
- package/Examples/Models/Products.ts +50 -0
- package/Examples/Models/Stocks.ts +60 -0
- package/Examples/Models/User.ts +100 -0
- package/Examples/Models/UserPermission.ts +37 -0
- package/Examples/Models/index.ts +19 -0
- package/Examples/index-keycloack.ts +78 -0
- package/Examples/index.ts +40 -0
- package/Examples/keycloak.json +7 -0
- package/Examples/log/access.log +0 -0
- package/Examples/log/app.log +6057 -0
- package/Examples/log/errors.log +1526 -0
- package/Examples/package.json +46 -0
- package/Examples/tsconfig.json +21 -0
- package/base/ActionFilter.ts +71 -0
- package/base/BaseError.ts +26 -0
- package/base/BaseObject.ts +19 -0
- package/base/Behavior.ts +6 -0
- package/base/Component.ts +66 -0
- package/base/Configurable.ts +10 -0
- package/base/Controller.ts +84 -0
- package/base/DataErrorDbException.ts +16 -0
- package/base/DbConnection.ts +51 -0
- package/base/ForbiddenHttpException.ts +15 -0
- package/base/InvalidConfigException.ts +16 -0
- package/base/Model.ts +358 -0
- package/base/ModelManager.ts +14 -0
- package/base/NotFoundHttpException.ts +14 -0
- package/base/RestClient.ts +28 -0
- package/base/UnauthorizedHttpException.ts +17 -0
- package/base/ValidationHttpException.ts +14 -0
- package/base/db/Exception.ts +14 -0
- package/base/index.ts +17 -0
- package/decorator/Middleware.ts +9 -0
- package/decorator/controller.ts +22 -0
- package/decorator/enums/ControllerDecoratorParams.ts +5 -0
- package/decorator/get.ts +37 -0
- package/decorator/index.ts +3 -0
- package/decorator/post.ts +36 -0
- package/{BaseChyz.js → dist/BaseChyz.js} +29 -4
- package/dist/BaseChyz.js.map +1 -0
- package/{Chyz.js → dist/Chyz.js} +0 -0
- package/{Chyz.js.map → dist/Chyz.js.map} +0 -0
- package/{base → dist/base}/ActionFilter.js +0 -0
- package/{base → dist/base}/ActionFilter.js.map +0 -0
- package/{base → dist/base}/BaseError.js +0 -0
- package/{base → dist/base}/BaseError.js.map +0 -0
- package/{base → dist/base}/BaseObject.js +0 -0
- package/{base → dist/base}/BaseObject.js.map +0 -0
- package/{base → dist/base}/Behavior.js +0 -0
- package/{base → dist/base}/Behavior.js.map +0 -0
- package/{base → dist/base}/Component.js +0 -0
- package/{base → dist/base}/Component.js.map +0 -0
- package/{base → dist/base}/Configurable.js +0 -0
- package/{base → dist/base}/Configurable.js.map +0 -0
- package/{base → dist/base}/Controller.js +0 -0
- package/{base → dist/base}/Controller.js.map +0 -0
- package/{base → dist/base}/DataErrorDbException.js +0 -0
- package/{base → dist/base}/DataErrorDbException.js.map +0 -0
- package/{base → dist/base}/DbConnection.js +0 -0
- package/{base → dist/base}/DbConnection.js.map +0 -0
- package/{base → dist/base}/ForbiddenHttpException.js +0 -0
- package/{base → dist/base}/ForbiddenHttpException.js.map +0 -0
- package/{base → dist/base}/InvalidConfigException.js +0 -0
- package/{base → dist/base}/InvalidConfigException.js.map +0 -0
- package/{base → dist/base}/Model.js +32 -28
- package/dist/base/Model.js.map +1 -0
- package/dist/base/ModelManager.js +17 -0
- package/dist/base/ModelManager.js.map +1 -0
- package/{base → dist/base}/NotFoundHttpException.js +0 -0
- package/{base → dist/base}/NotFoundHttpException.js.map +0 -0
- package/{base → dist/base}/RestClient.js +0 -0
- package/{base → dist/base}/RestClient.js.map +0 -0
- package/{base → dist/base}/UnauthorizedHttpException.js +0 -0
- package/{base → dist/base}/UnauthorizedHttpException.js.map +0 -0
- package/{base → dist/base}/ValidationHttpException.js +0 -0
- package/{base → dist/base}/ValidationHttpException.js.map +0 -0
- package/{base → dist/base}/db/Exception.js +0 -0
- package/{base → dist/base}/db/Exception.js.map +0 -0
- package/{base → dist/base}/index.js +1 -0
- package/{base → dist/base}/index.js.map +1 -1
- package/{decorator → dist/decorator}/Middleware.js +0 -0
- package/{decorator → dist/decorator}/Middleware.js.map +0 -0
- package/{decorator → dist/decorator}/controller.js +0 -0
- package/{decorator → dist/decorator}/controller.js.map +0 -0
- package/{decorator → dist/decorator}/enums/ControllerDecoratorParams.js +0 -0
- package/{decorator → dist/decorator}/enums/ControllerDecoratorParams.js.map +0 -0
- package/{decorator → dist/decorator}/get.js +0 -0
- package/{decorator → dist/decorator}/get.js.map +0 -0
- package/{decorator → dist/decorator}/index.js +0 -0
- package/{decorator → dist/decorator}/index.js.map +0 -0
- package/{decorator → dist/decorator}/post.js +0 -0
- package/{decorator → dist/decorator}/post.js.map +0 -0
- package/{filters → dist/filters}/AccessControl.js +0 -0
- package/{filters → dist/filters}/AccessControl.js.map +0 -0
- package/{filters → dist/filters}/AccessRule.js +0 -0
- package/{filters → dist/filters}/AccessRule.js.map +0 -0
- package/{filters → dist/filters}/auth/AuthInterface.js +0 -0
- package/{filters → dist/filters}/auth/AuthInterface.js.map +0 -0
- package/{filters → dist/filters}/auth/AuthMethod.js +0 -0
- package/{filters → dist/filters}/auth/AuthMethod.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpBasicAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpBasicAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpHeaderAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpHeaderAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/JwtHttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/JwtHttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/index.js +0 -0
- package/{filters → dist/filters}/auth/index.js.map +0 -0
- package/{filters → dist/filters}/index.js +0 -0
- package/{filters → dist/filters}/index.js.map +0 -0
- package/{index.js → dist/index.js} +0 -0
- package/{index.js.map → dist/index.js.map} +0 -0
- package/dist/log/config/log4js.json +55 -0
- package/{model → dist/model}/RouteDefinition.js +0 -0
- package/{model → dist/model}/RouteDefinition.js.map +0 -0
- package/{requiments → dist/requiments}/Glob.js +0 -0
- package/{requiments → dist/requiments}/Glob.js.map +0 -0
- package/{requiments → dist/requiments}/ReflectUtil.js +0 -0
- package/{requiments → dist/requiments}/ReflectUtil.js.map +0 -0
- package/{requiments → dist/requiments}/Utils.js +0 -0
- package/{requiments → dist/requiments}/Utils.js.map +0 -0
- package/{validators → dist/validators}/BooleanValidator.js +0 -0
- package/{validators → dist/validators}/BooleanValidator.js.map +0 -0
- package/{validators → dist/validators}/CompareValidator.js +0 -0
- package/{validators → dist/validators}/CompareValidator.js.map +0 -0
- package/{validators → dist/validators}/DateValidator.js +0 -0
- package/{validators → dist/validators}/DateValidator.js.map +0 -0
- package/{validators → dist/validators}/EmailValidator.js +0 -0
- package/{validators → dist/validators}/EmailValidator.js.map +0 -0
- package/{validators → dist/validators}/Validator.js +0 -0
- package/{validators → dist/validators}/Validator.js.map +0 -0
- package/{web → dist/web}/IdentityInterface.js +0 -0
- package/{web → dist/web}/IdentityInterface.js.map +0 -0
- package/{web → dist/web}/WebUser.js +0 -0
- package/{web → dist/web}/WebUser.js.map +0 -0
- package/filters/AccessControl.ts +64 -0
- package/filters/AccessRule.ts +137 -0
- package/filters/auth/AuthInterface.ts +34 -0
- package/filters/auth/AuthMethod.ts +88 -0
- package/filters/auth/HttpBasicAuth.ts +7 -0
- package/filters/auth/HttpBearerAuth.ts +31 -0
- package/filters/auth/HttpHeaderAuth.ts +53 -0
- package/filters/auth/JwtHttpBearerAuth.ts +80 -0
- package/filters/auth/KeyCloakHttpBearerAuth.ts +115 -0
- package/filters/auth/index.ts +3 -0
- package/filters/index.ts +2 -0
- package/index.ts +14 -0
- package/model/RouteDefinition.ts +18 -0
- package/package-lock.json +5259 -0
- package/package.json +3 -3
- package/requiments/Glob.ts +9 -0
- package/requiments/ReflectUtil.ts +26 -0
- package/requiments/Utils.ts +57 -0
- package/tsconfig.json +18 -0
- package/validators/BooleanValidator.ts +0 -0
- package/validators/CompareValidator.ts +0 -0
- package/validators/DateValidator.ts +0 -0
- package/validators/EmailValidator.ts +0 -0
- package/validators/Validator.ts +27 -0
- package/web/IdentityInterface.ts +62 -0
- package/web/WebUser.ts +100 -0
- package/BaseChyz.js.map +0 -1
- package/base/Model.js.map +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {Controller} from "../../base";
|
|
9
|
+
import BaseChyz from "../../BaseChyz";
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
import {Request, Response} from "express";
|
|
12
|
+
import {get} from "../../decorator";
|
|
13
|
+
import {post} from "../../decorator";
|
|
14
|
+
import {controller} from "../../decorator";
|
|
15
|
+
import {User} from "../Models/User";
|
|
16
|
+
import {ForbiddenHttpException} from "../../base";
|
|
17
|
+
import {JwtHttpBearerAuth} from "../../filters/auth";
|
|
18
|
+
|
|
19
|
+
const bcrypt = require('bcrypt');
|
|
20
|
+
const JsonWebToken = require("jsonwebtoken");
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@controller("/site")
|
|
24
|
+
class SiteController extends Controller {
|
|
25
|
+
|
|
26
|
+
public myCheck(token) {
|
|
27
|
+
console.log("myyyyyyyyyyyyyyyyyyyyy")
|
|
28
|
+
}
|
|
29
|
+
public behaviors(): any[] {
|
|
30
|
+
return [{
|
|
31
|
+
'authenticator': {
|
|
32
|
+
"class": JwtHttpBearerAuth,
|
|
33
|
+
"except":["index","login"]
|
|
34
|
+
// "auth": this.myCheck
|
|
35
|
+
}
|
|
36
|
+
}]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// public behaviors(): any[] {
|
|
41
|
+
//
|
|
42
|
+
// return [{
|
|
43
|
+
// // 'authenticator': {
|
|
44
|
+
// // "class": JwtHttpBearerAuth,
|
|
45
|
+
// // // "auth": this.myCheck
|
|
46
|
+
// // },
|
|
47
|
+
// 'access': {
|
|
48
|
+
// 'class': AccessControl,
|
|
49
|
+
// 'only': ['login', 'logout','index' ],
|
|
50
|
+
// 'rules': [
|
|
51
|
+
// {
|
|
52
|
+
// 'allow': false,
|
|
53
|
+
// 'actions': ['login', 'index' ],
|
|
54
|
+
// 'roles': ['?'],
|
|
55
|
+
// },
|
|
56
|
+
// {
|
|
57
|
+
// 'allow': true,
|
|
58
|
+
// 'actions': ['logout', "logout2"],
|
|
59
|
+
// 'roles': ['@'],
|
|
60
|
+
// }
|
|
61
|
+
// ]
|
|
62
|
+
// }
|
|
63
|
+
// }]
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
@get("index")
|
|
67
|
+
Index(req: Request, res: Response) {
|
|
68
|
+
|
|
69
|
+
BaseChyz.logs().info("Site Controller Burası", this.id)
|
|
70
|
+
return res.json({message: "index sayfası"})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@post("login")
|
|
74
|
+
async login(req: Request, res: Response) {
|
|
75
|
+
let UserModel: User = new User();
|
|
76
|
+
let token
|
|
77
|
+
let username = req.body.username;
|
|
78
|
+
let password = req.body.password;
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
let user = await UserModel.findOne({where: {username: username}})
|
|
82
|
+
if (user) {
|
|
83
|
+
BaseChyz.debug("Db found user", username)
|
|
84
|
+
const match = await bcrypt.compare(password, user.password);
|
|
85
|
+
if (match) {
|
|
86
|
+
BaseChyz.debug("Db user verify", username)
|
|
87
|
+
//login
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
let xForwardedFor = (req.headers['x-forwarded-for'] || '').replace(/:\d+$/, '');
|
|
90
|
+
let ip = xForwardedFor || req.socket.remoteAddress;
|
|
91
|
+
var source: string = req.headers['user-agent'] || '';
|
|
92
|
+
if (req.headers['x-ucbrowser-ua']) { //special case of UC Browser
|
|
93
|
+
source = req.headers['x-ucbrowser-ua']+"";
|
|
94
|
+
}
|
|
95
|
+
token = await JsonWebToken.sign({
|
|
96
|
+
user: user.id,
|
|
97
|
+
ip: ip,
|
|
98
|
+
agent: source,
|
|
99
|
+
}, user.authkey, {expiresIn: '1h'});
|
|
100
|
+
|
|
101
|
+
BaseChyz.debug("Db user create access token", username,"expiresIn","1h")
|
|
102
|
+
return res.json({token: token})
|
|
103
|
+
} else {
|
|
104
|
+
let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
|
|
105
|
+
res.status(500).json( error.toJSON())
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
|
|
109
|
+
res.status(500).json( error.toJSON())
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@get("logout")
|
|
116
|
+
logout(req: Request, res: Response) {
|
|
117
|
+
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
let identity = req.user ?? BaseChyz.getComponent("user").getIdentity();
|
|
120
|
+
// console.log("logout2", identity.id)
|
|
121
|
+
//console.log(identity)
|
|
122
|
+
|
|
123
|
+
BaseChyz.logs().info("Logout Controller")
|
|
124
|
+
return res.send("Logout Controller")
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@get("signup")
|
|
128
|
+
logout2(req: Request, res: Response) {
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
return res.send("Logout Controller")
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
error(req: Request, res: Response) {
|
|
135
|
+
BaseChyz.logs().info("Error Sayfası")
|
|
136
|
+
return res.send("Post Controller")
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
module.exports=SiteController
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
8
|
+
import {ProductToCategoriesClass} from "./ProductToCategories";
|
|
9
|
+
|
|
10
|
+
export class CategoriesClass extends Model {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
|
|
13
|
+
tableName() {
|
|
14
|
+
return 'categories';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
attributes() {
|
|
19
|
+
return {
|
|
20
|
+
// Model attributes are defined here
|
|
21
|
+
title: {
|
|
22
|
+
type: DataTypes.STRING,
|
|
23
|
+
allowNull: false
|
|
24
|
+
},
|
|
25
|
+
properties: {
|
|
26
|
+
type: DataTypes.STRING,
|
|
27
|
+
allowNull: false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
relations(): Relation[] {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
type: "belongsToMany",
|
|
37
|
+
foreignKey: "category_id",
|
|
38
|
+
sourceKey: "id",
|
|
39
|
+
model: ModelManager.Products.model(),
|
|
40
|
+
through: ModelManager.ProductToCategories.model()
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// const Categories = new CategoriesClass();
|
|
48
|
+
// export {Categories};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import {DataTypes, Model} from "../../base";
|
|
3
|
+
|
|
4
|
+
export class CustomerClass extends Model {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
|
|
7
|
+
public tableName() {
|
|
8
|
+
return 'customer';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public attributes() {
|
|
12
|
+
return {
|
|
13
|
+
name: {
|
|
14
|
+
type: DataTypes.STRING,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
validate: {
|
|
17
|
+
notEmpty: true,
|
|
18
|
+
is: ["^[a-z0-9A-Z]+$", 'i'],
|
|
19
|
+
len: [4, 255],
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
firstname: {
|
|
23
|
+
type: DataTypes.STRING,
|
|
24
|
+
validate: {
|
|
25
|
+
is: ["^[a-z0-9A-Z]+$", 'i'],
|
|
26
|
+
len: [4, 255],
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
lastname: {
|
|
30
|
+
type: DataTypes.STRING,
|
|
31
|
+
validate: {
|
|
32
|
+
is: ["^[a-z0-9A-Z]+$", 'i'],
|
|
33
|
+
len: [4, 255],
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
companyName: {
|
|
37
|
+
type: DataTypes.STRING,
|
|
38
|
+
allowNull: true,
|
|
39
|
+
validate: {
|
|
40
|
+
is: /^[0-9A-Za-z =().:;+-şŞçÇöÖğĞıİüÜ]+$/i,
|
|
41
|
+
len: [4, 255],
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
email: {
|
|
45
|
+
type: DataTypes.STRING,
|
|
46
|
+
validate: {
|
|
47
|
+
isEmail: true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
gsm_phone: {
|
|
51
|
+
type: DataTypes.STRING,
|
|
52
|
+
validate: {
|
|
53
|
+
is: ["^[0-9 +]+$", 'i'],
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
country: {
|
|
57
|
+
type: DataTypes.STRING,
|
|
58
|
+
validate: {
|
|
59
|
+
isAlpha: true,
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
address: {
|
|
63
|
+
type: DataTypes.STRING,
|
|
64
|
+
validate: {
|
|
65
|
+
is: ["^[\\w'\\-,.[0-9_\\/\\\\+=\"()<>;:\\[\\] şŞçÇöÖğĞıİüÜ ]{2,}$", "i"],
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
taxoffice: {
|
|
69
|
+
type: DataTypes.STRING,
|
|
70
|
+
validate: {
|
|
71
|
+
is: ["^[\\w'\\-,.[0-9_\\/\\\\+=\"()<>;:\\[\\] şŞçÇöÖğĞıİüÜ ]{2,}$", "i"],
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
taxnumber: {
|
|
75
|
+
unique: true,
|
|
76
|
+
type: DataTypes.STRING,
|
|
77
|
+
validate: {
|
|
78
|
+
is: ["^[0-9]+$", 'i'],
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
username: {
|
|
82
|
+
unique: true,
|
|
83
|
+
type: DataTypes.STRING,
|
|
84
|
+
validate: {
|
|
85
|
+
isEmail: true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
password: {
|
|
89
|
+
type: DataTypes.STRING,
|
|
90
|
+
validate: {
|
|
91
|
+
is: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?\.#&])[A-Za-z\d$@$!%*\.?&]{8,12}/
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"2fa": {
|
|
95
|
+
type: DataTypes.BOOLEAN,
|
|
96
|
+
validate: {
|
|
97
|
+
isBoolean: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
status: {
|
|
101
|
+
type: DataTypes.BOOLEAN,
|
|
102
|
+
validate: {
|
|
103
|
+
isBoolean: true
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// const Customer = new CustomerClass();
|
|
112
|
+
// export {Customer};
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {IdentityInterface} from "../../web/IdentityInterface";
|
|
9
|
+
import {DataTypes, Model} from "../../base";
|
|
10
|
+
import BaseChyz from "../../BaseChyz";
|
|
11
|
+
|
|
12
|
+
const JsonWebToken = require("jsonwebtoken");
|
|
13
|
+
|
|
14
|
+
export class KeycloakUser implements IdentityInterface {
|
|
15
|
+
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
findIdentity(id: number) {
|
|
20
|
+
throw new Error("Method not implemented.");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getId(): number {
|
|
24
|
+
throw new Error("Method not implemented.");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getAuthKey(): string {
|
|
28
|
+
throw new Error("Method not implemented.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
validateAuthKey(authKey: string): boolean {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public attributes() {
|
|
36
|
+
return {
|
|
37
|
+
// Model attributes are defined here
|
|
38
|
+
username: {
|
|
39
|
+
type: DataTypes.STRING,
|
|
40
|
+
allowNull: false
|
|
41
|
+
},
|
|
42
|
+
password: {
|
|
43
|
+
type: DataTypes.STRING,
|
|
44
|
+
allowNull: false
|
|
45
|
+
},
|
|
46
|
+
user_role: {
|
|
47
|
+
type: DataTypes.STRING,
|
|
48
|
+
allowNull: false
|
|
49
|
+
},
|
|
50
|
+
salt_text: {
|
|
51
|
+
type: DataTypes.STRING
|
|
52
|
+
// allowNull defaults to true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async findIdentityByAccessToken(token, type) {
|
|
58
|
+
console.log(token,type)
|
|
59
|
+
// console.log(this)
|
|
60
|
+
// console.log(BaseChyz)
|
|
61
|
+
return null;
|
|
62
|
+
// return keycloak.protect('realm:user');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {DataTypes, Model, Relation} from "../../base";
|
|
2
|
+
import {OrderItemClass} from "./OrderItem";
|
|
3
|
+
|
|
4
|
+
export class OrderClass extends Model {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
|
|
7
|
+
tableName() {
|
|
8
|
+
return 'order';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
attributes() {
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
customer_id: {
|
|
16
|
+
allowNull: false,
|
|
17
|
+
type: DataTypes.INTEGER,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
crm_order_id: {
|
|
21
|
+
allowNull: false,
|
|
22
|
+
type: DataTypes.INTEGER,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
total: {
|
|
26
|
+
allowNull: false,
|
|
27
|
+
type: DataTypes.FLOAT,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
created_date: {
|
|
31
|
+
allowNull: false,
|
|
32
|
+
type: DataTypes.DATE,
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
defaultValue: Model.NOW
|
|
35
|
+
},
|
|
36
|
+
status: {
|
|
37
|
+
type: DataTypes.BOOLEAN,
|
|
38
|
+
allowNull: false,
|
|
39
|
+
validate: {
|
|
40
|
+
isBoolean: true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
relation(): Relation[] {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
type: "hasOne",
|
|
51
|
+
sourceKey: "order_id",
|
|
52
|
+
foreignKey: "id",
|
|
53
|
+
model: (new OrderItemClass()).model()
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// const Order = new OrderClass()
|
|
60
|
+
// export {Order};
|
|
61
|
+
//
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {DataTypes, Model} from "../../base";
|
|
2
|
+
|
|
3
|
+
export class OrderItemClass extends Model {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
|
|
6
|
+
public tableName() {
|
|
7
|
+
return 'order_items';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public attributes() {
|
|
11
|
+
return {
|
|
12
|
+
|
|
13
|
+
status: {
|
|
14
|
+
type: DataTypes.BOOLEAN,
|
|
15
|
+
validate: {
|
|
16
|
+
isBoolean: true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
// const OrderItem = new OrderItemClass()
|
|
24
|
+
// export { OrderItem };
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
8
|
+
|
|
9
|
+
export class ProductModelsClass extends Model {
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
|
|
12
|
+
tableName() {
|
|
13
|
+
return 'models';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
attributes() {
|
|
18
|
+
return {
|
|
19
|
+
// Model attributes are defined here
|
|
20
|
+
title: {
|
|
21
|
+
type: DataTypes.STRING,
|
|
22
|
+
allowNull: false
|
|
23
|
+
},
|
|
24
|
+
stock_code: {
|
|
25
|
+
type: DataTypes.STRING,
|
|
26
|
+
allowNull: false
|
|
27
|
+
},
|
|
28
|
+
properties: {
|
|
29
|
+
type: DataTypes.STRING,
|
|
30
|
+
allowNull: false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
relation(): Relation[] {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
type: "hasOne",
|
|
40
|
+
foreignKey: "id",
|
|
41
|
+
sourceKey: "category_id",
|
|
42
|
+
model: ModelManager.Products.model()
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// const ProductModels = new ProductModelsClass();
|
|
49
|
+
// export {ProductModels}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
8
|
+
|
|
9
|
+
export class ProductToCategoriesClass extends Model {
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
|
|
12
|
+
tableName() {
|
|
13
|
+
return 'product_to_categories';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
attributes() {
|
|
18
|
+
return {
|
|
19
|
+
// Model attributes are defined here
|
|
20
|
+
product_id: {
|
|
21
|
+
type: DataTypes.INTEGER,
|
|
22
|
+
allowNull: false
|
|
23
|
+
},
|
|
24
|
+
category_id: {
|
|
25
|
+
type: DataTypes.INTEGER,
|
|
26
|
+
allowNull: false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// relations(): Relation[] {
|
|
33
|
+
// return [
|
|
34
|
+
// {
|
|
35
|
+
// type: "hasMany",
|
|
36
|
+
// foreignKey: "category_id",
|
|
37
|
+
// sourceKey: "id",
|
|
38
|
+
// model: ModelManager.Categories.model(),
|
|
39
|
+
// }
|
|
40
|
+
// ]
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// const ProductToCategories = new ProductToCategoriesClass()
|
|
46
|
+
// export {ProductToCategories}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class ProductsClass extends Model {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
|
|
13
|
+
tableName() {
|
|
14
|
+
return 'products';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
attributes() {
|
|
18
|
+
return {
|
|
19
|
+
// Model attributes are defined here
|
|
20
|
+
title: {
|
|
21
|
+
type: DataTypes.STRING,
|
|
22
|
+
allowNull: false
|
|
23
|
+
},
|
|
24
|
+
model_id: {
|
|
25
|
+
type: DataTypes.INTEGER,
|
|
26
|
+
allowNull: false
|
|
27
|
+
},
|
|
28
|
+
properties: {
|
|
29
|
+
type: DataTypes.STRING,
|
|
30
|
+
allowNull: false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
relations(): Relation[] {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
type: "belongsToMany",
|
|
40
|
+
foreignKey: "product_id",
|
|
41
|
+
sourceKey: "id",
|
|
42
|
+
model: ModelManager.Categories.model(),
|
|
43
|
+
through: ModelManager.ProductToCategories.model()
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// const Products = new ProductsClass()
|
|
50
|
+
// export {Products}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
import {DataTypes, Model} from "../../base";
|
|
8
|
+
|
|
9
|
+
export class StocksClass extends Model {
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
|
|
12
|
+
public tableName() {
|
|
13
|
+
return 'stock';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* product_id int4
|
|
18
|
+
* properties jsonb
|
|
19
|
+
* status int2
|
|
20
|
+
* barcode string(20)
|
|
21
|
+
* stock_code string(20)
|
|
22
|
+
* model_id int4
|
|
23
|
+
*/
|
|
24
|
+
public attributes() {
|
|
25
|
+
return {
|
|
26
|
+
// Model attributes are defined here
|
|
27
|
+
product_id: {
|
|
28
|
+
type: DataTypes.INTEGER,
|
|
29
|
+
allowNull: false
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
barcode: {
|
|
33
|
+
type: DataTypes.STRING,
|
|
34
|
+
allowNull: false,
|
|
35
|
+
validate: {
|
|
36
|
+
len: 20
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
stock_code: {
|
|
40
|
+
type: DataTypes.STRING,
|
|
41
|
+
allowNull: false,
|
|
42
|
+
validate: {
|
|
43
|
+
len: 20
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
model_id: {
|
|
47
|
+
type: DataTypes.INTEGER,
|
|
48
|
+
allowNull: false
|
|
49
|
+
},
|
|
50
|
+
status: {
|
|
51
|
+
type: DataTypes.INTEGER,
|
|
52
|
+
allowNull: false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// const Stocks = new StocksClass();
|
|
60
|
+
// export {Stocks}
|