Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-backend
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
cloud-backend
Commits
243c36fb
Commit
243c36fb
authored
Apr 08, 2021
by
袁伟铭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.0.0
parent
06d70504
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
27 deletions
+57
-27
api-server/src/main/java/com/zq/api/controller/ApiController.java
+1
-2
api-server/src/main/java/com/zq/api/feign/CmsFeign.java
+19
-0
api-server/src/main/java/com/zq/api/form/ApiResp.java
+0
-11
api-server/src/main/java/com/zq/api/service/ApiService.java
+7
-1
api-server/src/main/java/com/zq/api/service/impl/ApiV100Logic.java
+7
-1
api-server/src/main/java/com/zq/api/utils/ApiUtils.java
+11
-0
cms-server/src/main/java/com/zq/cms/config/JwtAuthenticationEntryPoint.java
+1
-1
common-utils/src/main/java/com/zq/common/utils/AssertUtils.java
+10
-10
config-server/src/main/resources/properties/config-dev.yml
+1
-1
No files found.
api-server/src/main/java/com/zq/api/controller/ApiController.java
View file @
243c36fb
...
...
@@ -27,8 +27,7 @@ public class ApiController {
private
final
ApiService
apiService
;
// 允许用户未登录状态下执行的方法名
private
String
[]
allowMethod
=
{
"test"
,
"phoneLogin"
,
"getSessionKey"
,
"getPhoneNumber"
,
"wxLogin"
,
"login"
,
"sendCode"
,
"register"
,
"getHospitalList"
,
"getDoctorList"
,
"uploadImage"
,
"getVersion"
,
"wxAuthorizeLogin"
};
private
String
[]
allowMethod
=
{
"te4st"
};
/**
* 获取信息入口
...
...
api-server/src/main/java/com/zq/api/feign/CmsFeign.java
0 → 100644
View file @
243c36fb
package
com
.
zq
.
api
.
feign
;
import
com.zq.common.vo.ResultVo
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.Map
;
@Component
public
class
CmsFeign
{
private
RestTemplate
restTemplate
=
new
RestTemplate
();
private
static
String
cmsServer
=
"http://127.0.0.1:9889/cms"
;
public
ResultVo
test
(
Map
<
String
,
Object
>
paramsMap
)
{
return
restTemplate
.
getForObject
(
cmsServer
+
"/adviceFeedback/getAdviceFeedbackById"
,
ResultVo
.
class
);
}
}
api-server/src/main/java/com/zq/api/form/ApiResp.java
View file @
243c36fb
package
com
.
zq
.
api
.
form
;
import
com.alibaba.fastjson.JSON
;
import
com.zq.api.constant.ApiCodeEnum
;
import
com.zq.common.vo.ResultVo
;
import
lombok.Data
;
import
java.util.HashMap
;
...
...
@@ -36,15 +34,6 @@ public class ApiResp {
this
.
msg
=
apiCodeEnum
.
msg
();
}
public
static
ApiResp
of
(
ApiForm
form
,
ResultVo
resultVo
)
{
if
(
resultVo
.
isSuccess
())
{
return
new
ApiResp
(
form
).
addData
(
"data"
,
resultVo
.
getData
());
}
else
{
System
.
out
.
println
(
JSON
.
toJSONString
(
resultVo
));
return
new
ApiResp
(
form
).
setCode
(
ApiCodeEnum
.
BUSINESS_ERROR
.
code
()).
setMsg
(
resultVo
.
getErrMsg
());
}
}
public
ApiResp
setFrom
(
ApiForm
from
)
{
if
(
from
!=
null
)
{
this
.
apiNo
=
from
.
getApiNo
();
...
...
api-server/src/main/java/com/zq/api/service/ApiService.java
View file @
243c36fb
package
com
.
zq
.
api
.
service
;
import
cn.hutool.core.exceptions.ExceptionUtil
;
import
com.zq.api.constant.ApiCodeEnum
;
import
com.zq.api.dao.ApiLogDao
;
import
com.zq.api.form.ApiForm
;
...
...
@@ -8,9 +9,11 @@ import com.zq.api.utils.ApiUtils;
import
com.zq.api.utils.ReflectionUtils
;
import
com.zq.common.entity.ApiLog
;
import
com.zq.common.utils.DateUtils
;
import
com.zq.common.vo.ResultVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.HttpClientErrorException
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
...
...
@@ -65,7 +68,10 @@ public class ApiService {
try
{
return
(
ApiResp
)
ReflectionUtils
.
invokeMethod
(
apiLogic
,
form
.
getMethod
(),
new
Class
<?>[]{
ApiForm
.
class
},
new
Object
[]{
form
});
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
// 判断指定异常是否来自或者包含指定异常
if
(
ExceptionUtil
.
isFromOrSuppressedThrowable
(
e
,
HttpClientErrorException
.
Unauthorized
.
class
))
{
return
ApiUtils
.
toApiResp
(
form
,
ResultVo
.
fail
(
401
,
"Unauthorized"
));
}
return
ApiUtils
.
getMethodHandlerError
(
form
);
}
}
...
...
api-server/src/main/java/com/zq/api/service/impl/ApiV100Logic.java
View file @
243c36fb
package
com
.
zq
.
api
.
service
.
impl
;
import
com.zq.api.feign.CmsFeign
;
import
com.zq.api.form.ApiForm
;
import
com.zq.api.form.ApiResp
;
import
com.zq.api.service.IApiLogic
;
import
com.zq.api.utils.ApiUtils
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ApiV100Logic
extends
BaseApiLogic
implements
IApiLogic
{
private
CmsFeign
cmsFeign
=
new
CmsFeign
();
/**
* 测试连接
*
...
...
@@ -14,6 +20,6 @@ public class ApiV100Logic extends BaseApiLogic implements IApiLogic {
*/
@Override
public
ApiResp
test
(
ApiForm
form
)
{
return
new
ApiResp
(
form
);
return
ApiUtils
.
toApiResp
(
form
,
cmsFeign
.
test
(
form
.
getParamsMap
())
);
}
}
api-server/src/main/java/com/zq/api/utils/ApiUtils.java
View file @
243c36fb
...
...
@@ -7,6 +7,7 @@ import com.zq.api.form.ApiResp;
import
com.zq.api.service.IApiLogic
;
import
com.zq.api.service.impl.ApiV100Logic
;
import
com.zq.api.service.impl.ApiV101Logic
;
import
com.zq.common.vo.ResultVo
;
import
org.apache.commons.codec.binary.Base64
;
import
java.io.UnsupportedEncodingException
;
...
...
@@ -104,6 +105,16 @@ public class ApiUtils {
return
new
ApiResp
(
form
,
ApiCodeEnum
.
METHOD_HANDLER_ERROR
);
}
public
static
ApiResp
toApiResp
(
ApiForm
form
,
ResultVo
resultVo
)
{
ApiResp
apiResp
=
new
ApiResp
(
form
);
if
(
resultVo
.
isSuccess
())
{
apiResp
.
addData
(
"data"
,
resultVo
.
getData
());
}
else
{
return
apiResp
.
setCode
(
String
.
valueOf
(
resultVo
.
getErrCode
())).
setMsg
(
resultVo
.
getErrMsg
());
}
return
apiResp
;
}
/**
* 解码
* <p>
...
...
cms-server/src/main/java/com/zq/cms/config/JwtAuthenticationEntryPoint.java
View file @
243c36fb
...
...
@@ -34,6 +34,6 @@ public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
HttpServletResponse
response
,
AuthenticationException
authException
)
throws
IOException
{
// 当用户尝试访问安全的REST资源而不提供任何凭据时,将调用此方法发送401 响应
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
authException
==
null
?
"Unauthorized"
:
authException
.
getMessage
());
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
authException
==
null
?
"Unauthorized"
:
authException
.
getMessage
());
}
}
common-utils/src/main/java/com/zq/common/utils/AssertUtils.java
View file @
243c36fb
...
...
@@ -29,7 +29,7 @@ public final class AssertUtils {
* @param errMsg 错误信息
*/
public
static
void
isImgExt
(
String
ext
,
String
errMsg
)
{
isImgExt
(
ext
,
0
,
errMsg
);
isImgExt
(
ext
,
40
0
,
errMsg
);
}
/**
...
...
@@ -54,7 +54,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
notTrue
(
boolean
expression
,
String
message
)
throws
BusinessException
{
notTrue
(
expression
,
0
,
message
);
notTrue
(
expression
,
40
0
,
message
);
}
/**
...
...
@@ -79,7 +79,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
isTrue
(
boolean
expression
,
String
message
)
throws
BusinessException
{
isTrue
(
expression
,
0
,
message
);
isTrue
(
expression
,
40
0
,
message
);
}
/**
...
...
@@ -114,7 +114,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
notNull
(
Object
object
,
String
message
)
throws
BusinessException
{
notNull
(
object
,
0
,
message
);
notNull
(
object
,
40
0
,
message
);
}
/**
...
...
@@ -138,7 +138,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
hasText
(
String
text
)
throws
BusinessException
{
hasText
(
text
,
0
,
"参数不能为空字符串"
);
hasText
(
text
,
40
0
,
"参数不能为空字符串"
);
}
/**
...
...
@@ -149,7 +149,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
hasText
(
String
text
,
String
message
)
throws
BusinessException
{
hasText
(
text
,
0
,
message
);
hasText
(
text
,
40
0
,
message
);
}
/**
...
...
@@ -175,7 +175,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
<
T
>
void
notEmpty
(
T
[]
array
,
String
message
)
throws
BusinessException
{
notEmpty
(
array
,
0
,
message
);
notEmpty
(
array
,
40
0
,
message
);
}
/**
...
...
@@ -202,7 +202,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
<
T
>
void
noNullElements
(
T
[]
array
,
String
message
)
throws
BusinessException
{
noNullElements
(
array
,
0
,
message
);
noNullElements
(
array
,
40
0
,
message
);
}
/**
...
...
@@ -232,7 +232,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
notEmpty
(
Collection
<?>
collection
,
String
message
)
throws
BusinessException
{
notEmpty
(
collection
,
0
,
message
);
notEmpty
(
collection
,
40
0
,
message
);
}
/**
...
...
@@ -257,7 +257,7 @@ public final class AssertUtils {
* @throws BusinessException
*/
public
static
void
notEmpty
(
Map
<?,
?>
map
,
String
message
)
throws
BusinessException
{
notEmpty
(
map
,
0
,
message
);
notEmpty
(
map
,
40
0
,
message
);
}
/**
...
...
config-server/src/main/resources/properties/config-dev.yml
View file @
243c36fb
...
...
@@ -13,7 +13,7 @@ api.name: API-SERVER
cms.port
:
9700
cms.name
:
CMS-SERVER
gateway.port
:
988
8
gateway.port
:
988
9
gateway.name
:
GATEWAY-SERVER
redis.url
:
127.0.0.1
...
...
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