|
|
@ -1,17 +1,14 @@
|
|
|
|
package au.com.royalpay.payment.manage.citypartner.web;
|
|
|
|
package au.com.royalpay.payment.manage.citypartner.web;
|
|
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerBean;
|
|
|
|
import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerBean;
|
|
|
|
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerRegisterService;
|
|
|
|
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerRegisterService;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientApply;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.CommonConsts;
|
|
|
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
|
|
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
|
|
|
import au.com.royalpay.payment.tools.secure.ApplyRequest;
|
|
|
|
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -22,10 +19,22 @@ import javax.validation.Valid;
|
|
|
|
public class CityPartnerRegisterController {
|
|
|
|
public class CityPartnerRegisterController {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CityPartnerRegisterService cityPartnerRegisterService;
|
|
|
|
private CityPartnerRegisterService cityPartnerRegisterService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ClientApply clientApply;
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
|
@ApplyRequest
|
|
|
|
public void register(@CookieValue(CommonConsts.CODE_KEY) String codeKey, HttpServletResponse response,
|
|
|
|
public void register(@RequestBody @Valid CityPartnerBean partner, Errors errors) {
|
|
|
|
@RequestBody @Valid CityPartnerBean partner, Errors errors) throws Exception{
|
|
|
|
|
|
|
|
String codeValue = clientApply.getVerifyCode(codeKey);
|
|
|
|
|
|
|
|
if (codeValue == null) {
|
|
|
|
|
|
|
|
throw new Exception("Verification code has expired");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!codeValue.equals(partner.getCaptcha())){
|
|
|
|
|
|
|
|
throw new Exception("Verification code is not correct");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
clientApply.deleteVerifyCodeKey(codeKey);
|
|
|
|
|
|
|
|
HttpUtils.dropCookie(response, CommonConsts.CODE_KEY);
|
|
|
|
|
|
|
|
}
|
|
|
|
HttpUtils.handleValidErrors(errors);
|
|
|
|
HttpUtils.handleValidErrors(errors);
|
|
|
|
cityPartnerRegisterService.saveRegistry(partner);
|
|
|
|
cityPartnerRegisterService.saveRegistry(partner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|