2022-02-22 09:35:44 +01:00
|
|
|
package managers
|
2022-02-20 11:55:11 +01:00
|
|
|
|
2022-03-08 12:01:51 +01:00
|
|
|
import (
|
|
|
|
"StoreBackEnd/pkg/protocol/repository"
|
|
|
|
"bufio"
|
|
|
|
)
|
2022-02-20 12:35:05 +01:00
|
|
|
|
2022-02-20 11:55:11 +01:00
|
|
|
type RequestManager struct {
|
2022-02-22 08:29:11 +01:00
|
|
|
Repository *repository.ProtocolRepository
|
2022-02-20 11:55:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-08 12:01:51 +01:00
|
|
|
func (receiver RequestManager) Execute(request string, reader *bufio.Reader) string {
|
2022-02-20 11:55:11 +01:00
|
|
|
// On lis ce que l'on reçoit
|
2022-03-08 12:01:51 +01:00
|
|
|
result, executed, readCb := receiver.Repository.ExecuteReader(request)
|
2022-03-08 14:48:14 +01:00
|
|
|
println("TESTTESTETTETT")
|
2022-02-20 11:55:11 +01:00
|
|
|
// On renvoie la réponse (Comment pour fichier ?)
|
2022-02-20 12:35:05 +01:00
|
|
|
if executed {
|
2022-03-08 12:01:51 +01:00
|
|
|
if readCb != nil {
|
|
|
|
cbResult, _ := readCb(reader)
|
|
|
|
if cbResult != "" {
|
|
|
|
result = cbResult
|
|
|
|
}
|
|
|
|
}
|
2022-02-20 12:35:05 +01:00
|
|
|
return result
|
|
|
|
} else {
|
2022-03-08 14:48:14 +01:00
|
|
|
println("HMMM")
|
2022-02-20 12:35:05 +01:00
|
|
|
// TODO : Renvoyer qu'une erreur est survenue
|
2022-03-05 18:32:27 +01:00
|
|
|
return "Error occurred while execute command"
|
2022-02-20 12:35:05 +01:00
|
|
|
}
|
2022-02-20 11:55:11 +01:00
|
|
|
}
|