in order to be compatible with a variety of businesses, I want to use some design patterns in the project for ease of management.
for example, I need to create a user and return userid,. Each business is created in a different way.
I chose Adapter pattern, but I found that new classes are often needed under the management of springmvc, and at this time, some spring tags in this class are invalid.
here is the code I used to create the user:
Interface
public interface IPlatformSendPay {
public abstract Object sendPayInA(Object object);
public abstract Object sendPayInB(Object object);
}
parent
public class PlatformSendPay {
private Object obj;
@Resource
private OpenPaymentDao openPaymentDao;
public PlatformSendPay(Object obj) {
this.obj = obj;
}
public Object getUserIdInA(){
JidouOrderData jidouOrderData = (JidouOrderData) obj;
int stationId = jidouOrderData.getStation_id();
//openPaymentDao@ResourcePlatformSendPayspring
Integer userId = openPaymentDao.getIdentifyUser(jidouOrderData.getIdentifyId(), "1000000013");
if (ObjectUtils.isEmpty(userId)){
//todo:
}
return userId;
}
}
subclass
public class SendPay extends PlatformSendPay implements IPlatformSendPay{
public SendPay(Object obj) {
super(obj);
}
@Override
public Object sendPayInA(Object object) {
return getUserIdInA();
}
@Override
public Object sendPayInB(Object object) {
return getUserIdInB();
}
}
this is my implementation class, the @ Service tag in springmvc
//
SendPay sendPay = new SendPay(jidouOrderData);
int userId = (int) sendPay.getUserIdInA();
//
SendPay sendPay = new SendPay(JdOrderData);
int userId = (int) sendPay.getUserIdInB();
questions
1.PlatformSendPay Why is spring binding unsuccessful? How can I bind successfully? In
2.springmvc, do you use such design patterns as little as possible? In the method in the object, the variable used has a spring tag, but in the case of new, will this be invalid?