增加备份和导出功能

This commit is contained in:
dushixiang
2021-11-15 14:21:46 +08:00
parent 52309870d8
commit 1d232f7269
14 changed files with 472 additions and 134 deletions

View File

@ -2,10 +2,10 @@ package api
import (
"errors"
"next-terminal/server/constant"
"strconv"
"strings"
"next-terminal/server/constant"
"next-terminal/server/global/cache"
"next-terminal/server/log"
"next-terminal/server/model"
@ -20,6 +20,10 @@ func UserCreateEndpoint(c echo.Context) (err error) {
if err := c.Bind(&item); err != nil {
return err
}
if userRepository.ExistByUsername(item.Username) {
return Fail(c, -1, "username is already in use")
}
password := item.Password
var pass []byte
@ -71,6 +75,11 @@ func UserPagingEndpoint(c echo.Context) error {
func UserUpdateEndpoint(c echo.Context) error {
id := c.Param("id")
account, _ := GetCurrentAccount(c)
if account.ID == id {
return Fail(c, -1, "cannot modify itself")
}
var item model.User
if err := c.Bind(&item); err != nil {
return err