/*
 * Copyright (C) 2018 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.security.web.acp.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jbb.security.api.lockout.MemberLockoutService;
import org.jbb.security.web.acp.form.SearchLockForm;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Slf4j
@Component
@RequiredArgsConstructor
@RequestMapping("/acp/members/locks")
public class AcpMemberLocksController {

    private static final String LOCK_BROWSER_ACP_VIEW = "acp/members/locks";
    private static final String LOCKS_SEARCH_FORM = "lockSearchForm";
    private static final String FORM_SAVED_FLAG = "lockSearchFormSaved";

    private final MemberLockoutService memberLockoutService;

    @RequestMapping(method = RequestMethod.GET)
    public String memberLocksGet(Model model,
        @ModelAttribute(LOCKS_SEARCH_FORM) SearchLockForm form) {
        model.addAttribute(LOCKS_SEARCH_FORM, form);
        return LOCK_BROWSER_ACP_VIEW;
    }

}

@@ -394,16 +394,64 @@
 .Slf4j;%0A
+import org.jbb.security.api.lockout.MemberLock;%0A
 import o
@@ -500,16 +500,16 @@
 ervice;%0A
-
 import o
@@ -553,16 +553,61 @@
 ckForm;%0A
+import org.springframework.data.domain.Page;%0A
 import o
@@ -684,16 +684,69 @@
 .Model;%0A
+import org.springframework.validation.BindingResult;%0A
 import o
@@ -924,16 +924,87 @@
 tMethod;
+%0Aimport org.springframework.web.servlet.mvc.support.RedirectAttributes;
 %0A%0A@Slf4j
@@ -1615,16 +1615,16 @@
  form);%0A
-
         
@@ -1660,10 +1660,723 @@
 %0A    %7D%0A%0A
+    @RequestMapping(method = RequestMethod.POST)%0A    public String memberLocksPost(@ModelAttribute(LOCKS_SEARCH_FORM) SearchLockForm form,%0A        BindingResult bindingResult, RedirectAttributes redirectAttributes) %7B%0A        if (bindingResult.hasErrors()) %7B%0A            log.debug(%22Lockout settings form error detected: %7B%7D%22, bindingResult.getAllErrors());%0A            return LOCK_BROWSER_ACP_VIEW;%0A        %7D%0A//        MemberLockoutSettings serviceSettings = translator.createSettingsModel(form);%0A        Page%3CMemberLock%3E resultPage = memberLockoutService.getLocksWithCriteria(null);%0A%0A        redirectAttributes.addFlashAttribute(FORM_SAVED_FLAG, true);%0A%0A        return %22redirect:/%22 + LOCK_BROWSER_ACP_VIEW;%0A    %7D%0A%0A
 %7D%0A

Send member locks form - draft