diff options
author | Vitaly Takmazov | 2018-11-20 15:16:08 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-11-20 15:16:23 +0300 |
commit | b0cfa955c77c4e36bd334324d0ccb2ff24ff549f (patch) | |
tree | c40954b3c453c7138514d1439fdcd6d969af0bec /src/main/java/com/juick/service | |
parent | 152efe1f31e1e568272fc401a3a19f2c6f7c9c49 (diff) |
versioned avatars in www
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r-- | src/main/java/com/juick/service/UserServiceImpl.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index fdc4f28c..f05fc93f 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -354,18 +354,22 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Transactional @Override public boolean updateUserInfo(final User user, final UserInfo info) { - return getJdbcTemplate().update( - "INSERT INTO usersinfo(user_id, fullname, country, url, descr) VALUES (?, ?, ?, ?, ?) " + - "ON DUPLICATE KEY UPDATE fullname = ?, country = ?, url = ?, descr = ?", - user.getUid(), - info.getFullName(), - info.getCountry(), - info.getUrl(), - info.getDescription(), - info.getFullName(), - info.getCountry(), - info.getUrl(), - info.getDescription()) > 0; + try { + return getJdbcTemplate().update( + "INSERT INTO usersinfo(user_id, fullname, country, url, descr) VALUES (?, ?, ?, ?, ?)", + user.getUid(), + info.getFullName(), + info.getCountry(), + info.getUrl(), + info.getDescription()) > 0; + } catch (DuplicateKeyException e) { + return getJdbcTemplate().update("UPDATE usersinfo SET fullname = ?, country = ?, url = ?, descr = ? WHERE user_id = ?", + info.getFullName(), + info.getCountry(), + info.getUrl(), + info.getDescription(), + user.getUid()) > 0; + } } @Transactional(readOnly = true) |