gpt4 book ai didi

java - 经过验证后,如何从 postman 获取数据到请求映射?

转载 作者:行者123 更新时间:2023-12-01 18:55:22 24 4
gpt4 key购买 nike

我的网址:

http://localhost:8083/Spring_Hibernate_Integ/updatedata?companyname=Tara Chand logistic Solutions limited&companystatus=LISTED

我的 postman 数据:

{
"orgLoginId" : "nse",
"uPassword" : "Scores@2015"
}
If the login and the validation is success then I should get the below data from postman tool to my requestmapping. How do i get that?
{
"officer" : "xyz",
"designation" : "xyz",
"sex" : "male",
"phoneno" : "1234567890",
"mobileno" : "1234567890",
"email" : "abc@gmail.com",
"address1" : "xyz",
"address2" : "cityname"
}

我的请求映射:

首先我得到登录ID和密码。验证登录ID和密码后..我正在做一些验证。如果验证成功,那么我应该要求 postman 提供上述数据。请告诉我该怎么做?

@RequestMapping(value="updatedata",method = { RequestMethod.GET, RequestMethod.POST })
public CompaniesPresenter UpdateData(@RequestBody UserDetails user,
@RequestParam(value="companyname",required = false) String companyName,
@RequestParam(value="companystatus",required=false) String companyStatus)

{
String OrgLoginId=user.getOrgLoginId();
String password=user.getuPassword();
String checkLoginId=null;
String uPassword=null;
String encPassword=null;
String loginId=null;
String checkAuthorized=null;
String StockExchangeCode=null;
String checkCompanyStatus=null;
String checkOrgloginId=userService.getLoginId(OrgLoginId);

if(checkOrgloginId==null){
return new CompaniesPresenter("Incorrect loginId..Please enter valid loginId");
}
List<Object[]> CheckIdPassword=userService.checkLoginId(OrgLoginId);
List<Object[]> results = CheckIdPassword;
for(Object[] obj:results){
checkLoginId=obj[0].toString();
if(null==obj[1]){
uPassword="";
}else{
uPassword=obj[1].toString();
}
loginId=obj[2].toString();
}
checkAuthorized=loginId.substring(0,3);
if (null != password) {
MD5 md5 = new MD5();
encPassword = md5.getPassword(password);
}

if(encPassword.equals(uPassword))
{
if (checkAuthorized.equals("STE"))
{
StockExchangeCode=userService.getStockExchangeCode(companyName);
if(StockExchangeCode.equals(loginId))
{
checkCompanyStatus=userService.getCompanyStatus(companyStatus);
if(companyStatus.equals(checkCompanyStatus))
{

//get the data from postman and update it in table
return new CompaniesPresenter("update success");
}
else
{
return new CompaniesPresenter("Invalid company status");
}
}
else
{
return new CompaniesPresenter("Incorrect company or you do not belong to this company as designated stock exchange");
}
}
else
{
return new CompaniesPresenter("You are not Authorized");
}
}
else
{
return new CompaniesPresenter("Incorrect Password");
}

}
}

最佳答案

您似乎返回了错误的对象。最好重构您的 Controller 以使其简单并避免代码异味(很多 if/else 情况)。

关于java - 经过验证后,如何从 postman 获取数据到请求映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59676124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com