|
@@ -10,6 +10,7 @@ import com.happy.Until.Enum.B;
|
|
|
import com.happy.Until.Enum.DataType;
|
|
import com.happy.Until.Enum.DataType;
|
|
|
import com.happy.common.http.HttpsClient;
|
|
import com.happy.common.http.HttpsClient;
|
|
|
import com.happy.constant.ResultStatusCode;
|
|
import com.happy.constant.ResultStatusCode;
|
|
|
|
|
+import com.happy.dto.IPage;
|
|
|
import com.happy.service.BookService;
|
|
import com.happy.service.BookService;
|
|
|
import com.happy.service.UserService;
|
|
import com.happy.service.UserService;
|
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
@@ -134,9 +135,9 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
querySql.append(" and contact_id = '").append(userId).append("' ");
|
|
querySql.append(" and contact_id = '").append(userId).append("' ");
|
|
|
}
|
|
}
|
|
|
querySql.append(" and data_type = '").append(DataType.关联数据.toString()).append("' ");
|
|
querySql.append(" and data_type = '").append(DataType.关联数据.toString()).append("' ");
|
|
|
- int total = userService.queryUserTotal(querySql.toString()); // 查询表中的总记录数
|
|
|
|
|
- List<Users> listPage = userService.queryUserPage(querySql.toString(), page, rows); // 查询分页
|
|
|
|
|
- ResponseUtil.writeJsonPageData(ServletActionContext.getResponse(),listPage,this.page,this.rows,total);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ IPage listPage = userService.queryUserPage(querySql.toString(), page, rows); // 查询分页
|
|
|
|
|
+ ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(),listPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -255,14 +256,13 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 用户登录小程序授权
|
|
|
|
|
|
|
+ * 判断是否有当前用户(加访问记录)
|
|
|
*/
|
|
*/
|
|
|
- public void authorizationUser()
|
|
|
|
|
|
|
+ public String isHaveUser()
|
|
|
{
|
|
{
|
|
|
if (Func.checkNull(this.code))
|
|
if (Func.checkNull(this.code))
|
|
|
- return;
|
|
|
|
|
|
|
+ return null;
|
|
|
|
|
|
|
|
String OPEN_ID = "";
|
|
String OPEN_ID = "";
|
|
|
JSONObject resultJson = new JSONObject();
|
|
JSONObject resultJson = new JSONObject();
|
|
@@ -274,10 +274,62 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
+ "&code="
|
|
+ "&code="
|
|
|
+ this.getCode() + "&grant_type=authorization_code";
|
|
+ this.getCode() + "&grant_type=authorization_code";
|
|
|
|
|
|
|
|
- // String json = HttpUtils.get(requestUrl);
|
|
|
|
|
- String json = HttpsClient.sendPost(requestUrl, "");
|
|
|
|
|
- Wechat_userinfo result = new Gson().fromJson(json, Wechat_userinfo.class);
|
|
|
|
|
- OPEN_ID = result.getOpenid();
|
|
|
|
|
|
|
+ // String json = HttpUtils.get(requestUrl);
|
|
|
|
|
+ String json = HttpsClient.sendPost(requestUrl, "");
|
|
|
|
|
+ Wechat_userinfo result = new Gson().fromJson(json, Wechat_userinfo.class);
|
|
|
|
|
+ OPEN_ID = result.getOpenid();
|
|
|
|
|
+ if (Func.checkNull(OPEN_ID))
|
|
|
|
|
+ {
|
|
|
|
|
+ resultJson.put(B.code,ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
|
|
+ resultJson.put(B.message,"未获取到OpenId");
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * 手机号前端过来,昵称、省份、性别等其他信息已保存的result中,
|
|
|
|
|
+ * 查询用户openid是否存在,存在就返回信息给前端,不存在就保存到数据库
|
|
|
|
|
+ * */
|
|
|
|
|
+ Users users = userService.queryByOpenid(OPEN_ID);
|
|
|
|
|
+ if (users == null)
|
|
|
|
|
+ {
|
|
|
|
|
+ resultJson.put(B.code,ResultStatusCode.BAD_REQUEST.getStatus());
|
|
|
|
|
+ resultJson.put(B.message," 当前用户未授权");
|
|
|
|
|
+ resultJson.put(B.data,users);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ resultJson.put(B.code,ResultStatusCode.OK.getStatus());
|
|
|
|
|
+ resultJson.put(B.message," 当前用户已授权");
|
|
|
|
|
+ resultJson.put(B.data,users);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户登录小程序授权
|
|
|
|
|
+ */
|
|
|
|
|
+ public void authorizationUser()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Func.checkNull(this.code))
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ String OPEN_ID = "";
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+// // 此处授权后的回调地址,主要获取token和openid TODO
|
|
|
|
|
+// String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="
|
|
|
|
|
+// + WeiXinUtil.appid_c
|
|
|
|
|
+// + "&secret="
|
|
|
|
|
+// + WeiXinUtil.screct_c
|
|
|
|
|
+// + "&code="
|
|
|
|
|
+// + this.getCode() + "&grant_type=authorization_code";
|
|
|
|
|
+//
|
|
|
|
|
+// // String json = HttpUtils.get(requestUrl);
|
|
|
|
|
+// String json = HttpsClient.sendPost(requestUrl, "");
|
|
|
|
|
+// Wechat_userinfo result = new Gson().fromJson(json, Wechat_userinfo.class);
|
|
|
|
|
+// OPEN_ID = result.getOpenid();
|
|
|
|
|
+ OPEN_ID = code;
|
|
|
if (Func.checkNull(OPEN_ID))
|
|
if (Func.checkNull(OPEN_ID))
|
|
|
{
|
|
{
|
|
|
resultJson.put(B.code,ResultStatusCode.BAD_REQUEST.getStatus());
|
|
resultJson.put(B.code,ResultStatusCode.BAD_REQUEST.getStatus());
|