Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
9380abc7
Commit
9380abc7
authored
Dec 11, 2025
by
wujipeng
Browse files
接口扫描
parent
9c51739b
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/CustomerProjectController.java
View file @
9380abc7
package
com.ruzhoukj.sms.controller
;
package
com.ruzhoukj.sms.controller
;
import
com.platform.model.resp.Result
;
import
com.platform.model.resp.Result
;
import
com.ruzhoukj.sms.model.vo.CustomerProjectVO
;
import
com.ruzhoukj.sms.service.CustomerProjectService
;
import
com.ruzhoukj.sms.service.CustomerProjectService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* @author : wujipeng
* @author : wujipeng
...
@@ -25,7 +27,7 @@ public class CustomerProjectController {
...
@@ -25,7 +27,7 @@ public class CustomerProjectController {
@ApiOperation
(
value
=
"经管"
)
@ApiOperation
(
value
=
"经管"
)
@RequestMapping
(
"/jg"
)
@RequestMapping
(
"/jg"
)
public
Result
jg
()
{
public
Result
<
List
<
CustomerProjectVO
>>
jg
()
{
return
Result
.
data
(
customerProjectService
.
jg
());
return
Result
.
data
(
customerProjectService
.
jg
());
}
}
...
...
src/main/java/com/ruzhoukj/sms/model/vo/CustomerProjectVO.java
0 → 100644
View file @
9380abc7
package
com.ruzhoukj.sms.model.vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.checkerframework.checker.lock.qual.NewObject
;
/**
* @author : wujipeng
* @date : 2025/11/4 15:59
* @Version: 1.0
* @Desc : 描述信息
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
CustomerProjectVO
{
private
String
name
;
private
String
type
;
private
String
url
;
private
String
result
;
}
src/main/java/com/ruzhoukj/sms/service/CustomerProjectService.java
View file @
9380abc7
...
@@ -2,6 +2,9 @@ package com.ruzhoukj.sms.service;
...
@@ -2,6 +2,9 @@ package com.ruzhoukj.sms.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.ruzhoukj.sms.entity.CustomerProjectEntity
;
import
com.ruzhoukj.sms.entity.CustomerProjectEntity
;
import
com.ruzhoukj.sms.model.vo.CustomerProjectVO
;
import
java.util.List
;
/**
/**
* @author : wujipeng
* @author : wujipeng
...
@@ -10,5 +13,5 @@ import com.ruzhoukj.sms.entity.CustomerProjectEntity;
...
@@ -10,5 +13,5 @@ import com.ruzhoukj.sms.entity.CustomerProjectEntity;
* @Desc : 描述信息
* @Desc : 描述信息
*/
*/
public
interface
CustomerProjectService
extends
IService
<
CustomerProjectEntity
>
{
public
interface
CustomerProjectService
extends
IService
<
CustomerProjectEntity
>
{
Ob
ject
jg
();
List
<
CustomerPro
ject
VO
>
jg
();
}
}
src/main/java/com/ruzhoukj/sms/service/impl/CustomerProjectServiceImpl.java
View file @
9380abc7
...
@@ -4,10 +4,9 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,10 +4,9 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.google.common.collect.Maps
;
import
com.platform.exception.BusinessException
;
import
com.ruzhoukj.sms.dao.CustomerProjectMapper
;
import
com.ruzhoukj.sms.dao.CustomerProjectMapper
;
import
com.ruzhoukj.sms.entity.CustomerProjectEntity
;
import
com.ruzhoukj.sms.entity.CustomerProjectEntity
;
import
com.ruzhoukj.sms.model.vo.CustomerProjectVO
;
import
com.ruzhoukj.sms.service.CustomerProjectService
;
import
com.ruzhoukj.sms.service.CustomerProjectService
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpGet
;
...
@@ -18,7 +17,7 @@ import org.apache.http.impl.client.HttpClients;
...
@@ -18,7 +17,7 @@ import org.apache.http.impl.client.HttpClients;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.
LinkedHashMap
;
import
java.util.
ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -30,21 +29,21 @@ import java.util.List;
...
@@ -30,21 +29,21 @@ import java.util.List;
@Service
@Service
public
class
CustomerProjectServiceImpl
extends
ServiceImpl
<
CustomerProjectMapper
,
CustomerProjectEntity
>
implements
CustomerProjectService
{
public
class
CustomerProjectServiceImpl
extends
ServiceImpl
<
CustomerProjectMapper
,
CustomerProjectEntity
>
implements
CustomerProjectService
{
@Override
@Override
public
Ob
ject
jg
()
{
public
List
<
CustomerPro
ject
VO
>
jg
()
{
Li
nkedHashMap
<
String
,
String
>
result
=
Maps
.
newLinkedHashMap
();
Li
st
<
CustomerProjectVO
>
result
=
new
ArrayList
<>
();
//登录获取token
//登录获取token
String
token
=
null
;
String
token
;
try
{
try
{
String
loginResponse
=
postWithApacheHttpClient
(
"http://1
9
2.
168.10.3:71
/api/auth/login"
,
String
loginResponse
=
postWithApacheHttpClient
(
"http://1
7
2.
24.33.190
/api/auth/login"
,
"{\"username\":\"wsadmin\",\"password\":\"cd2350c714eb2cf9b4eacde8d4834823\"}"
,
null
);
"{\"username\":\"wsadmin\",\"password\":\"cd2350c714eb2cf9b4eacde8d4834823\"}"
,
null
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
loginResponse
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
loginResponse
);
int
loginCode
=
jsonObject
.
getInteger
(
"code"
);
int
loginCode
=
jsonObject
.
getInteger
(
"code"
);
if
(
loginCode
==
200
)
{
if
(
loginCode
==
200
)
{
JSONObject
jsonObject1
=
jsonObject
.
getJSONObject
(
"data"
);
JSONObject
jsonObject1
=
jsonObject
.
getJSONObject
(
"data"
);
token
=
jsonObject1
.
getString
(
"access_token"
);
token
=
jsonObject1
.
getString
(
"access_token"
);
result
.
put
(
"登录接口"
,
"成功"
);
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"成功"
).
url
(
"http://172.24.33.190/api/auth/login"
).
build
()
);
}
else
{
}
else
{
result
.
put
(
"登录接口"
,
"失败"
);
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"失败"
).
url
(
"http://172.24.33.190/api/auth/login"
).
build
()
);
return
result
;
return
result
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -54,33 +53,35 @@ public class CustomerProjectServiceImpl extends ServiceImpl<CustomerProjectMappe
...
@@ -54,33 +53,35 @@ public class CustomerProjectServiceImpl extends ServiceImpl<CustomerProjectMappe
List
<
CustomerProjectEntity
>
customerProjectList
=
list
(
new
LambdaQueryWrapper
<
CustomerProjectEntity
>().
eq
(
CustomerProjectEntity:
:
getProject
,
"经管"
));
List
<
CustomerProjectEntity
>
customerProjectList
=
list
(
new
LambdaQueryWrapper
<
CustomerProjectEntity
>().
eq
(
CustomerProjectEntity:
:
getProject
,
"经管"
));
//执行接口调用
//执行接口调用
for
(
CustomerProjectEntity
customerProjectEntity
:
customerProjectList
)
{
for
(
CustomerProjectEntity
customerProjectEntity
:
customerProjectList
)
{
String
response
=
null
;
//判断请求方式
//判断请求方式
if
(
"POST"
.
equals
(
customerProjectEntity
.
getType
()))
{
try
{
try
{
if
(
"POST"
.
equals
(
customerProjectEntity
.
getType
()))
{
String
response
=
postWithApacheHttpClient
(
customerProjectEntity
.
getUrl
(),
customerProjectEntity
.
getParam
(),
token
);
response
=
postWithApacheHttpClient
(
customerProjectEntity
.
getUrl
(),
customerProjectEntity
.
getParam
(),
token
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
);
}
else
if
(
"GET"
.
equals
(
customerProjectEntity
.
getType
()))
{
int
code
=
jsonObject
.
getInteger
(
"code"
);
response
=
getWithApacheHttpClient
(
customerProjectEntity
.
getUrl
(),
token
);
if
(
code
==
200
)
{
result
.
put
(
customerProjectEntity
.
getName
(),
"成功"
);
}
else
{
result
.
put
(
customerProjectEntity
.
getName
(),
"失败"
);
}
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"调用接口失败"
);
}
}
else
if
(
"GET"
.
equals
(
customerProjectEntity
.
getType
()))
{
try
{
String
response
=
getWithApacheHttpClient
(
customerProjectEntity
.
getUrl
(),
token
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
);
int
code
=
jsonObject
.
getInteger
(
"code"
);
if
(
code
==
200
)
{
result
.
put
(
customerProjectEntity
.
getName
(),
"成功"
);
}
else
{
result
.
put
(
customerProjectEntity
.
getName
(),
"失败"
);
}
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
"调用接口失败"
);
}
}
}
catch
(
Exception
e
)
{
result
.
add
(
CustomerProjectVO
.
builder
()
.
name
(
customerProjectEntity
.
getName
())
.
type
(
customerProjectEntity
.
getType
())
.
result
(
"失败"
)
.
url
(
customerProjectEntity
.
getUrl
()).
build
());
}
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
);
int
code
=
jsonObject
.
getInteger
(
"code"
);
if
(
code
==
200
)
{
result
.
add
(
CustomerProjectVO
.
builder
()
.
name
(
customerProjectEntity
.
getName
())
.
type
(
customerProjectEntity
.
getType
())
.
result
(
"成功"
)
.
url
(
customerProjectEntity
.
getUrl
()).
build
());
}
else
{
result
.
add
(
CustomerProjectVO
.
builder
()
.
name
(
customerProjectEntity
.
getName
())
.
type
(
customerProjectEntity
.
getType
())
.
result
(
"失败"
)
.
url
(
customerProjectEntity
.
getUrl
()).
build
());
}
}
}
}
//结果反馈
//结果反馈
...
...
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