/*
 * @description:
 * @Author: CP
 * @Date: 2020-08-23 21:32:42
 * @FilePath: \construction_management\web\controllers\index.go
 */
package controllers

import (
	"github.com/kataras/iris/v12"
	"go.mod/models"
	"go.mod/services"
)

type IndexController struct {
	//框架-web应用上下文环境
	Ctx iris.Context
	// 需要用的service
	ServiceManager services.ManagerService
}

// 默认首页
func (c *IndexController) Get() string {
	c.Ctx.Header("Content-Type", "text/html")
	return "welcome to"
}

//返回json示例
func (c *IndexController) GetGifts() map[string]interface{} {
	rs := make(map[string]interface{})
	rs["code"] = 0
	rs["msg"] = ""
	datalist := c.ServiceManager.GetAll()
	list := make([]models.CmManager, 0)
	for _, data := range datalist {
		list = append(list, data)
		// 正常状态的才需要放进来
		// if data.SysStatus == 0 {
		// 	list = append(list, data)
		// }
	}
	rs["gifts"] = list
	return rs
}
