|
@@ -1,5 +1,9 @@
|
|
|
package cn.iselab.mooctest.user.web.ctrl;
|
|
|
|
|
|
+import cn.iselab.mooctest.rpc.user.data.UserDTO;
|
|
|
+import cn.iselab.mooctest.user.constants.ResponseStatus;
|
|
|
+import cn.iselab.mooctest.user.data.Callback;
|
|
|
+import cn.iselab.mooctest.user.data.ResponseResult;
|
|
|
import cn.iselab.mooctest.user.service.MailService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.Model;
|
|
@@ -7,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.mail.MessagingException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.rmi.MarshalledObject;
|
|
|
import java.util.HashMap;
|
|
@@ -17,7 +22,7 @@ import java.util.Map;
|
|
|
* @Date: 2018.12.24 19:11
|
|
|
*/
|
|
|
@RestController
|
|
|
-public class TestController {
|
|
|
+public class TestController extends BaseController{
|
|
|
|
|
|
@Autowired
|
|
|
MailService mailService;
|
|
@@ -38,10 +43,18 @@ public class TestController {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/test/mail", method = RequestMethod.GET)
|
|
|
- public void sendMail(){
|
|
|
- mailService.sendNormalEmail("", "171256175@qq.com",
|
|
|
- "[TEST]测试邮件", "这是一封测试邮件<a href='https://www.baidu.com'/>");
|
|
|
+ @RequestMapping(value = "/test/mail", method = RequestMethod.POST)
|
|
|
+ public ResponseResult<Object> sendMail(UserDTO userDTO){
|
|
|
+ ResponseResult<Object> result = new ResponseResult<>();
|
|
|
+ System.out.println("\nreceiver: "+userDTO.getEmail()+"\n");
|
|
|
+ try {
|
|
|
+ mailService.sendVerifyEmail("diors_po@126.com", "171256175@qq.com", "1234");
|
|
|
+ result.init(ResponseStatus.SUCCESS, "发送成功", null);
|
|
|
+ } catch (MessagingException e) {
|
|
|
+ result.init(ResponseStatus.FAILED, "发送失败", null);
|
|
|
+ LOG.error("发送邮件出错",e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/test/error", method = RequestMethod.GET)
|
|
@@ -58,12 +71,18 @@ public class TestController {
|
|
|
|
|
|
@RequestMapping(value = "/test/register", method = RequestMethod.GET)
|
|
|
public ModelAndView registerPage(){
|
|
|
+ // ResponseResult<Object> result = new ResponseResult<>();
|
|
|
+ // result.init(1000, "哈哈哈哈哈", null);
|
|
|
+ // model.addAttribute("result", result);
|
|
|
return new ModelAndView("register");
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/test/get", method = RequestMethod.GET)
|
|
|
- public String test(@RequestBody String afterLogin){
|
|
|
- return afterLogin;
|
|
|
+ @RequestMapping(value = "/test/get", method = RequestMethod.POST)
|
|
|
+ public String test(Callback afterLogin){
|
|
|
+ System.out.println("\nafterLogin====="+afterLogin.getRedirectURL()+"\n");
|
|
|
+ System.out.println("\nafterLogin====="+afterLogin.getDefaultURL()+"\n");
|
|
|
+
|
|
|
+ return afterLogin.getRedirectURL();
|
|
|
}
|
|
|
|
|
|
|