2022-06-07 17:54:33 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
2022-07-22 19:28:14 +00:00
|
|
|
"databag/internal/store"
|
|
|
|
"github.com/gorilla/mux"
|
2022-06-07 17:54:33 +00:00
|
|
|
"net/http"
|
2022-07-22 19:28:14 +00:00
|
|
|
"strconv"
|
2022-06-07 17:54:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func SetNodeAccountStatus(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
2022-07-22 19:28:14 +00:00
|
|
|
// get referenced account id
|
|
|
|
params := mux.Vars(r)
|
|
|
|
accountID, res := strconv.ParseUint(params["accountID"], 10, 32)
|
|
|
|
if res != nil {
|
|
|
|
ErrResponse(w, http.StatusBadRequest, res)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if code, err := ParamAdminToken(r); err != nil {
|
|
|
|
ErrResponse(w, code, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var flag bool
|
|
|
|
if err := ParseRequest(r, w, &flag); err != nil {
|
|
|
|
ErrResponse(w, http.StatusBadRequest, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := store.DB.Model(store.Account{}).Where("id = ?", accountID).Update("disabled", flag).Error; err != nil {
|
|
|
|
ErrResponse(w, http.StatusInternalServerError, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteResponse(w, nil)
|
2022-06-07 17:54:33 +00:00
|
|
|
}
|