Authored by 张帅

merge

... ... @@ -23,24 +23,22 @@
<dependencies>
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-common</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-server</artifactId>
</dependency>
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-common</artifactId>
</dependency>
</dependencies>
</project>
... ...
package com.yohobuy.platform.grass.restapi;
import com.yohobuy.platform.grass.service.IlabelGroupService;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.LabelGroupReq;
import com.yohobuy.platform.model.grass.response.LabelGroupBo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by meiling.ge on 2019/1/8.
*/
@Controller
@RequestMapping("/labelGroupManage")
public class LabelGroupController {
private static Logger logger = LoggerFactory.getLogger(LabelGroupController.class);
@Autowired
private IlabelGroupService labelGroupService;
@RequestMapping("/getLabelGroupList")
@ResponseBody
public ApiResponse getLabelGroupList(LabelGroupReq req){
logger.info("enter getRedpacketList,req={}",req);
PageResponseVO<LabelGroupBo> result = labelGroupService.getLabelGroupList(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/addUpLabelGroup")
@ResponseBody
public ApiResponse addUpLabelGroup(LabelGroupReq req){
logger.info("enter getRedpacketList,req={}",req);
labelGroupService.addUpLabelGroup(req);
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/deleteLabelGroup")
@ResponseBody
public ApiResponse deleteLabelGroup(LabelGroupReq req){
logger.info("enter updatePacketStatus,req = {}", req);
labelGroupService.deleteLabelGroup(req);
return new ApiResponse.ApiResponseBuilder().build();
}
}
... ...
package com.yohobuy.platform.grass.service;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.LabelGroupReq;
import com.yohobuy.platform.model.grass.response.LabelGroupBo;
/**
* Created by meiling.ge on 2019/1/8.
*/
public interface IlabelGroupService {
PageResponseVO<LabelGroupBo> getLabelGroupList(LabelGroupReq req);
void addUpLabelGroup(LabelGroupReq req);
void deleteLabelGroup(LabelGroupReq req);
}
... ...
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.IGrassLabelGroupDAO;
import com.yohobuy.platform.dal.grass.model.LabelGroup;
import com.yohobuy.platform.grass.service.IlabelGroupService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.LabelGroupReq;
import com.yohobuy.platform.model.grass.response.LabelGroupBo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by meiling.ge on 2019/1/8.
*/
@Service
public class LabelGroupServiceImpl implements IlabelGroupService {
private static final Logger logger = LoggerFactory.getLogger(LabelGroupServiceImpl.class);
@Autowired
private IGrassLabelGroupDAO grassLabelGroupDAO;
@Override
public PageResponseVO<LabelGroupBo> getLabelGroupList(LabelGroupReq req) {
logger.info("getLabelGroupList req={}",req);
String groupName = req.getGroupName();
int total = grassLabelGroupDAO.CountByCondition(groupName);
List<LabelGroup> list = new ArrayList();
if(total > 0){
list = grassLabelGroupDAO.selectByPageCondition(groupName, req.getStart(), req.getSize());
}
List<LabelGroupBo> respList = BeanTool.copyList(list, LabelGroupBo.class);
PageResponseVO<LabelGroupBo> result = new PageResponseVO<>();
result.setList(respList);
result.setTotal(total);
result.setSize(req.getSize());
result.setPage(req.getPage());
logger.info("getLabelGroupList success! req={},total={},respList.size={}",req, total, respList.size());
return result;
}
@Override
public void addUpLabelGroup(LabelGroupReq req) {
logger.info("enter addUpLabelGroup req={}", req);
Integer id = req.getId();
LabelGroup record = new LabelGroup();
record.setId(id);
record.setGroupName(req.getGroupName());
record.setStatus(req.getStatus());
if(id != null && id > 0 ){//修改
record.setUpdateTime(DateUtil.getCurrentTimeSeconds());
grassLabelGroupDAO.updateByPrimaryKeySelective(record);
logger.info("addUpLabelGroup update success! req={}, record={}", req, record);
}else{//新增
record.setCreateTime(DateUtil.getCurrentTimeSeconds());
record.setLabelAmount(0);
grassLabelGroupDAO.insert(record);
logger.info("addUpLabelGroup insert success! req={}, record={}", req, record);
}
}
@Override
public void deleteLabelGroup(LabelGroupReq req) {
logger.info("enter deleteLabelGroup id={}", req.getId());
grassLabelGroupDAO.deleteByPrimaryKey(req.getId());
logger.info("deleteLabelGroup success! id={}", req.getId());
}
}
... ...
... ... @@ -29,6 +29,10 @@
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-grass</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-suggest</artifactId>
</dependency>
<dependency>
... ...
... ... @@ -329,6 +329,7 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassArticleDao
- com.yohobuy.platform.dal.grass.IGrassArticleImageDao
- com.yohobuy.platform.dal.grass.IGrassArticleSknDao
- com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO
yhb_promotion:
servers:
... ...
... ... @@ -328,6 +328,7 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassArticleDao
- com.yohobuy.platform.dal.grass.IGrassArticleImageDao
- com.yohobuy.platform.dal.grass.IGrassArticleSknDao
- com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO
yhb_promotion:
servers:
... ...
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="activityAddForm" id="activityAddForm" method="post" enctype="multipart/form-data">
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>分组名称</label> <br>
<input id="groupName" name="groupName" class="easyui-textbox" style="width: 380px;"/>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>标签状态</label> <br>
<input type="radio" value="1" checked name="status" style="width:30px">开启</input>
<input type="radio" value="0" name="status" style="width:30px">关闭</input>
</td>
</tr>
</table>
</div>
</form>
</div>
<script>
$(function () {
$("#groupName").textbox({
required: true,
missingMessage: "分组名称不能为空",
prompt: "请输入分组名称"
});
var data = paramObject.mkData;
if (data){
$("#groupName").textbox("setValue", data.groupName);
if(data.status == 0){
$(":radio[name='status'][value='0']").prop("checked",true);
}else if(data.status == 1){
$(":radio[name='status'][value='1']").prop("checked",true);
}
}
});
</script>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout" >
<div region="north" style="height: 200px;">
<script>
document.write(addHead('运营管理', '标签分组管理'));
</script>
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-textbox" id="groupNameSearch" style="width: 140px">
</input>
<a id="searchBtn" class="btn-info">查询</a>
<!--<a id="addActivityBtn" class="btn-success">新增</a>-->
<a id="allBtn" class="btn-info">全部</a>
</div>
<div style="margin-left: 20px;margin-top: 10px">
<a id="addBtn" class="btn-long" style="background-color: #5CB85C;">+新建标签分组</a>
</div>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<table id="labelGroupListTable"></table>
</div>
</body>
<script>
$(function() {
//用于页面刷新后的数据行定位
var index ="";
$("#allBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#labelGroupListTable").datagrid("load", {});
}
});
$("#groupNameSearch").textbox({
required:false,
prompt: "请输入标签分组名称"
});
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#labelGroupListTable").datagrid("load", {
groupName: $("#groupNameSearch").textbox("getValue")
});
}
});
$("#addBtn").click(function () {
getEditDialog(null);
});
// 检索按钮
$("#labelGroupListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
/*queryParams: {
rewardName: $("#rewardName1").textbox("getValue"),
status: $("#rewardstatus1").combobox("getValue"),
type: $("#rewardtype1").combobox("getValue")
},*/
url: contextPath + "/labelGroupManage/getLabelGroupList",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list;
return tmp;
},
columns: [[
{
title: "ID",
field: "id",
width: 15,
align: "center"
},
{
title: "标签分组名称",
field: "groupName",
width: 30,
align: "left"
},
{
title: "所属标签数",
field: "labelAmount",
width: 20,
align: "labelAmount"
}, {
title: "状态",
field: "status",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
if(value == '0'){
return "关闭";
}
if(value == '1'){
return "开启";
}
}
},
{
title: "操作",
field: "ddg",
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
var str = "<a role='edit' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #31b0d5' index='"+ rowIndex +"'>编辑</a>";
str += "<a role='close' style='margin-left:10px;background-color: #ffa951' dataId='"+ rowData.id +"' index='"+ rowIndex +"'>删除</a>";
return str;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: true,
onLoadSuccess: function (data) {
if(index != ""){
$(this).datagrid("scrollTo",index);
index = "";
}
$(this).datagrid("getPanel").find("a[role='close']").linkbutton({
iconCls: "icon-redo",
onClick: function () {
var close_id = $(this).attr("dataId");
index = $(this).attr("index");
$.messager.confirm("确认", "确认删除该分组吗?", function (flag) {
if(flag){
$.post(contextPath + "/labelGroupManage/deleteLabelGroup", {
id : close_id,
}, function(data) {
if (data.code == CODE_SUCCESS) {
$("#labelGroupListTable").datagrid("reload");
window.self.$.messager.show({
title : "提示",
msg : "删除成功!"
});
} else {
window.self.$.messager.alert("失败", data.message, "error");
}
});
}
});
}
});
// 编辑
$(this).datagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls : "icon-edit",
onClick : function() {
index = $(this).attr("index");
var row = $("#labelGroupListTable").datagrid('getData').rows[index];
getEditDialog(row);
}
});
}
});
// 编辑分组
function getEditDialog(data){
var labelGroupList = $("<div id='labelGroupList'>").appendTo($(document.body));
var title = data == null ? "新建标签分组":"修改标签分组";
var textVar = data == null ? "保存":"保存";
var msgVar = data == null ? "确认新增分组吗?":"确认保存分组吗?";
window.self.paramObject.mkData = data;
$(labelGroupList).myDialog({
title: title,
width: "70%",
height: "80%",
resizable:false,
buttons:[{
id : "saveBtn",
text:textVar,
iconCls : "icon-save",
handler:function(){
$("#activityAddForm").form("submit", {
url: contextPath + "/labelGroupManage/addUpLabelGroup",
onSubmit: function (param) {
if(data != null){
param.id = data.id;
}
// param.status = $("input[name='statusRadio'][checked]").val();
if (!$("#activityAddForm").form("validate")) {
return false;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(labelGroupList).dialog("close");
$("#labelGroupListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$.messager.confirm("确认", "确认关闭吗?", function (flag) {
if(flag){
$(labelGroupList).dialog("close");
}
});
}
}],
modal: true,
href: contextPath + "/html/grass/labelGroupManage/labelGroupEdit.html",
});
}
});
</script>
</html>
\ No newline at end of file
... ...
//todo 分解成多个接口,或接受参数的方式,实现加载可配置化,而不是笼统的暴力加载方式,太low
var contextPath = "/platform";
var contextPath = "/pfcms";
document.write("<meta charset='UTF-8'>");
//首先加载样式,保证样式先显示
... ...
var contextPath = "/platform";
var contextPath = "/pfcms";
document.write("<meta charset='UTF-8'>");
document.write("<script src='"+ contextPath +"/js/jquery/jquery-3.1.0.min.js'></script>");
... ...