36分布式电商项目 - 运营商后台(广告管理)

简介: 36分布式电商项目 - 运营商后台(广告管理)

代码已上传至GitHub

下载地址:https://github.com/ylw-github/pingyougou.git

版本:2646456bff33de6ccecb9a598b156fecef78abed

需要实现广告类型表和广告表的增删改查

准备工作

1.构建工程

(1)pinyougou-content-interface

引入依赖 pinyougou-pojo

创建包 com.pinyougou.content.service

(2)pinyougou-content-service (WAR)

为 pinyougou-content-service 工程添加 web.xml

创建包 com.pinyougou.content.service.impl

添加 spring 相关配置文件

applicationContext-service.xml

注意:我们目前有两个服务工程,当两个工程同时启动时会发生端口冲突,因为连接dubbox 注册中心的端口默认是 20880。所以我们需要配置一下 pinyougou-content-service 工程的 dubbox 端口。

(3)pinyougou-manager-web 工程引入依赖pinyougou-content-interface

其它代码的拷入 …

广告管理

1.广告分类管理

修改content.html

<input type="checkbox" ng-model="entity.status" ng-true-value="1" ng-false-value="0">

修改 contentController.js

$scope.status=["无效","有效"];

修改 content.html 的列表

{{status[entity.status]}}
2.广告图片上传

将 pinyougou-shop-web 的以下资源拷贝到 pinyougou-manager-web

(1)UploadController.java

(2)uploadService.js

(3)application.properties

(4)fdfs_client.conf

在 pinyougou-manager-web 的 springmvc.xml 中添加配置

<!-- 配置多媒体解析器 -->
<bean id="multipartResolver"
  class="org.springframework.web.multipart.commons.CommonsMultipartResolver"<property name="defaultEncoding" value="UTF-8"></property>
  <!-- 设定文件上传的最大值 5MB,5*1024*1024 -->
  <property name="maxUploadSize" value="5242880"> </property>
</bean>

在 contentController.js 引入 uploadService

//控制层
app.controller('contentController' ,function($scope,$controller ,contentService,up
loadService){

在 content.html 引入 JS

<script type="text/javascript" src="../js/service/uploadService.js"> </script>

在 contentController.js 编写代码

//上传广告图
$scope.uploadFile=function(){
uploadService.uploadFile().success(
  function(response){
  if(response.success){
    $scope.entity.pic=response.message;
  }else{
    alert("上传失败!");
  }
  }
).error(
    function(){
      alert("上传出错!");
    }
  );
}

修改 content.html 实现上传功能

<tr> 
  <td>图片</td>
   <td>
     <input type="file" id="file">
     <button ng-click="uploadFile()">上传</button> 
     <img alt="" src="{{entity.pic}}" height="100px" width="200px">
   </td>
</tr>

列表中显示图片

<img alt="" src="{{entity.pic}}" height="50px" width="100px">
3.广告类目选择

将 contentCategoryService 引入 contentController

在 content.html 引入 contentCategoryService.js

在 contentController.js 中添加代码

//加载广告分类列表
$scope.findContentCategoryList=function(){
  contentCategoryService.findAll().success(
    function(response){
      $scope.contentCategoryList=response;
    }
  );
}

在 content.html 初始化调用此方法

<body class="hold-transition skin-red sidebar-mini" ng-app="pinyougou" ng-controller="contentController" ng-init="findContentCategoryList()">

将广告分类改为下拉列表

<select class="form-control" ng-model="entity.categoryId" ng-options="item.id as item.name for item in contentCategoryList"></select>


目录
相关文章
|
5月前
|
NoSQL 调度 Redis
19- 你的项目中哪里用到了分布式锁
在一个项目中,为解决集群环境下SpringTask定时任务的重复执行问题,采用了Redis实现分布式锁来管理任务调度,防止资源浪费。后来因任务量和执行规则增加,以及单节点效率限制,系统改用XXL-JOB,分布式锁不再使用。
60 2
|
11天前
|
NoSQL Java Redis
面试官:项目中如何实现分布式锁?
面试官:项目中如何实现分布式锁?
39 6
面试官:项目中如何实现分布式锁?
|
4月前
|
NoSQL Java 应用服务中间件
大厂面试必备:如何轻松实现分布式Session管理?
这篇文章介绍三种分布式Session的实现方案:基于JWT的Token、基于Tomcat的Redis和基于Spring的Redis。JWT方案通过生成Token存储用户信息,实现无状态、可扩展的会话管理,但可能增加请求负载且数据安全性较低。Tomcat与Redis结合,通过配置Tomcat和Redis,实现Session集中管理和高性能存储,但配置相对复杂。Spring整合Redis适用于SpringBoot和SpringCloud项目,集成方便,扩展性强,但同样依赖外部Redis服务。每种方法有其优缺点,适用场景不同。作者小米是一个技术爱好者,欢迎关注其微信公众号“软件求生”获取更多技术内容
183 4
|
2月前
|
资源调度 Java 调度
项目环境测试问题之Schedulerx2.0通过分布式分片任务解决单机计算瓶颈如何解决
项目环境测试问题之Schedulerx2.0通过分布式分片任务解决单机计算瓶颈如何解决
项目环境测试问题之Schedulerx2.0通过分布式分片任务解决单机计算瓶颈如何解决
|
3月前
|
负载均衡 监控 搜索推荐
面试题ES问题之Solr和Elasticsearch在分布式管理上如何解决
面试题ES问题之Solr和Elasticsearch在分布式管理上如何解决
33 1
|
2月前
|
存储 缓存 开发框架
看看 Asp.net core Webapi 项目如何优雅地使用分布式缓存
看看 Asp.net core Webapi 项目如何优雅地使用分布式缓存
|
5月前
|
缓存 NoSQL Java
分布式项目中锁的应用(本地锁-_redis【setnx】-_redisson-_springcache)-fen-bu-shi-xiang-mu-zhong-suo-de-ying-yong--ben-de-suo--redissetnx-springcache-redisson(一)
分布式项目中锁的应用(本地锁-_redis【setnx】-_redisson-_springcache)-fen-bu-shi-xiang-mu-zhong-suo-de-ying-yong--ben-de-suo--redissetnx-springcache-redisson
87 0
|
3月前
|
SQL NoSQL Java
如何在Java项目中实现分布式锁
如何在Java项目中实现分布式锁
|
3月前
|
消息中间件 Java 中间件
如何在Java项目中实现分布式事务管理
如何在Java项目中实现分布式事务管理
|
5月前
|
XML NoSQL Java
Java单体项目和分布式项目中的锁
Java单体项目和分布式项目中的锁 Java单体项目和分布式项目中的锁
74 2
下一篇
无影云桌面