Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
H
Hgs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐州
Hgs
Commits
d54ae4a9
Commit
d54ae4a9
authored
Sep 27, 2021
by
huagnxiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加通过用户id获取头像的外部接口
parent
62cf7313
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
179 additions
and
4 deletions
+179
-4
applicationContext-dubbo.xml
...rces/development/application/applicationContext-dubbo.xml
+4
-1
applicationContext-dubbo.xml
...urces/production/application/applicationContext-dubbo.xml
+4
-1
applicationContext-dubbo.xml
...n/resources/test/application/applicationContext-dubbo.xml
+4
-1
IGetHeadImgByUserId.java
.../com/house365/ws/interfaces/rest/IGetHeadImgByUserId.java
+6
-0
GetHeadImgByUserIdImpl.java
...m/house365/ws/interfaces/rest/GetHeadImgByUserIdImpl.java
+148
-0
applicationContext-dubbo.xml
...rces/development/application/applicationContext-dubbo.xml
+5
-0
applicationContext-dubbo.xml
...urces/production/application/applicationContext-dubbo.xml
+4
-1
applicationContext-dubbo.xml
...n/resources/test/application/applicationContext-dubbo.xml
+4
-0
No files found.
house365-hgs-web/src/main/resources/development/application/applicationContext-dubbo.xml
View file @
d54ae4a9
...
@@ -397,7 +397,10 @@
...
@@ -397,7 +397,10 @@
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--根据用户id获取用户头像接口-->
<dubbo:reference
id=
"getHeadImgByUserId"
interface=
"com.house365.ws.interfaces.rest.IGetHeadImgByUserId"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-web/src/main/resources/production/application/applicationContext-dubbo.xml
View file @
d54ae4a9
...
@@ -394,6 +394,9 @@
...
@@ -394,6 +394,9 @@
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--根据用户id获取用户头像接口-->
<dubbo:reference
id=
"getHeadImgByUserId"
interface=
"com.house365.ws.interfaces.rest.IGetHeadImgByUserId"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-web/src/main/resources/test/application/applicationContext-dubbo.xml
View file @
d54ae4a9
...
@@ -394,6 +394,9 @@
...
@@ -394,6 +394,9 @@
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
<dubbo:reference
id=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--根据用户id获取用户头像接口-->
<dubbo:reference
id=
"getHeadImgByUserId"
interface=
"com.house365.ws.interfaces.rest.IGetHeadImgByUserId"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws-interfaces/src/main/java/com/house365/ws/interfaces/rest/IGetHeadImgByUserId.java
0 → 100644
View file @
d54ae4a9
package
com
.
house365
.
ws
.
interfaces
.
rest
;
import
com.house365.rest.context.IService
;
public
interface
IGetHeadImgByUserId
extends
IService
{
}
house365-hgs-ws/src/main/java/com/house365/ws/interfaces/rest/GetHeadImgByUserIdImpl.java
0 → 100644
View file @
d54ae4a9
package
com
.
house365
.
ws
.
interfaces
.
rest
;
import
com.google.common.base.Strings
;
import
com.house365.beans.entity.BaseAttachment
;
import
com.house365.rest.context.Parameter
;
import
com.house365.rest.exception.IllegalServiceParameterException
;
import
com.house365.rest.exception.ServiceRunException
;
import
com.house365.rest.parameter.House365RestObject
;
import
com.house365.rest.parameter.House365RestResponse
;
import
com.house365.ws.beans.response.AttachmentListResponse
;
import
com.house365.ws.beans.response.CustomerResponse
;
import
com.house365.ws.interfaces.server.IAttachmentInterface
;
import
com.house365.ws.system.ReturnAppResult
;
import
com.house365.ws.util.Constant
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
@Service
(
"getHeadImgByUserId"
)
public
class
GetHeadImgByUserIdImpl
implements
IGetHeadImgByUserId
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
GetHeadImgByUserIdImpl
.
class
);
@Autowired
private
IAttachmentInterface
attachmentInterface
;
@Override
public
Object
rollback
()
{
return
null
;
}
@Override
public
void
commit
()
{
}
@Override
public
Object
exectue
(
Parameter
parameter
)
throws
ServiceRunException
{
// 取得所需参数
Map
<
String
,
Object
>
map
=
parameter
.
getArgs
();
House365RestResponse
<
CustomerResponse
>
response
=
new
House365RestResponse
<
CustomerResponse
>();
try
{
checkInterfaceParameter
(
map
,
Constant
.
USERID
);
response
.
setResult
(
ReturnAppResult
.
APP_SUCCESS
.
getResultCode
());
response
.
setMsg
(
ReturnAppResult
.
APP_SUCCESS
.
getResultMessage
());
}
catch
(
IllegalServiceParameterException
e
)
{
response
.
setResult
(
ReturnAppResult
.
APP_FAIL
.
getResultCode
());
response
.
setMsg
(
e
.
getMessage
());
return
JSONObject
.
fromObject
(
response
).
toString
();
}
House365RestResponse
<
String
>
response2
=
new
House365RestResponse
<>();
// 业务层统一处理
try
{
House365RestObject
<
String
>
data
=
doBusiness
(
map
);
response2
.
setData
(
data
);
response2
.
setResult
(
ReturnAppResult
.
APP_SUCCESS
.
getResultCode
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
response2
.
setResult
(
ReturnAppResult
.
APP_FAIL
.
getResultCode
());
response2
.
setMsg
((
ReturnAppResult
.
APP_FAIL
.
getResultMessage
()
+
":"
+
e
.
getMessage
()));
return
JSONObject
.
fromObject
(
response2
).
toString
();
}
String
result
=
JSONObject
.
fromObject
(
response2
).
toString
();
return
result
;
}
/**
* 业务层统逻辑处理
*/
private
House365RestObject
<
String
>
doBusiness
(
Map
<
String
,
Object
>
map
)
throws
Exception
{
// 返回Json对象
House365RestObject
<
String
>
restObject
=
new
House365RestObject
<>();
String
userId
=
getMapValueByKey
(
"userId"
,
map
,
""
);
AttachmentListResponse
headImgRes
=
attachmentInterface
.
queryByResourceIdAndResouceType
(
String
.
valueOf
(
userId
),
"hgs_user_headImg"
);
if
(
null
!=
headImgRes
.
getObjectList
()
&&
!
headImgRes
.
getObjectList
().
isEmpty
())
{
BaseAttachment
attachment
=
(
BaseAttachment
)
headImgRes
.
getObjectList
().
get
(
0
);
restObject
.
setEntity
(
attachment
.
getRemotePath
());
}
return
restObject
;
}
/**
* 获取map中的值
*
* @param key key
* @param map map
* @param defaultValue 默认值
* @return value
*/
private
String
getMapValueByKey
(
String
key
,
Map
<
String
,
Object
>
map
,
String
defaultValue
)
{
String
value
=
""
;
if
(
map
.
containsKey
(
key
)
&&
map
.
get
(
key
)
!=
null
&&
!
Strings
.
isNullOrEmpty
(((
String
[])
map
.
get
(
key
))[
0
]))
{
value
=
((
String
[])
map
.
get
(
key
))[
0
];
}
if
(
Strings
.
isNullOrEmpty
(
value
))
{
value
=
defaultValue
;
}
return
value
;
}
/**
* 业务层统校验自己所需参数是否存在
* 所有参数都要存在
*
* @author hqc
*/
protected
void
checkInterfaceParameter
(
Map
<
String
,
Object
>
map
,
String
[]
checkParams
)
throws
IllegalServiceParameterException
{
// 方法所需参数
for
(
String
str
:
checkParams
)
{
// 如果不存在跳出 同时抛出相应异常
if
(!
map
.
containsKey
(
str
))
{
throw
new
IllegalServiceParameterException
(
"业务入口参数异常:"
+
str
+
"参数为空!"
);
}
}
}
@Override
public
boolean
isControlService
()
{
return
false
;
}
@Override
public
boolean
isLogService
()
{
return
false
;
}
@Override
public
boolean
isMonitorService
()
{
return
false
;
}
}
house365-hgs-ws/src/main/resources/development/application/applicationContext-dubbo.xml
View file @
d54ae4a9
...
@@ -393,4 +393,9 @@
...
@@ -393,4 +393,9 @@
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--根据用户id获取用户头像接口-->
<dubbo:service
ref=
"getHeadImgByUserId"
interface=
"com.house365.ws.interfaces.rest.IGetHeadImgByUserId"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws/src/main/resources/production/application/applicationContext-dubbo.xml
View file @
d54ae4a9
...
@@ -385,5 +385,8 @@
...
@@ -385,5 +385,8 @@
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--根据用户id获取用户头像接口-->
<dubbo:service
ref=
"getHeadImgByUserId"
interface=
"com.house365.ws.interfaces.rest.IGetHeadImgByUserId"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
house365-hgs-ws/src/main/resources/test/application/applicationContext-dubbo.xml
View file @
d54ae4a9
...
@@ -394,5 +394,9 @@
...
@@ -394,5 +394,9 @@
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
<dubbo:service
ref=
"getOnlineLog"
interface=
"com.house365.ws.interfaces.rest.IGetOnlineLog"
version=
"${dubbo.app.version}"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
<!--根据用户id获取用户头像接口-->
<dubbo:service
ref=
"getHeadImgByUserId"
interface=
"com.house365.ws.interfaces.rest.IGetHeadImgByUserId"
version=
"${dubbo.app.version}"
timeout=
"${dubbo.app.timeout}"
retries=
"${dubbo.app.retries}"
/>
</beans>
</beans>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment