Exemplo n.º 1
0
func GetList(c *gin.Context) {
	db := utils.GetDb(c)
	query := BuildQuery(c)
	err, companies := companydb.GetList(db, query)
	if err != nil {
		log.Error(err.Error())
		c.JSON(http.StatusNotFound, companyNotFoundError)
		return
	}
	c.JSON(http.StatusOK, companies)
}
Exemplo n.º 2
0
func GetUserCompanies(c *gin.Context) {
	db := utils.GetDb(c)
	id := c.Params.ByName("id")

	err, companies := companydb.GetList(db, &bson.M{
		"owner": bson.ObjectIdHex(id),
	})

	if err != nil {
		c.JSON(http.StatusNotFound, userNotFoundError)
		return
	}

	c.JSON(http.StatusOK, companies)
}