流程中心-各分页列表调整。

用户token失效返回信息处理。
This commit is contained in:
wangzhijiang
2022-03-08 18:32:07 +08:00
parent 7a87cc72fd
commit eac73fc32c
5 changed files with 109 additions and 39 deletions
@@ -1,6 +1,8 @@
package com.jero.config.shiro; package com.jero.config.shiro;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.google.gson.Gson;
import com.jero.common.api.vo.Result;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationInfo;
@@ -18,10 +20,14 @@ import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.RedisUtil; import com.jero.common.util.RedisUtil;
import com.jero.common.util.SpringContextUtils; import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils; import com.jero.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set; import java.util.Set;
/** /**
@@ -41,6 +47,9 @@ public class ShiroRealm extends AuthorizingRealm {
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private HttpServletResponse response;
/** /**
* 必须重写此方法,不然Shiro会报错 * 必须重写此方法,不然Shiro会报错
*/ */
@@ -124,6 +133,25 @@ public class ShiroRealm extends AuthorizingRealm {
} }
// 校验token是否超时失效 & 或者账号密码是否错误 // 校验token是否超时失效 & 或者账号密码是否错误
if (!jwtTokenRefresh(token, username, loginUser.getPassword())) { if (!jwtTokenRefresh(token, username, loginUser.getPassword())) {
String reponseJson = new Gson().toJson(Result.error(401,"Token失效,请重新登录!"));
response.setContentType("application/json; charset=utf-8");
response.setCharacterEncoding("utf-8");
OutputStream out = null;
try {
out = response.getOutputStream();
out.write(reponseJson.getBytes());
}catch (IOException ex){
ex.printStackTrace();
}finally {
if(out != null){
try {
out.close();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
throw new AuthenticationException("Token失效,请重新登录!"); throw new AuthenticationException("Token失效,请重新登录!");
} }
@@ -1,7 +1,6 @@
package com.jero.modules.wkflow.controller; package com.jero.modules.wkflow.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.aspect.annotation.AutoLog;
import com.jero.modules.wkflow.entity.BusMes; import com.jero.modules.wkflow.entity.BusMes;
@@ -9,6 +8,7 @@ import com.jero.modules.wkflow.entity.BusProcessName;
import com.jero.modules.wkflow.entity.BusProcessNew; import com.jero.modules.wkflow.entity.BusProcessNew;
import com.jero.modules.wkflow.entity.TaskCommonQuery; import com.jero.modules.wkflow.entity.TaskCommonQuery;
import com.jero.modules.wkflow.feginClient.impl.TaskFeignClientImpl; import com.jero.modules.wkflow.feginClient.impl.TaskFeignClientImpl;
import com.jero.modules.wkflow.page.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -65,21 +65,21 @@ public class TaskController {
@AutoLog(value = "我的待办任务列表") @AutoLog(value = "我的待办任务列表")
@ApiOperation(value="我的待办任务列表", notes="我的待办任务列表") @ApiOperation(value="我的待办任务列表", notes="我的待办任务列表")
@PostMapping("/todoTaskList") @PostMapping("/todoTaskList")
public IPage<BusProcessName> todoTaskListByUserId(@RequestBody TaskCommonQuery taskCommonQuery){ public Page todoTaskListByUserId(@RequestBody TaskCommonQuery taskCommonQuery){
List<BusProcessName> busProcessNames = taskFeignClient.todoTaskListByUserId(taskCommonQuery); List<BusProcessName> busProcessNames = taskFeignClient.todoTaskListByUserId(taskCommonQuery);
List list1 = this.startPage(busProcessNames, taskCommonQuery.getCurrent(), taskCommonQuery.getSize()); List list1 = this.startPage(busProcessNames, taskCommonQuery.getCurrent(), taskCommonQuery.getSize());
IPage pageInfo = new Page(); Page pageInfo = new Page();
if(busProcessNames!=null){ if(busProcessNames!=null){
pageInfo.setRecords(list1); pageInfo.setList(list1);
pageInfo.setCurrent(taskCommonQuery.getCurrent()); pageInfo.setPageNo(taskCommonQuery.getCurrent());
pageInfo.setTotal(Long.valueOf(busProcessNames.size())); pageInfo.setCount(Long.valueOf(busProcessNames.size()));
pageInfo.setSize(taskCommonQuery.getSize()); pageInfo.setPageSize(taskCommonQuery.getSize());
}else{ }else{
List<BusProcessName> list = new ArrayList<>(); List<BusProcessName> list = new ArrayList<>();
pageInfo.setRecords(list); pageInfo.setList(list);
pageInfo.setCurrent(taskCommonQuery.getCurrent()); pageInfo.setPageNo(taskCommonQuery.getCurrent());
pageInfo.setTotal(Long.valueOf(0)); pageInfo.setCount(Long.valueOf(0));
pageInfo.setSize(taskCommonQuery.getSize()); pageInfo.setPageSize(taskCommonQuery.getSize());
} }
return pageInfo; return pageInfo;
} }
@@ -87,21 +87,21 @@ public class TaskController {
@AutoLog(value = "查询草稿") @AutoLog(value = "查询草稿")
@ApiOperation(value="查询草稿", notes="查询草稿") @ApiOperation(value="查询草稿", notes="查询草稿")
@PostMapping("/queryTaskDraft") @PostMapping("/queryTaskDraft")
public IPage<BusProcessName> queryTaskDraft(@RequestBody TaskCommonQuery taskCommonQuery){ public Page queryTaskDraft(@RequestBody TaskCommonQuery taskCommonQuery){
List<BusProcessName> busProcessNames = taskFeignClient.queryTaskDraft(taskCommonQuery); List<BusProcessName> busProcessNames = taskFeignClient.queryTaskDraft(taskCommonQuery);
List list1 = this.startPage(busProcessNames, taskCommonQuery.getCurrent(), taskCommonQuery.getSize()); List list1 = this.startPage(busProcessNames, taskCommonQuery.getCurrent(), taskCommonQuery.getSize());
IPage pageInfo = new Page(); Page pageInfo = new Page();
if(busProcessNames!=null){ if(busProcessNames!=null){
pageInfo.setRecords(list1); pageInfo.setList(list1);
pageInfo.setCurrent(taskCommonQuery.getCurrent()); pageInfo.setPageNo(taskCommonQuery.getCurrent());
pageInfo.setTotal(Long.valueOf(busProcessNames.size())); pageInfo.setCount(Long.valueOf(busProcessNames.size()));
pageInfo.setSize(taskCommonQuery.getSize()); pageInfo.setPageSize(taskCommonQuery.getSize());
}else{ }else{
List<BusProcessName> list = new ArrayList<BusProcessName>(); List<BusProcessName> list = new ArrayList<BusProcessName>();
pageInfo.setRecords(list); pageInfo.setList(list);
pageInfo.setCurrent(taskCommonQuery.getCurrent()); pageInfo.setPageNo(taskCommonQuery.getCurrent());
pageInfo.setTotal(Long.valueOf(0)); pageInfo.setCount(Long.valueOf(0));
pageInfo.setSize(taskCommonQuery.getSize()); pageInfo.setPageSize(taskCommonQuery.getSize());
} }
return pageInfo; return pageInfo;
} }
@@ -109,25 +109,22 @@ public class TaskController {
@AutoLog(value = "已办流程") @AutoLog(value = "已办流程")
@ApiOperation(value="已办流程", notes="已办流程") @ApiOperation(value="已办流程", notes="已办流程")
@PostMapping("/doneProcess") @PostMapping("/doneProcess")
public IPage<BusProcessName> doneProcess(@RequestBody TaskCommonQuery taskCommonQuery){ public Page doneProcess(@RequestBody TaskCommonQuery taskCommonQuery){
IPage page = taskFeignClient.doneProcess(taskCommonQuery); return taskFeignClient.doneProcess(taskCommonQuery);
return page;
} }
@AutoLog(value = "已发流程") @AutoLog(value = "已发流程")
@ApiOperation(value="已发流程", notes="已发流程") @ApiOperation(value="已发流程", notes="已发流程")
@PostMapping("/IssuedProcess") @PostMapping("/IssuedProcess")
public IPage<BusProcessName> IssuedProcess(@RequestBody TaskCommonQuery taskCommonQuery){ public Page IssuedProcess(@RequestBody TaskCommonQuery taskCommonQuery){
IPage page = taskFeignClient.issuedProcess(taskCommonQuery); return taskFeignClient.issuedProcess(taskCommonQuery);
return page;
} }
@AutoLog(value = "监控流程列表") @AutoLog(value = "监控流程列表")
@ApiOperation(value="监控流程列表", notes="监控流程列表") @ApiOperation(value="监控流程列表", notes="监控流程列表")
@PostMapping("/allProcess") @PostMapping("/allProcess")
public IPage<BusProcessName> allProcess(@RequestBody TaskCommonQuery taskCommonQuery){ public Page allProcess(@RequestBody TaskCommonQuery taskCommonQuery){
IPage page= taskFeignClient.allProcess(taskCommonQuery); return taskFeignClient.allProcess(taskCommonQuery);
return page;
} }
@AutoLog(value = "已办流程-根据taskId查询已办明细") @AutoLog(value = "已办流程-根据taskId查询已办明细")
@@ -6,6 +6,7 @@ import com.jero.modules.wkflow.entity.BusMes;
import com.jero.modules.wkflow.entity.BusProcessName; import com.jero.modules.wkflow.entity.BusProcessName;
import com.jero.modules.wkflow.entity.BusProcessNew; import com.jero.modules.wkflow.entity.BusProcessNew;
import com.jero.modules.wkflow.entity.TaskCommonQuery; import com.jero.modules.wkflow.entity.TaskCommonQuery;
import com.jero.modules.wkflow.page.Page;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -70,7 +71,7 @@ public interface TaskFeignClient {
* @return * @return
*/ */
@RequestMapping(value = "/bat-wkflow/doneProcess",method = RequestMethod.POST) @RequestMapping(value = "/bat-wkflow/doneProcess",method = RequestMethod.POST)
IPage doneProcess(@RequestBody TaskCommonQuery taskCommonQuery); Page doneProcess(@RequestBody TaskCommonQuery taskCommonQuery);
/** /**
* 已发流程 * 已发流程
@@ -78,7 +79,7 @@ public interface TaskFeignClient {
* @return * @return
*/ */
@RequestMapping(value = "/bat-wkflow/issuedProcess",method = RequestMethod.POST) @RequestMapping(value = "/bat-wkflow/issuedProcess",method = RequestMethod.POST)
IPage issuedProcess(@RequestBody TaskCommonQuery taskCommonQuery); Page issuedProcess(@RequestBody TaskCommonQuery taskCommonQuery);
/** /**
* 监控流程列表 * 监控流程列表
@@ -86,7 +87,7 @@ public interface TaskFeignClient {
* @return * @return
*/ */
@RequestMapping(value = "/bat-wkflow/allProcess",method = RequestMethod.POST) @RequestMapping(value = "/bat-wkflow/allProcess",method = RequestMethod.POST)
IPage allProcess(@RequestBody TaskCommonQuery taskCommonQuery); Page allProcess(@RequestBody TaskCommonQuery taskCommonQuery);
/** /**
* 已办流程-根据taskId查询已办明细 * 已办流程-根据taskId查询已办明细
@@ -1,12 +1,12 @@
package com.jero.modules.wkflow.feginClient.impl; package com.jero.modules.wkflow.feginClient.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.modules.wkflow.entity.BusMes; import com.jero.modules.wkflow.entity.BusMes;
import com.jero.modules.wkflow.entity.BusProcessName; import com.jero.modules.wkflow.entity.BusProcessName;
import com.jero.modules.wkflow.entity.BusProcessNew; import com.jero.modules.wkflow.entity.BusProcessNew;
import com.jero.modules.wkflow.entity.TaskCommonQuery; import com.jero.modules.wkflow.entity.TaskCommonQuery;
import com.jero.modules.wkflow.feginClient.TaskFeignClient; import com.jero.modules.wkflow.feginClient.TaskFeignClient;
import com.jero.modules.wkflow.page.Page;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -84,8 +84,8 @@ public class TaskFeignClientImpl {
* @param taskCommonQuery * @param taskCommonQuery
* @return * @return
*/ */
public IPage doneProcess(@RequestBody TaskCommonQuery taskCommonQuery){ public Page doneProcess(@RequestBody TaskCommonQuery taskCommonQuery){
IPage busProcessNames = taskFeignClient.doneProcess(taskCommonQuery); Page busProcessNames = taskFeignClient.doneProcess(taskCommonQuery);
return busProcessNames; return busProcessNames;
} }
@@ -94,8 +94,8 @@ public class TaskFeignClientImpl {
* @param taskCommonQuery * @param taskCommonQuery
* @return * @return
*/ */
public IPage issuedProcess(@RequestBody TaskCommonQuery taskCommonQuery){ public Page issuedProcess(@RequestBody TaskCommonQuery taskCommonQuery){
IPage busProcessNames = taskFeignClient.issuedProcess(taskCommonQuery); Page busProcessNames = taskFeignClient.issuedProcess(taskCommonQuery);
return busProcessNames; return busProcessNames;
} }
@@ -104,7 +104,7 @@ public class TaskFeignClientImpl {
* @param taskCommonQuery * @param taskCommonQuery
* @return * @return
*/ */
public IPage allProcess(@RequestBody TaskCommonQuery taskCommonQuery){ public Page allProcess(@RequestBody TaskCommonQuery taskCommonQuery){
return taskFeignClient.allProcess(taskCommonQuery); return taskFeignClient.allProcess(taskCommonQuery);
} }
@@ -0,0 +1,44 @@
package com.jero.modules.wkflow.page;
import com.jero.modules.wkflow.entity.BusProcessName;
import java.util.List;
public class Page {
private Integer pageNo;
private Integer pageSize;
private Long count;
private List<BusProcessName> list;
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public List<BusProcessName> getList() {
return list;
}
public void setList(List<BusProcessName> list) {
this.list = list;
}
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
}