diff --git a/src/main/java/com/study/design/DesignApplication.java b/src/main/java/com/study/design/DesignApplication.java index bb613bf465e5c5bc1d2daed3fe4a1a06024bd3c4..0b2dbeea0920996031f710147e2a0eb3ccef89c9 100644 --- a/src/main/java/com/study/design/DesignApplication.java +++ b/src/main/java/com/study/design/DesignApplication.java @@ -3,11 +3,19 @@ package com.study.design; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * 启动类 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:39 + */ @SpringBootApplication public class DesignApplication { - public static void main(String[] args) { - SpringApplication.run(DesignApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(DesignApplication.class, args); + } } diff --git a/src/main/java/com/study/design/pay/pojo/PayBody.java b/src/main/java/com/study/design/pay/pojo/PayBody.java index 4d5b8166f8e0dbd9123d5ad036e82f62e7bbd4af..2f6fc5ddad496dc1f80237e0b68700889c6e73d1 100644 --- a/src/main/java/com/study/design/pay/pojo/PayBody.java +++ b/src/main/java/com/study/design/pay/pojo/PayBody.java @@ -9,7 +9,7 @@ package com.study.design.pay.pojo; */ public class PayBody { /** - *支付账户 + *当前用户 */ private String account; /** diff --git a/src/main/java/com/study/design/pojo/TicketParam.java b/src/main/java/com/study/design/pojo/TicketParam.java index c858b01cd9c612155b9d8f9ad21f07c9d76d7e4a..5c5a209f4d99c447e0421a43ce1f312f0d53eab5 100644 --- a/src/main/java/com/study/design/pojo/TicketParam.java +++ b/src/main/java/com/study/design/pojo/TicketParam.java @@ -1,12 +1,32 @@ package com.study.design.pojo; + +/** + * 卖票业务 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:35 + */ public class TicketParam { /** * 真实的项目里,我们的account是set到用户的请求头里的 ,header里。过我们的网管的时候就已经记录了 */ + /** + * 账户 + */ private String account; + /** + * 名称 + */ private String title; + /** + * 银行信息 + */ private String bankInfo; + /** + * 商品id + */ private String productId; public String getAccount() { diff --git a/src/main/java/com/study/design/pojo/UserInfo.java b/src/main/java/com/study/design/pojo/UserInfo.java index 33f7b90d86542ee3bdc2cb79eb6419d83a5ec2bd..cebeeccecb49df3bf4de6848ce3d47cbeae178ea 100644 --- a/src/main/java/com/study/design/pojo/UserInfo.java +++ b/src/main/java/com/study/design/pojo/UserInfo.java @@ -2,10 +2,30 @@ package com.study.design.pojo; import java.util.List; + +/** + * 用户信息 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:34 + */ public class UserInfo { + /** + * 用户名 + */ private String username; + /** + * 城市 + */ private String city; + /** + * 购买的商品 + */ private List buyProducts; + /** + * 是否是新用户 + */ private boolean isNewUser; public String getUsername() { diff --git a/src/main/java/com/study/design/service/UserService.java b/src/main/java/com/study/design/service/UserService.java index 67fc8f6db7f1bbbbe7dee300c585e5a341f3617f..d13847fc88df069a078652d0d0449de254f084f6 100644 --- a/src/main/java/com/study/design/service/UserService.java +++ b/src/main/java/com/study/design/service/UserService.java @@ -6,16 +6,19 @@ import com.study.design.pojo.UserInfo; import com.study.design.ticket.builder.CompanyTicketBuilder; import com.study.design.ticket.builder.PersonalTicketBuilder; import com.study.design.ticket.builder.TicketBuilder; -import login.implementor.LoginFunc; -import login.implementor.WbLoginFunc; -import login.implementor.abstractlogin.AbstractLoginProcessor; -import login.implementor.abstractlogin.ThirdPartLogin; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +/** + * 用户相关的实现类 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:37 + */ @Service public class UserService { @@ -32,16 +35,29 @@ public class UserService { return results; } - //因为这部分是需要查询 缓存(如果缓存没有,需要查库)不应该写到 service层,但是为了代码书写简便 - //这部分我模拟在service 层。 + + /** + * 因为这部分是需要查询 缓存(如果缓存没有,需要查库)不应该写到 service层,但是为了代码书写简便 + * 这部分我模拟在service 层。 + * + * @param username + * @return + */ private UserInfo getUserInfo(String username) { return new UserInfo(); } + + /** + * 获取票 + * + * @param ticketParam + * @return + */ public Object getTicket(TicketParam ticketParam) { TicketBuilder builder = null; String bankInfo = null; - if(ticketParam.getBankInfo() != null) { + if (ticketParam.getBankInfo() != null) { bankInfo = "from 3rd party interface check."; builder = new CompanyTicketBuilder(); } else { @@ -54,9 +70,18 @@ public class UserService { builder.setProduct(product); builder.setBankInfo(bankInfo); // 详细的逻辑细节控制以及从配置中心或者是db中获取的逻辑步骤就是简单的 crud,自己明白即可 - return builder.buildTicket(); + return builder.buildTicket(); } + + /** + * 登录信息 + * + * @param name + * @param pwd + * @param type + * @return + */ public Boolean login(String name, String pwd, String type) { // 这部分我就不进行封装了,直接在 service里做了。小伙伴可以自行实现封装,类似享元。 diff --git a/src/main/java/login/implementor/ZfbLoginFunc.java b/src/main/java/login/implementor/ZfbLoginFunc.java index 9a6067509bc3a8e59885a4ad2c8e9dd75a009c55..5b30787f2ea19f9aec5cf9567135978a975406ec 100644 --- a/src/main/java/login/implementor/ZfbLoginFunc.java +++ b/src/main/java/login/implementor/ZfbLoginFunc.java @@ -1,6 +1,6 @@ package login.implementor; -public class ZfbLoginFunc implements LoginFunc{ +public class ZfbLoginFunc implements LoginFunc { @Override public boolean login(String name, String pwd, String type) { // 进行第三方账号的校验流程。 diff --git a/src/test/java/com/study/design/DesignApplicationTests.java b/src/test/java/com/study/design/DesignApplicationTests.java index 6b4cbf846adbb2c01028640caea2188657e603e2..644937e7b6acb0d64e8f25ec1ed948ff10ccf6a7 100644 --- a/src/test/java/com/study/design/DesignApplicationTests.java +++ b/src/test/java/com/study/design/DesignApplicationTests.java @@ -3,6 +3,14 @@ package com.study.design; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; + +/** + * 测试类 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:40 + */ @SpringBootTest class DesignApplicationTests {