Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
QA
qa-api
Commits
aa528eff
Commit
aa528eff
authored
Oct 28, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加接口getK8sConf
parent
4a378e0c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
34 deletions
+36
-34
dbconfig.js
app/controller/dbconfig.js
+3
-0
proconfig.js
app/controller/proconfig.js
+19
-12
index.js
app/middleware/auth/index.js
+1
-0
ProConfig.js
app/model/mongo/qa_api/ProConfig.js
+13
-22
No files found.
app/controller/dbconfig.js
View file @
aa528eff
...
@@ -55,6 +55,9 @@ const save = async (ctx) => {
...
@@ -55,6 +55,9 @@ const save = async (ctx) => {
}
}
}
}
// 处理多个空格
data
.
table_list
=
data
.
table_list
.
split
(
/ +/
).
join
(
'
'
)
// let db = await DBConfig.getOne({ "_id": data._id })
// let db = await DBConfig.getOne({ "_id": data._id })
// if (db && db.updatedAt && JSON.stringify(db.updatedAt).replace(/"/g, '') !== data.updatedAt) {
// if (db && db.updatedAt && JSON.stringify(db.updatedAt).replace(/"/g, '') !== data.updatedAt) {
// ctx.body = ctx.fail('停留时间太长导致时间戳不正确,请刷新后再试~')
// ctx.body = ctx.fail('停留时间太长导致时间戳不正确,请刷新后再试~')
...
...
app/controller/proconfig.js
View file @
aa528eff
const
Router
=
require
(
'
koa-router
'
)
const
Router
=
require
(
'
koa-router
'
)
const
bodyParser
=
require
(
'
koa-bodyparser
'
)
const
bodyParser
=
require
(
'
koa-bodyparser
'
)
const
_
=
require
(
'
lodash
'
)
const
_
=
require
(
'
lodash
'
)
const
{
ProConfig
}
=
require
(
'
../service/mongoService
'
)
const
{
ProConfig
}
=
require
(
'
../service/mongoService
'
)
const
getProjectByType
=
async
function
(
ctx
)
{
const
getProjectByType
=
async
function
(
ctx
)
{
let
item
=
await
ProConfig
.
getQgProjects
(
)
let
item
=
await
ProConfig
.
findByQuery
({
des
:
{
$ne
:
'
海外
'
}
},
{
is_active
:
-
1
,
project_name
:
1
}
)
item
=
_
.
groupBy
(
item
,
'
type
'
)
item
=
_
.
groupBy
(
item
,
'
type
'
)
const
arr
=
[]
const
arr
=
[]
...
@@ -56,20 +54,20 @@ const save = async function (ctx) {
...
@@ -56,20 +54,20 @@ const save = async function (ctx) {
data
[
prop
]
=
data
[
prop
].
trim
()
data
[
prop
]
=
data
[
prop
].
trim
()
}
}
}
}
await
ProConfig
.
saveProject
(
data
)
await
ProConfig
.
saveProject
(
data
)
ctx
.
body
=
ctx
.
ok
()
ctx
.
body
=
ctx
.
ok
()
}
}
const
getNewPort
=
async
function
(
ctx
)
{
const
getNewPort
=
async
function
(
ctx
)
{
const
port
=
await
ProConfig
.
getNewPort
()
const
port
=
await
ProConfig
.
getNewPort
()
ctx
.
body
=
ctx
.
ok
(
port
+
1
)
ctx
.
body
=
ctx
.
ok
(
port
+
1
)
}
}
const
findByQuery
=
async
function
(
ctx
)
{
//
const findByQuery = async function (ctx) {
const
item
=
await
ProConfig
.
findByQuery
(
ctx
.
request
.
body
)
//
const item = await ProConfig.findByQuery(ctx.request.body)
ctx
.
body
=
ctx
.
ok
(
item
)
//
ctx.body = ctx.ok(item)
}
//
}
const
remove
=
async
function
(
ctx
)
{
const
remove
=
async
function
(
ctx
)
{
const
rule
=
{
const
rule
=
{
...
@@ -97,7 +95,7 @@ const getInfo = async function (ctx) {
...
@@ -97,7 +95,7 @@ const getInfo = async function (ctx) {
data
.
system_name
=
'
xjfq-ui
'
data
.
system_name
=
'
xjfq-ui
'
}
}
const
item
=
await
ProConfig
.
get
Domain
(
data
.
system_name
)
const
item
=
await
ProConfig
.
get
OneProject
({
project_name
:
data
.
system_name
}
)
if
(
data
.
key
&&
item
[
data
.
key
])
{
if
(
data
.
key
&&
item
[
data
.
key
])
{
ctx
.
body
=
item
[
data
.
key
]
ctx
.
body
=
item
[
data
.
key
]
return
return
...
@@ -109,8 +107,9 @@ const getType = async function (ctx) {
...
@@ -109,8 +107,9 @@ const getType = async function (ctx) {
const
item
=
await
ProConfig
.
getType
()
const
item
=
await
ProConfig
.
getType
()
ctx
.
body
=
ctx
.
ok
(
item
)
ctx
.
body
=
ctx
.
ok
(
item
)
}
}
const
getDomain
=
async
function
(
ctx
)
{
const
getDomain
=
async
function
(
ctx
)
{
const
item
=
await
ProConfig
.
get
Domain
(
ctx
.
request
.
query
.
project_name
)
const
item
=
await
ProConfig
.
get
OneProject
({
project_name
:
ctx
.
request
.
query
.
project_name
}
)
if
(
item
&&
item
.
project_name
===
'
recruiting-management
'
)
{
if
(
item
&&
item
.
project_name
===
'
recruiting-management
'
)
{
item
.
host_name
=
'
recruitui.liangkebang.net
'
item
.
host_name
=
'
recruitui.liangkebang.net
'
}
}
...
@@ -119,6 +118,14 @@ const getDomain = async function (ctx) {
...
@@ -119,6 +118,14 @@ const getDomain = async function (ctx) {
}
}
ctx
.
body
=
ctx
.
ok
(
item
)
ctx
.
body
=
ctx
.
ok
(
item
)
}
}
const
getK8sConf
=
async
function
(
ctx
)
{
const
item
=
await
ProConfig
.
getOneProject
({
project_name
:
ctx
.
request
.
query
.
project_name
},
{
cpuRequest
:
1
,
cpuLimit
:
1
,
memRequest
:
1
,
memLimit
:
1
,
_id
:
0
,
})
ctx
.
body
=
ctx
.
ok
(
item
)
}
const
router
=
new
Router
()
const
router
=
new
Router
()
router
router
...
@@ -129,9 +136,9 @@ router
...
@@ -129,9 +136,9 @@ router
.
get
(
'
/get_new_port
'
,
getNewPort
)
.
get
(
'
/get_new_port
'
,
getNewPort
)
.
get
(
'
/delete
'
,
remove
)
.
get
(
'
/delete
'
,
remove
)
.
post
(
'
/save
'
,
save
)
.
post
(
'
/save
'
,
save
)
.
post
(
'
/find_by_query
'
,
findByQuery
)
//
.post('/find_by_query', findByQuery)
.
get
(
'
/get_type
'
,
getType
)
.
get
(
'
/get_type
'
,
getType
)
.
get
(
'
/getHostName
'
,
getDomain
)
.
get
(
'
/getHostName
'
,
getDomain
)
.
get
(
'
/getK8sConf
'
,
getK8sConf
)
module
.
exports
=
router
module
.
exports
=
router
app/middleware/auth/index.js
View file @
aa528eff
...
@@ -8,6 +8,7 @@ module.exports = function () {
...
@@ -8,6 +8,7 @@ module.exports = function () {
'
/user/get_station
'
,
'
/user/get_station
'
,
'
/user/check_token
'
,
'
/user/check_token
'
,
'
/proconfig/get_info
'
,
'
/proconfig/get_info
'
,
'
/proconfig/getK8sConf
'
,
'
/harborHook/endpoint
'
,
'
/harborHook/endpoint
'
,
'
/k8s/namespace/get_namespace_for_jenkins
'
,
'
/k8s/namespace/get_namespace_for_jenkins
'
,
'
/k8s/namespace
'
,
'
/k8s/namespace
'
,
...
...
app/model/mongo/qa_api/ProConfig.js
View file @
aa528eff
...
@@ -23,16 +23,16 @@ const schema = new Schema({
...
@@ -23,16 +23,16 @@ const schema = new Schema({
auth
:
{
type
:
String
},
auth
:
{
type
:
String
},
jar_path
:
{
type
:
String
},
jar_path
:
{
type
:
String
},
command1
:
{
type
:
String
},
command1
:
{
type
:
String
},
command2
:
{
type
:
String
},
command3
:
{
type
:
String
},
command4
:
{
type
:
String
},
command5
:
{
type
:
String
},
build_command
:
{
type
:
String
},
build_command
:
{
type
:
String
},
start_command
:
{
type
:
String
},
start_command
:
{
type
:
String
},
stop_command
:
{
type
:
String
},
stop_command
:
{
type
:
String
},
api
:
{
type
:
String
},
api
:
{
type
:
String
},
ddl
:
{
type
:
String
},
ddl
:
{
type
:
String
},
wiki
:
{
type
:
String
},
wiki
:
{
type
:
String
},
cpuRequest
:
{
type
:
Number
},
cpuLimit
:
{
type
:
Number
},
memRequest
:
{
type
:
Number
},
memLimit
:
{
type
:
Number
},
},
{
},
{
versionKey
:
false
,
versionKey
:
false
,
collection
:
'
proconfigs
'
,
// 表名
collection
:
'
proconfigs
'
,
// 表名
...
@@ -55,16 +55,15 @@ schema.statics.getActiveProjectsHostName = function () {
...
@@ -55,16 +55,15 @@ schema.statics.getActiveProjectsHostName = function () {
})
})
}
}
schema
.
statics
.
getQgProjects
=
function
()
{
schema
.
statics
.
findByQuery
=
function
(
query
,
sort
)
{
return
this
.
find
({
des
:
{
$ne
:
'
海外
'
}
}).
sort
({
is_active
:
-
1
,
project_name
:
1
})
if
(
query
.
project_name
)
{
}
query
.
project_name
=
new
RegExp
(
query
.
project_name
)
}
schema
.
statics
.
getActiveProjects
=
function
()
{
return
this
.
find
(
query
).
sort
(
sort
).
lean
()
return
this
.
find
({
des
:
{
$ne
:
'
海外
'
},
is_active
:
1
}).
sort
({
project_name
:
1
})
}
}
schema
.
statics
.
get
Domain
=
function
(
name
)
{
schema
.
statics
.
get
OneProject
=
function
(
query
,
column
,
sort
)
{
return
this
.
findOne
(
{
project_name
:
name
}
)
return
this
.
findOne
(
query
,
column
).
sort
(
sort
)
}
}
schema
.
statics
.
saveProject
=
function
(
doc
)
{
schema
.
statics
.
saveProject
=
function
(
doc
)
{
...
@@ -75,6 +74,7 @@ schema.statics.saveProject = function (doc) {
...
@@ -75,6 +74,7 @@ schema.statics.saveProject = function (doc) {
}
}
return
this
.
create
(
doc
)
return
this
.
create
(
doc
)
}
}
schema
.
statics
.
getNewPort
=
async
function
()
{
schema
.
statics
.
getNewPort
=
async
function
()
{
const
item
=
await
this
.
findOne
().
select
(
'
port
'
).
sort
({
port
:
-
1
})
const
item
=
await
this
.
findOne
().
select
(
'
port
'
).
sort
({
port
:
-
1
})
if
(
!
item
||
(
item
.
port
<
initPort
))
{
if
(
!
item
||
(
item
.
port
<
initPort
))
{
...
@@ -82,16 +82,7 @@ schema.statics.getNewPort = async function () {
...
@@ -82,16 +82,7 @@ schema.statics.getNewPort = async function () {
}
}
return
item
.
port
return
item
.
port
}
}
schema
.
statics
.
hostName
=
async
function
(
projectName
)
{
return
this
.
find
({
project_name
:
projectName
})
}
schema
.
statics
.
findByQuery
=
function
(
query
,
sort
)
{
if
(
query
.
project_name
)
{
query
.
project_name
=
new
RegExp
(
query
.
project_name
)
}
// query = Object.assign(query, { des: { $ne: '海外' } })
return
this
.
find
(
query
).
sort
(
sort
).
lean
()
}
schema
.
statics
.
delete
=
function
(
id
)
{
schema
.
statics
.
delete
=
function
(
id
)
{
return
this
.
findByIdAndRemove
(
id
)
return
this
.
findByIdAndRemove
(
id
)
}
}
...
...
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