如何验证要更新的特定字段

时间:2016-10-05 13:19:12

标签: java

有一个用户下面有certian客户端。每个客户端都有其确定的详细信息和唯一的UserName。我给出了一个选项,用户可以通过该选项更改或更新其客户端详细信息。

public String updateClientDetials()
{
    AccountService accountService = new AccountService();
    UserServiceAction userServiceAction = new UserServiceAction();
    Userr user = ( (OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
    user =  Userr.findUserr(user.getId());
    if(userServiceAction.isClientValid(user,uname,lastname,tandc).equals("valid")){
    Account account = accountService.getClientDetails(Long.parseLong(updateClientId));
    account.setUserName(uname);
    account.setLastName(lastname);
    account.setExpectedProfitPPA(userServiceAction.convertToDouble(eppa,new Double(100)));
    account.setMaxLossPPA(userServiceAction.convertToDouble(mlppa,new Double(80)));     
    }

}

现在在更新任何客户端详细信息时,我必须确保userName不应该相同,我正在通过caliiing" clientAlreadyExits()"

但与此同时,如果我只是更新lastName,那么它也会检查userName并显示userName已经退出。 如何验证要更新的特定字段?

public String isClientValid(Userr user,String uname,String lastName,String tandc){
    System.out.println("Entering into isClientValid() of UserServiceAction ");
    if(uname.isEmpty()){
        return "Enter valid First Name";
    }else if(clientAlreadyExist(user,uname)){
        return "uname ID already exists";
    }
    else if(lastName.isEmpty()){
        return "Enter valid Last Name";
    }
    else if(tandc == null || tandc.isEmpty()){
        return "Kindly agree to the Terms and Conditions";
    }
    else if(("false").equals(tandc)) {
        return "Kindly agree to the Terms and Conditions";
    }
    else{
    System.out.println("Exiting from isClientValid() of UserServiceAction ");
    return "valid";
    }

}

0 个答案:

没有答案