package controllers

import (
	"fmt"
	"github.com/beego/beego/v2/server/web"
)

type FilterController struct {
	web.Controller
}

// Filter jsonp请求过来的函数
func (c *FilterController) Filter() {
	userID, ok := c.GetSession("userID").(string)

	dataJSON := new(struct {
		Code int
	})

	if !ok || userID == "" {
		dataJSON.Code = 404
	} else {
		dataJSON.Code = 200
		_ = c.SetSession("userID", userID)
	}
	fmt.Println(dataJSON)
	c.Data["json"] = dataJSON
	_ = c.ServeJSON()
}
