func (c *APIMeController) LoginMe() {
	//// Apply Request Parameters
	param := parameters.NewLoginMeRequest()
	if ok := c.API().Preprocess(&param); !ok {
		return
	}

	//// Call a facade
	meFacade := facades.NewMeFacade(c.GetContext())
	me, err := meFacade.LoginMe(param.Name, param.AvatarURL, param.Location)
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "LoginMe::MeFacade",
			"message": err,
		})
		return
	}

	// Render result
	c.API().OK(map[string]interface{}{
		"status":   "OK",
		"instance": me,
	})
}
func (c *APIItemController) GetItemFavoriteList() {
	//// Apply Request Parameters
	param := parameters.NewGetItemFavoriteListRequest()
	if ok := c.API().Preprocess(&param); !ok {
		return
	}

	meFacade := facades.NewMeFacade(c.GetContext())
	me, err := meFacade.GetMe(param.GetAccessToken())
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "GetMe::MeFacade",
			"message": err,
		})
		return
	}

	//// Call a facade
	itemFacade := facades.NewItemFacade(c.GetContext())
	items, err := itemFacade.FindFavoriteItem(me.ID, param.Limit)
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "FindFavoriteItem::ItemFacade",
			"message": err,
		})
		return
	}

	itemResponseList, err := c.ConvertItems(items)
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "ConvertItems::ItemController",
			"message": err,
		})
		return
	}

	// Render result
	c.API().OK(map[string]interface{}{
		"status":    "OK",
		"instances": itemResponseList,
	})
}
func (c *APIItemController) CreateItemFavorite(id string) {
	//// Apply Request Parameters
	param := parameters.NewCreateItemFavoriteRequest()
	if ok := c.API().Preprocess(&param); !ok {
		return
	}

	// Parse string id to uint64
	uint64ID := c.ParseUint64(id)
	if uint64ID <= 0 {
		return
	}

	meFacade := facades.NewMeFacade(c.GetContext())
	me, err := meFacade.GetMe(param.GetAccessToken())
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "GetMe::MeFacade",
			"message": err,
		})
		return
	}

	//// Call a facade
	itemFacade := facades.NewItemFacade(c.GetContext())
	item, err := itemFacade.CreateFavoriteItem(me.ID, uint64ID)
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "CreateFavoriteItem::ItemFacade",
			"message": err,
		})
		return
	}

	go c.scoring(me.ID, item.ID)

	// Render result
	c.API().OK(map[string]interface{}{
		"status":   "OK",
		"instance": item,
	})
}
func (c *APITagController) GetTagList() {
	//// Apply Request Parameters
	param := parameters.NewGetTagListRequest()
	if ok := c.API().Preprocess(&param); !ok {
		return
	}

	tags, err := func() ([]models.Tag, error) {
		//// Call a facade
		tagFacade := facades.NewTagFacade(c.GetContext())
		meFacade := facades.NewMeFacade(c.GetContext())
		me, _ := meFacade.GetMe(param.GetAccessToken())
		if me != nil {
			const scoreCountThreshold = 3
			tags, _ := tagFacade.FindTagByScore(me.ID, param.Limit)
			counter := 0
			for _, tag := range tags {
				if tag.Score > 5 {
					counter++
				}
			}
			if scoreCountThreshold >= counter {
				return tags, nil
			}
		}
		return tagFacade.FindPopularTag(param.Limit)
	}()
	if err != nil {
		c.API().InternalServerError(map[string]interface{}{
			"status":  "NG",
			"func":    "FindPopularTag::TagFacade",
			"message": err,
		})
		return
	}
	// Render result
	c.API().OK(map[string]interface{}{
		"status":    "OK",
		"instances": tags,
	})
}