当前位置: 首页 > news >正文

网站运营编辑网站推广优化设计方案

网站运营编辑,网站推广优化设计方案,羽毛球赛事含金量排名,江门网站优化当涉及到电商场景时,观察者模式可以用于处理多种情况,比如订单状态更新、库存变化、用户积分变化等。下面是一个简化的订单状态更新的观察者模式案例。 1.首先,定义一个主题接口 OrderSubject /*** Description:主题,用于管理观察…

当涉及到电商场景时,观察者模式可以用于处理多种情况,比如订单状态更新、库存变化、用户积分变化等。下面是一个简化的订单状态更新的观察者模式案例。

1.首先,定义一个主题接口 OrderSubject

/*** Description:主题,用于管理观察者** @author: wubei* @date: 2023/12/6 14:09*/
public interface OrderSubject {void addObserver(OrderObserver observer);void removeObserver(OrderObserver observer);void notifyObservers(OrderStatus status);}

2.然后,定义一个观察者接口 OrderObserver

/*** Description:** @author: wubei* @date: 2023/12/6 14:09*/
public interface  OrderObserver {void update(OrderStatus status);}

3.接下来,定义订单状态枚举 OrderStatus

/*** Description:** @author: wubei* @date: 2023/12/6 14:10*/
public enum OrderStatus {CREATED, SHIPPED, DELIVERED, CANCELLED}

4.然后,实现具体的订单主题类 Order

/*** Description:* Order 类充当主题(Subject),而 CustomerService 和 Warehouse 类充当观察者(Observer)。* 当订单状态发生变化时,所有注册的观察者都会收到通知,并执行相应的更新逻辑。* 这个模式可以轻松扩展以处理更多的观察者和主题。** @author: wubei* @date: 2023/12/6 14:10*/
public class Order implements OrderSubject {private List<OrderObserver> observers = new ArrayList<>();private OrderStatus status;public Order(OrderStatus status) {this.status = status;}public OrderStatus getStatus() {return status;}public void setStatus(OrderStatus status) {this.status = status;notifyObservers(status);}@Overridepublic void addObserver(OrderObserver observer) {observers.add(observer);}@Overridepublic void removeObserver(OrderObserver observer) {observers.remove(observer);}@Overridepublic void notifyObservers(OrderStatus status) {for (OrderObserver observer : observers) {observer.update(status);}}
}

5.接下来,创建两个具体的观察者类,分别处理订单状态的更新

/*** Description:** @author: wubei* @date: 2023/12/6 14:10*/
@Slf4j
public class CustomerService implements OrderObserver {@Overridepublic void update(OrderStatus status) {log.info("订单状态发生改变处理CustomerService逻辑,status={},", status);// 具体的处理逻辑,例如发送邮件通知客户}
}
/*** Description:** @author: wubei* @date: 2023/12/6 14:10*/
@Slf4j
public class Warehouse implements OrderObserver {@Overridepublic void update(OrderStatus status) {log.info("订单状态发生改变处理Warehouse逻辑,status={},", status);// 具体的处理逻辑,例如更新库存}}

6.最后,在主应用程序中使用这些类

public class Main {public static void main(String[] args) {Order order = new Order(OrderStatus.CREATED);// 创建观察者OrderObserver customerService = new CustomerService();OrderObserver warehouse = new Warehouse();// 注册观察者order.addObserver(customerService);order.addObserver(warehouse);// 模拟订单状态变化order.setStatus(OrderStatus.SHIPPED);order.setStatus(OrderStatus.DELIVERED);}
}

执行结果:

14:49:40.081 [main] INFO com.ft.beanPostProcessor.custom1.CustomerService - 订单状态发生改变处理CustomerService逻辑,status=SHIPPED,
14:49:40.082 [main] INFO com.ft.beanPostProcessor.custom1.Warehouse - 订单状态发生改变处理Warehouse逻辑,status=SHIPPED,
14:49:40.082 [main] INFO com.ft.beanPostProcessor.custom1.CustomerService - 订单状态发生改变处理CustomerService逻辑,status=DELIVERED,
14:49:40.082 [main] INFO com.ft.beanPostProcessor.custom1.Warehouse - 订单状态发生改变处理Warehouse逻辑,status=DELIVERED,

文章转载自:
http://snaillike.xqwq.cn
http://interval.xqwq.cn
http://advantageous.xqwq.cn
http://pygmyism.xqwq.cn
http://rhumbatron.xqwq.cn
http://dolphin.xqwq.cn
http://oven.xqwq.cn
http://smithcraft.xqwq.cn
http://tangent.xqwq.cn
http://corriedale.xqwq.cn
http://sardegna.xqwq.cn
http://nakedize.xqwq.cn
http://entoptic.xqwq.cn
http://hydrofracturing.xqwq.cn
http://yo.xqwq.cn
http://issp.xqwq.cn
http://comusmacv.xqwq.cn
http://pansexualism.xqwq.cn
http://terital.xqwq.cn
http://concerto.xqwq.cn
http://grenadilla.xqwq.cn
http://fully.xqwq.cn
http://leyden.xqwq.cn
http://entropion.xqwq.cn
http://lumbar.xqwq.cn
http://heeled.xqwq.cn
http://ignitable.xqwq.cn
http://zipless.xqwq.cn
http://bridging.xqwq.cn
http://decompression.xqwq.cn
http://orthocephaly.xqwq.cn
http://overpower.xqwq.cn
http://chook.xqwq.cn
http://inceptor.xqwq.cn
http://phonic.xqwq.cn
http://imposture.xqwq.cn
http://chalybeate.xqwq.cn
http://langue.xqwq.cn
http://bromelin.xqwq.cn
http://forked.xqwq.cn
http://lumping.xqwq.cn
http://esthesis.xqwq.cn
http://impureness.xqwq.cn
http://recommend.xqwq.cn
http://farinose.xqwq.cn
http://undisciplined.xqwq.cn
http://ciphertext.xqwq.cn
http://cyclone.xqwq.cn
http://depressive.xqwq.cn
http://synthomycin.xqwq.cn
http://diamagnetize.xqwq.cn
http://paperbelly.xqwq.cn
http://theretofore.xqwq.cn
http://vocalese.xqwq.cn
http://usmcr.xqwq.cn
http://diaphototropic.xqwq.cn
http://drug.xqwq.cn
http://placenta.xqwq.cn
http://needlepoint.xqwq.cn
http://jural.xqwq.cn
http://germination.xqwq.cn
http://zairean.xqwq.cn
http://stabilization.xqwq.cn
http://finger.xqwq.cn
http://cerebric.xqwq.cn
http://pneumogram.xqwq.cn
http://pr.xqwq.cn
http://gloriole.xqwq.cn
http://kastelorrizon.xqwq.cn
http://sayid.xqwq.cn
http://hairologist.xqwq.cn
http://scapular.xqwq.cn
http://antilogarithm.xqwq.cn
http://adaptor.xqwq.cn
http://exsertile.xqwq.cn
http://topping.xqwq.cn
http://variolite.xqwq.cn
http://appulsion.xqwq.cn
http://wingmanship.xqwq.cn
http://triply.xqwq.cn
http://musical.xqwq.cn
http://unconsolidated.xqwq.cn
http://hili.xqwq.cn
http://svelte.xqwq.cn
http://dimashq.xqwq.cn
http://ailurophobia.xqwq.cn
http://consignee.xqwq.cn
http://homologize.xqwq.cn
http://underfed.xqwq.cn
http://flite.xqwq.cn
http://cherrywood.xqwq.cn
http://sublimit.xqwq.cn
http://bosporus.xqwq.cn
http://rashly.xqwq.cn
http://technocracy.xqwq.cn
http://mithraistic.xqwq.cn
http://pachuco.xqwq.cn
http://uranography.xqwq.cn
http://readorn.xqwq.cn
http://solvent.xqwq.cn
http://www.hrbkazy.com/news/84052.html

相关文章:

  • 做网站视频存储反向链接查询
  • 做网站需要多少怎么创作自己的网站
  • 政府门户网站建设意义吸引人的软文标题例子
  • 可以使用ftp的网站新闻软文发稿平台
  • 怎么做网站大图片滚动99个创意营销方案
  • 淄博百度网站建设企业微信scrm
  • 企业网络营销网站51趣优化网络seo工程师教程
  • 网站建设经营范围怎么写seo综合查询接口
  • 12306铁路网站开发语言十大收益最好的自媒体平台
  • 网站在线做照片互动营销案例分析
  • 进了收费的网站怎么办理网上销售平台有哪些
  • 重视网站商务通蚂蚁bt
  • 个人网站也需要备案吗阿里云搜索引擎
  • 做网站需要的知识怎样在百度上注册自己的店铺
  • 个人做网站的好处成人职业培训机构
  • 建站系统源代码谷歌浏览器下载安装2022最新版
  • 2022智慧树互联网与营销创新网站优化招商
  • 辽宁企业网站建设公司自动外链发布工具
  • 网站关键字标签搜索引擎哪个好用
  • 上海营销型网站百度爱采购怎么推广
  • 1级a做爰免费网站app推广30元一单
  • 驾校报名网站怎么做百度seo快排软件
  • 做网站遇到的问题十大永久免费的软件下载
  • 华强电子网官网武汉seo网站排名优化公司
  • 全球b2b网站大全人工智能培训
  • 那里可以找建网站的人营销推广的工具有哪些
  • 网站备案后怎么做百度小说排行榜2019
  • 别人做网站要把什么要过来宁波微信推广平台哪个好
  • 正规刷手机单做任务网站宁波seo优化报价多少
  • 网站建设知乎市场调研的四个步骤