From 42dca96cf13f7284167e3fd59f3d30c7a8e832bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sun, 30 Jul 2023 19:06:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E7=99=BB=E5=BD=95=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/study/design/login/LoginFunc.java | 13 +++++++++++ .../study/design/login}/WbLoginFunc.java | 12 ++++++++-- .../study/design/login}/ZfbLoginFunc.java | 10 +++++++- .../abstractlogin/AbstractLoginProcessor.java | 12 ++++++++-- .../login/abstractlogin/ThirdPartLogin.java | 23 +++++++++++++++++++ .../com/study/design/service/UserService.java | 20 +++++++++++----- .../java/login/implementor/LoginFunc.java | 5 ---- .../abstractlogin/ThirdPartLogin.java | 15 ------------ 8 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/study/design/login/LoginFunc.java rename src/main/java/{login/implementor => com/study/design/login}/WbLoginFunc.java (55%) rename src/main/java/{login/implementor => com/study/design/login}/ZfbLoginFunc.java (67%) rename src/main/java/{login/implementor => com/study/design/login}/abstractlogin/AbstractLoginProcessor.java (57%) create mode 100644 src/main/java/com/study/design/login/abstractlogin/ThirdPartLogin.java delete mode 100644 src/main/java/login/implementor/LoginFunc.java delete mode 100644 src/main/java/login/implementor/abstractlogin/ThirdPartLogin.java diff --git a/src/main/java/com/study/design/login/LoginFunc.java b/src/main/java/com/study/design/login/LoginFunc.java new file mode 100644 index 0000000..944a5b7 --- /dev/null +++ b/src/main/java/com/study/design/login/LoginFunc.java @@ -0,0 +1,13 @@ +package com.study.design.login; + + +/** + * 登录接口 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 19:01 + */ +public interface LoginFunc { + public boolean login(String name, String pwd, String type); +} diff --git a/src/main/java/login/implementor/WbLoginFunc.java b/src/main/java/com/study/design/login/WbLoginFunc.java similarity index 55% rename from src/main/java/login/implementor/WbLoginFunc.java rename to src/main/java/com/study/design/login/WbLoginFunc.java index ceadf59..09c8a46 100644 --- a/src/main/java/login/implementor/WbLoginFunc.java +++ b/src/main/java/com/study/design/login/WbLoginFunc.java @@ -1,6 +1,14 @@ -package login.implementor; +package com.study.design.login; -public class WbLoginFunc implements LoginFunc{ + +/** + * 微博登录 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 19:01 + */ +public class WbLoginFunc implements LoginFunc { @Override public boolean login(String name, String pwd, String type) { // 进行第三方账号的校验流程。 diff --git a/src/main/java/login/implementor/ZfbLoginFunc.java b/src/main/java/com/study/design/login/ZfbLoginFunc.java similarity index 67% rename from src/main/java/login/implementor/ZfbLoginFunc.java rename to src/main/java/com/study/design/login/ZfbLoginFunc.java index 5b30787..d921c5f 100644 --- a/src/main/java/login/implementor/ZfbLoginFunc.java +++ b/src/main/java/com/study/design/login/ZfbLoginFunc.java @@ -1,5 +1,13 @@ -package login.implementor; +package com.study.design.login; + +/** + * 支付宝登录 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 19:02 + */ public class ZfbLoginFunc implements LoginFunc { @Override public boolean login(String name, String pwd, String type) { diff --git a/src/main/java/login/implementor/abstractlogin/AbstractLoginProcessor.java b/src/main/java/com/study/design/login/abstractlogin/AbstractLoginProcessor.java similarity index 57% rename from src/main/java/login/implementor/abstractlogin/AbstractLoginProcessor.java rename to src/main/java/com/study/design/login/abstractlogin/AbstractLoginProcessor.java index 3063cbb..feba089 100644 --- a/src/main/java/login/implementor/abstractlogin/AbstractLoginProcessor.java +++ b/src/main/java/com/study/design/login/abstractlogin/AbstractLoginProcessor.java @@ -1,7 +1,15 @@ -package login.implementor.abstractlogin; +package com.study.design.login.abstractlogin; -import login.implementor.LoginFunc; +import com.study.design.login.LoginFunc; + +/** + * 登录处理器抽象类 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 19:02 + */ public abstract class AbstractLoginProcessor { protected LoginFunc loginFunc; diff --git a/src/main/java/com/study/design/login/abstractlogin/ThirdPartLogin.java b/src/main/java/com/study/design/login/abstractlogin/ThirdPartLogin.java new file mode 100644 index 0000000..3fccf0d --- /dev/null +++ b/src/main/java/com/study/design/login/abstractlogin/ThirdPartLogin.java @@ -0,0 +1,23 @@ +package com.study.design.login.abstractlogin; + +import com.study.design.login.LoginFunc; + + +/** + * 第三方登录封装 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/30 19:02 + */ +public class ThirdPartLogin extends AbstractLoginProcessor { + + public ThirdPartLogin(LoginFunc loginFunc) { + super(loginFunc); + } + + @Override + public boolean loginExecute(String name, String pwd, String type) { + return super.loginFunc.login(name, pwd, type); + } +} diff --git a/src/main/java/com/study/design/service/UserService.java b/src/main/java/com/study/design/service/UserService.java index 666ad15..8866f63 100644 --- a/src/main/java/com/study/design/service/UserService.java +++ b/src/main/java/com/study/design/service/UserService.java @@ -1,6 +1,11 @@ package com.study.design.service; import com.study.design.handler.SuggestRequirementHandlerProcess; +import com.study.design.login.LoginFunc; +import com.study.design.login.WbLoginFunc; +import com.study.design.login.ZfbLoginFunc; +import com.study.design.login.abstractlogin.AbstractLoginProcessor; +import com.study.design.login.abstractlogin.ThirdPartLogin; import com.study.design.pojo.TicketParam; import com.study.design.pojo.UserInfo; import com.study.design.ticket.builder.CompanyTicketBuilder; @@ -93,12 +98,15 @@ public class UserService { // 这部分我就不进行封装了,直接在 service里做了。小伙伴可以自行实现封装,类似享元。 // 这部分是桥接模式的实现。 -// if(type.equals("wb")) { -// LoginFunc func = new WbLoginFunc(); -// AbstractLoginProcessor processor = new ThirdPartLogin(func); -// return processor.loginExecute(name, pwd, type); -// } - + if ("wb".equals(type)) { + LoginFunc func = new WbLoginFunc(); + AbstractLoginProcessor processor = new ThirdPartLogin(func); + return processor.loginExecute(name, pwd, type); + } else if ("zfb".equals(type)) { + LoginFunc func = new ZfbLoginFunc(); + AbstractLoginProcessor processor = new ThirdPartLogin(func); + return processor.loginExecute(name, pwd, type); + } return true; } } diff --git a/src/main/java/login/implementor/LoginFunc.java b/src/main/java/login/implementor/LoginFunc.java deleted file mode 100644 index 59ed3dc..0000000 --- a/src/main/java/login/implementor/LoginFunc.java +++ /dev/null @@ -1,5 +0,0 @@ -package login.implementor; - -public interface LoginFunc { - public boolean login(String name, String pwd, String type); -} diff --git a/src/main/java/login/implementor/abstractlogin/ThirdPartLogin.java b/src/main/java/login/implementor/abstractlogin/ThirdPartLogin.java deleted file mode 100644 index 9430e83..0000000 --- a/src/main/java/login/implementor/abstractlogin/ThirdPartLogin.java +++ /dev/null @@ -1,15 +0,0 @@ -package login.implementor.abstractlogin; - -import login.implementor.LoginFunc; - -public class ThirdPartLogin extends AbstractLoginProcessor{ - - public ThirdPartLogin(LoginFunc loginFunc) { - super(loginFunc); - } - - @Override - public boolean loginExecute(String name, String pwd, String type) { - return super.loginFunc.login(name, pwd, type); - } -} -- GitLab