/*
 * Copyright 2014-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package org.docksidestage.app.web.mypage;

import java.util.List;
import java.util.stream.Collectors;

import javax.annotation.Resource;

import org.dbflute.cbean.result.ListResultBean;
import org.docksidestage.app.web.base.HarborBaseAction;
import org.docksidestage.dbflute.exbhv.ProductBhv;
import org.docksidestage.dbflute.exentity.Product;
import org.lastaflute.web.Execute;
import org.lastaflute.web.response.HtmlResponse;

/**
 * @author jflute
 */
public class MypageAction extends HarborBaseAction {

    @Resource
    protected ProductBhv productBhv;

    @Execute
    public HtmlResponse index() {
        ListResultBean<Product> memberList = productBhv.selectList(cb -> {
            cb.query().addOrderBy_RegularPrice_Desc();
            cb.fetchFirst(3);
        });
        List<MypageProductBean> beans = memberList.stream().map(member -> {
            return new MypageProductBean(member);
        }).collect(Collectors.toList());
        return asHtml(path_Mypage_MypageJsp).renderWith(data -> {
            data.register("beans", beans);
        });
    }
}

@@ -1040,16 +1040,65 @@
 esponse;
+%0Aimport org.lastaflute.web.response.JsonResponse;
 %0A%0A/**%0A *
@@ -1735,11 +1735,463 @@
 );%0A    %7D
+%0A%0A    @Execute%0A    public JsonResponse%3CList%3CMypageProductBean%3E%3E indexJson() %7B%0A        ListResultBean%3CProduct%3E memberList = productBhv.selectList(cb -%3E %7B%0A            cb.query().addOrderBy_RegularPrice_Desc();%0A            cb.fetchFirst(3);%0A        %7D);%0A        List%3CMypageProductBean%3E beans = memberList.stream().map(member -%3E %7B%0A            return new MypageProductBean(member);%0A        %7D).collect(Collectors.toList());%0A        return asJson(beans);%0A    %7D
 %0A%7D%0A

add Json Mypage