package com.ndpmedia.rocketmq.cockpit.controller.api;

import com.ndpmedia.rocketmq.cockpit.model.NameServer;
import com.ndpmedia.rocketmq.cockpit.mybatis.mapper.NameServerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping(value = "/api/name-server")
public class NameServerServiceController {

    @Autowired
    private NameServerMapper nameServerMapper;

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public List<NameServer> list() {
        List<NameServer> nameServerList = nameServerMapper.list();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (NameServer nameServer : nameServerList) {
            System.out.println(null == nameServer.getCreateTime() ? "NULL!!!" : dateFormat.format(nameServer.getCreateTime()));
        }
        return nameServerList;
    }

    @RequestMapping(value = "/id/{id}", method = RequestMethod.GET)
    @ResponseBody
    public NameServer get(@PathVariable("id") long id) {
        return nameServerMapper.get(id);
    }

    @RequestMapping(value = "/id/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public boolean delete(@PathVariable("id") long id) {
        nameServerMapper.delete(id);
        return true;
    }

    @RequestMapping(method = RequestMethod.PUT)
    @ResponseBody
    public NameServer add(@ModelAttribute NameServer nameServer, HttpServletResponse response) {
        nameServer.setCreateTime(new Date());
        nameServer.setUpdateTime(new Date());
        nameServerMapper.insert(nameServer);
        response.setContentType("application/json");
        response.setStatus(HttpStatus.OK.value());
        return nameServer;
    }

    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public NameServer update(@ModelAttribute NameServer nameServer) {
        long id = nameServerMapper.insert(nameServer);
        nameServer.setId(id);
        return nameServer;
    }
}

@@ -692,72 +692,8 @@
 se;%0A
-import java.text.DateFormat;%0Aimport java.text.SimpleDateFormat;%0A
 impo
@@ -707,24 +707,24 @@
 .util.Date;%0A
+
 import java.
@@ -1013,366 +1013,38 @@
     
-List%3CNameServer%3E nameServerList = nameServerMapper.list();%0A        DateFormat dateFormat = new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss%22);%0A        for (NameServer nameServer : nameServerList) %7B%0A            System.out.println(null == nameServer.getCreateTime() ? %22NULL!!!%22 : dateFormat.format(nameServer.getCreateTime()));%0A        %7D%0A        return nameServerList
+return nameServerMapper.list()
 ;%0A  

Remove debug code.