Authored by 张帅

merge

@@ -23,24 +23,22 @@ @@ -23,24 +23,22 @@
23 23
24 <dependencies> 24 <dependencies>
25 <dependency> 25 <dependency>
  26 + <groupId>com.yohobuy.platform</groupId>
  27 + <artifactId>platform-common</artifactId>
  28 + </dependency>
  29 +
  30 + <dependency>
26 <groupId>com.yoho.service.platform.model</groupId> 31 <groupId>com.yoho.service.platform.model</groupId>
27 <artifactId>platform-service-model</artifactId> 32 <artifactId>platform-service-model</artifactId>
28 </dependency> 33 </dependency>
  34 +
29 <dependency> 35 <dependency>
30 <groupId>com.yoho.core</groupId> 36 <groupId>com.yoho.core</groupId>
31 <artifactId>yoho-core-rest-server</artifactId> 37 <artifactId>yoho-core-rest-server</artifactId>
32 </dependency> 38 </dependency>
33 39
34 - <dependency>  
35 - <groupId>com.yohobuy.platform</groupId>  
36 - <artifactId>platform-common</artifactId>  
37 - </dependency>  
38 </dependencies> 40 </dependencies>
39 41
40 -  
41 -  
42 -  
43 -  
44 </project> 42 </project>
45 43
46 44
  1 +package com.yohobuy.platform.grass.restapi;
  2 +
  3 +import com.yohobuy.platform.grass.service.IlabelGroupService;
  4 +import com.yohobuy.platform.model.common.ApiResponse;
  5 +import com.yohobuy.platform.model.common.PageResponseVO;
  6 +import com.yohobuy.platform.model.grass.request.LabelGroupReq;
  7 +import com.yohobuy.platform.model.grass.response.LabelGroupBo;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Controller;
  12 +import org.springframework.web.bind.annotation.RequestBody;
  13 +import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.ResponseBody;
  15 +
  16 +/**
  17 + * Created by meiling.ge on 2019/1/8.
  18 + */
  19 +@Controller
  20 +@RequestMapping("/labelGroupManage")
  21 +public class LabelGroupController {
  22 + private static Logger logger = LoggerFactory.getLogger(LabelGroupController.class);
  23 +
  24 + @Autowired
  25 + private IlabelGroupService labelGroupService;
  26 +
  27 +
  28 + @RequestMapping("/getLabelGroupList")
  29 + @ResponseBody
  30 + public ApiResponse getLabelGroupList(LabelGroupReq req){
  31 + logger.info("enter getRedpacketList,req={}",req);
  32 + PageResponseVO<LabelGroupBo> result = labelGroupService.getLabelGroupList(req);
  33 + return new ApiResponse.ApiResponseBuilder().data(result).build();
  34 + }
  35 +
  36 + @RequestMapping("/addUpLabelGroup")
  37 + @ResponseBody
  38 + public ApiResponse addUpLabelGroup(LabelGroupReq req){
  39 + logger.info("enter getRedpacketList,req={}",req);
  40 + labelGroupService.addUpLabelGroup(req);
  41 + return new ApiResponse.ApiResponseBuilder().build();
  42 + }
  43 +
  44 + @RequestMapping("/deleteLabelGroup")
  45 + @ResponseBody
  46 + public ApiResponse deleteLabelGroup(LabelGroupReq req){
  47 + logger.info("enter updatePacketStatus,req = {}", req);
  48 + labelGroupService.deleteLabelGroup(req);
  49 + return new ApiResponse.ApiResponseBuilder().build();
  50 + }
  51 +}
  1 +package com.yohobuy.platform.grass.service;
  2 +
  3 +import com.yohobuy.platform.model.common.ApiResponse;
  4 +import com.yohobuy.platform.model.common.PageResponseVO;
  5 +import com.yohobuy.platform.model.grass.request.LabelGroupReq;
  6 +import com.yohobuy.platform.model.grass.response.LabelGroupBo;
  7 +
  8 +/**
  9 + * Created by meiling.ge on 2019/1/8.
  10 + */
  11 +public interface IlabelGroupService {
  12 +
  13 + PageResponseVO<LabelGroupBo> getLabelGroupList(LabelGroupReq req);
  14 +
  15 + void addUpLabelGroup(LabelGroupReq req);
  16 +
  17 + void deleteLabelGroup(LabelGroupReq req);
  18 +}
  1 +package com.yohobuy.platform.grass.service.impl;
  2 +
  3 +
  4 +import com.yohobuy.platform.common.util.BeanTool;
  5 +import com.yohobuy.platform.common.util.DateUtil;
  6 +import com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO;
  7 +import com.yohobuy.platform.dal.grass.model.LabelGroup;
  8 +import com.yohobuy.platform.grass.service.IlabelGroupService;
  9 +import com.yohobuy.platform.model.common.PageResponseVO;
  10 +import com.yohobuy.platform.model.grass.request.LabelGroupReq;
  11 +import com.yohobuy.platform.model.grass.response.LabelGroupBo;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Service;
  16 +import java.util.ArrayList;
  17 +import java.util.List;
  18 +
  19 +
  20 +/**
  21 + * Created by meiling.ge on 2019/1/8.
  22 + */
  23 +@Service
  24 +public class LabelGroupServiceImpl implements IlabelGroupService {
  25 + private static final Logger logger = LoggerFactory.getLogger(LabelGroupServiceImpl.class);
  26 +
  27 + @Autowired
  28 + private IGrassLabelGroupDAO grassLabelGroupDAO;
  29 +
  30 + @Override
  31 + public PageResponseVO<LabelGroupBo> getLabelGroupList(LabelGroupReq req) {
  32 + logger.info("getLabelGroupList req={}",req);
  33 + String groupName = req.getGroupName();
  34 + int total = grassLabelGroupDAO.CountByCondition(groupName);
  35 + List<LabelGroup> list = new ArrayList();
  36 + if(total > 0){
  37 + list = grassLabelGroupDAO.selectByPageCondition(groupName, req.getStart(), req.getSize());
  38 + }
  39 + List<LabelGroupBo> respList = BeanTool.copyList(list, LabelGroupBo.class);
  40 + PageResponseVO<LabelGroupBo> result = new PageResponseVO<>();
  41 + result.setList(respList);
  42 + result.setTotal(total);
  43 + result.setSize(req.getSize());
  44 + result.setPage(req.getPage());
  45 + logger.info("getLabelGroupList success! req={},total={},respList.size={}",req, total, respList.size());
  46 + return result;
  47 + }
  48 +
  49 + @Override
  50 + public void addUpLabelGroup(LabelGroupReq req) {
  51 + logger.info("enter addUpLabelGroup req={}", req);
  52 + Integer id = req.getId();
  53 + LabelGroup record = new LabelGroup();
  54 + record.setId(id);
  55 + record.setGroupName(req.getGroupName());
  56 + record.setStatus(req.getStatus());
  57 + if(id != null && id > 0 ){//修改
  58 + record.setUpdateTime(DateUtil.getCurrentTimeSeconds());
  59 + grassLabelGroupDAO.updateByPrimaryKeySelective(record);
  60 + logger.info("addUpLabelGroup update success! req={}, record={}", req, record);
  61 + }else{//新增
  62 + record.setCreateTime(DateUtil.getCurrentTimeSeconds());
  63 + record.setLabelAmount(0);
  64 + grassLabelGroupDAO.insert(record);
  65 + logger.info("addUpLabelGroup insert success! req={}, record={}", req, record);
  66 + }
  67 + }
  68 +
  69 + @Override
  70 + public void deleteLabelGroup(LabelGroupReq req) {
  71 + logger.info("enter deleteLabelGroup id={}", req.getId());
  72 + grassLabelGroupDAO.deleteByPrimaryKey(req.getId());
  73 + logger.info("deleteLabelGroup success! id={}", req.getId());
  74 + }
  75 +}
@@ -29,6 +29,10 @@ @@ -29,6 +29,10 @@
29 </dependency> 29 </dependency>
30 <dependency> 30 <dependency>
31 <groupId>com.yoho.dsf.yhplatform</groupId> 31 <groupId>com.yoho.dsf.yhplatform</groupId>
  32 + <artifactId>platform-cms-grass</artifactId>
  33 + </dependency>
  34 + <dependency>
  35 + <groupId>com.yoho.dsf.yhplatform</groupId>
32 <artifactId>platform-cms-suggest</artifactId> 36 <artifactId>platform-cms-suggest</artifactId>
33 </dependency> 37 </dependency>
34 <dependency> 38 <dependency>
@@ -329,6 +329,7 @@ datasources: @@ -329,6 +329,7 @@ datasources:
329 - com.yohobuy.platform.dal.grass.IGrassArticleDao 329 - com.yohobuy.platform.dal.grass.IGrassArticleDao
330 - com.yohobuy.platform.dal.grass.IGrassArticleImageDao 330 - com.yohobuy.platform.dal.grass.IGrassArticleImageDao
331 - com.yohobuy.platform.dal.grass.IGrassArticleSknDao 331 - com.yohobuy.platform.dal.grass.IGrassArticleSknDao
  332 + - com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO
332 333
333 yhb_promotion: 334 yhb_promotion:
334 servers: 335 servers:
@@ -328,6 +328,7 @@ datasources: @@ -328,6 +328,7 @@ datasources:
328 - com.yohobuy.platform.dal.grass.IGrassArticleDao 328 - com.yohobuy.platform.dal.grass.IGrassArticleDao
329 - com.yohobuy.platform.dal.grass.IGrassArticleImageDao 329 - com.yohobuy.platform.dal.grass.IGrassArticleImageDao
330 - com.yohobuy.platform.dal.grass.IGrassArticleSknDao 330 - com.yohobuy.platform.dal.grass.IGrassArticleSknDao
  331 + - com.yohobuy.platform.dal.grass.IGrassLabelGroupDAO
331 332
332 yhb_promotion: 333 yhb_promotion:
333 servers: 334 servers:
  1 +<!DOCTYPE html>
  2 +<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
  3 + <form name="activityAddForm" id="activityAddForm" method="post" enctype="multipart/form-data">
  4 + <div style="margin-top: 20px;margin-left: 30px">
  5 + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
  6 +
  7 + <tr style="height: 60px">
  8 +
  9 + <td >
  10 + <span style="color:red">*</span><label>分组名称</label> <br>
  11 + <input id="groupName" name="groupName" class="easyui-textbox" style="width: 380px;"/>
  12 + </td>
  13 + </tr>
  14 +
  15 + <tr style="height: 60px">
  16 + <td>
  17 + <span style="color:red">*</span><label>标签状态</label> <br>
  18 + <input type="radio" value="1" checked name="status" style="width:30px">开启</input>
  19 + <input type="radio" value="0" name="status" style="width:30px">关闭</input>
  20 + </td>
  21 + </tr>
  22 +
  23 + </table>
  24 + </div>
  25 + </form>
  26 +</div>
  27 +<script>
  28 + $(function () {
  29 +
  30 + $("#groupName").textbox({
  31 + required: true,
  32 + missingMessage: "分组名称不能为空",
  33 + prompt: "请输入分组名称"
  34 + });
  35 +
  36 +
  37 +
  38 + var data = paramObject.mkData;
  39 +
  40 +
  41 + if (data){
  42 +
  43 + $("#groupName").textbox("setValue", data.groupName);
  44 + if(data.status == 0){
  45 + $(":radio[name='status'][value='0']").prop("checked",true);
  46 + }else if(data.status == 1){
  47 + $(":radio[name='status'][value='1']").prop("checked",true);
  48 + }
  49 + }
  50 +
  51 + });
  52 +
  53 +
  54 +</script>
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta charset="UTF-8" />
  5 + <title>Yoho!Buy运营平台</title>
  6 + <script src="/pfcms/js/include.js"></script>
  7 + <script src="/pfcms/js/ajaxfileupload.js"></script>
  8 + <style>
  9 + .btn-long {
  10 + width: 120px;
  11 + height: 37px;
  12 + line-height: 37px;
  13 + font-size: 15px;
  14 + color: white;
  15 + border-radius: 5px;
  16 + display: inline-block;
  17 + cursor: pointer;
  18 + text-align: center;
  19 + }
  20 + .btn-long:hover {
  21 + opacity: 0.9;
  22 + }
  23 +
  24 + </style>
  25 +</head>
  26 +<body class="easyui-layout" >
  27 +<div region="north" style="height: 200px;">
  28 + <script>
  29 + document.write(addHead('运营管理', '标签分组管理'));
  30 + </script>
  31 +
  32 + <div style="margin-left: 20px;margin-top: 10px">
  33 +
  34 + <input class="easyui-textbox" id="groupNameSearch" style="width: 140px">
  35 + </input>
  36 +
  37 + <a id="searchBtn" class="btn-info">查询</a>
  38 + <!--<a id="addActivityBtn" class="btn-success">新增</a>-->
  39 + <a id="allBtn" class="btn-info">全部</a>
  40 +
  41 + </div>
  42 +
  43 + <div style="margin-left: 20px;margin-top: 10px">
  44 + <a id="addBtn" class="btn-long" style="background-color: #5CB85C;">+新建标签分组</a>
  45 + </div>
  46 +
  47 +</div>
  48 +
  49 +<div region="center" id="labelGroupList" style="margin-left: 20px">
  50 + <table id="labelGroupListTable"></table>
  51 +</div>
  52 +
  53 +</body>
  54 +
  55 +<script>
  56 +
  57 + $(function() {
  58 + //用于页面刷新后的数据行定位
  59 + var index ="";
  60 + $("#allBtn").linkbutton({
  61 + iconCls : "icon-search",
  62 + onClick : function() {
  63 + $("#labelGroupListTable").datagrid("load", {});
  64 + }
  65 + });
  66 +
  67 +
  68 + $("#groupNameSearch").textbox({
  69 + required:false,
  70 + prompt: "请输入标签分组名称"
  71 + });
  72 +
  73 +
  74 + $("#searchBtn").linkbutton({
  75 + iconCls : "icon-search",
  76 + onClick : function() {
  77 + $("#labelGroupListTable").datagrid("load", {
  78 + groupName: $("#groupNameSearch").textbox("getValue")
  79 + });
  80 + }
  81 + });
  82 +
  83 +
  84 + $("#addBtn").click(function () {
  85 + getEditDialog(null);
  86 + });
  87 +
  88 +
  89 + // 检索按钮
  90 + $("#labelGroupListTable").myDatagrid({
  91 + fit: true,
  92 + fitColumns: true,
  93 + striped: true,
  94 + /*queryParams: {
  95 + rewardName: $("#rewardName1").textbox("getValue"),
  96 + status: $("#rewardstatus1").combobox("getValue"),
  97 + type: $("#rewardtype1").combobox("getValue")
  98 + },*/
  99 + url: contextPath + "/labelGroupManage/getLabelGroupList",
  100 + method: 'POST',
  101 + loadFilter: function (data) {
  102 + var tmp = defaultLoadFilter(data);
  103 + tmp.rows = tmp.list;
  104 + return tmp;
  105 + },
  106 + columns: [[
  107 + {
  108 + title: "ID",
  109 + field: "id",
  110 + width: 15,
  111 + align: "center"
  112 + },
  113 +
  114 + {
  115 + title: "标签分组名称",
  116 + field: "groupName",
  117 + width: 30,
  118 + align: "left"
  119 + },
  120 + {
  121 + title: "所属标签数",
  122 + field: "labelAmount",
  123 + width: 20,
  124 + align: "labelAmount"
  125 + }, {
  126 + title: "状态",
  127 + field: "status",
  128 + width: 25,
  129 + align: "left",
  130 + formatter: function (value, rowData, rowIndex) {
  131 + if(value == '0'){
  132 + return "关闭";
  133 + }
  134 + if(value == '1'){
  135 + return "开启";
  136 + }
  137 + }
  138 + },
  139 + {
  140 + title: "操作",
  141 + field: "ddg",
  142 + width: 40,
  143 + align: "center",
  144 + formatter: function (value, rowData, rowIndex) {
  145 + var str = "<a role='edit' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #31b0d5' index='"+ rowIndex +"'>编辑</a>";
  146 + str += "<a role='close' style='margin-left:10px;background-color: #ffa951' dataId='"+ rowData.id +"' index='"+ rowIndex +"'>删除</a>";
  147 + return str;
  148 + }
  149 + }
  150 +
  151 + ]],
  152 + cache: false,
  153 + pagination: true,
  154 + pageSize: 10,
  155 + pageList: [10],
  156 + idField: "id",
  157 + singleSelect: true,
  158 + onLoadSuccess: function (data) {
  159 +
  160 + if(index != ""){
  161 + $(this).datagrid("scrollTo",index);
  162 + index = "";
  163 + }
  164 + $(this).datagrid("getPanel").find("a[role='close']").linkbutton({
  165 + iconCls: "icon-redo",
  166 + onClick: function () {
  167 + var close_id = $(this).attr("dataId");
  168 + index = $(this).attr("index");
  169 + $.messager.confirm("确认", "确认删除该分组吗?", function (flag) {
  170 + if(flag){
  171 + $.post(contextPath + "/labelGroupManage/deleteLabelGroup", {
  172 + id : close_id,
  173 + }, function(data) {
  174 + if (data.code == CODE_SUCCESS) {
  175 + $("#labelGroupListTable").datagrid("reload");
  176 + window.self.$.messager.show({
  177 + title : "提示",
  178 + msg : "删除成功!"
  179 + });
  180 + } else {
  181 + window.self.$.messager.alert("失败", data.message, "error");
  182 + }
  183 + });
  184 + }
  185 +
  186 + });
  187 + }
  188 + });
  189 +
  190 + // 编辑
  191 + $(this).datagrid("getPanel").find("a[role='edit']").linkbutton({
  192 + iconCls : "icon-edit",
  193 + onClick : function() {
  194 +
  195 + index = $(this).attr("index");
  196 + var row = $("#labelGroupListTable").datagrid('getData').rows[index];
  197 + getEditDialog(row);
  198 + }
  199 + });
  200 +
  201 + }
  202 + });
  203 +
  204 +
  205 + // 编辑分组
  206 + function getEditDialog(data){
  207 + var labelGroupList = $("<div id='labelGroupList'>").appendTo($(document.body));
  208 + var title = data == null ? "新建标签分组":"修改标签分组";
  209 + var textVar = data == null ? "保存":"保存";
  210 + var msgVar = data == null ? "确认新增分组吗?":"确认保存分组吗?";
  211 +
  212 + window.self.paramObject.mkData = data;
  213 + $(labelGroupList).myDialog({
  214 + title: title,
  215 + width: "70%",
  216 + height: "80%",
  217 + resizable:false,
  218 + buttons:[{
  219 + id : "saveBtn",
  220 + text:textVar,
  221 + iconCls : "icon-save",
  222 + handler:function(){
  223 +
  224 +
  225 + $("#activityAddForm").form("submit", {
  226 + url: contextPath + "/labelGroupManage/addUpLabelGroup",
  227 + onSubmit: function (param) {
  228 + if(data != null){
  229 + param.id = data.id;
  230 + }
  231 +// param.status = $("input[name='statusRadio'][checked]").val();
  232 + if (!$("#activityAddForm").form("validate")) {
  233 + return false;
  234 + }
  235 +
  236 + $.messager.progress({
  237 + title: "正在执行",
  238 + msg: "正在执行,请稍后..."
  239 + });
  240 + return true;
  241 + },
  242 + success: function (data) {
  243 + $.messager.progress("close");
  244 + data = JSON.parse(data);
  245 + if (data.code == 200) {
  246 + $(labelGroupList).dialog("close");
  247 + $("#labelGroupListTable").datagrid("reload");
  248 + $.messager.show({
  249 + title: "提示",
  250 + msg: title + "成功!",
  251 + height: 120
  252 + });
  253 + } else {
  254 + $.messager.alert("失败", data.message, "error");
  255 + }
  256 + }
  257 + });
  258 + }
  259 + }, {
  260 + text: "关闭",
  261 + iconCls: "icon-cancel",
  262 + handler: function () {
  263 + $.messager.confirm("确认", "确认关闭吗?", function (flag) {
  264 + if(flag){
  265 + $(labelGroupList).dialog("close");
  266 + }
  267 + });
  268 + }
  269 + }],
  270 + modal: true,
  271 + href: contextPath + "/html/grass/labelGroupManage/labelGroupEdit.html",
  272 + });
  273 + }
  274 +
  275 + });
  276 +
  277 +</script>
  278 +</html>
1 //todo 分解成多个接口,或接受参数的方式,实现加载可配置化,而不是笼统的暴力加载方式,太low 1 //todo 分解成多个接口,或接受参数的方式,实现加载可配置化,而不是笼统的暴力加载方式,太low
2 2
3 -var contextPath = "/platform"; 3 +var contextPath = "/pfcms";
4 4
5 document.write("<meta charset='UTF-8'>"); 5 document.write("<meta charset='UTF-8'>");
6 //首先加载样式,保证样式先显示 6 //首先加载样式,保证样式先显示
1 -var contextPath = "/platform"; 1 +var contextPath = "/pfcms";
2 2
3 document.write("<meta charset='UTF-8'>"); 3 document.write("<meta charset='UTF-8'>");
4 document.write("<script src='"+ contextPath +"/js/jquery/jquery-3.1.0.min.js'></script>"); 4 document.write("<script src='"+ contextPath +"/js/jquery/jquery-3.1.0.min.js'></script>");