Authored by 邱骏

修改数据库

... ... @@ -274,6 +274,7 @@ const activity = {
async createY100Article(req, res, next) {
const {
actId,
top = 0,
content = '',
imgUrl,
createTime = moment().format('YYYY-MM-DD hh:mm:ss'),
... ... @@ -307,7 +308,7 @@ const activity = {
// 向y100表中插入一条新记录
const y100ArticleId = await req.ctx(ActivityModel).createY100Article(
actId, articleId, imgUrl, numResult[0].total_count + 1, name, tag, style, career,
interest, skns, createTime);
interest, skns, top, createTime);
return res.json({
code: 200,
... ...
... ... @@ -158,12 +158,14 @@ class AdminModel extends global.yoho.BaseModel {
* @param createTime
* @returns {Promise.<*>}
*/
async createY100Article(actId, articleId, imageUrl, index, name, tag, style, career, interest, skns, createTime) {
async createY100Article(actId, articleId, imageUrl, index, name, tag, style, career, interest, skns, desc,
top, createTime) {
let strSQL = `INSERT INTO ${TB_ACT_ARTICLE_Y100}
(act_id, article_id, img_url, \`index\`, name, tag, style, career, interest, skns, create_time)
(act_id, article_id, img_url, \`index\`, name, tag, style, career, interest, skns, desc,
top, create_time)
VALUES
(:actId, :articleId, :imageUrl, :index, :name, :tag, :style, :career, :interest, :skns,
:createTime);`;
(:actId, :articleId, :imageUrl, :index, :name, :tag, :style, :career, :interest, :skns, :desc,
:top, :createTime);`;
console.log(strSQL, {actId, articleId, imageUrl, index, name, tag, style, career, skns, createTime});
... ... @@ -178,6 +180,8 @@ class AdminModel extends global.yoho.BaseModel {
career,
interest,
skns,
desc,
top,
createTime
});
}
... ...
... ... @@ -11,6 +11,18 @@
<div class="x_content">
<form id="createArticleForm" class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">推荐<span
class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select type="text" name="top" required="required"
class="form-control col-md-7 col-xs-12">
<option value="0">不推荐</option>
<option value="1">推荐</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">姓名<span
class="required">*</span>
</label>
... ... @@ -28,6 +40,7 @@
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">职业<span
class="required">*</span>
... ...
... ... @@ -11,7 +11,11 @@ const y100 = {
* @param next
*/
async y100List(req, res, next) {
const {actId, pageNo = 1, pageSize = 10, tag = '', top = true} = req.query;
const {actId, pageNo = 1, pageSize = 10, tag = '', top = 1} = req.query;
let top_int = parseInt(top, 10);
console.log(top_int, typeof top_int);
if (!actId) {
return res.json({
... ... @@ -26,9 +30,9 @@ const y100 = {
pageNo,
pageSize,
tag,
top
top: top_int
});
return res.json({
code: 200,
data: result,
... ... @@ -62,7 +66,7 @@ const y100 = {
actId,
num
});
return res.json({
code: 200,
data: result,
... ... @@ -103,6 +107,7 @@ const y100 = {
async y100DeviceScan(req, res, next) {
const {openId, avatar, deviceNo, actId, userName} = req.body;
console.log(req.body);
if (!deviceNo || !openId) {
return res.json({
code: 400
... ...
... ... @@ -34,7 +34,8 @@ class Y100Model extends global.yoho.BaseModel {
AAY.interest,
AAY.name,
AAY.style,
AAY.tag
AAY.tag,
AAY.desc
FROM ${TABLE_ACT_ARTICLE} AA
INNER JOIN ${TABLE_ACT_ARTICLE_Y100} AAY ON AA.id = AAY.article_id
WHERE AA.act_id = :actId`;
... ... @@ -44,13 +45,14 @@ class Y100Model extends global.yoho.BaseModel {
params.tag = `%${tag}%`;
}
if (top) {
if (top === 1 || top === true) {
sql += ' ORDER BY AAY.top DESC,AA.create_time DESC';
} else {
sql += ' ORDER BY AA.good_count DESC';
}
sql += ' LIMIT :start, :page';
return mysqlCli.query(sql, params);
}
... ... @@ -72,7 +74,9 @@ class Y100Model extends global.yoho.BaseModel {
let maxIndex = maxResult[0].maxIndex;
if (num > maxIndex) {
throw '随机数量超过数据库大小';
num = maxIndex;
// throw '随机数量超过数据库大小';
}
const ids = [],
selectIds = [];
... ... @@ -123,14 +127,13 @@ class Y100Model extends global.yoho.BaseModel {
AAY.style,
AAY.interest,
AAY.skns,
AAY.desc,
AAY.create_time,
AA.good_count
FROM ${TABLE_ACT_ARTICLE_Y100} AAY
INNER JOIN ${TABLE_ACT_ARTICLE} AA ON AAY.article_id = AA.id
where AAY.id = :id`;
console.log(sql, id);
const query = await mysqlCli.query(sql, {
id
});
... ... @@ -140,11 +143,27 @@ class Y100Model extends global.yoho.BaseModel {
const {skns} = query[0];
if (skns) {
const product_skns = skns.split('|')[0] || '';
const recommend_skns = skns.split('|')[1] || '';
const productsResult = await this.get({
data: {
method: 'h5.product.batch',
limit: skns.split(',').length,
productSkn: skns,
limit: product_skns.split(',').length,
productSkn: product_skns,
contain_all: 'Y'
},
param: {
cache: true
}
});
const recommendResult = await this.get({
data: {
method: 'h5.product.batch',
limit: recommend_skns.split(',').length,
productSkn: recommend_skns,
contain_all: 'Y'
},
param: {
... ... @@ -154,6 +173,7 @@ class Y100Model extends global.yoho.BaseModel {
if (productsResult.code === 200 && productsResult.data) {
result.products = productsResult.data.product_list;
result.recommend = recommendResult.data.product_list;
}
}
return result;
... ...
... ... @@ -24,8 +24,8 @@ router.get('/queryByUserId', article.queryByUserId);
router.get('/y100/list', y100.y100List); // y100图列表
router.get('/y100/detail', y100.y100Detail); // y100图详情
router.get('/y100/randomlist', y100.y100RandomList); // y100结果页随机列表
router.get('/y100/deviceScan', y100.y100DeviceScan); // y100扫描大屏接口-大屏
router.get('/y100/devicePost', y100.y100DevicePost); // y100完成游戏接口-大屏
router.post('/y100/deviceScan', y100.y100DeviceScan); // y100扫描大屏接口-大屏
router.post('/y100/devicePost', y100.y100DevicePost); // y100完成游戏接口-大屏
router.get('/y100/deviceCheck', y100.checkDeviceStatus); // y100大屏检查状态接口-大屏
module.exports = router;
... ...
... ... @@ -33,7 +33,9 @@ module.exports = {
'http://localhost:63342',
'http://huodong.yoho.cn',
'http://ad.yoho.cn',
'http://ad.yhurl.com'
'https:/ad.yoho.cn',
'http://ad.yhurl.com',
'http://feature.yoho.cn'
],
useCache: false,
memcache: {
... ...
... ... @@ -19,6 +19,8 @@ CREATE TABLE IF NOT EXISTS act_article_y100 (
`interest` varchar(200) DEFAULT '',
`skns` varchar(1000) DEFAULT '',
`index` int(8) NOT NULL DEFAULT 0,
`desc` varchar(200) DEFAULT '',
`desc2` varchar(200) DEFAULT '',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
... ... @@ -37,4 +39,4 @@ CREATE TABLE IF NOT EXISTS act_devices_y100 (
`status` TINYINT DEFAULT 0,
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
\ No newline at end of file
GO;
... ...