Skip to content

Commit

Permalink
[UPDATE]导航栏可后台配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Exrick committed Jul 27, 2018
1 parent e188d99 commit 64da988
Show file tree
Hide file tree
Showing 14 changed files with 832 additions and 179 deletions.
436 changes: 264 additions & 172 deletions .idea/workspace.xml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
- [X-Boot前后端分离开发平台](https://github.com/Exrick/x-boot)

![](https://i.loli.net/2018/07/21/5b52e274d2085.png)

- 机器学习笔记
- [Machine-Learning](https://github.com/Exrick/Machine-Learning)

### 基于SOA架构的分布式购物电商商城
- [x] 后台管理系统:管理商品、订单、类目、商品规格属性、用户、权限、系统统计、系统日志以及前台内容等功能
Expand All @@ -58,6 +61,7 @@
- [x] 增添限流
- [x] 2018.7.22 取消快速搜索接口需前端配置 发送邮件端口改为465
- [x] 2018.7.24 修复添加分类BUG
- [x] 2018.7.27 首页导航栏可后台配置
- 注:SKU设计预计将在开源小程序后台实现

![](https://i.loli.net/2018/07/22/5b5460eb23cb9.jpg "登录界面")
Expand Down Expand Up @@ -178,7 +182,7 @@
```
- 支持多维度IP、uid等限流 详见代码
### 技术疑问交流
- QQ交流群 `475743731`,可获取详细文档、共享付费学习资源和 和 [UI框架](https://github.com/Exrick/xmall/blob/master/study/FlatLab.md) [![](https://pub.idqqimg.com/wpa/images/group.png)](https://shang.qq.com/wpa/qunwpa?idkey=7b60cec12ba93ebed7568b0a63f22e6e034c0d1df33125ac43ed753342ec6ce7)
- QQ交流群 `475743731`,可获取详细文档、共享学习资源 和 [UI框架](https://github.com/Exrick/xmall/blob/master/study/FlatLab.md) [![](https://pub.idqqimg.com/wpa/images/group.png)](https://shang.qq.com/wpa/qunwpa?idkey=7b60cec12ba93ebed7568b0a63f22e6e034c0d1df33125ac43ed753342ec6ce7)
- 作者博客:[https://blog.exrick.cn](https://blog.exrick.cn)
### 商用授权
- 个人学习使用遵循GPL开源协议
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,10 @@ public interface ContentService {
* @return
*/
int updateThankRedis();

/**
* 获取导航栏
* @return
*/
List<TbPanelContent> getNavList();
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public class ContentServiceImpl implements ContentService {
@Value("${ITEM_EXPIRE}")
private int ITEM_EXPIRE;

@Value("${HEADER_PANEL_ID}")
private int HEADER_PANEL_ID;

@Value("${HEADER_PANEL}")
private String HEADER_PANEL;

@Override
public int addPanelContent(TbPanelContent tbPanelContent) {

Expand All @@ -72,6 +78,10 @@ public int addPanelContent(TbPanelContent tbPanelContent) {
if(tbPanelContentMapper.insert(tbPanelContent)!=1){
throw new XmallException("添加首页板块内容失败");
}
//同步导航栏缓存
if(tbPanelContent.getPanelId()==HEADER_PANEL_ID){
updateNavListRedis();
}
//同步缓存
deleteHomeRedis();
return 1;
Expand Down Expand Up @@ -107,6 +117,10 @@ public int deletePanelContent(int id) {
if(tbPanelContentMapper.deleteByPrimaryKey(id)!=1){
throw new XmallException("删除首页板块失败");
}
//同步导航栏缓存
if(id==HEADER_PANEL_ID){
updateNavListRedis();
}
//同步缓存
deleteHomeRedis();
return 1;
Expand All @@ -130,6 +144,10 @@ public int updateContent(TbPanelContent tbPanelContent) {
if(tbPanelContentMapper.updateByPrimaryKey(tbPanelContent)!=1){
throw new XmallException("更新板块内容失败");
}
//同步导航栏缓存
if(tbPanelContent.getPanelId()==HEADER_PANEL_ID){
updateNavListRedis();
}
//同步缓存
deleteHomeRedis();
return 1;
Expand Down Expand Up @@ -443,6 +461,50 @@ public int updateThankRedis() {
return 1;
}

public void updateNavListRedis() {

try {
jedisClient.del(HEADER_PANEL);
}catch (Exception e){
e.printStackTrace();
}
}

@Override
public List<TbPanelContent> getNavList() {

List<TbPanelContent> list = new ArrayList<>();
//查询缓存
try{
//有缓存则读取
String json=jedisClient.get(HEADER_PANEL);
if(json!=null){
list = new Gson().fromJson(json, new TypeToken<List<TbPanelContent>>(){}.getType());
log.info("读取了导航栏缓存");
return list;
}
}catch (Exception e){
e.printStackTrace();
}

TbPanelContentExample exampleContent=new TbPanelContentExample();
exampleContent.setOrderByClause("sort_order");
TbPanelContentExample.Criteria criteriaContent=exampleContent.createCriteria();
//条件查询
criteriaContent.andPanelIdEqualTo(HEADER_PANEL_ID);
list=tbPanelContentMapper.selectByExample(exampleContent);

//把结果添加至缓存
try{
jedisClient.set(HEADER_PANEL, new Gson().toJson(list));
log.info("添加了导航栏缓存");
}catch (Exception e){
e.printStackTrace();
}

return list;
}

/**
* 同步首页缓存
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ PRODUCT_HOME=PRODUCT_HOME
PRODUCT_ITEM=PRODUCT_ITEM
#商品详情缓存过期时间 一周(实际建议2小时)
ITEM_EXPIRE=604800

#导航栏板块表id
HEADER_PANEL_ID=0
#导航栏板块缓存key
HEADER_PANEL=HEADER_PANEL
#推荐商品板块表id
RECOMEED_PANEL_ID=6
#推荐商品板块缓存key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cn.exrick.content.service.ContentService;
import cn.exrick.manager.dto.front.ProductDet;
import cn.exrick.manager.pojo.TbPanel;
import cn.exrick.manager.pojo.TbPanelContent;
import cn.exrick.search.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Expand All @@ -27,6 +28,14 @@ public class GoodsController {
@Autowired
private SearchService searchService;

@RequestMapping(value = "/goods/navList",method = RequestMethod.GET)
@ApiOperation(value = "获取导航栏")
public Result<List<TbPanelContent>> getNavList(){

List<TbPanelContent> list=contentService.getNavList();
return new ResultUtil<List<TbPanelContent>>().setData(list);
}

@RequestMapping(value = "/goods/home",method = RequestMethod.GET)
@ApiOperation(value = "首页内容展示")
public Result<List<TbPanel>> getProductHome(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ul id="treeDemo" style="margin-left: 10px" class="ztree"></ul>
</div>
<div style="margin-left:200px;">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 首页轮播图管理 <span class="c-gray en">&gt;</span><span id="name"></span> <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商城管理 <span class="c-gray en">&gt;</span> 首页轮播图管理 <span class="c-gray en">&gt;</span><span id="name"></span> <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<form id="form-search" class="page-container">
<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" onclick="product_add('添加轮播图','content-banner-add')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加轮播图</a></span> <span class="r">最大容纳内容(商品)数:<strong id="limitNum"></strong></span> </div>
<div class="mt-20">
Expand Down
127 changes: 127 additions & 0 deletions xmall-manager-web/src/main/webapp/WEB-INF/jsp/content-header-add.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->

<title>添加导航栏</title>
</head>
<body>
<article class="page-container">
<form action="" method="post" class="form form-horizontal" id="form-admin-permission-add">
<input type="text" class="input-text" hidden value="0" id="panelId" name="panelId">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>名称:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" class="input-text" value="" placeholder="" id="picUrl" name="picUrl">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>跳转链接:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" class="input-text" value="" placeholder="https://" id="fullUrl" name="fullUrl">
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>类型:</label>
<div class="formControls col-xs-8 col-sm-9">
<select class="select-box" style="width: 100px" id="type" name="type">
<option value="1" selected>站内</option>
<option value="0">站外</option>
</select>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序值:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" class="input-text" value="" placeholder="请输入0~9999,值越小越靠前" id="sortOrder" name="sortOrder">
</div>
</div>
<div class="row cl">
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
<button id="saveButton" type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
</div>
</div>
</form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
$("#form-admin-permission-add").validate({
rules:{
picUrl:{
required:true,
minlength:1,
maxlength:20,
},
fullUrl:{
required:true,
minlength:10,
},
sortOrder:{
required:true,
digits:true,
maxlength:4,
},
},
onkeyup:false,
focusCleanup:false,
success:"valid",
submitHandler:function(form){
var index = layer.load(3);
$(form).ajaxSubmit({
url: "/content/add",
type: "POST",
success: function(data) {
layer.close(index);
if(data.success==true){
parent.refresh();
parent.msgSuccess("添加成功!");
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}else{
layer.alert(data.message, {title: '错误信息',icon: 2});
}
},
error:function(XMLHttpRequest) {
layer.close(index);
layer.alert('数据处理失败! 错误码:'+XMLHttpRequest.status+' 错误信息:'+JSON.parse(XMLHttpRequest.responseText).message,{title: '错误信息',icon: 2});
}
});
}
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
Loading

0 comments on commit 64da988

Please sign in to comment.