fix:添加不同的登录方式

上级 aefbb742
package login.implementor; package com.study.design.login;
/**
* 登录接口
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 19:01
*/
public interface LoginFunc { public interface LoginFunc {
public boolean login(String name, String pwd, String type); public boolean login(String name, String pwd, String type);
} }
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 @Override
public boolean login(String name, String pwd, String type) { public boolean login(String name, String pwd, String type) {
// 进行第三方账号的校验流程。 // 进行第三方账号的校验流程。
......
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 { public class ZfbLoginFunc implements LoginFunc {
@Override @Override
public boolean login(String name, String pwd, String type) { public boolean login(String name, String pwd, String type) {
......
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 { public abstract class AbstractLoginProcessor {
protected LoginFunc loginFunc; protected LoginFunc loginFunc;
......
package login.implementor.abstractlogin; package com.study.design.login.abstractlogin;
import login.implementor.LoginFunc; import com.study.design.login.LoginFunc;
public class ThirdPartLogin extends AbstractLoginProcessor{
/**
* 第三方登录封装
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/7/30 19:02
*/
public class ThirdPartLogin extends AbstractLoginProcessor {
public ThirdPartLogin(LoginFunc loginFunc) { public ThirdPartLogin(LoginFunc loginFunc) {
super(loginFunc); super(loginFunc);
......
package com.study.design.service; package com.study.design.service;
import com.study.design.handler.SuggestRequirementHandlerProcess; 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.TicketParam;
import com.study.design.pojo.UserInfo; import com.study.design.pojo.UserInfo;
import com.study.design.ticket.builder.CompanyTicketBuilder; import com.study.design.ticket.builder.CompanyTicketBuilder;
...@@ -93,12 +98,15 @@ public class UserService { ...@@ -93,12 +98,15 @@ public class UserService {
// 这部分我就不进行封装了,直接在 service里做了。小伙伴可以自行实现封装,类似享元。 // 这部分我就不进行封装了,直接在 service里做了。小伙伴可以自行实现封装,类似享元。
// 这部分是桥接模式的实现。 // 这部分是桥接模式的实现。
// if(type.equals("wb")) { if ("wb".equals(type)) {
// LoginFunc func = new WbLoginFunc(); LoginFunc func = new WbLoginFunc();
// AbstractLoginProcessor processor = new ThirdPartLogin(func); AbstractLoginProcessor processor = new ThirdPartLogin(func);
// return processor.loginExecute(name, pwd, type); 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; return true;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册