Skip to content

Commit

Permalink
addded home api
Browse files Browse the repository at this point in the history
  • Loading branch information
GURUAKASH-MUTHURAJAN committed Mar 11, 2024
1 parent 8b8f961 commit fd5d82b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
17 changes: 6 additions & 11 deletions controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,9 @@ func Inventory(c *gin.Context) {

}

var SearchName string

func Getallinventorydata(c *gin.Context) {
fmt.Println(SearchName)
result := service.Search(SearchName)
c.JSON(http.StatusOK, result)
}



func ValidateToken(c *gin.Context) {
var userdata models.Userdata
Expand All @@ -171,15 +167,14 @@ func ValidateToken(c *gin.Context) {
}

func Search(c *gin.Context) {
type Search struct {
ProductName string `json:"productName" bson:"productName"`
}
var search Search
var search models.Search
if err := c.BindJSON(&search); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid JSON data"})
return
}
SearchName = search.ProductName
result := service.Search(search.ProductName)
c.JSON(http.StatusOK, gin.H{"data":result})

}

func Update(c *gin.Context) {
Expand Down
4 changes: 4 additions & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,7 @@ type Block struct {
Email string `json:"email" bson:"email"`
Collection string `json:"collection" bson:"collection"`
}

type Search struct {
ProductName string `json:"productName" bson:"productName"`
}
1 change: 0 additions & 1 deletion router/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func Router() *gin.Engine {
router.POST("/inventory", controller.Inventory)
router.POST("/search", controller.Search)
router.POST("/update", controller.Update)
router.GET("/inventorydata", controller.Getallinventorydata)
router.POST("/sellercheck", controller.CheckSeller)
router.POST("/deleteproduct", controller.DeleteProduct)
router.POST("/deleteproductbyseller", controller.DeleteProductBySeller)
Expand Down
2 changes: 1 addition & 1 deletion service/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (sender *GmailSender) SendEmail(
}

func SendEmailforCustomerVerification(toEmail, id, name string) {
sender := NewGmailSender("GURUAKAKSH SM", "guruakash.ec20@bitsathy.ac.in", "snuk gatz ohoa agyt")
sender := NewGmailSender("GURUAKAKSH SM", "guruakash.ec20@bitsathy.ac.in", "")
subject := "A test Email"
htmlTemplate := `
<!DOCTYPE html>
Expand Down
1 change: 1 addition & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func Search(productName string) []models.Inventory1 {

Inventory = append(Inventory, inventory)
}

return Inventory
}
func Getalldata() []models.Customer {
Expand Down

0 comments on commit fd5d82b

Please sign in to comment.