From ee4eb8b4a7f42954c1663b2cefa530f0804dc72d Mon Sep 17 00:00:00 2001 From: yulixing Date: Mon, 27 May 2019 19:58:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=20->=20pikachu=20=20=E6=96=B0=E5=A2=9E=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86API=20=20=E4=BF=AE=E6=94=B9=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E4=BF=A1=E6=81=AFAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boundle.sh | 3 - config/config.js.1.example | 136 --------------- fixtures/platforms.js | 63 +++++++ fixtures/system_dics.js | 112 ++++++++++++ init-data.js | 18 ++ init-roles.js | 2 +- src/bin/express.js | 26 +-- src/controllers/games/games.js | 262 ++++++++++++++++------------- src/controllers/games/index.js | 2 + src/controllers/games/platforms.js | 72 ++++++++ src/models/admin/GameInfo.js | 22 +++ src/models/admin/Platform.js | 20 +++ 12 files changed, 468 insertions(+), 270 deletions(-) delete mode 100644 config/config.js.1.example create mode 100644 fixtures/platforms.js create mode 100644 fixtures/system_dics.js create mode 100644 init-data.js create mode 100644 src/controllers/games/platforms.js create mode 100644 src/models/admin/GameInfo.js create mode 100644 src/models/admin/Platform.js diff --git a/boundle.sh b/boundle.sh index 0346323..3ac9f70 100644 --- a/boundle.sh +++ b/boundle.sh @@ -5,9 +5,6 @@ source /etc/profile npm install --prefer-offline --loglevel info --unsafe-perm=true --allow-root >> boundle.log echo 'copy node_modules to /data/publish/node_packages' >> boundle.log -npm run clear -npm run init:roles - gulp rm -rf ./src diff --git a/config/config.js.1.example b/config/config.js.1.example deleted file mode 100644 index 1471f53..0000000 --- a/config/config.js.1.example +++ /dev/null @@ -1,136 +0,0 @@ -const path = require('path'); - -const rootPath = path.normalize(__dirname + '/..'); -const env = process.env.NODE_ENV || 'development'; - -const config = { - development: { - root: rootPath, - app: { - name: 'garfield' - }, - host: 'http://192.168.199.210:3000', - port: process.env.PORT || 2333, - secret: 'garfield_sd*3,Jd32-xd..q(jd,vHdklx2z;3', - session_name: 'sessionId_garfield', - - special_sid: '58c939a11c2c7cf2653d7f07', - empty_user: '000000000000000000000000', - db_admin: 'mongodb://localhost/garfield-development', - db_snoopy: 'mongodb://localhost/snoopy-development', - db_dalmatian: 'mongodb://localhost/dalmatian-development', - db_beagle: 'mongodb://localhost/beagle-development', - db_ghost: 'mongodb://localhost/ghost-development', - upload_to: rootPath + '/public/uploads', - upload_prefix: '/uploads', - short_url_base: 'https://wechat-test.kingsome.cn/s/', - redis: { - port: 6379, - host: '127.0.0.1', - password: '' - }, - redisPublish: { - port: 6379, - host: '192.144.140.87', - password: '' - }, - cos: { - SecretId: 'AKIDufGerr0GfssfTBiy3vZzEF4f3C8rfb3K', - SecretKey: 'B7mDPL3WlobBgy4xgDUXO0NVP3ScWBcn' - }, - cos_cdn: { - SecretId: 'AKIDvmW8mNvCQVt9GEnd3JNH5lHKI8oJnv46', - SecretKey: 'd6QZhgT7alnhR3VghWAg3FF4c2JMG1c2' - }, - pay_weapp: { - app_id: 'wxaf55c10d3fa61c40', - app_secret: 'c081f58f46a3d599751235a7b393db01', - message_template_id: 'BzyvfyHRic_prj7tYvzpfx5q_fAqgJRMN9iiuGiExxI', - schedule_send_time: '0 30 19 * * *', - message_value1: '晚间轻松一刻', - message_value2: '邀新人玩游戏,赚零花钱', - message_value3: '可以在小程序底部进入游戏哦' - }, - youme: { - baseUrl: 'https://api.youme.im/v1/im/', - identifier: 'admin', - app_key: 'YOUME4E2394D4CE21BAAFF95831701696A885A3372F6F', - app_secret: - '3vHmwZkDGHXsURalxCvg51ns11aCULY4HiGcQZQ4PG0vDJMZwTgK4oFOgo9dZJ/wsyHIT7lDQk8JMohNa6RqhmiwZ0Mo9yq0B3Glu/3yv+YYkqQbKXU/xHDEug6tiOTIf7Cz/GlZXxB5VuPyx2CgLCtNz8XUYAUrpnUM8yrAGkcBAAE=' - }, - ldap: { - url: 'ldap://ldap.kingsome.cn:389', - user: 'cn=admin,dc=kingsome,dc=cn', - password: 'milesQWE321' - }, - jwtSecret: 'OA3A$0X6*OsD*6oE', - pay_record: 'http://192.168.100.23:7051/webapp/index.php', - logs_path: '/Users/zhl/Documents/logs/garfield' - }, - - production: { - root: rootPath, - app: { - name: 'garfield' - }, - host: 'http://192.168.199.210:3000', - port: process.env.PORT || 3000, - secret: 'garfield_sd*3,Jd32-xd..q(jd,vHdklx2z;3', - session_name: 'sessionId_garfield', - - special_sid: '58c939a11c2c7cf2653d7f07', - empty_user: '000000000000000000000000', - db_admin: 'mongodb://localhost/garfield-production', - db_snoopy: 'mongodb://localhost/snoopy-production', - db_dalmatian: 'mongodb://localhost/dalmatian-production', - db_beagle: 'mongodb://localhost/beagle-production', - db_ghost: 'mongodb://localhost/ghost-production', - upload_to: rootPath + '/public/uploads', - upload_prefix: '/uploads', - short_url_base: 'https://wechat-test.kingsome.cn/s/', - redis: { - port: 6379, - host: '127.0.0.1', - password: '' - }, - redisPublish: { - port: 6379, - host: '192.144.140.87', - password: '' - }, - cos: { - SecretId: 'AKIDufGerr0GfssfTBiy3vZzEF4f3C8rfb3K', - SecretKey: 'B7mDPL3WlobBgy4xgDUXO0NVP3ScWBcn' - }, - cos_cdn: { - SecretId: 'AKIDvmW8mNvCQVt9GEnd3JNH5lHKI8oJnv46', - SecretKey: 'd6QZhgT7alnhR3VghWAg3FF4c2JMG1c2' - }, - pay_weapp: { - app_id: 'wxaf55c10d3fa61c40', - app_secret: 'c081f58f46a3d599751235a7b393db01', - message_template_id: 'BzyvfyHRic_prj7tYvzpfx5q_fAqgJRMN9iiuGiExxI', - schedule_send_time: '0 30 19 * * *', - message_value1: '晚间轻松一刻', - message_value2: '邀新人玩游戏,赚零花钱', - message_value3: '可以在小程序底部进入游戏哦' - }, - youme: { - baseUrl: 'https://api.youme.im/v1/im/', - identifier: 'admin', - app_key: 'YOUME4E2394D4CE21BAAFF95831701696A885A3372F6F', - app_secret: - '3vHmwZkDGHXsURalxCvg51ns11aCULY4HiGcQZQ4PG0vDJMZwTgK4oFOgo9dZJ/wsyHIT7lDQk8JMohNa6RqhmiwZ0Mo9yq0B3Glu/3yv+YYkqQbKXU/xHDEug6tiOTIf7Cz/GlZXxB5VuPyx2CgLCtNz8XUYAUrpnUM8yrAGkcBAAE=' - }, - ldap: { - url: 'ldap://ldap.kingsome.cn:389', - user: 'cn=admin,dc=kingsome,dc=cn', - password: 'milesQWE321' - }, - jwtSecret: 'OA3A$0X6*OsD*6oE', - pay_record: 'http://192.168.100.23:7051/webapp/index.php', - logs_path: '/var/logs' - } -}; - -module.exports = config[env]; diff --git a/fixtures/platforms.js b/fixtures/platforms.js new file mode 100644 index 0000000..4ee844f --- /dev/null +++ b/fixtures/platforms.js @@ -0,0 +1,63 @@ +const ObjectId = require('pow-mongodb-fixtures').createObjectId; +const ISODate = function(dateStr) { + return new Date(dateStr); +}; + +exports.platforms = [ + { + _id: ObjectId('5ceb909ef204f241e886378d'), + name: '内部测试', + name_en: 'test', + platform_id: '6000', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e886378e'), + name: '微信', + name_en: 'weixin', + platform_id: '6001', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e886378f'), + name: 'QQ 玩一玩', + name_en: 'qq', + platform_id: '6002', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e8863790'), + name: 'OPPO 小游戏', + name_en: 'oppo', + platform_id: '6003', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e8863791'), + name: 'VIVO 快游戏', + name_en: 'vivo', + platform_id: '6004', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e8863792'), + name: '百度', + name_en: 'baidu', + platform_id: '6005', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e8863793'), + name: '抖音', + name_en: 'douyin', + platform_id: '6006', + comment: '' + }, + { + _id: ObjectId('5ceb909ef204f241e8863794'), + name: 'Facebook 小游戏', + name_en: 'facebook', + platform_id: '6501', + comment: '' + } +]; diff --git a/fixtures/system_dics.js b/fixtures/system_dics.js new file mode 100644 index 0000000..c5e3159 --- /dev/null +++ b/fixtures/system_dics.js @@ -0,0 +1,112 @@ +const ObjectId = require('pow-mongodb-fixtures').createObjectId; +const ISODate = function(dateStr) { + return new Date(dateStr); +}; + +exports.system_dics = [ + /* 1 */ + { + '_id': ObjectId('572f646972fbeed78781f396'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': '6000', + 'value': '内部测试', + 'type': 'platform', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 2 */ + { + '_id': ObjectId('572f646972fbeed78781f397'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': '6001', + 'value': '微信', + 'type': 'platform', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 3 */ + { + '_id': ObjectId('572f646972fbeed78781f398'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': '6002', + 'value': 'QQ玩一玩', + 'type': 'platform', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 4 */ + { + '_id': ObjectId('572f646972fbeed78781f399'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': 'reborn', + 'value': {title: '复活', type: 'bool'}, + 'type': 'game_cfg', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 5 */ + { + '_id': ObjectId('572f646972fbeed78781f3a0'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': 'share_reward', + 'value': {title: '开启分享', type: 'bool'}, + 'type': 'game_cfg', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 6 */ + { + '_id': ObjectId('572f646972fbeed78781f3a1'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': 'exchange_reward', + 'value': {title: '交易', type: 'bool'}, + 'type': 'game_cfg', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 7 */ + { + '_id': ObjectId('572f646972fbeed78781f3a2'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': 'version', + 'value': {title: '版本', type: 'string'}, + 'type': 'game_cfg', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + /* 8 */ + { + '_id': ObjectId('572f646972fbeed78781f3a3'), + 'updatedAt': ISODate('2018-10-17T20:20:53.609Z'), + 'createdAt': ISODate('2018-10-17T20:20:53.609Z'), + 'key': 'ggl', + 'value': {title: '开启活动', type: 'bool'}, + 'type': 'game_cfg', + 'createdBy': '572f646972fbeed78781f396', + 'lastModifiedBy': '572f646972fbeed78781f396', + 'deleted': false, + '__v': 0, + }, + +]; diff --git a/init-data.js b/init-data.js new file mode 100644 index 0000000..575ce37 --- /dev/null +++ b/init-data.js @@ -0,0 +1,18 @@ +const pmf = require('pow-mongodb-fixtures'); +const config = require('./config/config'); +const path = require('path'); + +const fixtures = pmf.connect(config.db_admin); +const fixturesDir = path.join(config.root, '/fixtures'); + +const platforms = require('./fixtures/platforms'); + +// fixtures.load(__dirname + '/fixtures/platforms.js', function(err) { +// if (err) throw err; +// }); +// fixtures.load(__dirname + '/fixtures/roles.js', function(err) { +// if (err) throw err; +// }); +fixtures.load(__dirname + '/fixtures/system_dics.js', function(err) { + if (err) throw err; +}); diff --git a/init-roles.js b/init-roles.js index cc2e638..efb27bf 100644 --- a/init-roles.js +++ b/init-roles.js @@ -6,7 +6,7 @@ const fixtures = pmf.connect(config.db_admin); const fixturesDir = path.join(config.root, '/fixtures'); fixtures.clearAndLoad(fixturesDir, function(err) { - if (err) console.log(err); + if (err) throw err; console.log('roles 数据加载完毕!'); process.exit(0); }); diff --git a/src/bin/express.js b/src/bin/express.js index 2a363b5..2565da5 100644 --- a/src/bin/express.js +++ b/src/bin/express.js @@ -120,19 +120,19 @@ app.use( ); app.use(expressValidator()); app.use(cookieParser(config.secret)); -app.use( - session({ - secret: config.secret, - resave: false, - saveUninitialized: false, - name: config.session_name, - store: new MongoStore({ - url: config.db_admin, - autoReconnect: true, - collection: 'garfield_sessions' - }) - }) -); +// app.use( +// session({ +// secret: config.secret, +// resave: false, +// saveUninitialized: false, +// name: config.session_name, +// store: new MongoStore({ +// url: config.db_admin, +// autoReconnect: true, +// collection: 'garfield_sessions' +// }) +// }) +// ); app.use(flash()); app.use(expressUtils()); app.use(methodOverride()); diff --git a/src/controllers/games/games.js b/src/controllers/games/games.js index e5ae8d6..7c322f9 100644 --- a/src/controllers/games/games.js +++ b/src/controllers/games/games.js @@ -1,139 +1,167 @@ -import GameInfo from '../../models/snoopy/GameInfo'; +// import GameInfo from '../../models/snoopy/GameInfo'; +import GameInfo from '../../models/admin/GameInfo'; import { Router } from 'express'; const router = new Router(); -router.get('/list', async function gameListCtrl(req, res, next) { - const query = req.query || {}; - query.deleted = false; +// router.get('/list', async function gameListCtrl(req, res, next) { +// const query = req.query || {}; +// query.deleted = false; - try { - let result = await GameInfo.find(query).populate('linked_games'); - // 获取虚拟字段数据 - result = result.map(item => { - const game = JSON.parse(JSON.stringify(item)); - game.status_show = item.status_show; - game.show_type = item.show_type; - game.platform_show = item.platform_show; - return game; - }); - res.send({ - errcode: 0, - gameList: result - }); - } catch (err) { - next(err); - } -}); +// try { +// let result = await GameInfo.find(query).populate('linked_games'); +// // 获取虚拟字段数据 +// result = result.map(item => { +// const game = JSON.parse(JSON.stringify(item)); +// game.status_show = item.status_show; +// game.show_type = item.show_type; +// game.platform_show = item.platform_show; +// return game; +// }); +// res.send({ +// errcode: 0, +// gameList: result +// }); +// } catch (err) { +// next(err); +// } +// }); -router.get('/type', async function gameTypeCtrl(req, res, next) { - const gameType = GameInfo.all_type(); - const result = []; - for (const key in gameType) { - if ({}.hasOwnProperty.call(gameType, key)) { - result.push({ - value: key, - name: gameType[key] - }); - } - } - res.send({ - errcode: 0, - gameType: result - }); -}); +// router.get('/type', async function gameTypeCtrl(req, res, next) { +// const gameType = GameInfo.all_type(); +// const result = []; +// for (const key in gameType) { +// if ({}.hasOwnProperty.call(gameType, key)) { +// result.push({ +// value: key, +// name: gameType[key] +// }); +// } +// } +// res.send({ +// errcode: 0, +// gameType: result +// }); +// }); -router.get('/platform', async function platformCtrl(req, res, next) { - const platform = GameInfo.all_platform(); - const result = []; - for (const key in platform) { - if ({}.hasOwnProperty.call(platform, key)) { - result.push({ - value: key, - name: platform[key] - }); - } - } - res.send({ - errcode: 0, - platform: result - }); -}); +// router.get('/platform', async function platformCtrl(req, res, next) { +// const platform = GameInfo.all_platform(); +// const result = []; +// for (const key in platform) { +// if ({}.hasOwnProperty.call(platform, key)) { +// result.push({ +// value: key, +// name: platform[key] +// }); +// } +// } +// res.send({ +// errcode: 0, +// platform: result +// }); +// }); -router.get('/status', async function statusCtrl(req, res, next) { - const platform = GameInfo.status_list(); - res.send({ - errcode: 0, - statusList: platform - }); -}); +// router.get('/status', async function statusCtrl(req, res, next) { +// const platform = GameInfo.status_list(); +// res.send({ +// errcode: 0, +// statusList: platform +// }); +// }); -router.post('/edit', async function gameEditCtrl(req, res, next) { +// router.post('/edit', async function gameEditCtrl(req, res, next) { +// const body = req.body; +// try { +// const searchResult = await GameInfo.findOne({ +// _id: body._id, +// deleted: false +// }); +// if (searchResult) { +// const saveResult = await GameInfo.updateOne({ _id: body._id }, body); +// res.send({ +// errcode: 0 +// }); +// } else { +// res.send({ +// errcode: 1, +// errmsg: '该游戏已被删除,无法编辑!' +// }); +// } +// } catch (err) { +// next(err); +// } +// }); + +// router.post('/add', async function gameAddCtrl(req, res, next) { +// const body = req.body; +// try { +// const searchResult = await GameInfo.findOne({ +// game_id: body.game_id, +// deleted: false +// }); +// if (searchResult) { +// res.send({ +// errcode: 1, +// errmsg: '游戏 ID 已存在!' +// }); +// } else { +// const newGame = new GameInfo(body); +// const saveResult = await newGame.save(); +// res.send({ +// errcode: 0, +// userInfo: saveResult +// }); +// } +// } catch (err) { +// next(err); +// } +// }); + +// router.post('/del', async function gameDelCtrl(req, res, next) { +// const body = req.body; +// const gameList = body.gameList; +// try { +// for (let i = 0; i < gameList.length; i++) { +// const delResult = await GameInfo.updateOne( +// { _id: gameList[i]._id }, +// { +// deleted: true +// } +// ); +// } +// res.send({ +// errcode: 0 +// }); +// } catch (err) { +// next(err); +// } +// }); + +router.post('/save', async (req, res, next) => { const body = req.body; try { - const searchResult = await GameInfo.findOne({ - _id: body._id, - deleted: false + const search = await GameInfo.findOne({ + $or: [ + { game_id: body.game_id }, + { game_name: body.game_name }, + { game_name_en: body.game_name_en } + ] }); - if (searchResult) { - const saveResult = await GameInfo.updateOne({ _id: body._id }, body); + if (search) { + res.send({ + errcode: 1, + errmsg: '游戏已存在!' + }); + } else { + const newGameInfo = new GameInfo(body); + const result = await newGameInfo.save(); res.send({ errcode: 0 }); - } else { - res.send({ - errcode: 1, - errmsg: '该游戏已被删除,无法编辑!' - }); } } catch (err) { next(err); } }); -router.post('/add', async function gameAddCtrl(req, res, next) { - const body = req.body; - try { - const searchResult = await GameInfo.findOne({ - game_id: body.game_id, - deleted: false - }); - if (searchResult) { - res.send({ - errcode: 1, - errmsg: '游戏 ID 已存在!' - }); - } else { - const newGame = new GameInfo(body); - const saveResult = await newGame.save(); - res.send({ - errcode: 0, - userInfo: saveResult - }); - } - } catch (err) { - next(err); - } -}); - -router.post('/del', async function gameDelCtrl(req, res, next) { - const body = req.body; - const gameList = body.gameList; - try { - for (let i = 0; i < gameList.length; i++) { - const delResult = await GameInfo.updateOne( - { _id: gameList[i]._id }, - { - deleted: true - } - ); - } - res.send({ - errcode: 0 - }); - } catch (err) { - next(err); - } -}); - export default router; diff --git a/src/controllers/games/index.js b/src/controllers/games/index.js index 6000d31..e409295 100644 --- a/src/controllers/games/index.js +++ b/src/controllers/games/index.js @@ -1,6 +1,7 @@ import { Router } from 'express'; import gamesRouter from './games' import settingsRouter from './settings' +import platformsRouter from './platforms' @@ -10,6 +11,7 @@ const router = new Router(); router.use('/', gamesRouter); router.use('/settings', settingsRouter); +router.use('/platforms', platformsRouter); diff --git a/src/controllers/games/platforms.js b/src/controllers/games/platforms.js new file mode 100644 index 0000000..ab90d29 --- /dev/null +++ b/src/controllers/games/platforms.js @@ -0,0 +1,72 @@ +import Platform from '../../models/admin/Platform'; +import { Router } from 'express'; + +const router = new Router(); +// 获取平台列表 +router.get('/list', async (req, res, next) => { + try { + const result = await Platform.find({}); + res.send({ + errcode: 0, + platformList: result + }); + } catch (err) { + next(err); + } +}); +// 新增平台 +router.post('/save', async (req, res, next) => { + const body = req.body; + try { + const search = await Platform.findOne({ + $or: [ + { name: body.name }, + { name_en: body.name_en }, + { platform_id: body.platform_id } + ] + }); + if (search) { + res.send({ + errcode: 1, + errmsg: '平台名称或平台 ID 已存在!' + }); + } else { + const newPlatform = new Platform(body); + const result = await newPlatform.save(); + res.send({ + errcode: 0 + }); + } + } catch (err) { + next(err); + } +}); +// 编辑平台信息 +router.post('/edit', async (req, res, next) => { + const body = req.body; + try { + const search = await Platform.findOne({ platform_id: body.platform_id }); + console.log(search); + if (search) { + const result = await Platform.updateOne( + { platform_id: body.platform_id }, + { + name: body.name, + comment: body.comment + } + ); + res.send({ + errcode: 0 + }); + } else { + res.send({ + errcode: 1, + errmsg: '平台不存在,修改失败!' + }); + } + } catch (err) { + next(err); + } +}); + +export default router; diff --git a/src/models/admin/GameInfo.js b/src/models/admin/GameInfo.js new file mode 100644 index 0000000..d690c4c --- /dev/null +++ b/src/models/admin/GameInfo.js @@ -0,0 +1,22 @@ +'use strict'; +import mongoose from 'mongoose'; + +/** + * 游戏信息 + */ +const GameInfo = new mongoose.Schema( + { + game_name: { type: String }, + game_name_en: { type: String }, + game_id: { type: String }, + game_type: { type: String }, + game_icon: { type: String }, + platforms: [{type: Object}] + }, + { + collection: 'game_info', + timestamps: true + } +); + +export default mongoose.model('GameInfo', GameInfo); diff --git a/src/models/admin/Platform.js b/src/models/admin/Platform.js new file mode 100644 index 0000000..8ef3123 --- /dev/null +++ b/src/models/admin/Platform.js @@ -0,0 +1,20 @@ +'use strict'; +import mongoose from 'mongoose'; + +/** + * 平台信息 + */ +const Plateform = new mongoose.Schema( + { + name: { type: String }, + name_en: { type: String }, + platform_id: { type: String }, + comment: { type: String } + }, + { + collection: 'platforms', + timestamps: true + } +); + +export default mongoose.model('Plateform', Plateform);