记得上下班打卡 | git大法好,push需谨慎

Commit c324cca7 authored by wangyifan's avatar wangyifan

固定专题tag

parent ab3b4318
......@@ -45,4 +45,9 @@ public final class GoblinArtistConst {
public static final int RECOMMEND_MIN = 1;
/** 推荐位最大值 */
public static final int RECOMMEND_MAX = 10;
/** 专题标签:NEW */
public static final String TAG_NEW = "NEW";
/** 专题标签:HOT */
public static final String TAG_HOT = "HOT";
}
......@@ -175,7 +175,7 @@
}
function tagHtml(v) {
return v ? '<span class="badge-rec badge-rec-active">' + v + '</span>'
: '<span class="badge-rec badge-rec-none">无</span>';
: '<span class="badge-rec badge-rec-none">无标签</span>';
}
function saleTimeHtml(row) {
if (!row.onSaleStart && !row.onSaleEnd) return '-';
......@@ -208,7 +208,7 @@
html += '</div>';
html += '<a class="btn-act btn-act-rec ' + recommendFlg + '" onclick="openRecMenu(event, \'' + row.topicId + '\',' + (row.recommendPosition || 0) + ')">推荐设置 <i class="fa fa-caret-down"></i></a>';
var safeTag = (row.tag || '').replace(/\\/g, '\\\\').replace(/'/g, "\\'");
html += '<a class="btn-act btn-act-rec ' + tagFlg + '" onclick="openSetTag(\'' + row.topicId + '\',\'' + safeTag + '\')">设置标签</a>';
html += '<a class="btn-act btn-act-rec ' + tagFlg + '" onclick="openTagMenu(event, \'' + row.topicId + '\',\'' + safeTag + '\')">标签设置 <i class="fa fa-caret-down"></i></a>';
html += '</div>';
return html;
}}
......@@ -255,6 +255,7 @@
function openRecMenu(event, topicId, curPos) {
event.stopPropagation();
closeRecMenu();
closeTagMenu();
var html = '<div class="rec-menu">';
recPositions.forEach(function(pos) {
......@@ -335,20 +336,46 @@
});
}
// ---------- 设置标签 ----------
function openSetTag(topicId, curTag) {
layer.prompt({
title: '设置专题标签(如 HOT / 上新,可清空)',
formType: 0,
value: curTag || '',
maxlength: 32
}, function(value, index) {
layer.close(index);
doSetTag(topicId, value == null ? '' : value);
// ---------- 标签设置下拉菜单 ----------
var tagOptions = [
{ value: '', label: '无标签' },
{ value: 'NEW', label: 'NEW' },
{ value: 'HOT', label: 'HOT' }
];
var $tagMenu = null;
function openTagMenu(event, topicId, curTag) {
event.stopPropagation();
closeTagMenu();
closeRecMenu();
var cur = curTag || '';
var html = '<div class="rec-menu">';
tagOptions.forEach(function(opt) {
html += '<a data-val="' + opt.value + '"' + (opt.value === cur ? ' class="active"' : '') + '>' + opt.label + '</a>';
});
html += '</div>';
$tagMenu = $(html).appendTo('body');
var $btn = $(event.currentTarget);
$tagMenu.css({
top: $btn.offset().top + $btn.outerHeight() + 4,
left: $btn.offset().left
}).show();
$tagMenu.on('click', 'a', function() {
doSetTag(topicId, $(this).data('val') || '');
});
$(document).on('click.tagMenu', closeTagMenu);
}
function closeTagMenu() {
if ($tagMenu) { $tagMenu.remove(); $tagMenu = null; }
$(document).off('click.tagMenu');
}
function doSetTag(topicId, tag) {
closeTagMenu();
$.modal.loading("正在保存标签...");
$.ajax({
type: 'post', url: prefix + "/tag",
......@@ -356,7 +383,7 @@
success: function(res) {
$.modal.closeLoading();
if (res.code == 0) {
$.modal.msgSuccess("标签已更新");
$.modal.msgSuccess(tag ? ('已设置为 ' + tag) : '已取消标签');
$.table.refresh();
} else {
$.modal.alertError(res.msg);
......
......@@ -22,7 +22,7 @@ public interface IGoblinArtistTopicAdminService extends IService<GoblinArtistTop
boolean setRecommend(String topicId, int position);
/**
* 设置专题标签,同步写 MongoDB + MySQL;空串视为清空
* 设置专题标签:空/NEW/HOT,同步写 MongoDB + MySQL
*/
boolean setTag(String topicId, String tag);
......
......@@ -105,8 +105,10 @@ public class GoblinArtistTopicAdminServiceImpl
public boolean setTag(String topicId, String tag) {
LocalDateTime now = LocalDateTime.now();
String normalized = StringUtils.isBlank(tag) ? null : tag.trim();
if (normalized != null && normalized.length() > 32) {
normalized = normalized.substring(0, 32);
if (normalized != null
&& !GoblinArtistConst.TAG_NEW.equals(normalized)
&& !GoblinArtistConst.TAG_HOT.equals(normalized)) {
return false;
}
this.update(new LambdaUpdateWrapper<GoblinArtistTopic>()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment