...
|
...
|
@@ -4,6 +4,7 @@ |
|
|
* @date: 26/09/2018
|
|
|
*/
|
|
|
const wheelSurfModel = require('../models/wheel-surf');
|
|
|
const valid = require('../../../utils/validator');
|
|
|
|
|
|
const whSurfController = {
|
|
|
entry(req, res) {
|
...
|
...
|
@@ -72,6 +73,169 @@ const whSurfController = { |
|
|
} catch (err) {
|
|
|
res.json(err);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
getConfigList: async function(req, res) {
|
|
|
let result = await req.ctx(wheelSurfModel).configList();
|
|
|
|
|
|
return res.json(result);
|
|
|
},
|
|
|
|
|
|
configModify: async function(req, res) {
|
|
|
try {
|
|
|
let data = valid(req.body, {
|
|
|
id: {type: 'number', empty: true},
|
|
|
act_id: {type: 'number', empty: false},
|
|
|
rule_btn_bg: {type: 'string', empty: true},
|
|
|
rule: {type: 'string', empty: true},
|
|
|
share_btn_bg: {type: 'string', empty: true},
|
|
|
share_url: {type: 'string', empty: true},
|
|
|
main_bg: {type: 'string', empty: true},
|
|
|
wheel_bg: {type: 'string', empty: true},
|
|
|
prize_btn_bg: {type: 'string', empty: true},
|
|
|
day_limit_times: {type: 'number', empty: true},
|
|
|
act_total_times: {type: 'number', empty: true},
|
|
|
day_over_limit_bg: {type: 'string', empty: true},
|
|
|
btm_tip_one: {type: 'string', empty: true},
|
|
|
btm_tip_two: {type: 'string', empty: true},
|
|
|
my_prize_btn: {type: 'string', empty: true},
|
|
|
jump_url: {type: 'string', empty: true},
|
|
|
win_prize_bg: {type: 'string', empty: true},
|
|
|
try_again_bg: {type: 'string', empty: true},
|
|
|
status: {type: 'number', empty: true}
|
|
|
});
|
|
|
let result = await req.ctx(wheelSurfModel).configModify(data);
|
|
|
|
|
|
return res.json({
|
|
|
code: 200,
|
|
|
data: result
|
|
|
});
|
|
|
} catch (e) {
|
|
|
return res.json({
|
|
|
code: 203,
|
|
|
result: false,
|
|
|
msg: e
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
configFindOne: async function(req, res) {
|
|
|
let actId = req.query.act_id;
|
|
|
|
|
|
if (!actId) {
|
|
|
return res.json({
|
|
|
code: 202,
|
|
|
result: false,
|
|
|
msg: '参数为空'
|
|
|
});
|
|
|
}
|
|
|
let result = await req.ctx(wheelSurfModel).configFindOne(actId);
|
|
|
|
|
|
return res.json({
|
|
|
code: 200,
|
|
|
data: result
|
|
|
});
|
|
|
},
|
|
|
|
|
|
prizeCreate: async function(req, res) {
|
|
|
let param = req.body;
|
|
|
|
|
|
try {
|
|
|
if (param instanceof Array) {
|
|
|
let arr = param.map((value) => {
|
|
|
return valid(value, {
|
|
|
act_id: {type: 'number', empty: false},
|
|
|
name: {type: 'string', empty: true},
|
|
|
type: {type: 'number', empty: true},
|
|
|
value: {type: 'string', empty: true},
|
|
|
img: {type: 'string', empty: true},
|
|
|
total: {type: 'number', empty: true},
|
|
|
total_left: {type: 'number', empty: true},
|
|
|
chance: {type: 'number', empty: true},
|
|
|
prize_bg: {type: 'string', empty: true},
|
|
|
prize_idx: {type: 'number', empty: true},
|
|
|
});
|
|
|
});
|
|
|
let result = await req.ctx(wheelSurfModel).prizeCreate(arr);
|
|
|
|
|
|
return res.json({
|
|
|
code: 200,
|
|
|
data: result
|
|
|
});
|
|
|
} else {
|
|
|
return res.json({
|
|
|
code: 202,
|
|
|
result: false,
|
|
|
msg: '参数格式错误'
|
|
|
});
|
|
|
}
|
|
|
} catch (e) {
|
|
|
return res.json({
|
|
|
code: 203,
|
|
|
result: false,
|
|
|
msg: e
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
prizeUpdate: async function(req, res) {
|
|
|
let param = req.body;
|
|
|
|
|
|
try {
|
|
|
if (param instanceof Array) {
|
|
|
let arr = param.map((value) => {
|
|
|
return valid(value, {
|
|
|
id: {type: 'number', empty: false},
|
|
|
act_id: {type: 'number', empty: false},
|
|
|
name: {type: 'string', empty: true},
|
|
|
type: {type: 'number', empty: true},
|
|
|
value: {type: 'string', empty: true},
|
|
|
img: {type: 'string', empty: true},
|
|
|
total: {type: 'number', empty: true},
|
|
|
total_left: {type: 'number', empty: true},
|
|
|
chance: {type: 'number', empty: true},
|
|
|
prize_bg: {type: 'string', empty: true},
|
|
|
prize_idx: {type: 'number', empty: true},
|
|
|
});
|
|
|
});
|
|
|
let result = await req.ctx(wheelSurfModel).prizeUpdate(arr);
|
|
|
|
|
|
return res.json({
|
|
|
code: 200,
|
|
|
data: result
|
|
|
});
|
|
|
} else {
|
|
|
return res.json({
|
|
|
code: 202,
|
|
|
result: false,
|
|
|
msg: '参数格式错误'
|
|
|
});
|
|
|
}
|
|
|
} catch (e) {
|
|
|
return res.json({
|
|
|
code: 203,
|
|
|
result: false,
|
|
|
msg: e
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
prizeFindByActId: async function(req, res) {
|
|
|
let actId = req.query.act_id;
|
|
|
|
|
|
if (!actId) {
|
|
|
return res.json({
|
|
|
code: 202,
|
|
|
result: false,
|
|
|
msg: '参数为空'
|
|
|
});
|
|
|
}
|
|
|
let result = await req.ctx(wheelSurfModel).prizeFindByActId(actId);
|
|
|
|
|
|
return res.json({
|
|
|
code: 200,
|
|
|
data: result
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
|