Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
93023e5c
Commit
93023e5c
authored
Aug 28, 2020
by
Sxy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'center-manage' of gitlab.gongsibao.com:jiangyong/zhichan into center-manage
parents
f57aa41f
77e01456
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
30 deletions
+34
-30
center-manage/app/base/db/dao.base.js
+33
-29
center-manage/app/base/service/impl/product/productSve.js
+1
-1
No files found.
center-manage/app/base/db/dao.base.js
View file @
93023e5c
...
...
@@ -9,10 +9,10 @@ class Dao {
this
.
model
=
db
.
models
[
this
.
modelName
];
console
.
log
(
this
.
modelName
);
}
preCreate
(
u
)
{
preCreate
(
u
)
{
return
u
;
}
async
create
(
u
,
t
)
{
async
create
(
u
,
t
)
{
var
u2
=
this
.
preCreate
(
u
);
if
(
t
)
{
console
.
log
(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
);
...
...
@@ -26,10 +26,10 @@ class Dao {
});
}
}
static
getModelName
(
ClassObj
)
{
static
getModelName
(
ClassObj
)
{
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Dao"
)).
toLowerCase
()
}
async
refQuery
(
qobj
)
{
async
refQuery
(
qobj
)
{
var
w
=
qobj
.
refwhere
?
qobj
.
refwhere
:
{};
if
(
qobj
.
levelinfo
)
{
w
[
qobj
.
levelinfo
.
levelfield
]
=
qobj
.
levelinfo
.
level
;
...
...
@@ -48,7 +48,7 @@ class Dao {
return
this
.
model
.
findAll
({
where
:
w
,
attributes
:
qobj
.
fields
});
}
}
async
bulkDelete
(
ids
,
t
)
{
async
bulkDelete
(
ids
,
t
)
{
if
(
t
)
{
var
en
=
await
this
.
model
.
destroy
({
where
:
{
id
:
{
[
this
.
db
.
Op
.
in
]:
ids
}
},
transaction
:
t
});
return
en
;
...
...
@@ -58,7 +58,7 @@ class Dao {
}
}
async
bulkDeleteByWhere
(
whereParam
,
t
)
{
async
bulkDeleteByWhere
(
whereParam
,
t
)
{
var
en
=
null
;
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
whereParam
.
transaction
=
t
;
...
...
@@ -67,7 +67,7 @@ class Dao {
return
await
this
.
model
.
destroy
(
whereParam
);
}
}
async
delete
(
qobj
,
t
)
{
async
delete
(
qobj
,
t
)
{
var
en
=
null
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
en
=
await
this
.
model
.
findOne
({
where
:
{
id
:
qobj
.
id
},
transaction
:
t
});
...
...
@@ -83,14 +83,14 @@ class Dao {
}
return
null
;
}
extraModelFilter
(
pobj
)
{
extraModelFilter
(
pobj
)
{
//return {"key":"include","value":{model:this.db.models.app}};
return
null
;
}
extraWhere
(
obj
,
where
)
{
extraWhere
(
obj
,
where
)
{
return
where
;
}
orderBy
(
qobj
)
{
orderBy
(
qobj
)
{
//return {"key":"include","value":{model:this.db.models.app}};
if
(
!
qobj
.
orderInfo
||
qobj
.
orderInfo
.
length
==
0
)
{
return
[[
"created_at"
,
"DESC"
]];
...
...
@@ -99,7 +99,7 @@ class Dao {
}
}
buildQuery
(
qobj
)
{
buildQuery
(
qobj
)
{
var
linkAttrs
=
[];
const
pageNo
=
qobj
.
pageInfo
.
pageNo
;
const
pageSize
=
qobj
.
pageInfo
.
pageSize
;
...
...
@@ -159,7 +159,7 @@ class Dao {
console
.
log
(
qc
);
return
qc
;
}
buildaggs
(
qobj
)
{
buildaggs
(
qobj
)
{
var
aggsinfos
=
[];
if
(
qobj
.
aggsinfo
)
{
qobj
.
aggsinfo
.
sum
.
forEach
(
aggitem
=>
{
...
...
@@ -173,7 +173,7 @@ class Dao {
}
return
aggsinfos
;
}
async
findAggs
(
qobj
,
qcwhere
)
{
async
findAggs
(
qobj
,
qcwhere
)
{
var
aggArray
=
this
.
buildaggs
(
qobj
);
if
(
aggArray
.
length
!=
0
)
{
qcwhere
[
"attributes"
]
=
{};
...
...
@@ -192,7 +192,7 @@ class Dao {
}
}
async
findAndCountAll
(
qobj
,
t
)
{
async
findAndCountAll
(
qobj
,
t
)
{
var
qc
=
this
.
buildQuery
(
qobj
);
let
findList
=
{}
let
count
=
await
this
.
findCount
({
where
:
qc
.
where
})
...
...
@@ -205,18 +205,22 @@ class Dao {
rtn
.
aggresult
=
aggresult
;
return
rtn
;
}
preUpdate
(
obj
)
{
preUpdate
(
obj
)
{
return
obj
;
}
async
update
(
obj
,
tm
)
{
async
update
(
obj
,
tm
)
{
var
obj2
=
this
.
preUpdate
(
obj
);
if
(
tm
!=
null
&&
tm
!=
'undefined'
)
{
return
this
.
model
.
update
(
obj2
,
{
where
:
{
id
:
obj2
.
id
},
transaction
:
tm
});
await
this
.
model
.
update
(
obj2
,
{
where
:
{
id
:
obj2
.
id
},
transaction
:
tm
});
let
n
=
await
this
.
model
.
findOne
({
where
:
{
id
:
obj2
.
id
},
transaction
:
tm
});
return
n
}
else
{
return
this
.
model
.
update
(
obj2
,
{
where
:
{
id
:
obj2
.
id
}
});
await
this
.
model
.
update
(
obj2
,
{
where
:
{
id
:
obj2
.
id
}
});
let
n
=
await
this
.
model
.
findById
(
obj2
.
id
)
return
n
}
}
async
bulkCreate
(
ids
,
t
)
{
async
bulkCreate
(
ids
,
t
)
{
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
return
await
this
.
model
.
bulkCreate
(
ids
,
{
transaction
:
t
});
}
else
{
...
...
@@ -224,7 +228,7 @@ class Dao {
}
}
async
updateByWhere
(
setObj
,
whereObj
,
t
)
{
async
updateByWhere
(
setObj
,
whereObj
,
t
)
{
let
inWhereObj
=
{}
if
(
t
&&
t
!=
'undefined'
)
{
if
(
whereObj
&&
whereObj
!=
'undefined'
)
{
...
...
@@ -238,10 +242,10 @@ class Dao {
}
return
this
.
model
.
update
(
setObj
,
inWhereObj
);
}
async
customExecAddOrPutSql
(
sql
,
paras
=
null
)
{
async
customExecAddOrPutSql
(
sql
,
paras
=
null
)
{
return
this
.
db
.
query
(
sql
,
paras
);
}
async
customQuery
(
sql
,
paras
,
t
)
{
async
customQuery
(
sql
,
paras
,
t
)
{
var
tmpParas
=
null
;
//||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
if
(
t
&&
t
!=
'undefined'
)
{
if
(
paras
==
null
||
paras
==
'undefined'
)
{
...
...
@@ -256,15 +260,15 @@ class Dao {
}
return
this
.
db
.
query
(
sql
,
tmpParas
);
}
async
findCount
(
whereObj
=
null
)
{
async
findCount
(
whereObj
=
null
)
{
return
this
.
model
.
count
(
whereObj
,
{
logging
:
false
}).
then
(
c
=>
{
return
c
;
});
}
async
findSum
(
fieldName
,
whereObj
=
null
)
{
async
findSum
(
fieldName
,
whereObj
=
null
)
{
return
this
.
model
.
sum
(
fieldName
,
whereObj
);
}
async
getPageList
(
pageIndex
,
pageSize
,
whereObj
=
null
,
orderObj
=
null
,
attributesObj
=
null
,
includeObj
=
null
)
{
async
getPageList
(
pageIndex
,
pageSize
,
whereObj
=
null
,
orderObj
=
null
,
attributesObj
=
null
,
includeObj
=
null
)
{
var
tmpWhere
=
{};
tmpWhere
.
limit
=
pageSize
;
tmpWhere
.
offset
=
(
pageIndex
-
1
)
*
pageSize
;
...
...
@@ -285,20 +289,20 @@ class Dao {
}
return
await
this
.
model
.
findAndCountAll
(
tmpWhere
);
}
async
findOne
(
obj
,
attributes
=
[])
{
async
findOne
(
obj
,
attributes
=
[])
{
if
(
attributes
.
length
>
0
)
{
return
this
.
model
.
findOne
({
"where"
:
obj
,
attributes
,
row
:
true
});
}
else
{
return
this
.
model
.
findOne
({
"where"
:
obj
,
row
:
true
});
}
}
async
findOneWithTm
(
obj
,
t
)
{
async
findOneWithTm
(
obj
,
t
)
{
return
this
.
model
.
findOne
({
"where"
:
obj
,
transaction
:
t
});
}
async
findById
(
oid
)
{
async
findById
(
oid
)
{
return
this
.
model
.
findById
(
oid
);
}
async
findAll
(
obj
,
include
=
[],
other
=
{})
{
async
findAll
(
obj
,
include
=
[],
other
=
{})
{
return
this
.
model
.
findAll
({
"where"
:
obj
,
include
,
row
:
true
,
...
other
});
}
}
...
...
center-manage/app/base/service/impl/product/productSve.js
View file @
93023e5c
...
...
@@ -103,7 +103,7 @@ class ProductService extends ServiceBase {
if
(
productprices
.
length
>
0
)
{
await
self
.
priceDao
.
bulkCreate
(
productprices
,
t
)
}
return
{}
;
return
currentProduct
;
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment