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 0000000000000000000000000000000000000000..944a5b78aae5dc31e3ae2ac9df55063c48fbec23 --- /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 ceadf5950143dbe602b9cf44c58fd359b0a1d0d0..09c8a46bb60ad78c1851860c0c1037a50e19cb07 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 5b30787f2ea19f9aec5cf9567135978a975406ec..d921c5fd456fad72d98c56ebffb5699fbdbfbd7d 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 3063cbbac5030f6045d39a9ec41190312c746295..feba08913475994368d5d8cc41358bb10f50e0f4 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 0000000000000000000000000000000000000000..3fccf0d2db2628cde9132c9cfbcdf8af7a77734f --- /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 666ad15885fa3834a2cb695a268a5619882257b8..8866f630affad11391a5f64e8976a1a0a2e29a25 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 59ed3dcce831168573ca0de1212697c700ad82af..0000000000000000000000000000000000000000 --- 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 9430e83ef6c18a23dd1202855315e0256b448d09..0000000000000000000000000000000000000000 --- 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); - } -}