|
@@ -10,15 +10,17 @@ import (
|
|
|
"path/filepath"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/IceWhaleTech/CasaOS/model"
|
|
|
+ "github.com/IceWhaleTech/CasaOS/model/system_model"
|
|
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
|
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
|
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/encryption"
|
|
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
|
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
|
|
|
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
|
|
- "github.com/IceWhaleTech/CasaOS/types"
|
|
|
+ uuid "github.com/satori/go.uuid"
|
|
|
"github.com/tidwall/gjson"
|
|
|
|
|
|
"github.com/IceWhaleTech/CasaOS/service"
|
|
@@ -29,46 +31,47 @@ import (
|
|
|
// @Router /user/register/ [post]
|
|
|
func PostUserRegister(c *gin.Context) {
|
|
|
json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- username := json["user_name"]
|
|
|
+ c.ShouldBind(&json)
|
|
|
+
|
|
|
+ username := json["username"]
|
|
|
pwd := json["password"]
|
|
|
- key := c.Param("key")
|
|
|
+ key := json["key"]
|
|
|
if _, ok := service.UserRegisterHash[key]; !ok {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{Success: common_err.KEY_NOT_EXIST, Message: common_err.GetMsg(common_err.KEY_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if len(username) == 0 || len(pwd) == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
if len(pwd) < 6 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{Success: common_err.PWD_IS_TOO_SIMPLE, Message: common_err.GetMsg(common_err.PWD_IS_TOO_SIMPLE)})
|
|
|
return
|
|
|
}
|
|
|
oldUser := service.MyService.User().GetUserInfoByUserName(username)
|
|
|
if oldUser.Id > 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{Success: common_err.USER_EXIST, Message: common_err.GetMsg(common_err.USER_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
user := model2.UserDBModel{}
|
|
|
- user.UserName = username
|
|
|
- user.Password = encryption.GetMD5ByStr(config.UserInfo.PWD)
|
|
|
+ user.Username = username
|
|
|
+ user.Password = encryption.GetMD5ByStr(pwd)
|
|
|
user.Role = "admin"
|
|
|
|
|
|
user = service.MyService.User().CreateUser(user)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR)})
|
|
|
return
|
|
|
}
|
|
|
file.MkDir(config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id))
|
|
|
delete(service.UserRegisterHash, key)
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
|
|
|
}
|
|
|
|
|
@@ -82,44 +85,43 @@ func PostUserRegister(c *gin.Context) {
|
|
|
// @Router /user/login [post]
|
|
|
func PostUserLogin(c *gin.Context) {
|
|
|
json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
+ c.ShouldBind(&json)
|
|
|
|
|
|
username := json["username"]
|
|
|
- pwd := json["pwd"]
|
|
|
+
|
|
|
+ password := json["password"]
|
|
|
//check params is empty
|
|
|
- if len(username) == 0 || len(pwd) == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ if len(username) == 0 || len(password) == 0 {
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{
|
|
|
- Success: common_err.ERROR,
|
|
|
+ Success: common_err.CLIENT_ERROR,
|
|
|
Message: common_err.GetMsg(common_err.INVALID_PARAMS),
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
user := service.MyService.User().GetUserAllInfoByName(username)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
- if user.Password != encryption.GetMD5ByStr(pwd) {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ if user.Password != encryption.GetMD5ByStr(password) {
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
model.Result{Success: common_err.PWD_INVALID, Message: common_err.GetMsg(common_err.PWD_INVALID)})
|
|
|
return
|
|
|
}
|
|
|
+ token := system_model.VerifyInformation{}
|
|
|
+ token.AccessToken = jwt.GetAccessToken(user.Username, user.Password, user.Id)
|
|
|
+ token.RefreshToken = jwt.GetRefreshToken(user.Username, user.Password, user.Id)
|
|
|
+ token.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix()
|
|
|
+ data := make(map[string]interface{}, 2)
|
|
|
user.Password = ""
|
|
|
- // token := system_model.VerifyInformation{}
|
|
|
- // token.AccessToken = jwt.GetAccessToken(user.UserName, user.Password, user.Id)
|
|
|
- // token.RefreshToken = jwt.GetRefreshToken(user.UserName, user.Password, user.Id)
|
|
|
- // token.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix()
|
|
|
- // data := make(map[string]interface{}, 2)
|
|
|
- // data["token"] = token
|
|
|
- // data["user"] = user
|
|
|
- data := make(map[string]interface{}, 3)
|
|
|
- data["token"] = jwt.GetToken(username, pwd)
|
|
|
- data["version"] = types.CURRENTVERSION
|
|
|
+ data["token"] = token
|
|
|
+
|
|
|
+ // TODO:1 Database fields cannot be external
|
|
|
data["user"] = user
|
|
|
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SUCCESS,
|
|
|
model.Result{
|
|
|
Success: common_err.SUCCESS,
|
|
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
|
@@ -139,14 +141,14 @@ func PutUserAvatar(c *gin.Context) {
|
|
|
id := c.GetHeader("user_id")
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SERVICE_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
f, err := c.FormFile("file")
|
|
|
if err != nil {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
- model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR), Data: err.Error()})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
+ model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: err.Error()})
|
|
|
return
|
|
|
}
|
|
|
if len(user.Avatar) > 0 {
|
|
@@ -165,22 +167,6 @@ func PutUserAvatar(c *gin.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @description: get user avatar by user id
|
|
|
- * @param {query} id string user id
|
|
|
- * @method: GET
|
|
|
- */
|
|
|
-func GetUserAvatar(c *gin.Context) {
|
|
|
- id := c.Param("id")
|
|
|
- user := service.MyService.User().GetUserInfoById(id)
|
|
|
-
|
|
|
- path := "default.png"
|
|
|
- if user.Id > 0 {
|
|
|
- path = user.Avatar
|
|
|
- }
|
|
|
- c.File(path)
|
|
|
-}
|
|
|
-
|
|
|
// @Summary edit user name
|
|
|
// @Produce application/json
|
|
|
// @Accept application/json
|
|
@@ -189,27 +175,42 @@ func GetUserAvatar(c *gin.Context) {
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Success 200 {string} string "ok"
|
|
|
// @Router /user/name/:id [put]
|
|
|
-func PutUserName(c *gin.Context) {
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- //userName := json["user_name"]
|
|
|
- username := json["username"]
|
|
|
- id := json["user_id"]
|
|
|
- if len(username) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR)})
|
|
|
- return
|
|
|
- }
|
|
|
+func PutUserInfo(c *gin.Context) {
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
+ json := model2.UserDBModel{}
|
|
|
+ c.ShouldBind(&json)
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
-
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SERVICE_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
- user.UserName = username
|
|
|
- service.MyService.User().UpdateUser(user)
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
+ if len(json.Username) > 0 {
|
|
|
+ u := service.MyService.User().GetUserInfoByUserName(json.Username)
|
|
|
+ if u.Id > 0 {
|
|
|
+ c.JSON(common_err.CLIENT_ERROR,
|
|
|
+ model.Result{Success: common_err.USER_EXIST, Message: common_err.GetMsg(common_err.USER_EXIST)})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(json.Email) == 0 {
|
|
|
+ json.Email = user.Email
|
|
|
+ }
|
|
|
+ if len(json.Avatar) == 0 {
|
|
|
+ json.Avatar = user.Avatar
|
|
|
+ }
|
|
|
+ if len(json.Role) == 0 {
|
|
|
+ json.Role = user.Role
|
|
|
+ }
|
|
|
+ if len(json.Description) == 0 {
|
|
|
+ json.Description = user.Description
|
|
|
+ }
|
|
|
+ if len(json.Nickname) == 0 {
|
|
|
+ json.Nickname = user.Nickname
|
|
|
+ }
|
|
|
+ service.MyService.User().UpdateUser(json)
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json})
|
|
|
}
|
|
|
|
|
|
// @Summary edit user password
|
|
@@ -219,31 +220,30 @@ func PutUserName(c *gin.Context) {
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Success 200 {string} string "ok"
|
|
|
// @Router /user/password/:id [put]
|
|
|
-func PutUserPwd(c *gin.Context) {
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
+func PutUserPassword(c *gin.Context) {
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- oldPwd := json["old_pwd"]
|
|
|
- pwd := json["pwd"]
|
|
|
- id := json["user_id"]
|
|
|
+ c.ShouldBind(&json)
|
|
|
+ oldPwd := json["old_password"]
|
|
|
+ pwd := json["password"]
|
|
|
if len(oldPwd) == 0 || len(pwd) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
user := service.MyService.User().GetUserAllInfoById(id)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SERVICE_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
if user.Password != encryption.GetMD5ByStr(oldPwd) {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.PWD_INVALID_OLD, Message: common_err.GetMsg(common_err.PWD_INVALID_OLD)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.PWD_INVALID_OLD, Message: common_err.GetMsg(common_err.PWD_INVALID_OLD)})
|
|
|
return
|
|
|
}
|
|
|
user.Password = encryption.GetMD5ByStr(pwd)
|
|
|
service.MyService.User().UpdateUserPassword(user)
|
|
|
user.Password = ""
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
}
|
|
|
|
|
|
// @Summary edit user nick
|
|
@@ -256,12 +256,11 @@ func PutUserPwd(c *gin.Context) {
|
|
|
// @Router /user/nick [put]
|
|
|
func PutUserNick(c *gin.Context) {
|
|
|
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- nickName := json["nick_name"]
|
|
|
- id := json["user_id"]
|
|
|
- if len(nickName) == 0 {
|
|
|
+ c.ShouldBind(&json)
|
|
|
+ Nickname := json["nick_name"]
|
|
|
+ if len(Nickname) == 0 {
|
|
|
c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
@@ -271,10 +270,8 @@ func PutUserNick(c *gin.Context) {
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
- user.NickName = nickName
|
|
|
+ user.Nickname = Nickname
|
|
|
service.MyService.User().UpdateUser(user)
|
|
|
- //TODO:person remove together
|
|
|
- go service.MyService.Casa().PushUserInfo()
|
|
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
}
|
|
|
|
|
@@ -287,10 +284,9 @@ func PutUserNick(c *gin.Context) {
|
|
|
// @Success 200 {string} string "ok"
|
|
|
// @Router /user/desc [put]
|
|
|
func PutUserDesc(c *gin.Context) {
|
|
|
- // id := c.GetHeader("user_id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- id := json["user_id"]
|
|
|
+ c.ShouldBind(&json)
|
|
|
desc := json["description"]
|
|
|
if len(desc) == 0 {
|
|
|
c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
@@ -309,39 +305,6 @@ func PutUserDesc(c *gin.Context) {
|
|
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
}
|
|
|
|
|
|
-// @Summary Modify user person information (Initialization use)
|
|
|
-// @Produce application/json
|
|
|
-// @Accept multipart/form-data
|
|
|
-// @Tags user
|
|
|
-// @Param nick_name formData string false "user nick name"
|
|
|
-// @Param description formData string false "Description"
|
|
|
-// @Security ApiKeyAuth
|
|
|
-// @Success 200 {string} string "ok"
|
|
|
-// @Router /user/person/info [post]
|
|
|
-func PostUserPersonInfo(c *gin.Context) {
|
|
|
- json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- desc := json["description"]
|
|
|
- nickName := json["nick_name"]
|
|
|
- id := json["user_id"]
|
|
|
- if len(desc) == 0 || len(nickName) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
- return
|
|
|
- }
|
|
|
- user := service.MyService.User().GetUserInfoById(id)
|
|
|
- if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
- model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
- return
|
|
|
- }
|
|
|
- //user_service.SetUser("", "", "", "", desc, nickName)
|
|
|
- user.NickName = nickName
|
|
|
- user.Description = desc
|
|
|
- service.MyService.User().UpdateUser(user)
|
|
|
- go service.MyService.Casa().PushUserInfo()
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
-}
|
|
|
-
|
|
|
// @Summary get user info
|
|
|
// @Produce application/json
|
|
|
// @Accept application/json
|
|
@@ -349,51 +312,38 @@ func PostUserPersonInfo(c *gin.Context) {
|
|
|
// @Success 200 {string} string "ok"
|
|
|
// @Router /user/info/:id [get]
|
|
|
func GetUserInfo(c *gin.Context) {
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
|
|
|
- //*****
|
|
|
- var u = make(map[string]string, 5)
|
|
|
- u["user_name"] = user.UserName
|
|
|
- u["head"] = user.Avatar
|
|
|
- u["email"] = user.Email
|
|
|
- u["description"] = user.NickName
|
|
|
- u["nick_name"] = user.NickName
|
|
|
- u["id"] = strconv.Itoa(user.Id)
|
|
|
-
|
|
|
- //**
|
|
|
-
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SUCCESS,
|
|
|
model.Result{
|
|
|
Success: common_err.SUCCESS,
|
|
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
|
|
- Data: u,
|
|
|
+ Data: user,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// @Summary get user info
|
|
|
-// @Produce application/json
|
|
|
-// @Accept application/json
|
|
|
-// @Tags user
|
|
|
-// @Success 200 {string} string "ok"
|
|
|
-// @Router /user/info [get]
|
|
|
-func GetUserInfoByUserName(c *gin.Context) {
|
|
|
- json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- userName := json["user_name"]
|
|
|
- if len(userName) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+/**
|
|
|
+ * @description:
|
|
|
+ * @param {*gin.Context} c
|
|
|
+ * @param {string} Username
|
|
|
+ * @return {*}
|
|
|
+ * @method:
|
|
|
+ * @router:
|
|
|
+ */
|
|
|
+func GetUserInfoByUsername(c *gin.Context) {
|
|
|
+ username := c.Param("username")
|
|
|
+ if len(username) == 0 {
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
- user := service.MyService.User().GetUserInfoByUserName(userName)
|
|
|
+ user := service.MyService.User().GetUserInfoByUserName(username)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
- //**
|
|
|
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SUCCESS,
|
|
|
model.Result{
|
|
|
Success: common_err.SUCCESS,
|
|
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
|
@@ -401,29 +351,18 @@ func GetUserInfoByUserName(c *gin.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// @Summary Get my shareId
|
|
|
-// @Produce application/json
|
|
|
-// @Accept application/json
|
|
|
-// @Tags user
|
|
|
-// @Security ApiKeyAuth
|
|
|
-// @Success 200 {string} string "ok"
|
|
|
-// @Router /user/shareid [get]
|
|
|
-func GetUserShareID(c *gin.Context) {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: config.ServerInfo.Token})
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
- * @description: get all user name
|
|
|
+ * @description: get all Usernames
|
|
|
* @method:GET
|
|
|
* @router:/user/all/name
|
|
|
*/
|
|
|
-func GetUserAllUserName(c *gin.Context) {
|
|
|
+func GetUserAllUsername(c *gin.Context) {
|
|
|
users := service.MyService.User().GetAllUserName()
|
|
|
names := []string{}
|
|
|
for _, v := range users {
|
|
|
- names = append(names, v.UserName)
|
|
|
+ names = append(names, v.Username)
|
|
|
}
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SUCCESS,
|
|
|
model.Result{
|
|
|
Success: common_err.SUCCESS,
|
|
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
|
@@ -440,25 +379,26 @@ func GetUserAllUserName(c *gin.Context) {
|
|
|
func GetUserCustomConf(c *gin.Context) {
|
|
|
name := c.Param("key")
|
|
|
if len(name) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
+
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
- // user := service.MyService.User().GetUserInfoByUserName(userName)
|
|
|
+ // user := service.MyService.User().GetUserInfoByUsername(Username)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SERVICE_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
filePath := config.AppInfo.UserDataPath + "/" + id + "/" + name + ".json"
|
|
|
+
|
|
|
data := file.ReadFullFile(filePath)
|
|
|
if !gjson.ValidBytes(data) {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: string(data)})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: string(data)})
|
|
|
return
|
|
|
}
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))})
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -468,16 +408,16 @@ func GetUserCustomConf(c *gin.Context) {
|
|
|
* @router:/user/custom/:key
|
|
|
*/
|
|
|
func PostUserCustomConf(c *gin.Context) {
|
|
|
+
|
|
|
name := c.Param("key")
|
|
|
if len(name) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SERVICE_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
@@ -485,7 +425,7 @@ func PostUserCustomConf(c *gin.Context) {
|
|
|
filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id)
|
|
|
|
|
|
file.WriteToPath(data, filePath, name+".json")
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))})
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -497,20 +437,23 @@ func PostUserCustomConf(c *gin.Context) {
|
|
|
func DeleteUserCustomConf(c *gin.Context) {
|
|
|
name := c.Param("key")
|
|
|
if len(name) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
+ c.JSON(common_err.SERVICE_ERROR,
|
|
|
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + "/" + name + ".json"
|
|
|
- os.Remove(filePath)
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
+ err := os.Remove(filePath)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR)})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -522,19 +465,18 @@ func DeleteUserCustomConf(c *gin.Context) {
|
|
|
func DeleteUser(c *gin.Context) {
|
|
|
id := c.Param("id")
|
|
|
service.MyService.User().DeleteUserById(id)
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: id})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: id})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @description:update user image
|
|
|
* @method:POST
|
|
|
- * @router:/user/file/image/:key
|
|
|
+ * @router:/user/current/image/:key
|
|
|
*/
|
|
|
-func PostUserFileImage(c *gin.Context) {
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+func PutUserImage(c *gin.Context) {
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
+ c.ShouldBind(&json)
|
|
|
|
|
|
path := json["path"]
|
|
|
key := c.Param("key")
|
|
@@ -571,50 +513,57 @@ func PostUserFileImage(c *gin.Context) {
|
|
|
data := make(map[string]string, 3)
|
|
|
data["path"] = filePath
|
|
|
data["file_name"] = key + ext
|
|
|
- data["online_path"] = "/v1/user/image?path=" + filePath
|
|
|
+ data["online_path"] = "/v1/users/image?path=" + filePath
|
|
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description:create or update user's custom image
|
|
|
- * @param {formData} file file "a file to be uploaded"
|
|
|
- * @param {path} key string "file name"
|
|
|
- * @method:POST
|
|
|
- * @router:/user/upload/image/:key
|
|
|
+* @description:
|
|
|
+* @param {*gin.Context} c
|
|
|
+* @param {file} file
|
|
|
+* @param {string} key
|
|
|
+* @param {string} type:avatar,background
|
|
|
+* @return {*}
|
|
|
+* @method:
|
|
|
+* @router:
|
|
|
*/
|
|
|
func PostUserUploadImage(c *gin.Context) {
|
|
|
- //id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
f, err := c.FormFile("file")
|
|
|
key := c.Param("key")
|
|
|
+ t := c.PostForm("type")
|
|
|
if len(key) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
if err != nil {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR), Data: err.Error()})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: err.Error()})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
_, err = file.GetImageExtByName(f.Filename)
|
|
|
if err != nil {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.NOT_IMAGE, Message: common_err.GetMsg(common_err.NOT_IMAGE)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.NOT_IMAGE, Message: common_err.GetMsg(common_err.NOT_IMAGE)})
|
|
|
return
|
|
|
}
|
|
|
ext := filepath.Ext(f.Filename)
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
+ if t == "avatar" {
|
|
|
+ key = "avatar"
|
|
|
+ }
|
|
|
path := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + "/" + key + ext
|
|
|
+
|
|
|
c.SaveUploadedFile(f, path)
|
|
|
data := make(map[string]string, 3)
|
|
|
data["path"] = path
|
|
|
data["file_name"] = key + ext
|
|
|
- data["online_path"] = "/v1/user/image?path=" + path
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
|
|
+ data["online_path"] = "/v1/users/image?path=" + path
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -641,95 +590,94 @@ func GetUserImage(c *gin.Context) {
|
|
|
defer fileTmp.Close()
|
|
|
|
|
|
fileName := path.Base(filePath)
|
|
|
+
|
|
|
+ // @tiger - RESTful 规范下不应该返回文件本身内容,而是返回文件的静态URL,由前端去解析
|
|
|
c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(fileName))
|
|
|
c.File(filePath)
|
|
|
}
|
|
|
func DeleteUserImage(c *gin.Context) {
|
|
|
- // id := c.GetHeader("user_id")
|
|
|
- id := c.Param("id")
|
|
|
+ id := c.GetHeader("user_id")
|
|
|
path := c.Query("path")
|
|
|
if len(path) == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
return
|
|
|
}
|
|
|
user := service.MyService.User().GetUserInfoById(id)
|
|
|
if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
if !file.Exists(path) {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.FILE_DOES_NOT_EXIST, Message: common_err.GetMsg(common_err.FILE_DOES_NOT_EXIST)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.FILE_DOES_NOT_EXIST, Message: common_err.GetMsg(common_err.FILE_DOES_NOT_EXIST)})
|
|
|
return
|
|
|
}
|
|
|
if !strings.Contains(path, config.AppInfo.UserDataPath+"/"+strconv.Itoa(user.Id)) {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)})
|
|
|
+ c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)})
|
|
|
return
|
|
|
}
|
|
|
os.Remove(path)
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
}
|
|
|
|
|
|
-////refresh token
|
|
|
-// func PostUserRefreshToken(c *gin.Context) {
|
|
|
-// json := make(map[string]string)
|
|
|
-// c.BindJSON(&json)
|
|
|
-// refresh := json["refresh_token"]
|
|
|
-// claims, err := jwt.ParseToken(refresh)
|
|
|
-// if err != nil {
|
|
|
-// c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE), Data: err.Error()})
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if claims.VerifyExpiresAt(time.Now(), true) || claims.VerifyIssuer("refresh", true) {
|
|
|
-// c.JSON(http.StatusOK, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)})
|
|
|
-// return
|
|
|
-// }
|
|
|
-// newToken := jwt.GetAccessToken(claims.UserName, claims.PassWord, claims.Id)
|
|
|
-// if err != nil {
|
|
|
-// c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR), Data: err.Error()})
|
|
|
-// return
|
|
|
-// }
|
|
|
-// verifyInfo := system_model.VerifyInformation{}
|
|
|
-// verifyInfo.AccessToken = newToken
|
|
|
-// verifyInfo.RefreshToken = jwt.GetRefreshToken(claims.UserName, claims.PassWord, claims.Id)
|
|
|
-// verifyInfo.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix()
|
|
|
-
|
|
|
-// c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: verifyInfo})
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
-//******** soon to be removed ********
|
|
|
-
|
|
|
-// @Summary 设置用户名和密码
|
|
|
-// @Produce application/json
|
|
|
-// @Accept multipart/form-data
|
|
|
-// @Tags user
|
|
|
-// @Param username formData string true "User name"
|
|
|
-// @Param pwd formData string true "password"
|
|
|
-// @Security ApiKeyAuth
|
|
|
-// @Success 200 {string} string "ok"
|
|
|
-// @Router /user/setusernamepwd [post]
|
|
|
-func Set_Name_Pwd(c *gin.Context) {
|
|
|
- json := make(map[string]string)
|
|
|
- c.BindJSON(&json)
|
|
|
- username := json["username"]
|
|
|
- pwd := json["pwd"]
|
|
|
- if service.MyService.User().GetUserCount() > 0 || len(username) == 0 || len(pwd) == 0 {
|
|
|
- c.JSON(http.StatusOK,
|
|
|
- model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
|
|
+/**
|
|
|
+ * @description:
|
|
|
+ * @param {*gin.Context} c
|
|
|
+ * @param {string} refresh_token
|
|
|
+ * @return {*}
|
|
|
+ * @method:
|
|
|
+ * @router:
|
|
|
+ */
|
|
|
+func PostUserRefreshToken(c *gin.Context) {
|
|
|
+ js := make(map[string]string)
|
|
|
+ c.ShouldBind(&js)
|
|
|
+ refresh := js["refresh_token"]
|
|
|
+ claims, err := jwt.ParseToken(refresh, true)
|
|
|
+ if err != nil {
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE), Data: err.Error()})
|
|
|
return
|
|
|
}
|
|
|
- user := model2.UserDBModel{}
|
|
|
- user.UserName = username
|
|
|
- user.Password = encryption.GetMD5ByStr(pwd)
|
|
|
- user.Role = "admin"
|
|
|
-
|
|
|
- user = service.MyService.User().CreateUser(user)
|
|
|
- if user.Id == 0 {
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR)})
|
|
|
+ if !claims.VerifyExpiresAt(time.Now(), true) || !claims.VerifyIssuer("refresh", true) {
|
|
|
+ c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)})
|
|
|
return
|
|
|
}
|
|
|
- file.MkDir(config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id))
|
|
|
+ newToken := jwt.GetAccessToken(claims.Username, claims.PassWord, claims.Id)
|
|
|
+ verifyInfo := system_model.VerifyInformation{}
|
|
|
+ verifyInfo.AccessToken = newToken
|
|
|
+ verifyInfo.RefreshToken = jwt.GetRefreshToken(claims.Username, claims.PassWord, claims.Id)
|
|
|
+ verifyInfo.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix()
|
|
|
|
|
|
- c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: verifyInfo})
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func DeleteUserAll(c *gin.Context) {
|
|
|
+ service.MyService.User().DeleteAllUser()
|
|
|
+ c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
|
|
+}
|
|
|
|
|
|
+// @Summary 检查是否进入引导状态
|
|
|
+// @Produce application/json
|
|
|
+// @Accept application/json
|
|
|
+// @Tags sys
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Success 200 {string} string "ok"
|
|
|
+// @Router /sys/init/check [get]
|
|
|
+func GetUserStatus(c *gin.Context) {
|
|
|
+ data := make(map[string]interface{}, 2)
|
|
|
+
|
|
|
+ if service.MyService.User().GetUserCount() > 0 {
|
|
|
+ data["initialized"] = true
|
|
|
+ data["key"] = ""
|
|
|
+ } else {
|
|
|
+ key := uuid.NewV4().String()
|
|
|
+ service.UserRegisterHash[key] = key
|
|
|
+ data["key"] = key
|
|
|
+ data["initialized"] = false
|
|
|
+ }
|
|
|
+ c.JSON(common_err.SUCCESS,
|
|
|
+ model.Result{
|
|
|
+ Success: common_err.SUCCESS,
|
|
|
+ Message: common_err.GetMsg(common_err.SUCCESS),
|
|
|
+ Data: data,
|
|
|
+ })
|
|
|
}
|