package h5

import (
	"github.com/gin-gonic/gin"
	"slg/pkg/errno"
	"slg/pkg/handler"
	"slg/service/bank_service"
	"slg/validate_service"
	"strings"
)

func GetBank(c *gin.Context) {

	handler.SendResponse(c, nil, nil)
}

func AddBank(c *gin.Context) {
	bank := validate_service.Bank{}
	c.ShouldBindJSON(&bank)

	if ok, errors := validate_service.ValidateInputs(bank); !ok {
		for _, err := range errors {
			handler.SendResponse(c, errno.ErrBind, strings.Join(err, " "))
			return
		}
	}

	bank_service := bank_service.Bank{
		BankName: bank.BankName,
	}

	if err := bank_service.Add(); err != nil {
		handler.SendResponse(c, errno.ErrAddBank, nil)
		return
	}

	handler.SendResponse(c, nil, nil)
}

func UpdateBank(c *gin.Context) {

	handler.SendResponse(c, nil, nil)
}

func DeleteBank(c *gin.Context) {

	handler.SendResponse(c, nil, nil)
}