package com.cxyxiaomo.epp.gateway.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.LinkedList;

@RestController
public class Controller {

    @RequestMapping("/error")
    public String error() {
        return "[ERROR] 500 Internal Server Error";
    }

    /**
     * 为了通过微信的小程序审核所特别处理的
     *
     * @return
     */
    @RequestMapping("/getConfig")
    public HashMap<String, Object> WxMiniProgramAuditSpecialHandle() {
        boolean showCode = true;
        boolean showShop = true;
        boolean showReport = true;

        // 底部 tabbar
        LinkedList<String> tabbarItem = new LinkedList<>();
        tabbarItem.push("pages/index/index");
        if (showCode) tabbarItem.push("pages/residents/code");
        if (showReport) tabbarItem.push("pages/residents/report");
        if (showShop) tabbarItem.push("pages/shop/shop");
        tabbarItem.push("pages/person/person");

        // 首页显示按钮
        LinkedList<String> indexItem = new LinkedList<>();
        indexItem.push("/pages/index/login");
        if (showCode) indexItem.push("/pages/residents/code");
        if (showCode) indexItem.push("scanQRCode");
        if (showReport) indexItem.push("/pages/residents/report");
        if (showReport) indexItem.push("/pages/residents/reportHistory");
        if (showShop) indexItem.push("/pages/shop/shop");
        if (showShop) indexItem.push("/pages/shop/myOrder");
        indexItem.push("/pages/person/person");
        indexItem.push("/pages/person/updpwd");

        HashMap<String, Object> map = new HashMap<>();
        map.put("tabbarItem", tabbarItem);
        map.put("indexItem", indexItem);
        return map;
    }
}
