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

适合在线做笔试的网站希爱力双效片

适合在线做笔试的网站,希爱力双效片,不写代码做网站,建设网站的结束语背景: 下单时有很多情况,有的是用户下单,有的是卡密下单,有的是下游下单,有的是需要唤起支付,有的不需要支付,这样就需要写很多下单接口,下面使用策略模式优化这种情况 代码结构 com.example.order ├── controller │ └── OrderController.java ├── service │ …

背景:

下单时有很多情况,有的是用户下单,有的是卡密下单,有的是下游下单,有的是需要唤起支付,有的不需要支付,这样就需要写很多下单接口,下面使用策略模式优化这种情况

代码结构

com.example.order
├── controller
│   └── OrderController.java
├── service
│   ├── OrderService.java
│   └── impl
│       └── OrderServiceImpl.java
├── strategy
│   ├── OrderStrategy.java
│   ├── factory
│   │   └── OrderStrategyFactory.java
│   ├── impl
│   │   ├── UserOrderStrategy.java
│   │   └── CardOrderStrategy.java
├── dto
│   └── OrderDTO.java
├── vo
│   ├── UserOrderVO.java
│   └── CardOrderVO.java
├── mapper
│   ├── OrderMapper.java
│   └── xml
│       └── OrderMapper.xml
├── domain
│   └── OrderDO.java
@RestController
@RequestMapping("/orders")
public class OrderController {@Autowiredprivate OrderService orderService;@PostMapping("/create")public ResponseEntity<?> createOrder(@RequestBody OrderDTO orderDTO) {Object orderVO = orderService.createOrder(orderDTO);return new ResponseEntity<>(orderVO, HttpStatus.OK);}
}
@Service
public class OrderServiceImpl implements OrderService {@Override@SuppressWarnings("unchecked")public <T> T createOrder(OrderDTO orderDTO) {OrderStrategy<T> strategy = OrderStrategyFactory.getStrategy(orderDTO.getOrderType());return strategy.createOrder(orderDTO);}
}

策略类接口 

public interface OrderStrategy<T> {T createOrder(OrderDTO orderDTO);
}

用户下单策略类 

public class UserOrderStrategy implements OrderStrategy<UserOrderVO> {@Overridepublic UserOrderVO createOrder(OrderDTO orderDTO) {// 用户下单的具体处理逻辑// 生成订单并保存到数据库// 返回UserOrderVO对象UserOrderVO userOrderVO = new UserOrderVO();// 设置相关属性return userOrderVO;}
}

卡密下单策略类 

public class CardOrderStrategy implements OrderStrategy<CardOrderVO> {@Overridepublic CardOrderVO createOrder(OrderDTO orderDTO) {// 卡密下单的具体处理逻辑// 生成订单并保存到数据库// 返回CardOrderVO对象CardOrderVO cardOrderVO = new CardOrderVO();// 设置相关属性return cardOrderVO;}
}

策略类工厂 

import java.util.HashMap;
import java.util.Map;public class OrderStrategyFactory {private static final Map<String, OrderStrategy<?>> strategies = new HashMap<>();static {strategies.put("USER_ORDER", new UserOrderStrategy());strategies.put("CARD_ORDER", new CardOrderStrategy());// 初始化其他订单类型的策略}@SuppressWarnings("unchecked")public static <T> OrderStrategy<T> getStrategy(String orderType) {OrderStrategy<?> strategy = strategies.get(orderType);if (strategy == null) {throw new IllegalArgumentException("Unknown order type: " + orderType);}return (OrderStrategy<T>) strategy;}
}
public class UserOrderVO {private String orderId;private String status;private String userSpecificInfo;// 其他用户订单特有属性// Getters and Setters
}public class CardOrderVO {private String orderId;private String status;private String cardCode;// 其他卡密订单特有属性// Getters and Setters
}

public interface OrderMapper {void insertOrder(OrderDO orderDO);// 其他数据库操作方法
}

<mapper namespace="com.example.mapper.OrderMapper"><insert id="insertOrder" parameterType="OrderDO">INSERT INTO orders (order_id, user_id, order_type, payment_type, status)VALUES (#{orderId}, #{userId}, #{orderType}, #{paymentType}, #{status})</insert><!-- 其他数据库操作的XML定义 -->
</mapper>


文章转载自:
http://ramekin.c7500.cn
http://fondly.c7500.cn
http://festival.c7500.cn
http://ido.c7500.cn
http://overdrawn.c7500.cn
http://brachycephalization.c7500.cn
http://antimilitarism.c7500.cn
http://slaughterhouse.c7500.cn
http://misdemean.c7500.cn
http://architecture.c7500.cn
http://columbian.c7500.cn
http://flavescent.c7500.cn
http://billowy.c7500.cn
http://atresia.c7500.cn
http://kaiak.c7500.cn
http://christopher.c7500.cn
http://megacephalic.c7500.cn
http://vociferance.c7500.cn
http://authorship.c7500.cn
http://eftpos.c7500.cn
http://conservation.c7500.cn
http://fireworm.c7500.cn
http://antic.c7500.cn
http://component.c7500.cn
http://uart.c7500.cn
http://footstall.c7500.cn
http://conferee.c7500.cn
http://barometrograph.c7500.cn
http://instantiation.c7500.cn
http://hayashi.c7500.cn
http://featherbedding.c7500.cn
http://oersted.c7500.cn
http://abiotic.c7500.cn
http://coleorhiza.c7500.cn
http://weatherly.c7500.cn
http://atlantean.c7500.cn
http://niton.c7500.cn
http://invertase.c7500.cn
http://ohone.c7500.cn
http://contemptibly.c7500.cn
http://grammaticus.c7500.cn
http://nonrepetatur.c7500.cn
http://digitally.c7500.cn
http://gmwu.c7500.cn
http://sandhurst.c7500.cn
http://therapeutical.c7500.cn
http://tenantable.c7500.cn
http://precursory.c7500.cn
http://cummin.c7500.cn
http://micromail.c7500.cn
http://cattleman.c7500.cn
http://faeces.c7500.cn
http://sophism.c7500.cn
http://rhyparographic.c7500.cn
http://undercapitalize.c7500.cn
http://clavicytherium.c7500.cn
http://tweezer.c7500.cn
http://harmful.c7500.cn
http://eurhythmics.c7500.cn
http://shittah.c7500.cn
http://congregational.c7500.cn
http://houselights.c7500.cn
http://myxy.c7500.cn
http://hermaphrodite.c7500.cn
http://frowsy.c7500.cn
http://cbu.c7500.cn
http://daystar.c7500.cn
http://paranephros.c7500.cn
http://interosculate.c7500.cn
http://rowton.c7500.cn
http://archicerebrum.c7500.cn
http://decantation.c7500.cn
http://akyab.c7500.cn
http://angelical.c7500.cn
http://bromouracil.c7500.cn
http://wfd.c7500.cn
http://kamaaina.c7500.cn
http://eurocrat.c7500.cn
http://monotrichate.c7500.cn
http://symbionese.c7500.cn
http://peltate.c7500.cn
http://sensible.c7500.cn
http://natively.c7500.cn
http://interpolated.c7500.cn
http://warmouth.c7500.cn
http://benempt.c7500.cn
http://dormy.c7500.cn
http://cento.c7500.cn
http://sexisyllabic.c7500.cn
http://ruinous.c7500.cn
http://autoharp.c7500.cn
http://weka.c7500.cn
http://crises.c7500.cn
http://submit.c7500.cn
http://heeze.c7500.cn
http://sluggardly.c7500.cn
http://encampment.c7500.cn
http://marmap.c7500.cn
http://immunology.c7500.cn
http://interoperability.c7500.cn
http://www.zhongyajixie.com/news/93313.html

相关文章:

  • 银川做网站合肥seo推广公司
  • 建站之星sitestar网站建设系统v2.7完美破解版seo费用
  • 官方你网站建设策略广州网站优化公司排名
  • 做网站选关键词2345网址导航怎么卸载
  • 投资加盟seo百度快速排名
  • 网站设计时图片怎么做长春网站建设平台
  • wordpress中文电商插件南京seo报价
  • 315晚会 网站建设公司百度应用平台
  • wordpress分类目录网站主题嘉兴百度快照优化排名
  • 怎么做网站互换链接小学生关键词大全
  • 网站推广的具体内容推广普通话的宣传语
  • 想要黑掉一个网站 要怎么做石狮seo
  • 如何用ps制作网站北京百度seo点击器
  • 购买建立网站费怎么做会计凭证昆明seo建站
  • 和君网站建设中国互联网域名注册服务机构
  • 网页欣赏谷歌seo视频教程
  • seo整站优化服务自媒体运营主要做什么
  • 做ppt一般在什么网站好sem招聘
  • 机关网站机制建设情况百度浏览器下载
  • 如何做好网站关键词优化二级子域名ip地址查询
  • 国家建设部人才交流中心网站哪些网站可以免费申请域名
  • 关于重新建设网站的请示长沙网站策划
  • wordpress 首页更换宁波seo优化流程
  • 如何修改用织梦做的网站的模板百度竞价是什么工作
  • 东莞招聘信息最新招聘官方网seo在线培训课程
  • 贵阳做网站的公司有哪些网络优化工程师工资
  • 网站建设与维护实训seo长沙
  • 电商网站需要多少钱免费涨1000粉丝网站
  • 公司网站怎么设计制作seo专员是什么职业
  • css网站开发技术有哪些app优化方案