package remark

import (
	"common/httpServer"
	"fmt"
	"net/http"

	"common/webServer"
)

// init
// @description: init
// parameter:
// return:
func init() {
	webServer.RegisterRemarkFunc(remarkdCallback)
	httpServer.RegisterRemarkFunc(remarkdCallback)
}

// remarkdCallback
// @description: remarkdCallback
// parameter:
// @w: w
// @r: r
// return:
func remarkdCallback(w http.ResponseWriter, r *http.Request) {

	for index, moduleItem := range remarksSlice {
		// 输出模块信息
		fmt.Fprintf(w, fmt.Sprintf("%d、%s【Name:%s  Author:%s  Mendor:%s  Date:%s】\n", index+1, moduleItem.Desc, moduleItem.Name, moduleItem.Author, moduleItem.Mendor, moduleItem.Date))

		// 输出方法列表信息
		for subIndex, methodItem := range moduleItem.MethodRemarkSlice {
			fmt.Fprintf(w, fmt.Sprintf("  %d.%d、%s【Name:%s  Author:%s  Mendor:%s  Date:%s】\n", index+1, subIndex+1, methodItem.Desc, methodItem.Name, methodItem.Author, methodItem.Mendor, methodItem.Date))

			fmt.Fprintln(w, "  \t输入参数：")
			if len(methodItem.InParam) > 0 {
				for _, param := range methodItem.InParam {
					fmt.Fprintln(w, "    ", param)
				}
			} else {
				fmt.Fprintln(w, "    ", "无")
			}

			fmt.Fprintln(w, "  \t输出参数：")
			if methodItem.OutParam != "" {
				fmt.Fprintln(w, "    ", methodItem.OutParam)
			} else {
				fmt.Fprintln(w, "    ", "无")
			}

			fmt.Fprintln(w)
		}
	}
	return
}
