Browse Source

更新镜像服务id

dev_trial
巴林闲侠 2 years ago
parent
commit
1813789134
  1. 30
      code/VideoAccess-VCMP/api/app/lib/controllers/mirror/index.js
  2. 3
      code/VideoAccess-VCMP/api/app/lib/routes/mirror/index.js

30
code/VideoAccess-VCMP/api/app/lib/controllers/mirror/index.js

@ -62,7 +62,7 @@ async function edit (ctx) {
title: data.title, title: data.title,
showHeader: Boolean(data.showHeader), showHeader: Boolean(data.showHeader),
publish: false, publish: false,
mid: timeNow.format(`ssmmHHDDMMYYYY`) mid: timeNow.format(`ssmmHHDDMMYY${Math.floor(Math.random() * 89 + 10)}`)
} }
if (data.publish) { if (data.publish) {
createData.publish = true createData.publish = true
@ -161,6 +161,31 @@ async function edit (ctx) {
} }
} }
async function refreshId (ctx) {
try {
const { models } = ctx.fs.dc;
const { mirrorId } = ctx.params
if (!mirrorId) throw '更新镜像服务ID失败';
await models.MirrorTree.update({
mid: timeNow.format(`ssmmHHDDMMYY${Math.floor(Math.random() * 89 + 10)}`)
}, {
where: {
id: mirrorId
}
})
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function list (ctx) { async function list (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
@ -447,7 +472,7 @@ async function copy (ctx) {
title: mirrorRes.title + '-副本', title: mirrorRes.title + '-副本',
showHeader: mirrorRes.showHeader, showHeader: mirrorRes.showHeader,
publish: mirrorRes.publish, publish: mirrorRes.publish,
mid: timeNow.format(`ssmmHHDDMMYYYY`) mid: timeNow.format(`ssmmHHDDMMYY${Math.floor(Math.random() * 89 + 10)}`)
}, { }, {
transaction transaction
}) })
@ -543,6 +568,7 @@ async function copy (ctx) {
module.exports = { module.exports = {
edit, edit,
refreshId,
list, list,
get, get,
del, del,

3
code/VideoAccess-VCMP/api/app/lib/routes/mirror/index.js

@ -6,6 +6,9 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['PUT/mirror'] = { content: '编辑镜像信息', visible: false }; app.fs.api.logAttr['PUT/mirror'] = { content: '编辑镜像信息', visible: false };
router.put('/mirror', mirror.edit); router.put('/mirror', mirror.edit);
app.fs.api.logAttr['PUT/mirror/:mirrorId/id'] = { content: '更新镜像服务ID', visible: false };
router.put('/mirror/:mirrorId/id', mirror.refreshId);
app.fs.api.logAttr['GET/mirror/list'] = { content: '获取镜像信息列表', visible: false }; app.fs.api.logAttr['GET/mirror/list'] = { content: '获取镜像信息列表', visible: false };
router.get('/mirror/list', mirror.list); router.get('/mirror/list', mirror.list);

Loading…
Cancel
Save