Authored by mlge

种草--话题修改

package com.yohobuy.platform.grass.restapi;
import com.yohobuy.platform.dal.grass.model.GrassTopic;
import com.yohobuy.platform.grass.service.ITopicService;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
... ... @@ -14,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* Created by meiling.ge on 2019/1/8.
*/
... ... @@ -41,17 +39,11 @@ public class GrassTopicController {
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/grassTopicById")
@RequestMapping("/changeTopicStatus")
@ResponseBody
public ApiResponse grassTopicById(GrassTopicReq req){
TopicRespBo resp = topicService.grassTopicById(req);
return new ApiResponse.ApiResponseBuilder().data(resp).build();
public ApiResponse changeTopicStatus(@RequestBody GrassTopicReq req){
topicService.changeTopicStatus(req);
return new ApiResponse.ApiResponseBuilder().build();
}
/*@RequestMapping("/getAllTopic")
@ResponseBody
public ApiResponse getAllTopic(){
List<TopicRespBo> result = topicService.getAllTopic();
return new ApiResponse.ApiResponseBuilder().data(result).build();
}*/
}
... ...
... ... @@ -29,7 +29,7 @@ public class TopicGroupController {
@RequestMapping("/getTopicGroupList")
@ResponseBody
public ApiResponse getTopicGroupList( TopicGroupReq req){
public ApiResponse getTopicGroupList(@RequestBody TopicGroupReq req){
logger.info("enter getTopicGroupList,req={}",req);
PageResponseVO<TopicGroupBo> result = topicGroupService.getTopicGroupList(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
... ... @@ -37,7 +37,7 @@ public class TopicGroupController {
@RequestMapping("/addUpTopicGroup")
@ResponseBody
public ApiResponse addUpTopicGroup( TopicGroupReq req){
public ApiResponse addUpTopicGroup(@RequestBody TopicGroupReq req){
logger.info("enter addUpTopicGroup,req={}",req);
return topicGroupService.addUpTopicGroup(req);
... ... @@ -45,13 +45,9 @@ public class TopicGroupController {
@RequestMapping("/deleteTopicGroup")
@ResponseBody
public ApiResponse deleteTopicGroup( TopicGroupReq req){
public ApiResponse deleteTopicGroup(@RequestBody TopicGroupReq req){
logger.info("enter updatePacketStatus,req = {}", req);
int flag = topicGroupService.deleteTopicGroup(req);
if(flag == 2){
return new ApiResponse.ApiResponseBuilder().code(403).message("该分组下存在标签,删除失败!").build();
}
return new ApiResponse.ApiResponseBuilder().build();
return topicGroupService.deleteTopicGroup(req);
}
/**
... ...
... ... @@ -15,7 +15,7 @@ public interface ITopicGroupService {
ApiResponse addUpTopicGroup(TopicGroupReq req);
int deleteTopicGroup(TopicGroupReq req);
ApiResponse deleteTopicGroup(TopicGroupReq req);
List<TopicGroupBo> getAllTopicGroupInfo();
}
... ...
... ... @@ -15,9 +15,8 @@ import java.util.List;
public interface ITopicService {
PageResponseVO<TopicRespBo> getGrassTopicList(GrassTopicReq req);
List<TopicRespBo> getAllTopic();
void addUpGrassTopic(GrassTopicReq req);
TopicRespBo grassTopicById(GrassTopicReq req);
void changeTopicStatus(GrassTopicReq req);
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yohobuy.platform.grass.service.impl;
import com.yohobuy.platform.common.util.BeanTool;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.dal.grass.IGrassTopicDAO;
import com.yohobuy.platform.dal.grass.IGrassTopicGroupDAO;
import com.yohobuy.platform.dal.grass.model.TopicGroup;
import com.yohobuy.platform.grass.service.ITopicGroupService;
... ... @@ -28,6 +29,9 @@ public class TopicGroupServiceImpl implements ITopicGroupService {
@Autowired
private IGrassTopicGroupDAO topicGroupDAO ;
@Autowired
private IGrassTopicDAO topicDAO ;
@Override
public PageResponseVO<TopicGroupBo> getTopicGroupList(TopicGroupReq req) {
logger.info("getTopicGroupList req={}",req);
... ... @@ -77,16 +81,16 @@ public class TopicGroupServiceImpl implements ITopicGroupService {
}
@Override
public int deleteTopicGroup(TopicGroupReq req) {
public ApiResponse deleteTopicGroup(TopicGroupReq req) {
logger.info("enter deleteTopicGroup id={}", req.getId());
Integer id = req.getId();
TopicGroup topicGroup = topicGroupDAO.selectByPrimaryKey(id);
if(topicGroup.getTopicAmount() > 0){
return 2;
int count = topicDAO.countByGroupId(id);
if(count > 0){
return new ApiResponse.ApiResponseBuilder().code(403).message("该分组下存在话题,禁止删除!").build();
}
topicGroupDAO.deleteByPrimaryKey(id);
logger.info("deleteTopicGroup success! id={}", req.getId());
return 1;
return new ApiResponse.ApiResponseBuilder().build();
}
... ...
... ... @@ -6,9 +6,8 @@ import com.yohobuy.platform.common.util.BeanTool;
import com.yohobuy.platform.common.util.CollectionUtil;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.common.util.StringUtil;
import com.yohobuy.platform.dal.grass.IGrassLabelDAO;
import com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO;
import com.yohobuy.platform.dal.grass.IGrassTopicDAO;
import com.yohobuy.platform.dal.grass.*;
import com.yohobuy.platform.dal.grass.model.GrassArticle;
import com.yohobuy.platform.dal.grass.model.GrassLabel;
import com.yohobuy.platform.dal.grass.model.GrassTopic;
import com.yohobuy.platform.grass.service.ITopicService;
... ... @@ -42,20 +41,23 @@ public class TopicServiceImpl implements ITopicService {
private IGrassTopicDAO grassTopicDAO;
@Autowired
private IGrassLabelDAO grassLabelDAO;
private IGrassTopicGroupDAO topicGroupDAO;
@Override
public PageResponseVO<TopicRespBo> getGrassTopicList(GrassTopicReq req) {
logger.info("enter getGrassTopicList req={}",req);
Integer status = req.getStatus() == null || req.getStatus() == 8 ? null : req.getStatus();
Integer isOfficial = req.getIsOfficial() == null || req.getIsOfficial() == 8 ? null : req.getIsOfficial();
String topicName = req.getTopicName();
Integer status = req.getStatus();
String groupName = req.getGroupName();
Integer startTime = req.getStartTime();
Integer endTime = req.getEndTime();
int total = grassTopicDAO.CountByCondition(topicName,status,startTime,endTime);
int total = grassTopicDAO.countByCondition(status,isOfficial,topicName,groupName,startTime,endTime);
List<TopicRespBo> pageData = new ArrayList<>();
if(total > 0){
List<GrassTopic> list = grassTopicDAO.selectByPageCondition(topicName,status,startTime,endTime,req.getStart(),req.getSize());
List<GrassTopic> list = grassTopicDAO.selectByPageCondition(status,isOfficial,topicName,groupName,startTime,endTime,req.getStart(),req.getSize());
pageData = convertTopicRespBo(list);
}
PageResponseVO responseVO = new PageResponseVO();
... ... @@ -67,18 +69,6 @@ public class TopicServiceImpl implements ITopicService {
return responseVO;
}
@Override
public List<TopicRespBo> getAllTopic() {
List<GrassTopic> topicList = grassTopicDAO.selectUsingTopics();
List<TopicRespBo> rspList = Lists.newArrayList();
topicList.forEach(grassTopic -> {
TopicRespBo bo = new TopicRespBo();
bo.setId(grassTopic.getId());
bo.setTopicName(grassTopic.getTopicName());
rspList.add(bo);
});
return rspList;
}
@Override
public void addUpGrassTopic(GrassTopicReq req) {
... ... @@ -87,83 +77,40 @@ public class TopicServiceImpl implements ITopicService {
record.setId(req.getId());
record.setTopicName(req.getTopicName());
record.setTopicDesc(req.getTopicDesc());
record.setStatus(req.getStatus());
String relatedLabels = "";
//一定要关联标签(前台)
//每个标签id都不能为空,标签id 不能重复(前台没有做判断)
if(StringUtils.isNotEmpty(req.getRelatedLabels()) && StringUtils.endsWith(req.getRelatedLabels(),",")){
String[] str = StringUtils.split(req.getRelatedLabels(),",");
Set<String> labelSet = new HashSet<>();
for(String s : str){
if(StringUtils.isNotEmpty(s)){//前台可能传递重复的或者空值
labelSet.add(s);
}
}
for(String labelId : labelSet){
relatedLabels += labelId + ",";
}
// relatedLabels = StringUtils.substring(relatedLabels, 0,relatedLabels.length() -1);
}
record.setRelatedLabels(relatedLabels);
record.setTopicImageUrl(req.getTopicImageUrl());
record.setRelatedGroup(req.getRelatedGroup());
record.setViewModel(req.getViewModel());
record.setIsOfficial(req.getIsOfficial() == null ? 0 : req.getIsOfficial());
record.setAllowAttention(req.getAllowAttention()== null ? 0 : req.getAllowAttention());
record.setShowAttAmount(req.getShowAttAmount()== null ? 0 : req.getShowAttAmount());
if(req.getId() == null){
record.setArticleAmount(0);
record.setAttAmount(0);
record.setStatus(0);
record.setCreateTime(DateUtil.getCurrentTimeSeconds());
topicGroupDAO.updateTopicNum(req.getRelatedGroup(),true);
grassTopicDAO.insert(record);
logger.info("addUpGrassTopic add success! req={}",req);
}else{
record.setUpdateTime(DateUtil.getCurrentTimeSeconds());
GrassTopic grassTopic = grassTopicDAO.selectByPrimaryKey(req.getId());
//更改分组
if(grassTopic.getRelatedGroup().intValue() != req.getRelatedGroup().intValue()){
//分组计数
topicGroupDAO.updateTopicNum(grassTopic.getRelatedGroup(),false);
topicGroupDAO.updateTopicNum(req.getRelatedGroup(),true);
}
grassTopicDAO.updateByPrimaryKeySelective(record);
logger.info("addUpGrassTopic update success! req={}",req);
}
}
/**
* 获取话题的详细信息
* @param req
* @return
*/
@Override
public TopicRespBo grassTopicById(GrassTopicReq req) {
logger.info("enter grassTopicById req={}", req);
if(req == null || req.getId() == null){
return null;
}
Integer topicId = req.getId();
GrassTopic grassTopic = grassTopicDAO.selectByPrimaryKey(topicId);
if(grassTopic == null){//没找到
logger.warn("grassTopicById topic not exists topicId={} ", topicId);
return null;
}
//返回结果
TopicRespBo bo = new TopicRespBo();
BeanUtils.copyProperties(grassTopic,bo);
bo.setCreateTimeStr(grassTopic.getCreateTime() == null ? "" : DateUtil.int2DateStr(grassTopic.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
//关联的标签
String relatedLabels = grassTopic.getRelatedLabels();
if(StringUtils.isNotEmpty(relatedLabels)){
List<String> list = Arrays.asList(StringUtils.split(relatedLabels,","));
Set<Integer> labelSet = list.stream().filter(o -> StringUtils.isNotBlank(o)).map(org.apache.commons.lang3.math.NumberUtils::toInt).collect(Collectors.toSet());
if(CollectionUtils.isNotEmpty(labelSet)){
//查询label名称
List<GrassLabel> labelList = grassLabelDAO.selectBatchByIds(labelSet);
List<TopicRespBo.LabelInfo> labelInfoList = new ArrayList<>();
for(GrassLabel grassLabel : labelList){
TopicRespBo.LabelInfo labelInfo = new TopicRespBo.LabelInfo(grassLabel.getId(), grassLabel.getLabelName());
labelInfoList.add(labelInfo);
}
bo.setLabelInfoList(labelInfoList);
}
}
return bo;
public void changeTopicStatus(GrassTopicReq req) {
logger.info("enter changeTopicStatus , req={}", req);
Integer id = req.getId();
Integer status = req.getStatus();
grassTopicDAO.changeStatus(id,status);
}
//转换
... ... @@ -172,39 +119,17 @@ public class TopicServiceImpl implements ITopicService {
return new ArrayList<>();
}
List<TopicRespBo> result = new ArrayList<>();
Set<Integer> labelIdSet = new HashSet<>();
List<Integer> topicId = sourceList.stream().map(GrassTopic::getId).distinct().collect(Collectors.toList());
//查询文章表 统计话题下的文章数(不考虑文章状态)
for(GrassTopic grassTopic : sourceList){
TopicRespBo bo = new TopicRespBo();
BeanUtils.copyProperties(grassTopic,bo);
bo.setCreateTimeStr(grassTopic.getCreateTime() == null ? "" : DateUtil.int2DateStr(grassTopic.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
String relatedLabels = grassTopic.getRelatedLabels();
//关联的标签id
if(StringUtils.isNotEmpty(relatedLabels)){
List<String> list = Arrays.asList(StringUtils.split(relatedLabels,","));
List<Integer> labelIdList = list.stream().filter(o -> StringUtils.isNotBlank(o)).map(org.apache.commons.lang3.math.NumberUtils::toInt).collect(Collectors.toList());
bo.setRelatedLabelIdList(labelIdList);
labelIdSet.addAll(labelIdList);
}
bo.setUpdateTimeStr(grassTopic.getUpdateTime() == null ? "" : DateUtil.int2DateStr(grassTopic.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
result.add(bo);
}
//从标签表中查询数据
if(CollectionUtils.isNotEmpty(labelIdSet)){
//查询label名称
List<GrassLabel> labelList = grassLabelDAO.selectBatchByIds(labelIdSet);
Map<Integer,String> labelMap = labelList.stream().collect(Collectors.toMap(GrassLabel::getId, obj -> obj.getLabelName()));
//用于前端展示
for(TopicRespBo bo : result){
List<TopicRespBo.LabelInfo> labelInfoList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(bo.getRelatedLabelIdList())){
for(Integer labelId : bo.getRelatedLabelIdList()){
TopicRespBo.LabelInfo labelInfo = new TopicRespBo.LabelInfo(labelId,labelMap.get(labelId) );
labelInfoList.add(labelInfo);
}
}
bo.setLabelInfoList(labelInfoList);
}
}
return result;
}
}
... ...
... ... @@ -17,39 +17,52 @@
<td>
<span style="color:red">*</span><label>话题描述</label> <br>
<textarea id="topicDesc" name="topicDesc" style="width: 380px;" rows="6" placeholder=""
required="true" maxlength="500"></textarea>
required maxlength="100"></textarea>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>图片</label> <br>
<span style="color:red">*</span><label>背景图</label> <br>
<div id="imageUpload">
</div>
<!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>-->
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>话题分组</label><br>
<tr style="height: 80px">
<input class="easyui-combobox" id="relatedGroup" name="relatedGroup">
</input>
<!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>-->
</td>
</tr>
<td>
<span style="color:red">*</span><label>关联标签</label> <br>
<div id="relatedLabelsDiv">
<span>已选择:</span><br>
<div id="labelListDiv" style="margin-bottom: 10px; height:40px ">
</div>
<tr style="height: 60px">
</div>
<td >
<input value="1" type="checkbox" id="isOfficial" name="isOfficial" >官方话题</input>
</td>
</tr>
<input id="labelId" name="labelId" class="easyui-combobox" style="width:380px "/>
<!--<a id="searchLabelBtn" class="btn-info">+选择标签</a>-->
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>列表模式</label><br>
<input value="0" type="radio" name="viewModel">大图详情</input>
<input value="1" type="radio" name="viewModel" required="true">小图列表</input>
</td>
</tr>
<tr style="height: 60px">
<td >
<input value="1" type="checkbox" id="showAttAmount" name="showAttAmount">展示参与人数</input>
<input value="1" type="checkbox" id="allowAttention" name="allowAttention" >允许用户关注</input>
</td>
</tr>
</table>
</div>
</form>
... ... @@ -59,7 +72,6 @@
<script>
var topicId = getUrlParam("topicId");
$(function () {
$("#topicName").textbox({
... ... @@ -68,6 +80,28 @@
prompt: "请输入话题名称"
});
/* $("#topicDesc").textarea({
required: true,
maxLength: 100,
missingMessage: "话题描述不能为空,并小于100字",
prompt: "请输入话题名称"
});*/
$("#relatedGroup").combobox({
valueField : "id",
textField : "groupName",
required:true,
prompt: "请选择话题分组",
url : serverContextPath + "/topicGroupManage/getAllTopicGroupInfo",
loadFilter: function (data) {
var data = defaultLoadFilter(data);
data.unshift({'id': '', 'groupName': '--请选择分组--'});
return data;
}
});
$("#imageUpload").imageUpload({
width: 171,
... ... @@ -75,7 +109,7 @@
realInputName: "topicImageUrl",
url: serverContextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "activity"
bucket: "grassImg"
},
onBeforeSubmit: function () {
$.messager.progress({
... ... @@ -106,293 +140,36 @@
}
});
$("#labelId").combobox({
prompt: "请选择标签",
required: false,
selectOnNavigation: true,
valueField: 'id',
textField: 'labelName',
multiple: true,
url: serverContextPath + "/grassLabelManage/getAllGrassLabelInfo",
onSelect: function (newVal, oldVal) {//选中事件
debugger
labelChange(newVal, oldVal);
// //被选中的值
// var selectedValue = data;
// //被选中的文本
// var allData = $(this).combobox('getData');
// console.log("aa" + aa);
},
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
var data = paramObject.mkData;
if (data) {//编辑窗口
$("#topicName").textbox("setValue", data.topicName);
$("#topicDesc").html(data.topicDesc);
//图片
$("#imageUpload").imageUpload('setValue', data.topicImageUrl);
// //已经选择的标签
debugger
var labelInfoList = data.labelInfoList;
if (labelInfoList != null) {
for (var i = 0; i < labelInfoList.length; i++) {
var tempId = labelInfoList[i].labelId;
var tempName = labelInfoList[i].labelName;
var choosedTagSpan = '<span class="tag" role="choose" style="margin-left: 10px;font-size: 14px" name="choosedTag" data-labelId="' + tempId + '" data-labelName="' + tempName + '"><span style="background-color: #1caf9a;color: white;font-size: 14px">' + tempName + '</span><a href="#" style="background-color: #1caf9a;font-size: 14px" title="Removing tag" data-index="0" class="removetag">x</a></span>';
$("#labelListDiv").append(choosedTagSpan);
}
$("#relatedGroup").combobox('setValue', data.relatedGroup);
if(data.isOfficial == 1){
$("#isOfficial").attr("checked",true)
}
}
$("input[name='viewModel'][value='"+data.viewModel+"']").attr("checked", "checked").parent().addClass('checked');
if(data.showAttAmount == 1){
$("#showAttAmount").attr("checked",true)
}
/* //查询标签列表
$("#searchLabelBtn").linkbutton({
iconCls: "icon-search",
onClick: function () {
chooseLabels();
}
});*/
// //新建--修改话题--提交
// $("#subBotton").linkbutton({
// iconCls: "icon-save",
// width: 100,
// onClick: function () {
// $("#topicForm").form("submit", {
// url: serverContextPath + "/grassTopicManage/addUpGrassTopic",
// onSubmit: function (param) {
// debugger;
// //1)表单基本检查
// if (!$("#topicForm").form("validate")) {
// return false;
// }
//
// //2)是否上传了图片
// var imageCount = 0;
// $("input[name='topicImageUrl']").each(function (j, item) {
// var url = item.value;
// if (url != '') {
// imageCount++;
// }
// });
// if (imageCount == 0) {
// $.messager.alert("保存失败", "至少要选择一张图片", "error");
// return false;
//
// }
// //3)是否选择了标签
// var relatedLabels = "";
// var tagCount = 0;
// $("#taglist").find("span[role='choose']").each(function (item, index) {
// debugger
// var tempId = $(this).attr('data-labelid');
// if (tempId != null) {
// tagCount++;
// relatedLabels += tempId + ",";
// }
// });
//
// if (tagCount == 0 || tagCount > 5) {
// $.messager.alert("保存失败", "至少选择一个标签,最多5个", "error");
// return false;
// }
//
// param.relatedLabels = relatedLabels;
// param.id = topicId;
// return true;
//
//
// },
// success: function (data) {
// if (data) {
// data = $.parseJSON(data);
// if (data.code == 200) {
// $.messager.alert("提示", "保存成功", "info", function () {
// window.location.reload()
// });
// // alert("保存成功");
//
//
// } else {
// $.messager.alert("保存失败", data.message, "error");
// }
// } else {
// $.messager.alert("保存失败", data.message, "error");
// }
// }
// });
//
// }
// });
// //编辑话题
// if (topicId != "null") {//去加载数据
// var title = "修改话题";
// $("#titleSpan").html(title);
// //加载数据
// $.ajax({
// type: "get",
// url: serverContextPath + "/grassTopicManage/grassTopicById?id=" + topicId,
// success: function (data) {
// debugger
// if (data != null && data.code == 200) {//成功的
// var detailInfo = data.data;
// $("#topicName").textbox("setValue", detailInfo.topicName);
// $("#topicDesc").html(detailInfo.topicDesc);
// //图片
// $("#imageUpload").imageUpload('setValue', detailInfo.topicImageUrl);
//
// //已经选择的标签
// var labelInfoList = detailInfo.labelInfoList;
// if(labelInfoList!=null){
// for (var i = 0; i < labelInfoList.length; i++) {
// var tempId = labelInfoList[i].labelId;
// var tempName = labelInfoList[i].labelName;
// var choosedTagSpan = '<span class="tag" role="choose" style="margin-left: 10px" name="choosedTag" data-labelId="' + tempId + '" data-labelName="' + tempName + '"><span style="background-color: #1caf9a;color: white">' + tempName + '</span><a href="#" style="background-color: #1caf9a" title="Removing tag" data-index="0" class="removetag">x</a></span>';
// $("#taglist").append(choosedTagSpan);
//
// }
// }
//
//
//
// }
// }
// });
//
//
// }
$(document).on('click', '.removetag', function () {
// $(this).remove();
$(this).closest(".tag").remove();
});
if(data.allowAttention == 1){
$("#allowAttention").attr("checked",true)
}
}
});
// //选择标签列表
// function chooseLabels() {
// var chooseLabelList = $("<div id='chooseLabelList'>").appendTo($(document.body));
// var chooseLabelList = $("<div id='chooseLabelList'>").appendTo($(document.body));
// var title = "选择标签";
// $("#chooseLabelList").myDialog({
// title: title,
// width: "60%",
// height: "70%",
// resizable: false,
// buttons: [{
// id: "saveChooseLabelBtn",
// text: "保存",
// iconCls: "icon-save",
// handler: function () {
// //确定保存之前,要把之前已经选择的标签清空
//
// $("#taglist").html("");
// //做相应的处理 回填信息--所有被选择的复选框
// var tempHtml = $("#choosedDiv").html();
// debugger
// $("#taglist").html(tempHtml);
// /* $("#taglist").find("span[role='choose']").each(function (item, index) {
// $(item).val(picTextData[index][$(item).attr('data-')]);
// });*/
//
//
// $(chooseLabelList).dialog("close");
//// $.messager.show({
//// title: "提示",
//// msg: title + "成功!",
//// height: 120
//// });
// }
// }, {
// id: "closeChooseBtn",
// text: "关闭",
// iconCls: "icon-cancel",
// handler: function () {
// $.messager.confirm("确认", "确认关闭吗?", function (flag) {
// if (flag) {
// $(chooseLabelList).dialog("close");
// }
// });
// }
// }],
// modal: true,
// href: contextPath + "/html/grass/labelManage/chooseLabels.html",
// });
//
// }
//获取url中的参数方法
function getUrlParam(name) {
//构造一个含有目标参数的正则表达式对象
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
//匹配目标参数
var r = window.location.search.substr(1).match(reg);
//返回参数
if (r != null) {
return unescape(r[2]);
} else {
return null;
}
}
function labelChange(newVal, oldVal) {
//newVal---是指新增加的值
if (newVal == null) {
return;
}
//新增加的数据
var selectedValue = newVal;
var tempId = selectedValue.id;
var tempName = selectedValue.labelName;
var divStr = '<span class="tag" role="choose" style="margin-left: 10px;font-size: 14px" name="choosedTag" data-labelId="' + tempId + '" data-labelName="' + tempName + '"><span style="background-color: #1caf9a;color: white;font-size: 14px">' + tempName + '</span><a href="#" style="background-color: #1caf9a;font-size: 14px" title="Removing tag" data-index="0" class="removetag">x</a></span>';
//新增加的数据
$("#labelListDiv").append(divStr);
// //新增加的数据
// var selectedValue = newVal;
//
// //被选中的文本
// var allData = $("#labelId").combobox('getData');
// //
// var divStr = "";
// for(var i = 0; i< selectedValue.length; i++){
//
//
// var tempId = selectedValue[i];
// if(tempId == null){//搜索的时候 有可能把搜索项给写进去了
// continue;
// }
// //找出对应的文本
// var tempName="";
//
// for(var j = 0; j< allData.length; j++){
// if(selectedValue[i] == allData[j].id){
// tempName = allData[j].labelName;
// break;//跳出循环
// }
// }
// //把文本写到已选择的里面去
// divStr += '<span class="tag" role="choose" style="margin-left: 10px;font-size: 14px" name="choosedTag" data-labelId="' + tempId + '" data-labelName="' + tempName + '"><span style="background-color: #1caf9a;color: white;font-size: 14px">' + tempName + '</span><a href="#" style="background-color: #1caf9a;font-size: 14px" title="Removing tag" data-index="0" class="removetag">x</a></span>';
// }
//
//
// $("#labelListDiv").html(divStr);
}
});
</script>
... ...
... ... @@ -32,13 +32,19 @@
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-textbox" id="topicNameParam" style="width: 140px">
<input class="easyui-combobox" id="statusParam">
</input>
<input class="easyui-combobox" id="isOfficialParam">
</input>
<input class="easyui-combobox" id="statusParam">
<input class="easyui-textbox" id="topicNameParam" style="width: 140px">
</input>
<input class="easyui-textbox" id="topicGroupParam" style="width: 140px">
</input>
<span>最近修改时间</span>
<input id="startTimeStr" name="startTimeStr" class="easyui-datetimebox" data-options="prompt:'开始时间'"/>
~ &nbsp;
... ... @@ -75,19 +81,34 @@
}
});
$("#topicNameParam").textbox({
$("#statusParam").combobox({
valueField: "value",
textField: "text",
required: false,
prompt: "请输入话题名称"
prompt: "请选择状态",
data: [{text: "请选择状态", value: "8"}, {text: "进行中", value: "1"}, {text: "已下架", value: "0"}]
});
$("#statusParam").combobox({
$("#isOfficialParam").combobox({
valueField: "value",
textField: "text",
required: false,
prompt: "请选择状态",
data: [{text: "请选择状态", value: ""}, {text: "进行中", value: "1"}, {text: "已下架", value: "0"}]
prompt: "是否官方",
data: [{text: "全部", value: "8"}, {text: "官方", value: "1"}, {text: "非官方", value: "0"}]
});
$("#topicNameParam").textbox({
required: false,
prompt: "请输入话题名称"
});
$("#topicGroupParam").textbox({
required: false,
prompt: "请输入分组名称"
});
$("#searchBtn").linkbutton({
iconCls: "icon-search",
onClick: function () {
... ... @@ -100,8 +121,10 @@
endTime = parseInt(new Date($("#endTimeStr").datetimebox('getValue')).getTime() / 1000);
}
$("#labelListTable").datagrid("load", {
topicName: $("#topicNameParam").textbox("getValue"),
status: $("#statusParam").combobox("getValue"),
isOfficial: $("#isOfficialParam").combobox("getValue"),
topicName: $("#topicNameParam").textbox("getValue"),
groupName: $("#topicGroupParam").textbox("getValue"),
startTime: startTime,
endTime: endTime
});
... ... @@ -133,7 +156,7 @@
},
columns: [[
{
title: "ID",
title: "话题ID",
field: "id",
width: 15,
align: "center"
... ... @@ -160,24 +183,25 @@
}
},
{
title: "关联标签",
field: "labelInfoList",
title: "话题分组",
field: "groupName",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
var str = "";
for (var i = 0; i < value.length; i++) {
str += value[i].labelName + "&nbsp;&nbsp;";
}
return str;
}
}, {
title: "创建时间",
field: "createTimeStr",
align: "left"
},
{
title: "最近修改时间",
field: "updateTimeStr",
width: 25,
align: "left"
}, {
},
{
title: "参与人数",
field: "articleAmount",
width: 25,
align: "left"
},
{
title: "关注人数",
field: "attAmount",
width: 25,
align: "left"
... ... @@ -190,7 +214,7 @@
if (value == 1) {
return "进行中";
} else {
return "下架";
return "下架";
}
}
... ... @@ -205,9 +229,14 @@
var changeStatus = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='0' dataId='" + rowData.id + "' index='" + rowIndex + "'>下架</a>";
;
if (rowData.status == 0) {
changeStatus = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>上架</a>";
changeStatus = "<a role='changeStatus' style='margin-left:10px;background-color: #c4ddff' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>上架</a>";
}
return str + changeStatus;
str += changeStatus;
// str += "<a role='' style='margin-left:10px;background-color: #ffa951' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>复制链接</a>" ;
return str ;
}
}
... ... @@ -391,7 +420,7 @@
status: data.status
};
$.post(serverContextPath + "/grassTopicManage/addUpGrassTopic", param, function (data) {
$.post(serverContextPath + "/grassTopicManage/changeTopicStatus", param, function (data) {
//数据填到框框里面
// debugger
if (data.code == 200) {
... ... @@ -419,7 +448,7 @@
var labelList = $("<div id='labelList'>").appendTo($(document.body));
var title = data == null ? "新建话题" : "修改话题";
var textVar = data == null ? "保存" : "保存";
var msgVar = data == null ? "确认新增标签吗?" : "确认保存标签吗?";
var msgVar = data == null ? "确认新增话题吗?" : "确认保存话题吗?";
window.self.paramObject.mkData = data;
$(labelList).myDialog({
... ... @@ -445,6 +474,13 @@
return false;
}
//话题描述
var topicDesc = $("#topicDesc").val();
if(topicDesc == null || topicDesc =="" || topicDesc.length > 100){
$.messager.alert("保存失败", "话题描述不能为空,且小于100字", "error");
return false;
}
//2)是否上传了图片
var imageCount = 0;
$("input[name='topicImageUrl']").each(function (j, item) {
... ... @@ -458,24 +494,14 @@
return false;
}
//3)是否选择了标签
var relatedLabels = "";
var tagCount = 0;
$("#labelListDiv").find("span[role='choose']").each(function (item, index) {
debugger
var tempId = $(this).attr('data-labelid');
if (tempId != null) {
tagCount++;
relatedLabels += tempId + ",";
}
});
if (tagCount == 0 || tagCount > 5) {
$.messager.alert("保存失败", "至少选择一个标签,最多5个", "error");
var group = $("#relatedGroup").combobox("getValue");
if( group == null || group == ""){
$.messager.alert("保存失败", "请选择分组", "error");
return false;
}
param.relatedLabels = relatedLabels;
$.messager.progress({
... ...