Authored by mlge

种草--话题修改

... ... @@ -54,6 +54,13 @@ public class GrassTopicController {
List<TopicRespBo> resp = topicService.grassTopicByGroupId(req);
return new ApiResponse.ApiResponseBuilder().data(resp).build();
}
@RequestMapping("/changeTopicHotStatus")
@ResponseBody
public ApiResponse changeTopicHotStatus(@RequestBody GrassTopicReq req){
return topicService.changeTopicHotStatus(req);
}
/*@RequestMapping("/getAllTopic")
@ResponseBody
public ApiResponse getAllTopic(){
... ...
package com.yohobuy.platform.grass.service;
import com.yohobuy.platform.dal.grass.model.GrassTopic;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassLabelReq;
import com.yohobuy.platform.model.grass.request.GrassTopicReq;
... ... @@ -20,4 +21,6 @@ public interface ITopicService {
List<TopicRespBo> grassTopicByGroupId(GrassTopicReq req);
void changeTopicStatus(GrassTopicReq req);
ApiResponse changeTopicHotStatus(GrassTopicReq req);
}
... ...
... ... @@ -13,6 +13,7 @@ import com.yohobuy.platform.dal.grass.model.GrassLabel;
import com.yohobuy.platform.dal.grass.model.GrassTopic;
import com.yohobuy.platform.grass.service.ITopicService;
import com.yohobuy.platform.grass.service.IlabelService;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassLabelReq;
import com.yohobuy.platform.model.grass.request.GrassTopicReq;
... ... @@ -54,14 +55,15 @@ public class TopicServiceImpl implements ITopicService {
Integer status = req.getStatus() == null || req.getStatus() == 8 ? null : req.getStatus();
Integer isOfficial = req.getIsOfficial() == null || req.getIsOfficial() == 8 ? null : req.getIsOfficial();
Integer isHot = req.getIsHot() == null || req.getIsHot() == 8 ? null : req.getIsHot();
String topicName = req.getTopicName();
String groupName = req.getGroupName();
Integer startTime = req.getStartTime();
Integer endTime = req.getEndTime();
int total = grassTopicDAO.countByCondition(status,isOfficial,topicName,groupName,startTime,endTime);
int total = grassTopicDAO.countByCondition(status,isOfficial,topicName,groupName,isHot,startTime,endTime);
List<TopicRespBo> pageData = new ArrayList<>();
if(total > 0){
List<GrassTopic> list = grassTopicDAO.selectByPageCondition(status,isOfficial,topicName,groupName,startTime,endTime,req.getStart(),req.getSize());
List<GrassTopic> list = grassTopicDAO.selectByPageCondition(status,isOfficial,topicName,groupName,isHot,startTime,endTime,req.getStart(),req.getSize());
pageData = convertTopicRespBo(list);
}
PageResponseVO responseVO = new PageResponseVO();
... ... @@ -117,6 +119,32 @@ public class TopicServiceImpl implements ITopicService {
grassTopicDAO.changeStatus(id,status);
}
/**
* 设置是否是热门
* 最多只能同时存在5个热门话题
* @param req
* @return
*/
@Override
public ApiResponse changeTopicHotStatus(GrassTopicReq req) {
logger.info("enter changeTopicHotStatus req={} ", req);
Integer id = req.getId();
Integer isHot = req.getIsHot();
if(isHot == 1){//设置为热门 要控制下个数
int total = grassTopicDAO.countHotTopics();
if(total == 5){
return new ApiResponse.ApiResponseBuilder().code(201).message("设置失败!最多只能设置5个热门话题").build();
}
}
GrassTopic record = new GrassTopic();
record.setId(id);
record.setIsHot(isHot);
grassTopicDAO.updateByPrimaryKeySelective(record);
logger.info("changeTopicHotStatus success! req={}",req);
return new ApiResponse.ApiResponseBuilder().code(200).build();
}
@Override
public List<TopicRespBo> grassTopicByGroupId(GrassTopicReq req) {
Integer groupId = req.getGroupId();
... ...
... ... @@ -38,6 +38,9 @@
<input class="easyui-combobox" id="isOfficialParam">
</input>
<input class="easyui-combobox" id="isHotParam">
</input>
<input class="easyui-textbox" id="topicNameParam" style="width: 140px">
</input>
... ... @@ -99,6 +102,15 @@
data: [{text: "全部", value: "8"}, {text: "官方", value: "1"}, {text: "非官方", value: "0"}]
});
$("#isHotParam").combobox({
valueField: "value",
textField: "text",
required: false,
prompt: "是否热门",
data: [{text: "全部", value: "8"}, {text: "热门", value: "1"}, {text: "非热门", value: "0"}]
});
$("#topicNameParam").textbox({
required: false,
prompt: "请输入话题名称"
... ... @@ -125,6 +137,7 @@
$("#labelListTable").datagrid("load", {
status: $("#statusParam").combobox("getValue"),
isOfficial: $("#isOfficialParam").combobox("getValue"),
isHot: $("#isHotParam").combobox("getValue"),
topicName: $("#topicNameParam").textbox("getValue"),
groupName: $("#topicGroupParam").textbox("getValue"),
startTime: startTime,
... ... @@ -230,16 +243,19 @@
var str = "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #31b0d5' index='" + rowIndex + "'>编辑</a>";
var changeStatus = "<a role='changeStatus' style='margin-left:10px;background-color: #c4ddff' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>上架</a>";
var changeHot = "<a role='changeHot' style='margin-left:10px;background-color: #a395ff' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>设为热门</a>";
var link = "<div style='position:relative;color: #0099CC'><a role='copy' copyValue='"+rowData.id+"' style='margin-left:10px'>复制链接</a></div>";
if (rowData.status == 1) {
str = "";//进行中的话题不可编辑
changeStatus = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='0' dataId='" + rowData.id + "' index='" + rowIndex + "'>下架</a>";
}
str += changeStatus;
// str += "<a role='' style='margin-left:10px;background-color: #ffa951' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>复制链接</a>" ;
debugger
if(rowData.isHot == 1){
changeHot = "<a role='changeHot' style='margin-left:10px;background-color: #ea40ff' changedStatus='0' dataId='" + rowData.id + "' index='" + rowIndex + "'>取消热门</a>";
}
return str ;
//编辑 上下架 复制链接 设置热门
return str + changeStatus + changeHot + link ;
}
}
... ... @@ -279,6 +295,31 @@
changeStatus(row);
}
});
//设置 取消热门
$(this).datagrid("getPanel").find("a[role='changeHot']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var index = $(this).attr("index");
var row = $("#labelListTable").datagrid('getData').rows[index];
row.status = $(this).attr("changedStatus");
changeHot(row);
}
});
$("[role='copy']").zclip({
path: contextPath + '/js/jquery/ZeroClipboard.swf',
copy: function(){
return $(this).attr("copyValue");
},
afterCopy: function(){
$.messager.show({
title: "提示",
msg: "复制成功!",
height:120
});
}
});
}
});
... ... @@ -318,6 +359,36 @@
}
// 设置 取消 热门
function changeHot(data) {
var param = {
id: data.id,
isHot: data.status
};
$.post(serverContextPath + "/grassTopicManage/changeTopicHotStatus", param, function (data) {
//数据填到框框里面
// debugger
if (data.code == 200) {
//刷新table
$("#labelListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: "更新成功!",
height: 120
});
} else {//
$.messager.alert("失败", data.message, "error");
}
}, "json");
}
// 编辑分组
function getEditDialog(data) {
var labelList = $("<div id='labelList'>").appendTo($(document.body));
... ...