@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { // 获取用户 User user = this.getUser(username); user.setPassword(""); // if(user!=null){ // user.setLastLoginIp(lastLoginIp); // user.setLastLoginTime(new Date()); // user.setVisitCount(user.getVisitCount()+1); // this.editUser(user, false); // } return user; }
@Override @Transactional public long addUser(final User user) { try { // 添加用户记录 long userId = (Long) this.sqlMapClientTemplate.insert("tbl_user.addUser", user); user.setUserId(userId); Map<String, Object> params = new HashMap<String, Object>(); params.put("userIds", new long[] {user.getUserId()}); return userId; } catch (DuplicateKeyException e) { throw new RpcException("用户名或邮箱重复", e); } catch (Exception e) { throw new RpcException("添加用户出错", e); } }
@Override @Transactional public long editUser(final User user) { try { // 编辑用户记录 long count = this.sqlMapClientTemplate.update("tbl_user.editUser", user); Map<String, Object> params = new HashMap<String, Object>(); params.put("userIds", new long[] {user.getUserId()}); return count; } catch (DuplicateKeyException e) { throw new RpcException("用户名或邮箱重复", e); } catch (Exception e) { throw new RpcException("编辑用户出错", e); } }