待添加消息队列处理

This commit is contained in:
APLS 2020-03-23 22:05:08 +08:00
parent b913ec36ef
commit 823bfbdbd2
5 changed files with 59 additions and 8 deletions

View File

@ -18,7 +18,8 @@ public enum ResultEnum {
NO_ROBOT_FOUND(-10006,"No QQ robot corresponding to this token was found"), NO_ROBOT_FOUND(-10006,"No QQ robot corresponding to this token was found"),
NO_ROBOT_FOUND_(-10007,"No QQ robot corresponding to this token was found"), NO_ROBOT_FOUND_(-10007,"No QQ robot corresponding to this token was found"),
STATE_HAS_EXPIRED(-10008,"state has expired, please re-authorize."), STATE_HAS_EXPIRED(-10008,"state has expired, please re-authorize."),
INVALID_EMAIL(-10009,"Invalid Email!"); INVALID_EMAIL(-10009,"Invalid Email!"),
INVALID_format(-10010, "Invalid format");
private Integer code; private Integer code;
private String msg; private String msg;

View File

@ -46,7 +46,7 @@ public class WebController {
if (one != null) { if (one != null) {
model.addAttribute("client_id", one.getClientId()); model.addAttribute("client_id", one.getClientId());
model.addAttribute("client_secret", one.getClientSecret()); model.addAttribute("client_secret", one.getClientSecret());
model.addAttribute("cron_time", one.getCronTime()); model.addAttribute("cron_time", one.getCronTime().toString());
model.addAttribute("cron_time_random_start", one.getCronTimeRandomStart()); model.addAttribute("cron_time_random_start", one.getCronTimeRandomStart());
model.addAttribute("cron_time_random_end", one.getCronTimeRandomEnd()); model.addAttribute("cron_time_random_end", one.getCronTimeRandomEnd());
} else { } else {

View File

@ -36,9 +36,22 @@ public class OutlookController {
} }
@PostMapping("/saveRandomTime") @PostMapping("/saveRandomTime")
public Result saveRandomTime(@RequestParam int cronTime, @RequestParam int crondomTime) { public Result saveRandomTime(@RequestParam int cronTime, @RequestParam String crondomTime) {
String[] split = crondomTime.split("-");
if (split.length != 2) {
return ResultUtil.error(ResultEnum.INVALID_format);
}
int cron_time_random_start;
int cron_time_random_end;
try {
cron_time_random_start = Integer.valueOf(split[0]);
cron_time_random_end = Integer.valueOf(split[1]);
} catch (NumberFormatException e) {
e.printStackTrace();
return ResultUtil.error(ResultEnum.INVALID_format);
}
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
if (outlookService.saveRandomTime(authentication.getGithub_id(), cronTime, 0, 0)) { if (outlookService.saveRandomTime(authentication.getGithub_id(), cronTime, cron_time_random_start, cron_time_random_end)) {
return ResultUtil.success(); return ResultUtil.success();
} }
return ResultUtil.error(ResultEnum.UNKNOWN_ERROR); return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);

View File

@ -109,7 +109,18 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
@Override @Override
public boolean saveRandomTime(int github_id, int cron_time, int cron_time_random_start, int cron_time_random_end) { public boolean saveRandomTime(int github_id, int cron_time, int cron_time_random_start, int cron_time_random_end) {
if (github_id == 0) {
return false;
}
UpdateWrapper<Outlook> Wrapper = new UpdateWrapper<>();
Wrapper.eq("github_id", github_id);
Outlook outlook = new Outlook();
outlook.setCronTime(cron_time).setCronTimeRandomStart(cron_time_random_start).setCronTimeRandomEnd(cron_time_random_end);
int update = baseMapper.update(outlook, Wrapper);
// 有数据
if (update > 0) {
return true;
}
return false; return false;
} }

View File

@ -48,11 +48,11 @@
<div class="mdui-table-fluid table-container floats"> <div class="mdui-table-fluid table-container floats">
<div class="mdui-textfield"> <div class="mdui-textfield">
<label class="mdui-textfield-label" style="font-weight: 500;">调用时间间隔</label> <label class="mdui-textfield-label" style="font-weight: 500;">调用时间间隔</label>
<input id="client_secret" class="mdui-textfield-input" type="text" value="${cron_time!}"/> <input id="cron_time" class="mdui-textfield-input" type="number" value="${cron_time!}"/>
</div> </div>
<div class="mdui-textfield"> <div class="mdui-textfield">
<label class="mdui-textfield-label" style="font-weight: 500;">随机时间范围</label> <label class="mdui-textfield-label" style="font-weight: 500;">随机时间范围</label>
<input id="client_secret" class="mdui-textfield-input" type="text" <input id="cron_time_random" class="mdui-textfield-input" type="text"
value="${cron_time_random_start!}-${cron_time_random_end!}"/> value="${cron_time_random_start!}-${cron_time_random_end!}"/>
</div> </div>
<ol> <ol>
@ -72,6 +72,32 @@
var url = "/outlookLog/findLog" var url = "/outlookLog/findLog"
window.open(url, '_blank') window.open(url, '_blank')
}) })
//保存随机时间
$("#save_random_time").click(function () {
var cron_time = $("#cron_time").val();
var cron_time_random = $("#cron_time_random").val();
if ((cron_time || cron_time_random) == "") {
alert("cron_time 或 cron_time_random 不能为空!")
return;
}
;
$.post("/outlook/outlook/saveRandomTime", {
cronTime: cron_time,
crondomTime: cron_time_random
}, function (data, status) {
console.log(data);
if (status != "success") {
alert("未知错误,请联系管理员!")
return;
}
if (data.code == 0) {
alert("保存成功!");
} else {
alert("错误: " + data.msg);
}
})
})
// 授权 // 授权
$("#authorization").click(function () { $("#authorization").click(function () {
var url = "/outlook/auth2/getAuthorizeUrl" var url = "/outlook/auth2/getAuthorizeUrl"
@ -98,7 +124,7 @@
if (data.code == 0) { if (data.code == 0) {
alert("保存成功!"); alert("保存成功!");
} else { } else {
alert("错误: + " + data.msg); alert("错误: " + data.msg);
} }
}) })