Former-commit-id: f44fa1b74559ddf8b6aa4445c078921209cf2aa0
master
王兵 5 years ago
parent f457fa3678
commit 057f3ddb9f

@ -112,10 +112,14 @@ public class SpringBootCallable implements Callable {
}
}
// base 和 frame等内容
// frame等内容
System.out.println("生成模块:frame");
generateFrame(Tool.createPath(domainDir.getAbsolutePath(), "frame"), project, dataBase, option);
// Task
System.out.println("生成模块:task");
generateTask(Tool.createPath(domainDir.getAbsolutePath(), "task"), project, dataBase, option);
// Application
System.out.println("生成模块:Application");
generateApplication(Tool.createPath(domainDir.getAbsolutePath()), project, dataBase, option);
@ -565,6 +569,30 @@ public class SpringBootCallable implements Callable {
}
}
/**
* frame
*
* @param root
* @param project
*/
public void generateTask(File root, Project project, DataBase dataBase, String option) {
if (!root.exists()) {
root.mkdirs();
} else {
Tool.clear(root);
}
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("basePackage", project.getProjectBasePackage());
ctx.put("moduleName", project.getProjectName());
ctx.put("timestamp", new Date().getTime());
//task
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/task/")) {
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), name), option + "/java/task/" + name, ctx);
}
}
/**
* base
*

@ -278,7 +278,7 @@ public class TokensManagerImpl implements xyz.wbsite.module.system.mgr.TokensMan
return response;
}
if (request.getToken().equals(LocalData.getToken().getToken())) {
if (request.getToken().equals(token.getToken())) {
response.addError(ErrorType.BUSINESS_ERROR, "无法注销当前登录用户!");
return response;
}

@ -0,0 +1,44 @@
package ${basePackage}.task;
import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.schedule.RunDelayRepeatTask;
import ${basePackage}.module.system.ent.Tokens;
import ${basePackage}.module.system.mgr.TokensManager;
import ${basePackage}.module.system.req.TokensFindRequest;
import ${basePackage}.module.system.req.TokensLogoutRequest;
import ${basePackage}.module.system.rsp.TokensFindResponse;
import ${basePackage}.module.system.rsp.TokensLogoutResponse;
import java.time.Duration;
import java.util.Date;
public class TokenTask extends RunDelayRepeatTask {
@Override
public String taskId() {
return "task1";
}
@Override
public Duration interval() {
return Duration.ofMinutes(1);
}
@Override
public void run() {
TokensManager tokensManager = LocalData.getBean(TokensManager.class);
TokensFindRequest tokensFindRequest = new TokensFindRequest();
tokensFindRequest.setPageSize(0);
tokensFindRequest.setValid(true);
TokensFindResponse tokensFindResponse = tokensManager.find(tokensFindRequest, LocalData.getSysToken());
Date current = new Date();
for (Tokens tokens : tokensFindResponse.getResult()) {
if (tokens.getValidTime().before(current)) {
TokensLogoutRequest tokensLogoutRequest = new TokensLogoutRequest();
tokensLogoutRequest.setToken(tokens.getToken());
TokensLogoutResponse tokensLogoutResponse = tokensManager.logout(tokensLogoutRequest, LocalData.getSysToken());
}
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.