优化操作消息

master
RuoYi 6 years ago committed by Limy
parent 81f954d87d
commit eaf64dc222

@ -0,0 +1,15 @@
package com.ruoyi.common.exception;
/**
*
*
* @author ruoyi
*/
public class DemoModeException extends RuntimeException
{
private static final long serialVersionUID = 1L;
public DemoModeException()
{
}
}

@ -1,64 +0,0 @@
package com.ruoyi.framework.web.domain;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author ruoyi
*/
public class JSON extends HashMap<String, Object>
{
private static final long serialVersionUID = 1L;
public JSON()
{
put("code", 0);
put("msg", "操作成功");
}
public static JSON error()
{
return error(1, "操作失败");
}
public static JSON error(String msg)
{
return error(500, msg);
}
public static JSON error(int code, String msg)
{
JSON json = new JSON();
json.put("code", code);
json.put("msg", msg);
return json;
}
public static JSON ok(String msg)
{
JSON json = new JSON();
json.put("msg", msg);
return json;
}
public static JSON ok(Map<String, Object> map)
{
JSON json = new JSON();
json.putAll(map);
return json;
}
public static JSON ok()
{
return new JSON();
}
@Override
public JSON put(String key, Object value)
{
super.put(key, value);
return this;
}
}

@ -0,0 +1,109 @@
package com.ruoyi.framework.web.domain;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author ruoyi
*/
public class Message extends HashMap<String, Object>
{
private static final long serialVersionUID = 1L;
/**
* Message
*/
public Message()
{
put("code", 0);
put("msg", "操作成功");
}
/**
*
*
* @return
*/
public static Message error()
{
return error(1, "操作失败");
}
/**
*
*
* @param msg
* @return
*/
public static Message error(String msg)
{
return error(500, msg);
}
/**
*
*
* @param code
* @param msg
* @return
*/
public static Message error(int code, String msg)
{
Message json = new Message();
json.put("code", code);
json.put("msg", msg);
return json;
}
/**
*
*
* @param msg
* @return
*/
public static Message ok(String msg)
{
Message json = new Message();
json.put("msg", msg);
return json;
}
/**
*
*
* @param map
* @return
*/
public static Message ok(Map<String, Object> map)
{
Message json = new Message();
json.putAll(map);
return json;
}
/**
*
*
* @return
*/
public static Message ok()
{
return new Message();
}
/**
*
*
* @param key
* @param value
* @return
*/
@Override
public Message put(String key, Object value)
{
super.put(key, value);
return this;
}
}

@ -3,10 +3,12 @@ package com.ruoyi.framework.web.exception;
import org.apache.shiro.authz.AuthorizationException; import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.common.exception.DemoModeException;
import com.ruoyi.framework.web.domain.Message;
/** /**
* *
@ -22,40 +24,49 @@ public class DefaultExceptionHandler
* *
*/ */
@ExceptionHandler(AuthorizationException.class) @ExceptionHandler(AuthorizationException.class)
public JSON handleAuthorizationException(AuthorizationException e) public Message handleAuthorizationException(AuthorizationException e)
{ {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return JSON.error("您没有数据的权限,请联系管理员添加"); return Message.error("您没有数据的权限,请联系管理员添加");
} }
/** /**
* *
*/ */
@ExceptionHandler({ HttpRequestMethodNotSupportedException.class }) @ExceptionHandler({ HttpRequestMethodNotSupportedException.class })
public JSON handleException(HttpRequestMethodNotSupportedException e) public Message handleException(HttpRequestMethodNotSupportedException e)
{ {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return JSON.error("不支持' " + e.getMethod() + "'请求"); return Message.error("不支持' " + e.getMethod() + "'请求");
} }
/** /**
* *
*/ */
@ExceptionHandler(RuntimeException.class) @ExceptionHandler(RuntimeException.class)
public JSON notFount(RuntimeException e) public Message notFount(RuntimeException e)
{ {
log.error("运行时异常:", e); log.error("运行时异常:", e);
return JSON.error("运行时异常:" + e.getMessage()); return Message.error("运行时异常:" + e.getMessage());
} }
/** /**
* *
*/ */
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public JSON handleException(Exception e) public Message handleException(Exception e)
{ {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return JSON.error("服务器错误,请联系管理员"); return Message.error("服务器错误,请联系管理员");
}
/**
*
*/
@ExceptionHandler(DemoModeException.class)
public Message demoModeException(DemoModeException e)
{
return Message.error("演示模式,不允许操作");
} }
} }

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.monitor.job.domain.Job; import com.ruoyi.project.monitor.job.domain.Job;
import com.ruoyi.project.monitor.job.service.IJobService; import com.ruoyi.project.monitor.job.service.IJobService;
@ -56,35 +56,35 @@ public class JobController extends BaseController
@RequiresPermissions("monitor:job:remove") @RequiresPermissions("monitor:job:remove")
@RequestMapping("/remove/{jobId}") @RequestMapping("/remove/{jobId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("jobId") Long jobId) public Message remove(@PathVariable("jobId") Long jobId)
{ {
Job job = jobService.selectJobById(jobId); Job job = jobService.selectJobById(jobId);
if (job == null) if (job == null)
{ {
return JSON.error("调度任务不存在"); return Message.error("调度任务不存在");
} }
if (jobService.deleteJob(job) > 0) if (jobService.deleteJob(job) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@Log(title = "监控管理", action = "定时任务-批量删除") @Log(title = "监控管理", action = "定时任务-批量删除")
@RequiresPermissions("monitor:job:batchRemove") @RequiresPermissions("monitor:job:batchRemove")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
try try
{ {
jobService.batchDeleteJob(ids); jobService.batchDeleteJob(ids);
return JSON.ok(); return Message.ok();
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
return JSON.error(e.getMessage()); return Message.error(e.getMessage());
} }
} }
@ -95,13 +95,13 @@ public class JobController extends BaseController
@RequiresPermissions("monitor:job:changeStatus") @RequiresPermissions("monitor:job:changeStatus")
@PostMapping("/changeStatus") @PostMapping("/changeStatus")
@ResponseBody @ResponseBody
public JSON changeStatus(Job job) public Message changeStatus(Job job)
{ {
if (jobService.changeStatus(job) > 0) if (jobService.changeStatus(job) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**
@ -135,12 +135,12 @@ public class JobController extends BaseController
@RequiresPermissions("monitor:job:save") @RequiresPermissions("monitor:job:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(Job job) public Message save(Job job)
{ {
if (jobService.saveJobCron(job) > 0) if (jobService.saveJobCron(job) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
} }

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.monitor.job.domain.JobLog; import com.ruoyi.project.monitor.job.domain.JobLog;
import com.ruoyi.project.monitor.job.service.IJobLogService; import com.ruoyi.project.monitor.job.service.IJobLogService;
@ -55,35 +55,35 @@ public class JobLogController extends BaseController
@RequiresPermissions("monitor:job:remove") @RequiresPermissions("monitor:job:remove")
@RequestMapping("/remove/{jobLogId}") @RequestMapping("/remove/{jobLogId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("jobLogId") Long jobLogId) public Message remove(@PathVariable("jobLogId") Long jobLogId)
{ {
JobLog jobLog = jobLogService.selectJobLogById(jobLogId); JobLog jobLog = jobLogService.selectJobLogById(jobLogId);
if (jobLog == null) if (jobLog == null)
{ {
return JSON.error("调度任务不存在"); return Message.error("调度任务不存在");
} }
if (jobLogService.deleteJobLogById(jobLogId) > 0) if (jobLogService.deleteJobLogById(jobLogId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@Log(title = "监控管理", action = "定时任务-批量删除日志") @Log(title = "监控管理", action = "定时任务-批量删除日志")
@RequiresPermissions("monitor:job:batchRemove") @RequiresPermissions("monitor:job:batchRemove")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
try try
{ {
jobLogService.batchDeleteJoblog(ids); jobLogService.batchDeleteJoblog(ids);
return JSON.ok(); return Message.ok();
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
return JSON.error(e.getMessage()); return Message.error(e.getMessage());
} }
} }
} }

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.monitor.logininfor.domain.Logininfor; import com.ruoyi.project.monitor.logininfor.domain.Logininfor;
import com.ruoyi.project.monitor.logininfor.service.ILogininforService; import com.ruoyi.project.monitor.logininfor.service.ILogininforService;
@ -51,13 +51,13 @@ public class LogininforController extends BaseController
@Log(title = "监控管理", action = "登录日志-批量删除") @Log(title = "监控管理", action = "登录日志-批量删除")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = logininforService.batchDeleteLogininfor(ids); int rows = logininforService.batchDeleteLogininfor(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
} }

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO; import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.monitor.online.domain.OnlineSession; import com.ruoyi.project.monitor.online.domain.OnlineSession;
import com.ruoyi.project.monitor.online.domain.UserOnline; import com.ruoyi.project.monitor.online.domain.UserOnline;
@ -57,47 +57,47 @@ public class UserOnlineController extends BaseController
@Log(title = "监控管理", action = "在线用户-批量强退用户") @Log(title = "监控管理", action = "在线用户-批量强退用户")
@PostMapping("/batchForceLogout") @PostMapping("/batchForceLogout")
@ResponseBody @ResponseBody
public JSON batchForceLogout(@RequestParam("ids[]") String[] ids) public Message batchForceLogout(@RequestParam("ids[]") String[] ids)
{ {
for (String sessionId : ids) for (String sessionId : ids)
{ {
UserOnline online = userOnlineService.selectOnlineById(sessionId); UserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null) if (online == null)
{ {
return JSON.error("用户已下线"); return Message.error("用户已下线");
} }
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
if (onlineSession == null) if (onlineSession == null)
{ {
return JSON.error("用户已下线"); return Message.error("用户已下线");
} }
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
online.setStatus(OnlineSession.OnlineStatus.off_line); online.setStatus(OnlineSession.OnlineStatus.off_line);
userOnlineService.saveOnline(online); userOnlineService.saveOnline(online);
} }
return JSON.ok(); return Message.ok();
} }
@RequiresPermissions("monitor:online:forceLogout") @RequiresPermissions("monitor:online:forceLogout")
@Log(title = "监控管理", action = "在线用户-强退用户") @Log(title = "监控管理", action = "在线用户-强退用户")
@RequestMapping("/forceLogout/{sessionId}") @RequestMapping("/forceLogout/{sessionId}")
@ResponseBody @ResponseBody
public JSON forceLogout(@PathVariable("sessionId") String sessionId) public Message forceLogout(@PathVariable("sessionId") String sessionId)
{ {
UserOnline online = userOnlineService.selectOnlineById(sessionId); UserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null) if (online == null)
{ {
return JSON.error("用户已下线"); return Message.error("用户已下线");
} }
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
if (onlineSession == null) if (onlineSession == null)
{ {
return JSON.error("用户已下线"); return Message.error("用户已下线");
} }
onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); onlineSession.setStatus(OnlineSession.OnlineStatus.off_line);
online.setStatus(OnlineSession.OnlineStatus.off_line); online.setStatus(OnlineSession.OnlineStatus.off_line);
userOnlineService.saveOnline(online); userOnlineService.saveOnline(online);
return JSON.ok(); return Message.ok();
} }
} }

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.monitor.operlog.domain.OperLog; import com.ruoyi.project.monitor.operlog.domain.OperLog;
import com.ruoyi.project.monitor.operlog.service.IOperLogService; import com.ruoyi.project.monitor.operlog.service.IOperLogService;
@ -53,14 +53,14 @@ public class OperlogController extends BaseController
@Log(title = "监控管理", action = "操作日志-批量删除") @Log(title = "监控管理", action = "操作日志-批量删除")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = operLogService.batchDeleteOperLog(ids); int rows = operLogService.batchDeleteOperLog(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@RequiresPermissions("monitor:operlog:detail") @RequiresPermissions("monitor:operlog:detail")

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.project.system.dept.domain.Dept; import com.ruoyi.project.system.dept.domain.Dept;
import com.ruoyi.project.system.dept.service.IDeptService; import com.ruoyi.project.system.dept.service.IDeptService;
@ -80,13 +80,13 @@ public class DeptController extends BaseController
@RequiresPermissions("system:dept:save") @RequiresPermissions("system:dept:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(Dept dept) public Message save(Dept dept)
{ {
if (deptService.saveDept(dept) > 0) if (deptService.saveDept(dept) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**
@ -96,22 +96,22 @@ public class DeptController extends BaseController
@RequiresPermissions("system:dept:remove") @RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{deptId}") @GetMapping("/remove/{deptId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("deptId") Long deptId) public Message remove(@PathVariable("deptId") Long deptId)
{ {
if (deptService.selectDeptCount(deptId) > 0) if (deptService.selectDeptCount(deptId) > 0)
{ {
return JSON.error(1, "存在下级部门,不允许删除"); return Message.error(1, "存在下级部门,不允许删除");
} }
if (deptService.checkDeptExistUser(deptId)) if (deptService.checkDeptExistUser(deptId))
{ {
return JSON.error(1, "部门存在用户,不允许删除"); return Message.error(1, "部门存在用户,不允许删除");
} }
if (deptService.deleteDeptById(deptId) > 0) if (deptService.deleteDeptById(deptId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.dict.domain.DictData; import com.ruoyi.project.system.dict.domain.DictData;
import com.ruoyi.project.system.dict.service.IDictDataService; import com.ruoyi.project.system.dict.service.IDictDataService;
@ -81,13 +81,13 @@ public class DictDataController extends BaseController
@RequiresPermissions("system:dict:save") @RequiresPermissions("system:dict:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(DictData dict) public Message save(DictData dict)
{ {
if (dictDataService.saveDictData(dict) > 0) if (dictDataService.saveDictData(dict) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**
@ -97,31 +97,31 @@ public class DictDataController extends BaseController
@RequiresPermissions("system:dict:remove") @RequiresPermissions("system:dict:remove")
@RequestMapping("/remove/{dictCode}") @RequestMapping("/remove/{dictCode}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("dictCode") Long dictCode) public Message remove(@PathVariable("dictCode") Long dictCode)
{ {
DictData dictData = dictDataService.selectDictDataById(dictCode); DictData dictData = dictDataService.selectDictDataById(dictCode);
if (dictData == null) if (dictData == null)
{ {
return JSON.error("字典数据不存在"); return Message.error("字典数据不存在");
} }
if (dictDataService.deleteDictDataById(dictCode) > 0) if (dictDataService.deleteDictDataById(dictCode) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@Log(title = "系统管理", action = "字典类型-批量删除") @Log(title = "系统管理", action = "字典类型-批量删除")
@RequiresPermissions("system:dict:batchRemove") @RequiresPermissions("system:dict:batchRemove")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = dictDataService.batchDeleteDictData(ids); int rows = dictDataService.batchDeleteDictData(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
} }

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.dict.domain.DictType; import com.ruoyi.project.system.dict.domain.DictType;
import com.ruoyi.project.system.dict.service.IDictTypeService; import com.ruoyi.project.system.dict.service.IDictTypeService;
@ -82,13 +82,13 @@ public class DictTypeController extends BaseController
@RequiresPermissions("system:dict:save") @RequiresPermissions("system:dict:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(DictType dict) public Message save(DictType dict)
{ {
if (dictTypeService.saveDictType(dict) > 0) if (dictTypeService.saveDictType(dict) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**
@ -98,32 +98,32 @@ public class DictTypeController extends BaseController
@RequiresPermissions("system:dict:remove") @RequiresPermissions("system:dict:remove")
@RequestMapping("/remove/{dictId}") @RequestMapping("/remove/{dictId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("dictId") Long dictId) public Message remove(@PathVariable("dictId") Long dictId)
{ {
DictType dictType = dictTypeService.selectDictTypeById(dictId); DictType dictType = dictTypeService.selectDictTypeById(dictId);
if (dictType == null) if (dictType == null)
{ {
return JSON.error("字典不存在"); return Message.error("字典不存在");
} }
if (dictTypeService.deleteDictTypeById(dictId) > 0) if (dictTypeService.deleteDictTypeById(dictId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@Log(title = "系统管理", action = "字典类型-批量删除") @Log(title = "系统管理", action = "字典类型-批量删除")
@RequiresPermissions("system:dict:batchRemove") @RequiresPermissions("system:dict:batchRemove")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = dictTypeService.batchDeleteDictType(ids); int rows = dictTypeService.batchDeleteDictType(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.project.system.menu.domain.Menu; import com.ruoyi.project.system.menu.domain.Menu;
import com.ruoyi.project.system.menu.service.IMenuService; import com.ruoyi.project.system.menu.service.IMenuService;
import com.ruoyi.project.system.role.domain.Role; import com.ruoyi.project.system.role.domain.Role;
@ -56,15 +56,15 @@ public class MenuController extends BaseController
@RequiresPermissions("system:menu:remove") @RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}") @GetMapping("/remove/{menuId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("menuId") Long menuId) public Message remove(@PathVariable("menuId") Long menuId)
{ {
if (menuService.deleteMenuById(menuId) > 0) if (menuService.deleteMenuById(menuId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
else else
{ {
return JSON.error(1, "删除失败"); return Message.error(1, "删除失败");
} }
} }
@ -111,13 +111,13 @@ public class MenuController extends BaseController
@RequiresPermissions("system:menu:save") @RequiresPermissions("system:menu:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(Menu menu) public Message save(Menu menu)
{ {
if (menuService.saveMenu(menu) > 0) if (menuService.saveMenu(menu) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.post.domain.Post; import com.ruoyi.project.system.post.domain.Post;
import com.ruoyi.project.system.post.service.IPostService; import com.ruoyi.project.system.post.service.IPostService;
@ -56,32 +56,32 @@ public class PostController extends BaseController
@RequiresPermissions("system:post:remove") @RequiresPermissions("system:post:remove")
@RequestMapping("/remove/{postId}") @RequestMapping("/remove/{postId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("postId") Long postId) public Message remove(@PathVariable("postId") Long postId)
{ {
Post post = postService.selectPostById(postId); Post post = postService.selectPostById(postId);
if (post == null) if (post == null)
{ {
return JSON.error("岗位不存在"); return Message.error("岗位不存在");
} }
if (postService.deletePostById(postId) > 0) if (postService.deletePostById(postId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@RequiresPermissions("system:post:batchRemove") @RequiresPermissions("system:post:batchRemove")
@Log(title = "系统管理", action = "岗位管理-批量删除") @Log(title = "系统管理", action = "岗位管理-批量删除")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = postService.batchDeletePost(ids); int rows = postService.batchDeletePost(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**
@ -115,13 +115,13 @@ public class PostController extends BaseController
@RequiresPermissions("system:post:save") @RequiresPermissions("system:post:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(Post post) public Message save(Post post)
{ {
if (postService.savePost(post) > 0) if (postService.savePost(post) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
} }

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.role.domain.Role; import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.service.IRoleService; import com.ruoyi.project.system.role.service.IRoleService;
@ -81,45 +81,45 @@ public class RoleController extends BaseController
@Log(title = "系统管理", action = "角色管理-保存角色") @Log(title = "系统管理", action = "角色管理-保存角色")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(Role role) public Message save(Role role)
{ {
if (roleService.saveRole(role) > 0) if (roleService.saveRole(role) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@RequiresPermissions("system:role:remove") @RequiresPermissions("system:role:remove")
@Log(title = "系统管理", action = "角色管理-删除角色") @Log(title = "系统管理", action = "角色管理-删除角色")
@RequestMapping("/remove/{roleId}") @RequestMapping("/remove/{roleId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("roleId") Long roleId) public Message remove(@PathVariable("roleId") Long roleId)
{ {
Role role = roleService.selectRoleById(roleId); Role role = roleService.selectRoleById(roleId);
if (role == null) if (role == null)
{ {
return JSON.error("角色不存在"); return Message.error("角色不存在");
} }
if (roleService.deleteRoleById(roleId) > 0) if (roleService.deleteRoleById(roleId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@RequiresPermissions("system:role:batchRemove") @RequiresPermissions("system:role:batchRemove")
@Log(title = "系统管理", action = "角色管理-批量删除") @Log(title = "系统管理", action = "角色管理-批量删除")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = roleService.batchDeleteRole(ids); int rows = roleService.batchDeleteRole(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**

@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
/** /**
* *
@ -30,14 +30,14 @@ public class LoginController extends BaseController
@PostMapping("/login") @PostMapping("/login")
@ResponseBody @ResponseBody
public JSON ajaxLogin(String username, String password) public Message ajaxLogin(String username, String password)
{ {
UsernamePasswordToken token = new UsernamePasswordToken(username, password); UsernamePasswordToken token = new UsernamePasswordToken(username, password);
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
try try
{ {
subject.login(token); subject.login(token);
return JSON.ok(); return Message.ok();
} }
catch (AuthenticationException e) catch (AuthenticationException e)
{ {
@ -46,7 +46,7 @@ public class LoginController extends BaseController
{ {
msg = e.getMessage(); msg = e.getMessage();
} }
return JSON.error(msg); return Message.error(msg);
} }
} }

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON; import com.ruoyi.framework.web.domain.Message;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.post.domain.Post; import com.ruoyi.project.system.post.domain.Post;
import com.ruoyi.project.system.post.service.IPostService; import com.ruoyi.project.system.post.service.IPostService;
@ -106,46 +106,46 @@ public class UserController extends BaseController
@Log(title = "系统管理", action = "用户管理-重置密码") @Log(title = "系统管理", action = "用户管理-重置密码")
@PostMapping("/resetPwd") @PostMapping("/resetPwd")
@ResponseBody @ResponseBody
public JSON resetPwd(User user) public Message resetPwd(User user)
{ {
int rows = userService.updateUser(user); int rows = userService.updateUser(user);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@RequiresPermissions("system:user:remove") @RequiresPermissions("system:user:remove")
@Log(title = "系统管理", action = "用户管理-删除用户") @Log(title = "系统管理", action = "用户管理-删除用户")
@RequestMapping("/remove/{userId}") @RequestMapping("/remove/{userId}")
@ResponseBody @ResponseBody
public JSON remove(@PathVariable("userId") Long userId) public Message remove(@PathVariable("userId") Long userId)
{ {
User user = userService.selectUserById(userId); User user = userService.selectUserById(userId);
if (user == null) if (user == null)
{ {
return JSON.error("用户不存在"); return Message.error("用户不存在");
} }
if (userService.deleteUserById(userId) > 0) if (userService.deleteUserById(userId) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
@RequiresPermissions("system:user:batchRemove") @RequiresPermissions("system:user:batchRemove")
@Log(title = "系统管理", action = "用户管理-批量删除") @Log(title = "系统管理", action = "用户管理-批量删除")
@PostMapping("/batchRemove") @PostMapping("/batchRemove")
@ResponseBody @ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids) public Message batchRemove(@RequestParam("ids[]") Long[] ids)
{ {
int rows = userService.batchDeleteUser(ids); int rows = userService.batchDeleteUser(ids);
if (rows > 0) if (rows > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**
@ -155,13 +155,13 @@ public class UserController extends BaseController
@Log(title = "系统管理", action = "部门管理-保存部门") @Log(title = "系统管理", action = "部门管理-保存部门")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(User user) public Message save(User user)
{ {
if (userService.saveUser(user) > 0) if (userService.saveUser(user) > 0)
{ {
return JSON.ok(); return Message.ok();
} }
return JSON.error(); return Message.error();
} }
/** /**

Loading…
Cancel
Save