经过验证后,如何从邮递员获取数据到requestmapping?

问题描述 投票:0回答:1

我的网址:

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

我的邮递员数据:

{
    "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"       : "[email protected]",
    "address1"    :  "xyz",
    "address2"    : "cityname"
}

我的请求映射:

首先,我得到了登录名和密码。在验证了登录名和密码之后。如果验证成功,那么我应该请邮递员提供以上数据。请让我知道该怎么做?

@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");
        }

    }   
}
java spring spring-mvc postman
1个回答
0
投票
似乎您要返回错误的对象。重构控制器使其简化并避免代码异味(很多if / else情况)将是一个很好的选择。
© www.soinside.com 2019 - 2024. All rights reserved.