parent
807166f6fc
commit
a4fb42ef4b
@ -0,0 +1,14 @@
|
|||||||
|
package au.com.royalpay.payment.manage.application.core;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
public interface SimpleClientApplyService {
|
||||||
|
String getSMSVerifyCode(String codeKey);
|
||||||
|
|
||||||
|
JSONObject newAccount(NewAccountBean accountBean);
|
||||||
|
|
||||||
|
void deleteSMSVerifyCodeKey(String codeKey);
|
||||||
|
|
||||||
|
String partnerSignIn(JSONObject account);
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package au.com.royalpay.payment.manage.application.web;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
|
||||||
|
import au.com.royalpay.payment.tools.CommonConsts;
|
||||||
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/register")
|
||||||
|
public class SimpleClientApplyController {
|
||||||
|
@Resource
|
||||||
|
private SimpleClientApplyService simpleClientApplyService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/account/{codeKey}", method = RequestMethod.POST)
|
||||||
|
public void registerAccount(@PathVariable String codeKey, @RequestBody @Valid NewAccountBean accountBean, Errors errors, HttpServletResponse response) throws Exception {
|
||||||
|
HttpUtils.handleValidErrors(errors);
|
||||||
|
String codeValue = simpleClientApplyService.getSMSVerifyCode(codeKey);
|
||||||
|
if (codeValue == null || !codeValue.equals(accountBean.getUsername())) {
|
||||||
|
throw new Exception("Verification code has expired or is not correct");
|
||||||
|
}
|
||||||
|
JSONObject account = simpleClientApplyService.newAccount(accountBean);
|
||||||
|
simpleClientApplyService.deleteSMSVerifyCodeKey(codeKey);
|
||||||
|
String statusKey = simpleClientApplyService.partnerSignIn(account);
|
||||||
|
HttpUtils.setCookie(response, CommonConsts.CODE_KEY, statusKey);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue