VerificationCodeController.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package com.wechat.controller;
  2. import java.io.IOException;
  3. import java.util.Map;
  4. import javax.annotation.Resource;
  5. import javax.servlet.http.Cookie;
  6. import javax.servlet.http.HttpServletRequest;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import com.wechat.common.utils.StringsUtils;
  13. import com.wechat.global.base.BaseController;
  14. import com.wechat.global.message.InfoMsg;
  15. import com.wechat.model.responseDto.ResultEntity;
  16. import com.wechat.service.VerificationCodeService;
  17. @Controller
  18. @RequestMapping("verifyCode")
  19. public class VerificationCodeController extends BaseController {
  20. @Resource
  21. private VerificationCodeService vefificationCodeService;
  22. /**
  23. * 短信验证码取得
  24. *
  25. * @param map
  26. * @param request
  27. * @return
  28. * @throws IOException
  29. */
  30. @RequestMapping(value = "getVerifyCode", method = RequestMethod.POST)
  31. @ResponseBody
  32. public ResultEntity<String> getVerifyCode(@RequestBody Map<String, String> map, HttpServletRequest request)
  33. throws IOException {
  34. Cookie[] cookies = request.getCookies();
  35. String type = map.get("type");
  36. // type 0:个人 1:企业 2:忘记密码
  37. if (StringsUtils.isEmpty(type)) {
  38. return new ResultEntity<String>(InfoMsg.ERROR_NULL_PARAM);
  39. }
  40. String userName = StringsUtils.trim(map.get("userName"));
  41. String imageCode = map.get("imageCode");
  42. String entPhone = StringsUtils.trim(map.get("entPhone"));
  43. String phoneCode = map.get("phoneCode");
  44. //去除验证码首尾空格
  45. imageCode = StringsUtils.trim(imageCode);
  46. // 个人注册
  47. if (type.equals("0")) {
  48. return vefificationCodeService.getPersonVerifyCode(userName, imageCode, cookies, phoneCode);
  49. } else if (type.equals("1")) {
  50. // 企业注册
  51. return vefificationCodeService.getEnterpriseVerifyCode(userName, imageCode, entPhone, cookies);
  52. } else if (type.equals("2")) {
  53. // 忘记密码
  54. return vefificationCodeService.getForgetVerifyCode( userName, imageCode, cookies, request);
  55. } else {
  56. return new ResultEntity<>(InfoMsg.ERROR_TYPE_ERROR);
  57. }
  58. }
  59. /**
  60. * 企业发送汇款短信
  61. *
  62. * @param param
  63. * @return
  64. */
  65. @RequestMapping(value = "sendRemittanceInformation", method = RequestMethod.POST)
  66. @ResponseBody
  67. public ResultEntity<String> sendRemit(@RequestBody Map<String, String> param) {
  68. String phoneNo = param.get("phoneNo"); // 手机号
  69. String orderId = param.get("orderId"); // 汇付识别码
  70. if (StringsUtils.isEmpty(orderId) || StringsUtils.isEmpty(phoneNo)) {
  71. return new ResultEntity<>(InfoMsg.ERROR_PARAMS_ERROR);
  72. }
  73. return vefificationCodeService.sendRemit( phoneNo, orderId);
  74. }
  75. }