2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 00:39:32 +08:00
Files
panel/internal/service/ssh.go
2024-10-20 22:14:11 +08:00

43 lines
843 B
Go

package service
import (
"net/http"
"github.com/TheTNB/panel/internal/biz"
"github.com/TheTNB/panel/internal/data"
"github.com/TheTNB/panel/internal/http/request"
)
type SSHService struct {
sshRepo biz.SSHRepo
}
func NewSSHService() *SSHService {
return &SSHService{
sshRepo: data.NewSSHRepo(),
}
}
func (s *SSHService) GetInfo(w http.ResponseWriter, r *http.Request) {
info, err := s.sshRepo.GetInfo()
if err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
}
Success(w, info)
}
func (s *SSHService) UpdateInfo(w http.ResponseWriter, r *http.Request) {
req, err := Bind[request.SSHUpdateInfo](r)
if err != nil {
Error(w, http.StatusUnprocessableEntity, "%v", err)
return
}
if err = s.sshRepo.UpdateInfo(req); err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
}
}