mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 02:48:17 +08:00
优化代码
This commit is contained in:
parent
403bc5653d
commit
373305d82a
1
pom.xml
1
pom.xml
@ -15,7 +15,6 @@
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
<common-boot.version>1.2.5</common-boot.version>
|
||||
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
19
src/main/java/cn/jiangzeyin/controller/BaseController.java
Normal file
19
src/main/java/cn/jiangzeyin/controller/BaseController.java
Normal file
@ -0,0 +1,19 @@
|
||||
package cn.jiangzeyin.controller;
|
||||
|
||||
import cn.jiangzeyin.common.interceptor.LoginInterceptor;
|
||||
import cn.jiangzeyin.controller.base.AbstractBaseControl;
|
||||
|
||||
/**
|
||||
* @author jiangzeyin
|
||||
* @date 2018/9/28
|
||||
*/
|
||||
public abstract class BaseController extends AbstractBaseControl {
|
||||
protected String userName;
|
||||
protected String userPwd;
|
||||
|
||||
@Override
|
||||
public void resetInfo() {
|
||||
userName = getSessionAttribute(LoginInterceptor.SESSION_NAME);
|
||||
userPwd = getSessionAttribute(LoginInterceptor.SESSION_PWD);
|
||||
}
|
||||
}
|
@ -1,31 +1,20 @@
|
||||
package cn.jiangzeyin.controller;
|
||||
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.interceptor.LoginInterceptor;
|
||||
import cn.jiangzeyin.controller.base.AbstractBaseControl;
|
||||
import cn.jiangzeyin.service.UserService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "/")
|
||||
public class IndexControl extends AbstractBaseControl {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping(value = "error", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
||||
public String error() {
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载首页
|
||||
*
|
||||
@ -51,33 +40,4 @@ public class IndexControl extends AbstractBaseControl {
|
||||
getSession().invalidate();
|
||||
return "login";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param oldPwd 旧密码
|
||||
* @param newPwd 新密码
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "updatePwd")
|
||||
@ResponseBody
|
||||
public String updatePwd(String oldPwd, String newPwd) {
|
||||
try {
|
||||
String result = userService.updatePwd(getSession().getAttribute(LoginInterceptor.SESSION_NAME).toString(), oldPwd, newPwd);
|
||||
// 用户不存在
|
||||
if ("notexist".equals(result)) {
|
||||
return JsonMessage.getString(500, "用户不存在!");
|
||||
}
|
||||
// 旧密码不正确
|
||||
if ("olderror".equals(result)) {
|
||||
return JsonMessage.getString(500, "旧密码不正确!");
|
||||
}
|
||||
// 如果修改成功,则销毁会话
|
||||
getSession().invalidate();
|
||||
return JsonMessage.getString(200, "修改密码成功!");
|
||||
} catch (Exception e) {
|
||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||
return JsonMessage.getString(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ public class LoginControl extends AbstractBaseControl {
|
||||
boolean flag = userService.login(userName, userPwd);
|
||||
if (flag) {
|
||||
stringBuffer.append(",结果:").append("OK");
|
||||
getSession().setAttribute(LoginInterceptor.SESSION_NAME, userName);
|
||||
getSession().setAttribute(LoginInterceptor.SESSION_PWD, userPwd);
|
||||
setSessionAttribute(LoginInterceptor.SESSION_NAME, userName);
|
||||
setSessionAttribute(LoginInterceptor.SESSION_PWD, userPwd);
|
||||
return JsonMessage.getString(200, "登录成功");
|
||||
} else {
|
||||
stringBuffer.append(",结果:").append("faild");
|
||||
|
@ -0,0 +1,44 @@
|
||||
package cn.jiangzeyin.controller.manage;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.jiangzeyin.controller.BaseController;
|
||||
import cn.jiangzeyin.model.ProjectInfoModel;
|
||||
import cn.jiangzeyin.service.manage.ManageService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by jiangzeyin on 2018/9/28.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/manage/")
|
||||
public class ConsoleController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ManageService manageService;
|
||||
|
||||
/**
|
||||
* 管理项目
|
||||
*
|
||||
* @return page
|
||||
*/
|
||||
@RequestMapping(value = "console", method = RequestMethod.GET)
|
||||
public String console(String id) {
|
||||
ProjectInfoModel pim = null;
|
||||
try {
|
||||
pim = manageService.getProjectInfo(id);
|
||||
} catch (IOException e) {
|
||||
DefaultSystemLog.LOG().error(e.getMessage(), e);
|
||||
}
|
||||
setAttribute("projectInfo", JSONObject.toJSONString(pim));
|
||||
String md5 = SecureUtil.md5(String.format("%s:%s", userName, userPwd));
|
||||
setAttribute("userInfo", md5);
|
||||
return "manage/console";
|
||||
}
|
||||
}
|
@ -39,26 +39,6 @@ public class ManageControl extends AbstractBaseControl {
|
||||
return "manage/projectInfo";
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理项目
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "console")
|
||||
public String console(String id) {
|
||||
ProjectInfoModel pim = null;
|
||||
try {
|
||||
pim = manageService.getProjectInfo(id);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
DefaultSystemLog.LOG().error(e.getMessage(), e);
|
||||
}
|
||||
setAttribute("projectInfo", JSONObject.toJSONString(pim));
|
||||
setAttribute("userInfo", SecureUtil.md5(String.format("%s:%s", getSession().getAttribute(LoginInterceptor.SESSION_NAME), getSession().getAttribute(LoginInterceptor.SESSION_PWD))));
|
||||
return "manage/console";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有项目
|
||||
*
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.jiangzeyin.controller.user;
|
||||
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.controller.BaseController;
|
||||
import cn.jiangzeyin.service.UserService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author jiangzeyin
|
||||
* @date 2018/9/28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/")
|
||||
public class UpdatePwdController extends BaseController {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param oldPwd 旧密码
|
||||
* @param newPwd 新密码
|
||||
* @return json
|
||||
*/
|
||||
@RequestMapping(value = "updatePwd", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public String updatePwd(String oldPwd, String newPwd) {
|
||||
try {
|
||||
String result = userService.updatePwd(userName, oldPwd, newPwd);
|
||||
// 用户不存在
|
||||
if ("notexist".equals(result)) {
|
||||
return JsonMessage.getString(500, "用户不存在!");
|
||||
}
|
||||
// 旧密码不正确
|
||||
if ("olderror".equals(result)) {
|
||||
return JsonMessage.getString(500, "旧密码不正确!");
|
||||
}
|
||||
// 如果修改成功,则销毁会话
|
||||
getSession().invalidate();
|
||||
return JsonMessage.getString(200, "修改密码成功!");
|
||||
} catch (Exception e) {
|
||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||
return JsonMessage.getString(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
package cn.jiangzeyin.service;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.jiangzeyin.util.JsonUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Service
|
||||
public class UserService extends BaseService {
|
||||
|
||||
@ -24,6 +30,25 @@ public class UserService extends BaseService {
|
||||
return pwd.equals(userInfo.getString("password"));
|
||||
}
|
||||
|
||||
|
||||
public boolean checkUser(String userMd5) throws IOException {
|
||||
JSONObject jsonData = getJsonObject(FILENAME);
|
||||
if (jsonData == null) {
|
||||
return false;
|
||||
}
|
||||
for (String strKey : jsonData.keySet()) {
|
||||
JSONObject jsonUser = jsonData.getJSONObject(strKey);
|
||||
String id = jsonUser.getString("id");
|
||||
String pwd = jsonUser.getString("password");
|
||||
String strUsermd5 = SecureUtil.md5(String.format("%s:%s", id, pwd));
|
||||
if (strUsermd5.equals(userMd5)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
|
@ -3,14 +3,12 @@ package cn.jiangzeyin.socket;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import cn.jiangzeyin.model.ProjectInfoModel;
|
||||
import cn.jiangzeyin.pool.ThreadPoolService;
|
||||
import cn.jiangzeyin.service.BaseService;
|
||||
import cn.jiangzeyin.service.UserService;
|
||||
import cn.jiangzeyin.service.manage.CommandService;
|
||||
import cn.jiangzeyin.service.manage.ManageService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -21,19 +19,22 @@ import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* socket
|
||||
* Created by jiangzeyin on 2017/9/8.
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @date 2017/9/8
|
||||
*/
|
||||
@ServerEndpoint(value = "/console/{userInfo}")
|
||||
@Component
|
||||
public class LogWebSocketHandle implements TailLogThread.Evn {
|
||||
|
||||
private static ExecutorService EXECUTOR_SERVICE = null;
|
||||
private static final String RUNING_TAG = "running";
|
||||
private static final String STOP_TAG = "stopped";
|
||||
|
||||
private static ExecutorService EXECUTOR_SERVICE = null;
|
||||
private Process process;
|
||||
private InputStream inputStream;
|
||||
private TailLogThread thread;
|
||||
@ -48,26 +49,8 @@ public class LogWebSocketHandle implements TailLogThread.Evn {
|
||||
}
|
||||
// 通过用户名和密码的Md5值判断是否是登录的
|
||||
try {
|
||||
boolean flag = false;
|
||||
if (!StrUtil.isEmpty(userInfo)) {
|
||||
BaseService service = new BaseService();
|
||||
JSONObject obj = service.getJsonObject("user.json");
|
||||
|
||||
Set<String> set_key = obj.keySet();
|
||||
|
||||
for (String str_key : set_key) {
|
||||
JSONObject json_user = obj.getJSONObject(str_key);
|
||||
String str_userMd5 = SecureUtil.md5(String.format("%s:%s", json_user.getString("id"), json_user.getString("password")));
|
||||
if (str_userMd5.equals(userInfo)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sendMsg(session, JsonMessage.getString(500, "用户名或密码错误!"));
|
||||
session.close();
|
||||
}
|
||||
if (!flag) {
|
||||
UserService userService = SpringUtil.getBean(UserService.class);
|
||||
if (!userService.checkUser(userInfo)) {
|
||||
sendMsg(session, JsonMessage.getString(500, "用户名或密码错误!"));
|
||||
session.close();
|
||||
}
|
||||
@ -86,14 +69,10 @@ public class LogWebSocketHandle implements TailLogThread.Evn {
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session) {
|
||||
|
||||
DefaultSystemLog.LOG().info("客户端消息:" + message);
|
||||
JSONObject json = JSONObject.parseObject(message);
|
||||
JSONObject projectInfo = json.getJSONObject("projectInfo");
|
||||
|
||||
String str_result;
|
||||
String id = projectInfo.getString("id");
|
||||
|
||||
ManageService manageService = SpringUtil.getBean(ManageService.class);
|
||||
ProjectInfoModel projectInfoModel = null;
|
||||
try {
|
||||
@ -107,73 +86,54 @@ public class LogWebSocketHandle implements TailLogThread.Evn {
|
||||
}
|
||||
String op = json.getString("op");
|
||||
JSONObject resultData = null;
|
||||
String strResult;
|
||||
// 执行相应命令
|
||||
switch (op) {
|
||||
case "start":
|
||||
// 启动项目
|
||||
str_result = execCommand(session, "start", projectInfoModel);
|
||||
if (str_result.contains("running")) {
|
||||
strResult = execCommand(session, "start", projectInfoModel);
|
||||
if (strResult.contains(RUNING_TAG)) {
|
||||
resultData = JsonMessage.toJson(200, "启动成功", json);
|
||||
} else {
|
||||
resultData = JsonMessage.toJson(400, str_result, json);
|
||||
resultData = JsonMessage.toJson(400, strResult, json);
|
||||
}
|
||||
break;
|
||||
|
||||
case "restart":
|
||||
// 重启项目
|
||||
str_result = execCommand(session, "restart", projectInfoModel);
|
||||
if (str_result.contains("running")) {
|
||||
strResult = execCommand(session, "restart", projectInfoModel);
|
||||
if (strResult.contains(RUNING_TAG)) {
|
||||
resultData = JsonMessage.toJson(200, "重启成功", json);
|
||||
} else {
|
||||
resultData = JsonMessage.toJson(400, str_result, json);
|
||||
resultData = JsonMessage.toJson(400, strResult, json);
|
||||
}
|
||||
break;
|
||||
|
||||
case "stop":
|
||||
// 停止项目
|
||||
str_result = execCommand(session, "stop", projectInfoModel);
|
||||
if (str_result.contains("stopped")) {
|
||||
strResult = execCommand(session, "stop", projectInfoModel);
|
||||
if (strResult.contains(STOP_TAG)) {
|
||||
resultData = JsonMessage.toJson(200, "已停止", json);
|
||||
thread.stop();
|
||||
if (thread != null) {
|
||||
thread.stop();
|
||||
}
|
||||
} else {
|
||||
resultData = JsonMessage.toJson(500, str_result, json);
|
||||
resultData = JsonMessage.toJson(500, strResult, json);
|
||||
}
|
||||
break;
|
||||
|
||||
case "status":
|
||||
// 获取项目状态
|
||||
str_result = execCommand(session, "status", projectInfoModel);
|
||||
json.put("result", str_result);
|
||||
if (str_result.contains("running")) {
|
||||
strResult = execCommand(session, "status", projectInfoModel);
|
||||
json.put("result", strResult);
|
||||
if (strResult.contains(RUNING_TAG)) {
|
||||
resultData = JsonMessage.toJson(200, "运行中", json);
|
||||
} else {
|
||||
resultData = JsonMessage.toJson(404, "未运行", json);
|
||||
}
|
||||
break;
|
||||
case "showlog":
|
||||
// 进入管理页面后需要实时加载日志
|
||||
String log = projectInfoModel.getLog();
|
||||
try {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
// 执行tail -f命令
|
||||
process = Runtime.getRuntime().exec(String.format("tail -f %s", log));
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
inputStream = process.getInputStream();
|
||||
// 一定要启动新的线程,防止InputStream阻塞处理WebSocket的线程
|
||||
if (thread != null) {
|
||||
thread.stop();
|
||||
}
|
||||
thread = new TailLogThread(inputStream, session, this);
|
||||
EXECUTOR_SERVICE.execute(thread);
|
||||
} catch (IOException e) {
|
||||
DefaultSystemLog.ERROR().error("打开日志异常", e);
|
||||
}
|
||||
showLog(session, projectInfoModel);
|
||||
break;
|
||||
default:
|
||||
resultData = JsonMessage.toJson(404, "不支持的方式:" + op);
|
||||
break;
|
||||
}
|
||||
if (resultData != null) {
|
||||
@ -182,6 +142,31 @@ public class LogWebSocketHandle implements TailLogThread.Evn {
|
||||
}
|
||||
}
|
||||
|
||||
private void showLog(Session session, ProjectInfoModel projectInfoModel) {
|
||||
// 进入管理页面后需要实时加载日志
|
||||
String log = projectInfoModel.getLog();
|
||||
try {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
// 执行tail -f命令
|
||||
process = Runtime.getRuntime().exec(String.format("tail -f %s", log));
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
inputStream = process.getInputStream();
|
||||
// 一定要启动新的线程,防止InputStream阻塞处理WebSocket的线程
|
||||
if (thread != null) {
|
||||
thread.stop();
|
||||
}
|
||||
thread = new TailLogThread(inputStream, session, this);
|
||||
EXECUTOR_SERVICE.execute(thread);
|
||||
} catch (IOException e) {
|
||||
DefaultSystemLog.ERROR().error("打开日志异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行shell命令
|
||||
*
|
||||
@ -252,6 +237,9 @@ public class LogWebSocketHandle implements TailLogThread.Evn {
|
||||
* @param msg 消息
|
||||
*/
|
||||
private synchronized void sendMsg(Session session, String msg) {
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
DefaultSystemLog.LOG().info(msg);
|
||||
session.getBasicRemote().sendText(msg);
|
||||
|
@ -9,7 +9,9 @@ import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* 线程处理
|
||||
* Created by jiangzeyin on 2017/9/8.
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @date 2017/9/8
|
||||
*/
|
||||
public class TailLogThread implements Runnable {
|
||||
|
||||
@ -28,10 +30,6 @@ public class TailLogThread implements Runnable {
|
||||
run = false;
|
||||
}
|
||||
|
||||
public boolean isRun() {
|
||||
return run;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String line;
|
||||
@ -63,6 +61,9 @@ public class TailLogThread implements Runnable {
|
||||
}
|
||||
|
||||
public interface Evn {
|
||||
/**
|
||||
* 尝试次数过多
|
||||
*/
|
||||
void onError();
|
||||
}
|
||||
}
|
@ -4,6 +4,9 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
/**
|
||||
* @author jiangzeyin
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
@Bean
|
||||
|
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2017/5/11.
|
||||
* Created by jiangzeyin on 2017/5/11.
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@ -25,7 +25,7 @@ public class WebAopLog {
|
||||
}
|
||||
|
||||
@Before("webLog()")
|
||||
public void doBefore(JoinPoint joinPoint) throws Throwable {
|
||||
public void doBefore(JoinPoint joinPoint) {
|
||||
// 接收到请求,记录请求内容
|
||||
IS_LOG.set(true);
|
||||
Signature signature = joinPoint.getSignature();
|
||||
@ -42,13 +42,13 @@ public class WebAopLog {
|
||||
}
|
||||
|
||||
@AfterReturning(returning = "ret", pointcut = "webLog()")
|
||||
public void doAfterReturning(Object ret) throws Throwable {
|
||||
// 处理完请求,返回内容
|
||||
Boolean isLog_ = IS_LOG.get();
|
||||
if (isLog_ != null && !isLog_) {
|
||||
public void doAfterReturning(Object ret) {
|
||||
if (ret == null) {
|
||||
return;
|
||||
}
|
||||
if (ret == null) {
|
||||
// 处理完请求,返回内容
|
||||
Boolean isLog = IS_LOG.get();
|
||||
if (isLog != null && !isLog) {
|
||||
return;
|
||||
}
|
||||
DefaultSystemLog.LOG().info(" :" + ret.toString());
|
||||
|
@ -23,15 +23,11 @@ public class JsonUtil {
|
||||
if (null == obj) {
|
||||
flag = true;
|
||||
} else if (obj instanceof JSONObject) {
|
||||
JSONObject jsonobj = (JSONObject) obj;
|
||||
if (0 == jsonobj.keySet().size()) {
|
||||
flag = true;
|
||||
}
|
||||
JSONObject jsonObject = (JSONObject) obj;
|
||||
flag = jsonObject.isEmpty();
|
||||
} else if (obj instanceof JSONArray) {
|
||||
JSONArray jsonarr = (JSONArray) obj;
|
||||
if (0 == jsonarr.size()) {
|
||||
flag = true;
|
||||
}
|
||||
JSONArray jsonArray = (JSONArray) obj;
|
||||
flag = jsonArray.isEmpty();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user