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

Commit c324cca7 authored by wangyifan's avatar wangyifan

固定专题tag

parent ab3b4318
...@@ -45,4 +45,9 @@ public final class GoblinArtistConst { ...@@ -45,4 +45,9 @@ public final class GoblinArtistConst {
public static final int RECOMMEND_MIN = 1; public static final int RECOMMEND_MIN = 1;
/** 推荐位最大值 */ /** 推荐位最大值 */
public static final int RECOMMEND_MAX = 10; 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 @@ ...@@ -175,7 +175,7 @@
} }
function tagHtml(v) { function tagHtml(v) {
return v ? '<span class="badge-rec badge-rec-active">' + v + '</span>' 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) { function saleTimeHtml(row) {
if (!row.onSaleStart && !row.onSaleEnd) return '-'; if (!row.onSaleStart && !row.onSaleEnd) return '-';
...@@ -208,7 +208,7 @@ ...@@ -208,7 +208,7 @@
html += '</div>'; 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>'; 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, "\\'"); 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>'; html += '</div>';
return html; return html;
}} }}
...@@ -255,6 +255,7 @@ ...@@ -255,6 +255,7 @@
function openRecMenu(event, topicId, curPos) { function openRecMenu(event, topicId, curPos) {
event.stopPropagation(); event.stopPropagation();
closeRecMenu(); closeRecMenu();
closeTagMenu();
var html = '<div class="rec-menu">'; var html = '<div class="rec-menu">';
recPositions.forEach(function(pos) { recPositions.forEach(function(pos) {
...@@ -335,20 +336,46 @@ ...@@ -335,20 +336,46 @@
}); });
} }
// ---------- 设置标签 ---------- // ---------- 标签设置下拉菜单 ----------
function openSetTag(topicId, curTag) { var tagOptions = [
layer.prompt({ { value: '', label: '无标签' },
title: '设置专题标签(如 HOT / 上新,可清空)', { value: 'NEW', label: 'NEW' },
formType: 0, { value: 'HOT', label: 'HOT' }
value: curTag || '', ];
maxlength: 32 var $tagMenu = null;
}, function(value, index) {
layer.close(index); function openTagMenu(event, topicId, curTag) {
doSetTag(topicId, value == null ? '' : value); 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) { function doSetTag(topicId, tag) {
closeTagMenu();
$.modal.loading("正在保存标签..."); $.modal.loading("正在保存标签...");
$.ajax({ $.ajax({
type: 'post', url: prefix + "/tag", type: 'post', url: prefix + "/tag",
...@@ -356,7 +383,7 @@ ...@@ -356,7 +383,7 @@
success: function(res) { success: function(res) {
$.modal.closeLoading(); $.modal.closeLoading();
if (res.code == 0) { if (res.code == 0) {
$.modal.msgSuccess("标签已更新"); $.modal.msgSuccess(tag ? ('已设置为 ' + tag) : '已取消标签');
$.table.refresh(); $.table.refresh();
} else { } else {
$.modal.alertError(res.msg); $.modal.alertError(res.msg);
......
...@@ -22,7 +22,7 @@ public interface IGoblinArtistTopicAdminService extends IService<GoblinArtistTop ...@@ -22,7 +22,7 @@ public interface IGoblinArtistTopicAdminService extends IService<GoblinArtistTop
boolean setRecommend(String topicId, int position); boolean setRecommend(String topicId, int position);
/** /**
* 设置专题标签,同步写 MongoDB + MySQL;空串视为清空 * 设置专题标签:空/NEW/HOT,同步写 MongoDB + MySQL
*/ */
boolean setTag(String topicId, String tag); boolean setTag(String topicId, String tag);
......
...@@ -105,8 +105,10 @@ public class GoblinArtistTopicAdminServiceImpl ...@@ -105,8 +105,10 @@ public class GoblinArtistTopicAdminServiceImpl
public boolean setTag(String topicId, String tag) { public boolean setTag(String topicId, String tag) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String normalized = StringUtils.isBlank(tag) ? null : tag.trim(); String normalized = StringUtils.isBlank(tag) ? null : tag.trim();
if (normalized != null && normalized.length() > 32) { if (normalized != null
normalized = normalized.substring(0, 32); && !GoblinArtistConst.TAG_NEW.equals(normalized)
&& !GoblinArtistConst.TAG_HOT.equals(normalized)) {
return false;
} }
this.update(new LambdaUpdateWrapper<GoblinArtistTopic>() 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