From f825da68fec11f02fd676757d60a258b136589e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sat, 29 Jul 2023 17:40:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=8A=95=E6=94=BE=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/study/design/DesignApplication.java | 14 +++++-- .../com/study/design/pay/pojo/PayBody.java | 2 +- .../com/study/design/pojo/TicketParam.java | 20 +++++++++ .../java/com/study/design/pojo/UserInfo.java | 20 +++++++++ .../com/study/design/service/UserService.java | 41 +++++++++++++++---- .../java/login/implementor/ZfbLoginFunc.java | 2 +- .../study/design/DesignApplicationTests.java | 8 ++++ 7 files changed, 94 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/study/design/DesignApplication.java b/src/main/java/com/study/design/DesignApplication.java index bb613bf..0b2dbee 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 4d5b816..2f6fc5d 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 c858b01..5c5a209 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 33f7b90..cebeecc 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 67fc8f6..d13847f 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 9a60675..5b30787 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 6b4cbf8..644937e 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 { -- GitLab