明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
letian_backend
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
letian_backend
Commits
d63dec1c
Commit
d63dec1c
authored
Jan 08, 2026
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e1a26041
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
7 deletions
+110
-7
companyInfoController.js
controller/companyInfoController.js
+54
-7
index.js
db/index.js
+2
-0
letianSccj.js
db/models/letianSccj.js
+48
-0
compInfoRouter.js
router/compInfoRouter.js
+6
-0
No files found.
controller/companyInfoController.js
View file @
d63dec1c
...
...
@@ -5,7 +5,7 @@
async
function
findCompInfo
(
req
,
res
,
next
)
{
try
{
let
ret
=
await
DB
.
CompanyInfo
.
findOne
({}).
populate
({
path
:
"companyInfoImgs"
}).
populate
({
path
:
"qualiCertiImgs"
}).
populate
({
path
:
"addressInfo.img"
}).
populate
({
path
:
"gcImg"
}).
populate
({
path
:
"jdImg"
}).
lean
().
exec
();
let
ret
=
await
DB
.
CompanyInfo
.
findOne
({}).
populate
({
path
:
"companyInfoImgs"
}).
populate
({
path
:
"qualiCertiImgs"
}).
populate
({
path
:
"addressInfo.img"
}).
populate
({
path
:
"gcImg"
}).
populate
({
path
:
"jdImg"
}).
lean
().
exec
();
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
);
...
...
@@ -15,10 +15,10 @@ async function findCompInfo(req, res, next) {
async
function
updateCompInfo
(
req
,
res
,
next
)
{
try
{
let
body
=
req
.
body
;
body
.
companyInfoImgs
=
(
body
.
companyInfoImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
qualiCertiImgs
=
(
body
.
qualiCertiImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
addressInfo
=
body
.
addressInfo
||
[];
let
newAdr
=
[];
body
.
companyInfoImgs
=
(
body
.
companyInfoImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
qualiCertiImgs
=
(
body
.
qualiCertiImgs
||
[]).
map
(
o
=>
{
return
o
&&
o
.
_id
||
o
});
body
.
addressInfo
=
body
.
addressInfo
||
[];
let
newAdr
=
[];
for
(
let
index
=
0
;
index
<
body
.
addressInfo
.
length
;
index
++
)
{
const
element
=
body
.
addressInfo
[
index
];
element
.
img
=
element
.
img
&&
element
.
img
.
_id
||
element
.
img
;
...
...
@@ -26,7 +26,7 @@ async function updateCompInfo(req, res, next) {
}
body
.
addressInfo
=
newAdr
;
console
.
log
(
body
,
"==========================="
)
let
ret
=
await
DB
.
CompanyInfo
.
findOneAndUpdate
({
_id
:
body
.
_id
},
body
);
let
ret
=
await
DB
.
CompanyInfo
.
findOneAndUpdate
({
_id
:
body
.
_id
},
body
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
...
...
@@ -36,8 +36,52 @@ async function updateCompInfo(req, res, next) {
async
function
createSccj
(
req
,
res
,
next
)
{
try
{
let
ret
=
await
DB
.
Sccj
.
create
(
req
.
body
)
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
)
}
}
async
function
updateSccj
(
req
,
res
,
next
)
{
try
{
let
updateInfo
=
{
...
req
.
body
,
}
let
ret
=
await
DB
.
Sccj
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
updateInfo
);
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
)
}
}
async
function
delSccj
(
req
,
res
,
next
)
{
try
{
let
ret
=
await
DB
.
Sccj
.
findOneAndUpdate
({
_id
:
req
.
body
.
_id
},
{
del
:
1
});
res
.
sendData
(
ret
);
}
catch
(
error
)
{
next
(
error
)
}
}
async
function
getSccjList
(
req
,
res
,
next
)
{
try
{
let
search
=
{
del
:
0
};
let
page
=
req
.
body
.
page
||
1
;
let
pageSize
=
req
.
body
.
pageSize
||
10
;
let
skip
=
(
page
-
1
)
*
pageSize
;
if
(
req
.
body
.
name
)
{
search
.
name
=
req
.
body
.
name
;
}
let
count
=
await
DB
.
Sccj
.
countDocuments
(
search
)
let
list
=
await
DB
.
Sccj
.
find
(
search
).
skip
(
skip
).
limit
(
pageSize
).
sort
({
order
:
1
}).
lean
().
exec
();
res
.
sendData
({
count
,
list
});
}
catch
(
error
)
{
next
(
error
)
}
}
...
...
@@ -45,5 +89,8 @@ async function updateCompInfo(req, res, next) {
module
.
exports
=
{
findCompInfo
,
updateCompInfo
,
createSccj
,
updateSccj
,
delSccj
,
getSccjList
,
}
\ No newline at end of file
db/index.js
View file @
d63dec1c
...
...
@@ -88,6 +88,7 @@ const PackMatOutList = require("./models/letianPackMatOutList");
const
SuppFact
=
require
(
"./models/letianSuppFact"
);
const
TechProcess
=
require
(
"./models/letianTechProcess"
);
const
Sccj
=
require
(
"./models/letianSccj"
);
global
.
DB
=
{
File
,
...
...
@@ -145,6 +146,7 @@ global.DB = {
SuppFact
,
TechProcess
,
ProductLt
,
Sccj
,
}
...
...
db/models/letianSccj.js
0 → 100644
View file @
d63dec1c
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
moment
=
require
(
'moment'
);
// const autoIncrement = require('mongoose-auto-increment');
// autoIncrement.initialize(mongoose.connection);
/**
* //营养成分表
*/
const
letianSccjSchema
=
new
Schema
({
name
:
{
type
:
String
,
comment
:
"名称"
,
},
order
:
Number
,
creator
:
{
type
:
mongoose
.
Types
.
ObjectId
,
ref
:
'User'
,
comment1
:
"创建人"
},
createdAt
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
updatedAt
:
{
type
:
Date
,
default
:
Date
.
now
,
get
:
v
=>
moment
(
v
).
format
(
"YYYY-MM-DD HH:mm:ss"
),
},
del
:
{
type
:
Number
,
default
:
0
,
comment1
:
'默认0 , 1:表示删除, 若有其他隐藏业务 不要混用此字段。'
}
},
{
toJSON
:
{
getters
:
true
}
});
const
Sccj
=
mongoose
.
model
(
'Sccj'
,
letianSccjSchema
,
'letianSccj'
);
module
.
exports
=
Sccj
;
\ No newline at end of file
router/compInfoRouter.js
View file @
d63dec1c
...
...
@@ -10,4 +10,10 @@ router.post('/info', companyInfoController.findCompInfo);
router
.
post
(
'/update'
,
companyInfoController
.
updateCompInfo
);
router
.
post
(
'/sccj/create'
,
companyInfoController
.
createSccj
);
router
.
post
(
'/sccj/update'
,
companyInfoController
.
updateSccj
);
router
.
post
(
'/sccj/delete'
,
companyInfoController
.
delSccj
);
router
.
post
(
'/sccj/list'
,
companyInfoController
.
getSccjList
);
module
.
exports
=
router
;
\ No newline at end of file
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