|
|
@@ -1,6 +1,7 @@
|
|
|
package com.thmodel.servlet.model;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -9,6 +10,14 @@ import javax.servlet.http.HttpServlet;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.aliyuncs.CommonRequest;
|
|
|
+import com.aliyuncs.CommonResponse;
|
|
|
+import com.aliyuncs.DefaultAcsClient;
|
|
|
+import com.aliyuncs.IAcsClient;
|
|
|
+import com.aliyuncs.exceptions.ClientException;
|
|
|
+import com.aliyuncs.http.MethodType;
|
|
|
+import com.aliyuncs.profile.DefaultProfile;
|
|
|
import com.thmodel.constants.Constants;
|
|
|
import com.thmodel.dao.impl.MemberinfoDaoImpl;
|
|
|
import com.thmodel.entity.MemberInfo;
|
|
|
@@ -26,6 +35,7 @@ import com.thmodel.util.CommentUtils;
|
|
|
import com.thmodel.util.JsonUtils;
|
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang.RandomStringUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
/**
|
|
|
@@ -39,12 +49,12 @@ public class ModelServlet extends HttpServlet {
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
- private static UtilServer utilServer = new UtilServerImpl();
|
|
|
- private static ModelInfoService modelInfoService = new ModelInfoServiceImpl();
|
|
|
- private static ModelCardService modelCardService = new ModelCardServiceImpl();
|
|
|
- private static MemberinfoService memberinfoService = new MemberinfoServiceImpl();
|
|
|
- private static NimserverService nimserverService = new NimserverServiceImpl();
|
|
|
- private static com.thmodel.dao.MemberinfoDao memberinfoDao = new MemberinfoDaoImpl();
|
|
|
+ private static UtilServer utilServer = new UtilServerImpl();
|
|
|
+ private static ModelInfoService modelInfoService = new ModelInfoServiceImpl();
|
|
|
+ private static ModelCardService modelCardService = new ModelCardServiceImpl();
|
|
|
+ private static MemberinfoService memberinfoService = new MemberinfoServiceImpl();
|
|
|
+ private static NimserverService nimserverService = new NimserverServiceImpl();
|
|
|
+ private static com.thmodel.dao.MemberinfoDao memberinfoDao = new MemberinfoDaoImpl();
|
|
|
|
|
|
public ModelServlet() {
|
|
|
super();
|
|
|
@@ -431,6 +441,41 @@ public class ModelServlet extends HttpServlet {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //
|
|
|
+ else if (action.equalsIgnoreCase("sendsms")) {
|
|
|
+ String code = RandomStringUtils.randomNumeric(4);
|
|
|
+ DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "PXzJyah5rZfWHIIH", "e1MS6j0wypXJrw8CM0hObZu8qKbfah");
|
|
|
+ IAcsClient client = new DefaultAcsClient(profile);
|
|
|
+ String phone = CommentUtils.myToString(request.getParameter("phone"));
|
|
|
+
|
|
|
+ CommonRequest rq = new CommonRequest();
|
|
|
+ rq.setMethod(MethodType.POST);
|
|
|
+ rq.setDomain("dysmsapi.aliyuncs.com");
|
|
|
+ rq.setVersion("2017-05-25");
|
|
|
+ rq.setAction("SendSms");
|
|
|
+ rq.putQueryParameter("PhoneNumbers", phone);
|
|
|
+ rq.putQueryParameter("SignName", "走马信息");
|
|
|
+ rq.putQueryParameter("TemplateCode", "SMS_175485688");
|
|
|
+ rq.putQueryParameter("TemplateParam", "{\"code\":\"" + code + "\"}");
|
|
|
+ try {
|
|
|
+ CommonResponse rs = client.getCommonResponse(rq);
|
|
|
+ if (rs.getHttpStatus() == 200) {
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(rs.getData());
|
|
|
+ if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
|
|
|
+ resultJson.put("msg", Constants.success);
|
|
|
+ resultJson.put("code", code);
|
|
|
+ } else {
|
|
|
+ resultJson.put("msg", Constants.fail);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ resultJson.put("msg", Constants.fail);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ resultJson.put("msg", Constants.fail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
resultJson.put("msg", Constants.error);
|