package controllers;

import com.avaje.ebean.Page;
import models.Issue;
import models.Post;
import models.Project;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.search.contentsSearch;
import views.html.search.issueContentsSearch;
import views.html.search.postContentsSearch;

public class SearchApp extends Controller {

    public static class ContentSearchCondition {
        public String filter;
        public int page;
        public int pageSize;
        public String type;

        public ContentSearchCondition() {
            this.filter = "";
            this.page = 1;
            this.pageSize = 10;
            this.type = "all";
        }
    }

    public static Result contentsSearch(String userName, String projectName) {
        Project project = ProjectApp.getProject(userName, projectName);

        if (project == null) {
            notFound();
        }

        ContentSearchCondition condition = form(ContentSearchCondition.class).bindFromRequest().get();

        Page<Issue> resultIssues = null;
        Page<Post> resultPosts = null;

        if(!condition.type.equals("post")) {
            resultIssues = Issue.findIssues(project, condition);
        }
        if(!condition.type.equals("issue")) {
            resultPosts = Post.findPosts(project, condition);
        }

        if(condition.type.equals("post")) {
            return ok(postContentsSearch.render(project, resultPosts));
        } else if(condition.type.equals("issue")) {
            return ok(issueContentsSearch.render(project, resultIssues));
        }

        return ok(contentsSearch.render("title.contentSearchResult", project, condition.filter, resultIssues, resultPosts));
    }
}
@@ -888,32 +888,70 @@
 nd();%0A        %7D%0A
+%09%09/* @TODO %EC%BF%BC%EB%A6%AC%EC%97%90 %EB%8C%80%ED%95%B4%EC%84%9C %ED%8A%B9%EC%88%98%EB%AC%B8%EC%9E%90%EB%82%98 %EA%B3%B5%EB%B0%B1 %EC%B2%B4%ED%81%AC %ED%95%B4%EC%95%BC%ED%95%A8. */
 %0A        Content

Add TODO Comment.