Class: Profile::Thrift::ThriftUserProfileService
- Inherits:
-
Object
- Object
- Profile::Thrift::ThriftUserProfileService
- Defined in:
- lib/profile_thrift_client.rb
Instance Method Summary collapse
- #checkNickname(oldNickname, nickname) ⇒ Object
- #checkNicknameDuplicate(oldNickname, nickname) ⇒ Object
- #checkNicknameFormat(nickname) ⇒ Object
- #convert_profile_to_hash(profile) ⇒ Object
- #convert_user_basicinfo_to_hash(profile) ⇒ Object
- #convert_user_simpleinfo_to_hash(simple_info) ⇒ Object
- #destroy ⇒ Object
- #getMultiNickNameByUids(uidList) ⇒ Object
- #getMultiUserBasicInfos(uids) ⇒ Object
- #getMultiUserSimpleInfos(uids) ⇒ Object
- #getNicknameByUid(uid) ⇒ Object
- #getProfielByEmail(email) ⇒ Object
- #getProfileByNickname(nickname) ⇒ Object
- #getProfileByUid(uid) ⇒ Object
- #getProfileByUids(uids) ⇒ Object
-
#initialize(config = {}) ⇒ ThriftUserProfileService
constructor
A new instance of ThriftUserProfileService.
- #modifyNicknameByUid(uid, nickname, statistic_parameters_hash = nil) ⇒ Object
- #queryUserBasicInfo(uid) ⇒ Object
- #queryUserSimpleInfo(uid) ⇒ Object
- #updateMobileBackground(uid, pic_path, statistic_parameters_hash = nil) ⇒ Object
- #updatePrifileLogo(uid, logo_pic, statistic_parameters_hash = nil) ⇒ Object
- #updateWebBackground(uid, pic_path, positionx = 0, positiony = 0, statistic_parameters_hash = nil) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ ThriftUserProfileService
Returns a new instance of ThriftUserProfileService.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/profile_thrift_client.rb', line 39 def initialize(config = {}) if config['servers'].nil? raise 'servers must be determined!' return end config = DEFAULT_CONFIG.merge(config) config['client_class'] = 'Profile::Thrift::RemoteUserProfileService::Client' @thriftClient = ThriftClient.new(config) @@logger = LoggerFactory.getLogger("ThriftUserProfileService") end |
Instance Method Details
#checkNickname(oldNickname, nickname) ⇒ Object
160 161 162 |
# File 'lib/profile_thrift_client.rb', line 160 def checkNickname(oldNickname, nickname) @thriftClient.checkNickname(oldNickname, nickname) end |
#checkNicknameDuplicate(oldNickname, nickname) ⇒ Object
168 169 170 |
# File 'lib/profile_thrift_client.rb', line 168 def checkNicknameDuplicate(oldNickname, nickname) @thriftClient.checkNicknameDuplicate(oldNickname, nickname) end |
#checkNicknameFormat(nickname) ⇒ Object
164 165 166 |
# File 'lib/profile_thrift_client.rb', line 164 def checkNicknameFormat(nickname) @thriftClient.checkNicknameFormat(nickname) end |
#convert_profile_to_hash(profile) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/profile_thrift_client.rb', line 204 def convert_profile_to_hash(profile) unless profile.nil? || profile.isNull profile = profile.to_hash if profile['createTime'] > 0 profile['createTime'] = Time.at(profile['createTime'] / 1000).to_s else profile['createTime'] = nil end if profile['lastModifyTime'] > 0 profile['lastModifyTime'] = Time.at(profile['lastModifyTime'] / 1000).to_s else profile['lastModifyTime'] = nil end if profile['loginBanStart'] > 0 profile['loginBanStart'] = Time.at(profile['loginBanStart'] / 1000).to_s else profile['loginBanStart'] = nil end if profile['loginBanEnd'] > 0 profile['loginBanEnd'] = Time.at(profile['loginBanEnd'] / 1000).to_s else profile['loginBanEnd'] = nil end return profile end return nil end |
#convert_user_basicinfo_to_hash(profile) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/profile_thrift_client.rb', line 235 def convert_user_basicinfo_to_hash(profile) unless profile.nil? || profile.isNull profile = profile.to_hash if profile['createdTime'] > 0 profile['createdTime'] = Time.at(profile['createdTime'] / 1000).to_s else profile['createdTime'] = nil end if profile['loginBanStart'] > 0 profile['loginBanStart'] = Time.at(profile['loginBanStart'] / 1000).to_s else profile['loginBanStart'] = nil end if profile['loginBanEnd'] > 0 profile['loginBanEnd'] = Time.at(profile['loginBanEnd'] / 1000).to_s else profile['loginBanEnd'] = nil end if profile['vCategoryId'] <= 0 profile['vCategoryId'] = nil end return profile end return nil end |
#convert_user_simpleinfo_to_hash(simple_info) ⇒ Object
265 266 267 |
# File 'lib/profile_thrift_client.rb', line 265 def convert_user_simpleinfo_to_hash(simple_info) return simple_info.to_hash end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/profile_thrift_client.rb', line 50 def destroy @@logger.error("before ThriftUserProfileService destroy") begin @thriftClient.destroy rescue Exception => e @@logger.error("ThriftUserProfileService destroy error !! #{e.message}" + "\n" + e.backtrace.join("\n")) end @@logger.error("thriftUserProfileService destroyed!") end |
#getMultiNickNameByUids(uidList) ⇒ Object
81 82 83 |
# File 'lib/profile_thrift_client.rb', line 81 def getMultiNickNameByUids(uidList) @thriftClient.getMultiNickNameByUids(uidList) end |
#getMultiUserBasicInfos(uids) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/profile_thrift_client.rb', line 136 def getMultiUserBasicInfos(uids) info_map = @thriftClient.getMultiUserBasicInfos(uids) unless info_map.nil? hash_info_map = {} info_map.each do |k, v| hash_info_map[k] = convert_user_basicinfo_to_hash(v) end return hash_info_map end return nil end |
#getMultiUserSimpleInfos(uids) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/profile_thrift_client.rb', line 103 def getMultiUserSimpleInfos(uids) if uids.nil? || uids.size == 0 return nil end info_map = @thriftClient.getMultiUserSimpleInfos(uids) unless info_map.nil? hash_info_map = {} info_map.each do |k, v| hash_info_map[k] = convert_user_simpleinfo_to_hash(v) end return hash_info_map end return nil end |
#getNicknameByUid(uid) ⇒ Object
77 78 79 |
# File 'lib/profile_thrift_client.rb', line 77 def getNicknameByUid(uid) @thriftClient.getNicknameByUid(uid) end |
#getProfielByEmail(email) ⇒ Object
172 173 174 |
# File 'lib/profile_thrift_client.rb', line 172 def getProfielByEmail(email) convert_profile_to_hash(@thriftClient.getProfielByEmail(email)) end |
#getProfileByNickname(nickname) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/profile_thrift_client.rb', line 148 def getProfileByNickname(nickname) profile_list = @thriftClient.getProfileByNickname(nickname) unless profile_list.nil? hash_profile_list = [] profile_list.each do |p| hash_profile_list << convert_profile_to_hash(p) end return hash_profile_list end return nil end |
#getProfileByUid(uid) ⇒ Object
60 61 62 63 |
# File 'lib/profile_thrift_client.rb', line 60 def getProfileByUid(uid) profile = @thriftClient.getProfileByUid(uid) return convert_profile_to_hash(profile) end |
#getProfileByUids(uids) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/profile_thrift_client.rb', line 65 def getProfileByUids(uids) profile_map = @thriftClient.getProfileByUids(uids) unless profile_map.nil? hash_profile_map = {} profile_map.each do |k, v| hash_profile_map[k] = convert_profile_to_hash(v) end return hash_profile_map end return nil end |
#modifyNicknameByUid(uid, nickname, statistic_parameters_hash = nil) ⇒ Object
176 177 178 179 180 181 |
# File 'lib/profile_thrift_client.rb', line 176 def modifyNicknameByUid(uid, nickname, statistic_parameters_hash=nil) if uid.nil? || nickname.nil? raise "parameter error,uid and nickname can not be null" end @thriftClient.modifyNicknameByUid(uid, nickname, statistic_parameters_hash.nil? ? nil : StatisticParameters.new(statistic_parameters_hash)) end |
#queryUserBasicInfo(uid) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/profile_thrift_client.rb', line 118 def queryUserBasicInfo(uid) begin if uid && uid.to_i > 0 info = @thriftClient.queryUserBasicInfo(uid) info = convert_user_basicinfo_to_hash(info) end unless info @@logger.error("query user basic info return nil , uid: #{uid}") end return info rescue Exception => e @@logger.error("query user basic info error, uid: #{uid},cause by :#{e.message}," + " \n" + e.backtrace.join("\n")) if info @@logger.error("info : #{info.inspect}") end end end |
#queryUserSimpleInfo(uid) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/profile_thrift_client.rb', line 85 def queryUserSimpleInfo(uid) begin if uid && uid.to_i > 0 info = @thriftClient.queryUserSimpleInfo(uid) info = convert_user_simpleinfo_to_hash(info) end unless info @@logger.error("query user basic info return nil, uid:#{uid}") end return info rescue Exception => e @logger.error("query user simple info error, uid:#{uid}, cause by : #{e.message},"+"\n"+e.backtrace.join("\n")) if info @@logger.error("simpleinfo:#{info.inspect}") end end end |
#updateMobileBackground(uid, pic_path, statistic_parameters_hash = nil) ⇒ Object
197 198 199 200 201 202 |
# File 'lib/profile_thrift_client.rb', line 197 def updateMobileBackground(uid, pic_path, statistic_parameters_hash=nil) if uid.nil? || pic_path.nil? raise "parameter error,uid and pic_path can not be null" end @thriftClient.updateMobileBackground(uid, pic_path, statistic_parameters_hash.nil? ? nil : StatisticParameters.new(statistic_parameters_hash)) end |
#updatePrifileLogo(uid, logo_pic, statistic_parameters_hash = nil) ⇒ Object
183 184 185 186 187 188 |
# File 'lib/profile_thrift_client.rb', line 183 def updatePrifileLogo(uid, logo_pic, statistic_parameters_hash=nil) if uid.nil? || logo_pic.nil? raise "parameter error,uid and logo_pic can not be null" end @thriftClient.updatePrifileLogo(uid, logo_pic, statistic_parameters_hash.nil? ? nil : StatisticParameters.new(statistic_parameters_hash)) end |
#updateWebBackground(uid, pic_path, positionx = 0, positiony = 0, statistic_parameters_hash = nil) ⇒ Object
190 191 192 193 194 195 |
# File 'lib/profile_thrift_client.rb', line 190 def updateWebBackground(uid, pic_path, positionx=0, positiony=0, statistic_parameters_hash=nil) if uid.nil? || pic_path.nil? raise "parameter error,uid and pic_path can not be null" end @thriftClient.updateWebBackground(uid, pic_path, positionx,positiony, statistic_parameters_hash.nil? ? nil : StatisticParameters.new(statistic_parameters_hash)) end |