peng.peng
2 years ago
14 changed files with 213 additions and 178 deletions
@ -0,0 +1,88 @@ |
|||||
|
'use strict'; |
||||
|
const moment = require('moment') |
||||
|
|
||||
|
|
||||
|
//获取REST服务失败
|
||||
|
function getServiceManagement (opts) { |
||||
|
return async function (ctx, next) { |
||||
|
|
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { page, limit, keyword } = ctx.query; |
||||
|
try { |
||||
|
|
||||
|
let option = { |
||||
|
where: {}, |
||||
|
order: [["id", "desc"]], |
||||
|
} |
||||
|
if (keyword) { |
||||
|
option.where.name = { $iLike: `%${keyword}%` } |
||||
|
} |
||||
|
|
||||
|
if (limit) { |
||||
|
option.limit = Number(limit) |
||||
|
} |
||||
|
if (page && limit) { |
||||
|
option.offset = Number(page) * Number(limit) |
||||
|
} |
||||
|
|
||||
|
let res = await models.RestfulApi.findAndCount(option) |
||||
|
|
||||
|
|
||||
|
|
||||
|
ctx.status = 200; |
||||
|
ctx.body = res |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { message: '获取REST服务失败' } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//编辑REST服务
|
||||
|
function postServiceManagement (opts) { |
||||
|
return async function (ctx, next) { |
||||
|
|
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { id, name, endbled } = ctx.request.body; |
||||
|
|
||||
|
await models.RestfulApi.update({ name, endbled }, { where: { id: id } }) |
||||
|
|
||||
|
ctx.status = 204; |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { message: '编辑REST服务失败' } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//编辑REST服务
|
||||
|
function delServiceManagement (opts) { |
||||
|
return async function (ctx, next) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { id } = ctx.params; |
||||
|
|
||||
|
await models.RestfulApi.destroy({ |
||||
|
where: { |
||||
|
id: id |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
ctx.status = 204; |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { message: '删除REST服务失败' } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
getServiceManagement, |
||||
|
postServiceManagement, |
||||
|
delServiceManagement |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const model = require('../../controllers/dataService/index'); |
||||
|
|
||||
|
module.exports = function (app, router, opts, AuthCode) { |
||||
|
|
||||
|
app.fs.api.logAttr['GET/service-management'] = { content: '获取REST服务', visible: true }; |
||||
|
router.get('/service-management', model.getServiceManagement(opts)); |
||||
|
|
||||
|
app.fs.api.logAttr['POST/service-management'] = { content: '编辑REST服务', visible: true }; |
||||
|
router.post('/service-management', model.postServiceManagement(opts)) |
||||
|
|
||||
|
app.fs.api.logAttr['DEL/service-management/:id'] = { content: '删除REST服务', visible: true }; |
||||
|
router.del('/service-management/:id', model.delServiceManagement(opts)) |
||||
|
|
||||
|
}; |
@ -1,78 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
import { basicAction } from '@peace/utils' |
|
||||
import { ApiTable } from '$utils' |
|
||||
|
|
||||
export function getStandardDocFolders (query = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
query, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_STANDARD_DOC_FOLDERS', |
|
||||
url: `${ApiTable.standardDocFolders}`, |
|
||||
msg: { error: '获取标准文档目录列表失败' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
export function postStandardDocFolders (data = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'POST_STANDARD_DOC_FOLDERS', |
|
||||
url: `${ApiTable.standardDocFolders}`, |
|
||||
msg: { option: '标准文档目录新增' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function postStandardDocs (data = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'POST_STANDARD_DOCS', |
|
||||
url: `${ApiTable.standardDocs}`, |
|
||||
msg: { option: '新增标准文档' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function getStandardDocs (query = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
query, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_STANDARD_DOCS', |
|
||||
url: `${ApiTable.standardDocs}`, |
|
||||
msg: { error: '获取标准文档列表失败' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function postFolderFile (data) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'POST_FOLDER_FILE', |
|
||||
url: ApiTable.postFolderFile, |
|
||||
msg: { option: '删除文件夹或文件' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function fetchFiles (data = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'POST_FETCH_FILES', |
|
||||
url: `${ApiTable.fetchFiles}`, |
|
||||
msg: { error: '获取文件夹下文件失败' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
@ -1,15 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
import { basicAction } from '@peace/utils' |
|
||||
import { ApiTable } from '$utils' |
|
||||
|
|
||||
// export function getMembers(orgId) {
|
|
||||
// return dispatch => basicAction({
|
|
||||
// type: 'get',
|
|
||||
// dispatch: dispatch,
|
|
||||
// actionType: 'GET_MEMBERS',
|
|
||||
// url: `${ApiTable.getEnterprisesMembers.replace('{enterpriseId}', orgId)}`,
|
|
||||
// msg: { error: '获取用户列表失败' },
|
|
||||
// reducer: { name: 'members' }
|
|
||||
// });
|
|
||||
// }
|
|
@ -1,11 +1,11 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
import * as example from './example' |
|
||||
import * as documentLibrary from './documentLibrary' |
import * as serviceManagement from './serviceManagement' |
||||
import * as ruleLibrary from './ruleLibrary' |
|
||||
|
|
||||
export default { |
export default { |
||||
...example, |
|
||||
...documentLibrary, |
...serviceManagement, |
||||
...ruleLibrary, |
|
||||
} |
} |
@ -1,52 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
import { basicAction } from '@peace/utils' |
|
||||
import { ApiTable } from '$utils' |
|
||||
|
|
||||
export function postBusinessRules (data = {}) { |
|
||||
let reminder = data?.id ? '修改业务规则' : '新增业务规则' |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'POST_BUSINESS_RULES', |
|
||||
url: `${ApiTable.businessRules}`, |
|
||||
msg: { option: reminder }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function getBusinessRules (query = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
query, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_BUSINESS_RULES', |
|
||||
url: `${ApiTable.businessRules}`, |
|
||||
msg: { error: '查询业务规则列表失败' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function delBusinessRules (id) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'del', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'del_BUSINESS_RULES', |
|
||||
url: `${ApiTable.delBusinessRules.replace('{id}', id)}`, |
|
||||
msg: { option: '删除业务规则' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function getRegularBasis (query = {}) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
query, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_REGULAR_BASIS', |
|
||||
url: `${ApiTable.regularBasis}`, |
|
||||
msg: { error: '查询规则依据列表失败' }, |
|
||||
reducer: { name: '' } |
|
||||
}); |
|
||||
} |
|
@ -0,0 +1,42 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
import { basicAction } from '@peace/utils' |
||||
|
import { ApiTable } from '$utils' |
||||
|
|
||||
|
export function getServiceManagement (query = {}) { |
||||
|
return dispatch => basicAction({ |
||||
|
type: 'get', |
||||
|
query, |
||||
|
dispatch: dispatch, |
||||
|
actionType: 'GET_SERVICE_MANAGEMENT', |
||||
|
url: `${ApiTable.serviceManagement}`, |
||||
|
msg: { error: '获取REST服务失败' }, |
||||
|
reducer: { name: '' } |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
export function postServiceManagement (data = {}) { |
||||
|
return dispatch => basicAction({ |
||||
|
type: 'post', |
||||
|
data, |
||||
|
dispatch: dispatch, |
||||
|
actionType: 'POST_SERVICE_MANAGEMENT', |
||||
|
url: `${ApiTable.serviceManagement}`, |
||||
|
msg: { option: '编辑REST服务' }, |
||||
|
reducer: { name: '' } |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
export function delServiceManagement (id) { |
||||
|
return dispatch => basicAction({ |
||||
|
type: 'del', |
||||
|
dispatch: dispatch, |
||||
|
actionType: 'del_SERVICE_MANAGEMENT', |
||||
|
url: `${ApiTable.delServiceManagement.replace('{id}', id)}`, |
||||
|
msg: { option: '删除REST服务' }, |
||||
|
reducer: { name: '' } |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
Loading…
Reference in new issue