generated from root/miduo_server
添加服务器
parent
90a4130a20
commit
b9a0616cc6
|
|
@ -14,6 +14,7 @@ import org.springframework.ui.ModelMap;
|
|||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -163,10 +164,15 @@ public class ServerInfoController {
|
|||
|
||||
|
||||
@RequestMapping(value = "/addServer", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public int addServer(@RequestBody ServerInfo serverInfo1, HttpServletRequest request, ModelMap map) throws Exception {
|
||||
List<ServerInfoVo> serverInfoVos = new ArrayList<>();
|
||||
int server_id = seqUtils.getSequence("serverid", 2000);
|
||||
serverInfo1.set_id(server_id);
|
||||
public @ResponseBody int addServer(@RequestBody ServerInfo serverInfo1, HttpServletRequest request) throws Exception {
|
||||
int server_id ;
|
||||
if(serverInfo1.get_id()==0){
|
||||
server_id = seqUtils.getSequence("serverid", 2000);
|
||||
serverInfo1.set_id(server_id);
|
||||
}else {
|
||||
server_id = serverInfo1.get_id();
|
||||
}
|
||||
|
||||
serverInfo1.setServer_id(String.valueOf(server_id));
|
||||
if (null == serverInfo1.getOpen_time() || "".equals(serverInfo1.getOpen_time())) {
|
||||
if(serverInfo1.getOpen_type().equals(Constants.SERVEROPEN_HAND)){
|
||||
|
|
@ -183,7 +189,6 @@ public class ServerInfoController {
|
|||
String startTime = JsonUtil.date3TimeStamp(serverInfo1.getOpen_time());
|
||||
serverInfo1.setOpen_time(startTime);
|
||||
serverInfoDao.addServerInfo(serverInfo1);
|
||||
map.addAttribute("serverInfos", serverInfoVos);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public class SeqUtils {
|
|||
CAutoIncrement sequence = mongoTemplate.findAndModify(query, update, CAutoIncrement.class);
|
||||
if (sequence == null){
|
||||
saveSeq(name,defaultInt);
|
||||
cnt= defaultInt;
|
||||
}else {
|
||||
cnt = sequence.getCnt();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,16 @@
|
|||
<div class="tabCon">
|
||||
|
||||
<span class="ERRINFO"></span>
|
||||
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
服务器id:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="number" name="_id" placeholder="0自动生成" class="input-text"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
|
|
@ -186,6 +196,7 @@
|
|||
|
||||
function addServer() {
|
||||
var erroCode = $('.ERRINFO');
|
||||
var _id = $("input[name='_id']").val();
|
||||
var name = $("input[name='name']").val();
|
||||
var ip = $("input[name='ip']").val();
|
||||
var port = $("input[name='port']").val();
|
||||
|
|
@ -226,6 +237,7 @@
|
|||
type: "POST",
|
||||
data:
|
||||
JSON.stringify({
|
||||
"_id": _id,
|
||||
"name": name,
|
||||
"ip": ip,
|
||||
"port": port,
|
||||
|
|
@ -245,13 +257,13 @@
|
|||
contentType: 'application/json',
|
||||
|
||||
success: function (data) {
|
||||
if (data == 0) {
|
||||
if (data === 0) {
|
||||
layer.msg('添加成功!', {icon: 6, time: 1000});
|
||||
}
|
||||
if (data == 1) {
|
||||
if (data === 1) {
|
||||
layer.msg('添加失败!', {icon: 6, time: 1000});
|
||||
}
|
||||
if (data == 2) {
|
||||
if (data === 2) {
|
||||
layer.msg('添加失败 自动开服请设置开服时间!', {icon: 6, time: 2000});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue