|
|
@@ -9,7 +9,6 @@ import com.cnd3b.common.data.Rows;
|
|
|
import com.cnd3b.common.data.SQLFactory;
|
|
|
import com.cnd3b.common.data.db.DBConnect;
|
|
|
import com.cnd3b.common.data.db.DataPool;
|
|
|
-import com.cnd3b.common.parameter.ErrModel;
|
|
|
import com.cnd3b.common.parameter.parameter;
|
|
|
import com.cnd3b.restcontroller.system.system.uploadExcelData;
|
|
|
import com.cnd3b.utility.Sms;
|
|
|
@@ -53,7 +52,7 @@ public class WebClientRest {
|
|
|
try {
|
|
|
requestcontent = JSONObject.parseObject(RequestContent);
|
|
|
} catch (Exception e) {
|
|
|
- return ErrModel.request_BasicJsonFormat().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("请求正文格式错误,必须为JSONObject格式").toString();
|
|
|
}
|
|
|
/**
|
|
|
* 验证请求正文中是否包含必填的键值
|
|
|
@@ -61,7 +60,7 @@ public class WebClientRest {
|
|
|
String[] mustkeys = {"classname", "method", "content"};
|
|
|
for (String mustkey : mustkeys) {
|
|
|
if (!requestcontent.containsKey(mustkey)) {
|
|
|
- return ErrModel.request_ContainsMustKey(mustkey).toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("json缺少KEY"+mustkey).toString();
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
@@ -71,7 +70,7 @@ public class WebClientRest {
|
|
|
try {
|
|
|
content = requestcontent.getJSONObject("content");
|
|
|
} catch (Exception e) {
|
|
|
- return ErrModel.request_ContentJsonFormat().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("正文content格式错误,必须为JSONObject格式").toString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -81,7 +80,7 @@ public class WebClientRest {
|
|
|
String className = requestcontent.getString("classname");
|
|
|
if (!className.contains("publicmethod")) {
|
|
|
if (!requestcontent.containsKey("accesstoken")) {
|
|
|
- return ErrModel.token_Validate().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("登陆状态已过期,请重新登陆!").toString();
|
|
|
}
|
|
|
accesstoken = requestcontent.getString("accesstoken");
|
|
|
/**
|
|
|
@@ -89,7 +88,7 @@ public class WebClientRest {
|
|
|
*/
|
|
|
if (!parameter.tokenlist.containsKey(accesstoken) && !istokeninuserlist(accesstoken)) {
|
|
|
//如果缓存中不存在,则在账号列表中进行查询,查到结果后,将tokne存入缓存
|
|
|
- return ErrModel.token_Validate().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("登陆状态已过期,请重新登陆!").toString();
|
|
|
}
|
|
|
parameter.requesttime.put(accesstoken, Calendar.getInstance().getTime());
|
|
|
}
|
|
|
@@ -132,19 +131,19 @@ public class WebClientRest {
|
|
|
}
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
- result = ErrModel.request_GetClass("找不到指定的类" + className).toString();
|
|
|
+ result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className).toString();
|
|
|
} catch (InstantiationException e) {
|
|
|
e.printStackTrace();
|
|
|
- result = ErrModel.request_GetClass("类" + className + "实例化异常").toString();
|
|
|
+ result = new D3BReturnObject_Err().setErrMsg("类" + className + "实例化异常").toString();
|
|
|
} catch (IllegalAccessException e) {
|
|
|
e.printStackTrace();
|
|
|
- result = ErrModel.request_GetClass("类" + className + "安全权限异常,可能该类为非public类").toString();
|
|
|
+ result = new D3BReturnObject_Err().setErrMsg("类" + className + "安全权限异常,可能该类为非public类").toString();
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
e.printStackTrace();
|
|
|
- result = ErrModel.request_GetClass("找不到指定的类" + className + "的" + methodName + "方法").toString();
|
|
|
+ result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className + "的" + methodName + "方法").toString();
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
e.printStackTrace();
|
|
|
- result = ErrModel.request_GetClass("类" + className + "的" + methodName + "方法参数不合法").toString();
|
|
|
+ result = new D3BReturnObject_Err().setErrMsg("类" + className + "的" + methodName + "方法参数不合法").toString();
|
|
|
} catch (InvocationTargetException e) {
|
|
|
Throwable targetException = e.getTargetException();
|
|
|
D3BReturnObject_Err d3BReturnObject_err = new D3BReturnObject_Err();
|
|
|
@@ -152,7 +151,7 @@ public class WebClientRest {
|
|
|
result = d3BReturnObject_err.toString();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- result = ErrModel.request_GetClass("发生未知异常" + e.getMessage()).toString();
|
|
|
+ result = new D3BReturnObject_Err().setErrMsg("发生未知异常" + e.getMessage()).toString();
|
|
|
} finally {
|
|
|
if (obj != null) {
|
|
|
try {
|
|
|
@@ -242,7 +241,7 @@ public class WebClientRest {
|
|
|
try {
|
|
|
requestcontent = JSONObject.parseObject(RequestContent);
|
|
|
} catch (Exception e) {
|
|
|
- return ErrModel.request_BasicJsonFormat().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("请求正文格式错误,必须为JSONObject格式").toString();
|
|
|
}
|
|
|
/**
|
|
|
* 验证请求正文中是否包含必填的键值
|
|
|
@@ -250,7 +249,7 @@ public class WebClientRest {
|
|
|
String[] mustkeys = {"phonenumber"};
|
|
|
for (String mustkey : mustkeys) {
|
|
|
if (!requestcontent.containsKey(mustkey)) {
|
|
|
- return ErrModel.request_ContainsMustKey(mustkey).toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("json缺少KEY" + mustkey).toString();
|
|
|
}
|
|
|
}
|
|
|
String phonenumber = requestcontent.getString("phonenumber");
|
|
|
@@ -317,7 +316,7 @@ public class WebClientRest {
|
|
|
try {
|
|
|
requestcontent = JSONObject.parseObject(RequestContent);
|
|
|
} catch (Exception e) {
|
|
|
- return ErrModel.request_BasicJsonFormat().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("请求正文格式错误,必须为JSONObject格式").toString();
|
|
|
}
|
|
|
/**
|
|
|
* 验证请求正文中是否包含必填的键值
|
|
|
@@ -325,7 +324,7 @@ public class WebClientRest {
|
|
|
String[] mustkeys = {"phonenumber", "password"};
|
|
|
for (String mustkey : mustkeys) {
|
|
|
if (!requestcontent.containsKey(mustkey)) {
|
|
|
- return ErrModel.request_ContainsMustKey(mustkey).toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("json缺少KEY" + mustkey).toString();
|
|
|
}
|
|
|
}
|
|
|
String phonenumber = requestcontent.getString("phonenumber");
|
|
|
@@ -398,84 +397,6 @@ public class WebClientRest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Path("loginbyaccount")
|
|
|
- @POST
|
|
|
- public String loginbyaccount(String RequestContent) {
|
|
|
- /**
|
|
|
- * 验证请求正文是否为规范的SONObject格式
|
|
|
- */
|
|
|
- JSONObject requestcontent = null;
|
|
|
- try {
|
|
|
- requestcontent = JSONObject.parseObject(RequestContent);
|
|
|
- } catch (Exception e) {
|
|
|
- return ErrModel.request_BasicJsonFormat().toString();
|
|
|
- }
|
|
|
- /**
|
|
|
- * 验证请求正文中是否包含必填的键值
|
|
|
- */
|
|
|
- String[] mustkeys = {"accountno", "password"};
|
|
|
- for (String mustkey : mustkeys) {
|
|
|
- if (!requestcontent.containsKey(mustkey)) {
|
|
|
- return ErrModel.request_ContainsMustKey(mustkey).toString();
|
|
|
- }
|
|
|
- }
|
|
|
- String accountno = requestcontent.getString("accountno");
|
|
|
- String password = requestcontent.getString("password");//md5加密
|
|
|
-
|
|
|
-
|
|
|
- boolean result = true;
|
|
|
-
|
|
|
- DBConnect connect = new DBConnect();
|
|
|
-
|
|
|
- Rows usersrows = connect.runSqlQuery("select t1.* from tenterprise_users t1 inner join tenterprise t2 on t1.siteid=t2.siteid where t2.floginmode in(2,3) and convert(varchar(100),t1.faccountno)='" + accountno + "'");
|
|
|
- if (usersrows.isEmpty()) {
|
|
|
- result = false;
|
|
|
- } else {
|
|
|
- //系统验证码
|
|
|
- String syspassword = usersrows.get(0).getString("fpassword");
|
|
|
- result = password.equals(syspassword);
|
|
|
- }
|
|
|
- if (result) {
|
|
|
- SQLFactory factory = new SQLFactory(this, "账号列表查询");
|
|
|
- factory.addParameter("faccountno", accountno);
|
|
|
- Rows rows = connect.runSqlQuery(factory.getSQL());
|
|
|
-
|
|
|
- if (rows.isEmpty()) {
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("code", 0);
|
|
|
- object.put("msg", "没有包含此账号的企业或经销商!");
|
|
|
- return object.toString();
|
|
|
- }
|
|
|
- ArrayList<String> tokensaveList = new ArrayList<>();
|
|
|
- for (Row row : rows) {
|
|
|
- long userid = row.getLong("userid");
|
|
|
- String usertoken = new Encryption().Encode_MD5(accountno + password + userid + Calendar.getInstance().getTimeInMillis());
|
|
|
- row.put("token", usertoken);
|
|
|
- row.put("logintime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
|
|
|
- parameter.userIdList.put(userid, row);
|
|
|
- parameter.tokenlist.put(usertoken, userid);
|
|
|
- tokensaveList.add("update tenterprise_users set accesstoken='" + usertoken + "' where tenterprise_userid=" + userid);
|
|
|
- }
|
|
|
- if (!tokensaveList.isEmpty()) {
|
|
|
- /**
|
|
|
- * 账号登录态持久化
|
|
|
- */
|
|
|
- connect.runSqlUpdate(tokensaveList);
|
|
|
- }
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("code", 1);
|
|
|
- object.put("msg", "成功");
|
|
|
- object.put("webclienturl", "");
|
|
|
- object.put("servicehotline", "");
|
|
|
- object.put("account_list", rows.toJsonArray());
|
|
|
- return object.toString();
|
|
|
- } else {
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("code", 0);
|
|
|
- object.put("msg", "用户名或密码错误");
|
|
|
- return object.toString();
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
@Path("logout")
|
|
|
@POST
|
|
|
@@ -487,7 +408,7 @@ public class WebClientRest {
|
|
|
try {
|
|
|
requestcontent = JSONObject.parseObject(RequestContent);
|
|
|
} catch (Exception e) {
|
|
|
- return ErrModel.request_BasicJsonFormat().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("请求正文格式错误,必须为JSONObject格式").toString();
|
|
|
}
|
|
|
/**
|
|
|
* 验证请求正文中是否包含必填的键值
|
|
|
@@ -495,7 +416,7 @@ public class WebClientRest {
|
|
|
String[] mustkeys = {"accesstoken"};
|
|
|
for (String mustkey : mustkeys) {
|
|
|
if (!requestcontent.containsKey(mustkey)) {
|
|
|
- return ErrModel.request_ContainsMustKey(mustkey).toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("json缺少KEY" + mustkey).toString();
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
@@ -532,7 +453,7 @@ public class WebClientRest {
|
|
|
* 验证正文中的token是否有效
|
|
|
*/
|
|
|
if (!parameter.tokenlist.containsKey(accesstoken)) {
|
|
|
- return ErrModel.token_Validate().toString();
|
|
|
+ return new D3BReturnObject_Err().setErrMsg("登陆状态已过期,请重新登陆!").toString();
|
|
|
}
|
|
|
JSONObject content = new JSONObject();
|
|
|
content.put("userid", userid);
|