-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjobs.js
268 lines (147 loc) · 6.34 KB
/
jobs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
const express = require('express')
const app = express.Router()
const { Unix_timestamp, Is_number, knex, t_mail, is_Empty } = require('./funcs.js')
app.get("/", async(req, res) => {
let qzdtwq22 = await knex('job').select('*').orderByRaw('`jid` desc limit 6');
let catl213123z = await knex('category').select('cid','namd');
let cntzzzz22zz = await knex('job').count();
//console.log(catl213123z)
let psrq = {
title:'Jobs',
user: tusert ? tdatausr : undefined,
dataFetch: qzdtwq22,
ciddt: catl213123z,
howmany: cntzzzz22zz[0]['count(*)']
}
res.render("jobs.html", psrq)
res.end()
})
app.get("/my", async(req, res) => {
if (tusert == 0) {
return res.redirect('/')
}
let qz = await knex("job").where("user",tdatausr.uid).select(knex.raw('count(*) as cnt')).first()
//console.log(qz.cnt)
let qzdtwq = await knex('job').where("user",tdatausr.uid).select('*').orderByRaw('jid desc limit 6');
res.render("my_jobs.html", {title:'Job list', user: tdatausr, cnt:qz.cnt, dataFetch:qzdtwq})
res.end()
})
app.get("/add", async(req, res) => {
if (tusert == 0) {
return res.redirect('/')
}
/*
Database changed
MariaDB [HRG]> select * from company;
+-----+------------+--------+------------------+--------+-----------------+--------------+------+------------------------------------------------------+
| cid | time | name | mail | number | description | country | user | picurl |
+-----+------------+--------+------------------+--------+-----------------+--------------+------+------------------------------------------------------+
| 22 | 1669923218 | abaa | [email protected] | NULL | qweqweqweqweqwe | georgia | 1 | 3974_1669923218119_2918581.png |
| 23 | 1669923256 | qweqwe | [email protected] | NULL | qqqqqqqqq | qweqweqwe | 1 | 7989_1669923256059_user-vector.webp |
| 24 | 1670024117 | wwww | [email protected] | NULL | 11111111 | wwwwwwwwwwww | 1 | 877_1670024117345_8402_1669921927241_11607991960.jpg |
| 25 | 1670027631 | qqqqqq | [email protected] | NULL | wwwwwwwwww | qqqqqqqqq | 1 | 9947_1670027631814_9004_1669922236043_eye.webp |
+-----+------------+--------+------------------+--------+-----------------+--------------+------+------------------------------------------------------+
4 rows in set (0.000 sec)
*/
let qz221a = await knex('company').where("user",tdatausr.uid).select('*')
/*
console.log(qz221a[0].name)
console.log(qz221a[1].name)
console.log(qz221a[2].name)
console.log(qz221a[3].name)
qz221a.map((val)=> {
console.log(val.name)
});
*/
let catldata = await knex('category').select('namd','cid')
let psrq = {title:'New job', user: tdatausr, cdata: qz221a, cats: catldata}
res.render("jobadd.html", psrq)
res.end()
})
app.post("/add", async(req, res) => {
if (tusert == 0) {
return res.redirect('/')
}
const qcomp = req.body.cid
const rquid = Math.abs(parseInt(qcomp))
if (isNaN(rquid) === true || rquid == 0) {
return res.status(200).send('uups1')
}
let qz221a = await knex('company').where("cid",rquid).select('*')
if (!qz221a) {
return res.status(200).send('uups2')
}
const qtitle = req.body.title
const qexp = req.body.exp
const qexpt = req.body.exp_time
const jtype = req.body.typej
const etype = req.body.etype
const qdesc = req.body.descr
const qwplc = req.body.working_place
const catid_1 = parseInt(req.body.cat_id)
let ctq21zg3123 = await knex('category').where("cid",catid_1).select('*').first()
if (!ctq21zg3123) {
return res.status(200).send('upsss cat doesnt exists, are you trying to do something ? boy ')
}
//let qrwwarr = [qtitle,qdesc];
//console.log(qtitle.length)
if (!is_Empty(qtitle,128)){ return res.status(200).send('uups3') }
else if (!is_Empty(qexp,30)){ return res.status(200).send('uups4') }
else if (!is_Empty(qexpt,30)){ return res.status(200).send('uups5') }
else if (!is_Empty(jtype,30)){ return res.status(200).send('uups6') }
else if (!is_Empty(etype,50)){ return res.status(200).send('uups7') }
else if (!is_Empty(qdesc,5000)){ return res.status(200).send('uups8') }
else if (!is_Empty(qwplc,128)){ return res.status(200).send('uups9') }
else if (isNaN(catid_1) === true || catid_1 == 0) { return res.status(200).send('cat id error') }
else { }
let qw2zze = new Date()
let tmqwe21213
if (qexpt == 1) {
tmqwe21213 = qw2zze.getTime()+(60*60*24*7)*1000
} else if (qexpt == 2) {
tmqwe21213 = qw2zze.getTime()+(60*60*24*14)*1000
} else if (qexpt == 3) {
tmqwe21213 = qw2zze.getTime()+(60*60*24*21)*1000
} else if (qexpt == 4) {
tmqwe21213 = qw2zze.getTime()+(60*60*24*28)*1000
} else {
tmqwe21213 = qw2zze.getTime()+(60*60*24*35)*1000
}
/*
+-----------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------+------+-----+---------+----------------+
| jid | bigint(32) | NO | PRI | NULL | auto_increment |
| user | bigint(32) | YES | MUL | NULL | |
| cid | bigint(32) | YES | MUL | NULL | |
| time | bigint(32) | YES | | NULL | |
| expire_time | bigint(32) | YES | | NULL | |
| name | text | YES | | NULL | |
| mail | text | YES | | NULL | |
| number | text | YES | | NULL | |
| subject | text | YES | | NULL | |
| desc | text | YES | | NULL | |
| work_type | text | YES | | '' | |
| empl_type | text | YES | | '' | |
| experience_time | text | YES | | '' | |
| place | text | YES | | '' | |
+-----------------+------------+------+-----+---------+----------------+
14 rows in set (0.001 sec)
*/
let kzr2 = await knex('job').insert({
user: tdatausr.uid,
name: qtitle,
cid: rquid,
desc: qdesc,
experience_time: qexp,
empl_type: etype,
work_type: jtype,
expire_time: tmqwe21213,
place: qwplc,
time: new Date().getTime(),
cat_id: catid_1
}).returning('jid');
return res.redirect(`/job/${kzr2}`)
res.end()
})
module.exports = app