package com.haozileung.test.web;

import com.haozileung.test.domain.system.User;
import com.haozileung.test.infra.QueryHelper;
import com.haozileung.test.infra.cache.CacheHelper;
import org.apache.velocity.Template;
import org.apache.velocity.context.Context;
import org.apache.velocity.tools.view.VelocityLayoutServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@WebServlet(name = "index", urlPatterns = {"/index"}, loadOnStartup = 1)
public class IndexServlet extends VelocityLayoutServlet {

    /**
     *
     */
    private static final long serialVersionUID = -7189409201757362254L;

    // 处理请求
    @Override
    protected Template handleRequest(HttpServletRequest request,
                                     HttpServletResponse response, Context ctx) {
        List<User> list = CacheHelper.get(User.class.getName(), "all", () -> {
            return QueryHelper.query(User.class,
                    "select username from sys_user where status = ?", 1);
        });
        ctx.put("list", list);
        return getTemplate("/index.html");
    }
}

@@ -957,29 +957,8 @@
 ) -%3E
- %7B%0A            return
  Que
@@ -984,20 +984,16 @@
 .class,%0A
-    
         
@@ -1056,19 +1056,8 @@
 , 1)
-;%0A        %7D
 );%0A 

修改java 8 lambda表达式