|
@@ -228,18 +228,15 @@ func UpdateUser(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
if user.Id.IsZero() {
|
|
|
return nil, errors.New("id错误")
|
|
|
}
|
|
|
- su := &model.User{}
|
|
|
- found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
- CollectName: repo.CollectionUser,
|
|
|
- Query: repo.Map{"nid": user.Nid},
|
|
|
- }, su)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
+
|
|
|
+ if len(user.Password) > 0 {
|
|
|
+ user.Password = UtilMd5(user.Password)
|
|
|
}
|
|
|
- if found {
|
|
|
- return nil, errors.New("该编号已存在")
|
|
|
+ result, err := repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionUser, user.Id.Hex(), user)
|
|
|
+ if err != nil {
|
|
|
+ return nil, errors.New("更新失败,请检查编码是否重复")
|
|
|
}
|
|
|
- return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionUser, user.Id.Hex(), user)
|
|
|
+ return result, err
|
|
|
}
|
|
|
|
|
|
// 获取自己的信息
|