如何将 userDetails 作为参数传递
How do I can pass userDetails as a parameter
如何将 Userr 实例作为参数传递。我已经尝试过了,但它不起作用。
public Double getCurrentProfitAndLoss() {
Double currentProfitAndLoss = null;
Userr user = ( (OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
user = Userr.findUserr(user.getId());
HomePageService homePageService = homePageServiceFactory.getObject();
System.out.println("homePageService object created");
try {
currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user);
} catch(Exception e) {
e.printStackTrace();
}
return currentProfitAndLoss;
}
但是当我像这样作为单个 属性 Userr 传递时,它工作正常。
public Double getCurrentProfitAndLoss() {
Double currentProfitAndLoss = null;
Userr user = ( (OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
user = Userr.findUserr(user.getId());
HomePageService homePageService = homePageServiceFactory.getObject();
System.out.println("homePageService object created");
try {
currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user.getId());
} catch(Exception e) {
e.printStackTrace();
}
return currentProfitAndLoss;
}
如何传递用户对象?
这是接受用户对象的方法,我没有收到任何错误。
public class主页服务{
public Double getCurrentProfitAndLoss(Userr user) {
System.out.println("iside HOmepageService");
Double currentProfitPercPA = StrategyExitReport.findCurrentProfitAndLossById(user);
System.out.println("iside currentProfitPercPA" + currentProfitPercPA);
return currentProfitPercPA;
}
}
我假设您使用的是 jpa。因此,您定义了以 ById 结尾的 findCurrentProfitAndLossById 方法,但实际上您使用了该对象。
所以将方法的名称更改为
findCurrentProfitAndLossByUser
如何将 Userr 实例作为参数传递。我已经尝试过了,但它不起作用。
public Double getCurrentProfitAndLoss() {
Double currentProfitAndLoss = null;
Userr user = ( (OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
user = Userr.findUserr(user.getId());
HomePageService homePageService = homePageServiceFactory.getObject();
System.out.println("homePageService object created");
try {
currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user);
} catch(Exception e) {
e.printStackTrace();
}
return currentProfitAndLoss;
}
但是当我像这样作为单个 属性 Userr 传递时,它工作正常。
public Double getCurrentProfitAndLoss() {
Double currentProfitAndLoss = null;
Userr user = ( (OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
user = Userr.findUserr(user.getId());
HomePageService homePageService = homePageServiceFactory.getObject();
System.out.println("homePageService object created");
try {
currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user.getId());
} catch(Exception e) {
e.printStackTrace();
}
return currentProfitAndLoss;
}
如何传递用户对象?
这是接受用户对象的方法,我没有收到任何错误。
public class主页服务{
public Double getCurrentProfitAndLoss(Userr user) {
System.out.println("iside HOmepageService");
Double currentProfitPercPA = StrategyExitReport.findCurrentProfitAndLossById(user);
System.out.println("iside currentProfitPercPA" + currentProfitPercPA);
return currentProfitPercPA;
}
}
我假设您使用的是 jpa。因此,您定义了以 ById 结尾的 findCurrentProfitAndLossById 方法,但实际上您使用了该对象。 所以将方法的名称更改为
findCurrentProfitAndLossByUser