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
55efc423
Commit
55efc423
authored
Dec 19, 2025
by
wujipeng
Browse files
接口扫描
parent
41c818b0
Changes
5
Show whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/CustomerProjectController.java
View file @
55efc423
...
@@ -32,4 +32,9 @@ public class CustomerProjectController {
...
@@ -32,4 +32,9 @@ public class CustomerProjectController {
return
Result
.
data
(
customerProjectService
.
jg
());
return
Result
.
data
(
customerProjectService
.
jg
());
}
}
@ApiOperation
(
value
=
"生产"
)
@GetMapping
(
"/sc"
)
public
Result
<
List
<
CustomerProjectVO
>>
sc
()
{
return
Result
.
data
(
customerProjectService
.
sc
());
}
}
}
src/main/java/com/ruzhoukj/sms/dao/CustomerProjectMapper.java
View file @
55efc423
...
@@ -2,8 +2,11 @@ package com.ruzhoukj.sms.dao;
...
@@ -2,8 +2,11 @@ package com.ruzhoukj.sms.dao;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.ruzhoukj.sms.entity.CustomerProjectEntity
;
import
com.ruzhoukj.sms.entity.CustomerProjectEntity
;
import
com.ruzhoukj.sms.model.vo.CustomerProjectVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
/**
* @author : wujipeng
* @author : wujipeng
* @date : 2025/11/4 13:49
* @date : 2025/11/4 13:49
...
@@ -12,4 +15,9 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -12,4 +15,9 @@ import org.apache.ibatis.annotations.Mapper;
*/
*/
@Mapper
@Mapper
public
interface
CustomerProjectMapper
extends
BaseMapper
<
CustomerProjectEntity
>
{
public
interface
CustomerProjectMapper
extends
BaseMapper
<
CustomerProjectEntity
>
{
List
<
CustomerProjectVO
>
jg
();
List
<
CustomerProjectVO
>
sc
();
}
}
src/main/java/com/ruzhoukj/sms/service/CustomerProjectService.java
View file @
55efc423
...
@@ -14,4 +14,5 @@ import java.util.List;
...
@@ -14,4 +14,5 @@ import java.util.List;
*/
*/
public
interface
CustomerProjectService
extends
IService
<
CustomerProjectEntity
>
{
public
interface
CustomerProjectService
extends
IService
<
CustomerProjectEntity
>
{
List
<
CustomerProjectVO
>
jg
();
List
<
CustomerProjectVO
>
jg
();
List
<
CustomerProjectVO
>
sc
();
}
}
src/main/java/com/ruzhoukj/sms/service/impl/CustomerProjectServiceImpl.java
View file @
55efc423
...
@@ -16,6 +16,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
...
@@ -16,6 +16,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import
org.apache.http.impl.client.HttpClients
;
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
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -34,16 +35,20 @@ public class CustomerProjectServiceImpl extends ServiceImpl<CustomerProjectMappe
...
@@ -34,16 +35,20 @@ public class CustomerProjectServiceImpl extends ServiceImpl<CustomerProjectMappe
//登录获取token
//登录获取token
String
token
;
String
token
;
try
{
try
{
String
loginResponse
=
postWithApacheHttpClient
(
"http://172.24.33.190/api/auth/login"
,
// String loginResponse = postWithApacheHttpClient("http://172.24.33.190/api/auth/login",
"{\"username\":\"wsadmin\",\"password\":\"cced9dbff1f6b878702a7c9bc60dd125\"}"
,
null
);
// "{\"username\":\"wsadmin\",\"password\":\"cced9dbff1f6b878702a7c9bc60dd125\"}", null);
String
loginResponse
=
postWithApacheHttpClient
(
"http://192.168.10.3:71/api/auth/login"
,
"{\"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
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"成功"
).
url
(
"http://172.24.33.190/api/auth/login"
).
build
());
// result.add(CustomerProjectVO.builder().name("登录接口").type("POST").result("成功").url("http://172.24.33.190/api/auth/login").build());
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"成功"
).
url
(
"http://192.168.10.3:71/api/auth/login"
).
build
());
}
else
{
}
else
{
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"失败"
).
url
(
"http://172.24.33.190/api/auth/login"
).
build
());
// result.add(CustomerProjectVO.builder().name("登录接口").type("POST").result("失败").url("http://172.24.33.190/api/auth/login").build());
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"失败"
).
url
(
"http://192.168.10.3/api/auth/login"
).
build
());
return
result
;
return
result
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -88,6 +93,86 @@ public class CustomerProjectServiceImpl extends ServiceImpl<CustomerProjectMappe
...
@@ -88,6 +93,86 @@ public class CustomerProjectServiceImpl extends ServiceImpl<CustomerProjectMappe
return
result
;
return
result
;
}
}
@Override
public
List
<
CustomerProjectVO
>
sc
()
{
List
<
CustomerProjectVO
>
result
=
new
ArrayList
<>();
//登录获取token
String
token
;
try
{
// String loginResponse = postWithApacheHttpClient("http://172.24.33.190/api/auth/login",
// "{\"username\":\"wsadmin\",\"password\":\"cced9dbff1f6b878702a7c9bc60dd125\"}", null);
String
loginResponse
=
postWithApacheHttpClient
(
"http://192.168.10.3:76/api/business/sys/user/userLogin"
,
"{\"userName\":\"admin\",\"password\":\"Ruzhoukj@2025\"}"
,
null
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
loginResponse
);
int
loginCode
=
jsonObject
.
getInteger
(
"code"
);
if
(
loginCode
==
200
)
{
JSONObject
jsonObject1
=
jsonObject
.
getJSONObject
(
"data"
);
token
=
jsonObject1
.
getString
(
"token"
);
// result.add(CustomerProjectVO.builder().name("登录接口").type("POST").result("成功").url("http://172.24.33.190/api/auth/login").build());
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"成功"
).
url
(
"http://192.168.10.3:76/api/business/sys/user/userLogin"
).
build
());
}
else
{
// result.add(CustomerProjectVO.builder().name("登录接口").type("POST").result("失败").url("http://172.24.33.190/api/auth/login").build());
result
.
add
(
CustomerProjectVO
.
builder
().
name
(
"登录接口"
).
type
(
"POST"
).
result
(
"失败"
).
url
(
"http://192.168.10.3:76/api/business/sys/user/userLogin"
).
build
());
return
result
;
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
//查询接口列表
List
<
CustomerProjectEntity
>
customerProjectList
=
list
(
new
LambdaQueryWrapper
<
CustomerProjectEntity
>().
eq
(
CustomerProjectEntity:
:
getProject
,
"生产"
));
//执行接口调用
for
(
CustomerProjectEntity
customerProjectEntity
:
customerProjectList
)
{
String
response
=
null
;
//判断请求方式
try
{
if
(
"POST"
.
equals
(
customerProjectEntity
.
getType
()))
{
response
=
postWithApacheHttpClient
(
customerProjectEntity
.
getUrl
(),
customerProjectEntity
.
getParam
(),
"Bearer "
+
token
);
}
else
if
(
"GET"
.
equals
(
customerProjectEntity
.
getType
()))
{
response
=
getWithApacheHttpClient
(
customerProjectEntity
.
getUrl
(),
"Bearer "
+
token
);
}
}
catch
(
Exception
e
)
{
result
.
add
(
CustomerProjectVO
.
builder
()
.
name
(
customerProjectEntity
.
getName
())
.
type
(
customerProjectEntity
.
getType
())
.
result
(
"失败"
)
.
url
(
customerProjectEntity
.
getUrl
()).
build
());
}
if
(
ObjectUtils
.
isEmpty
(
response
))
{
result
.
add
(
CustomerProjectVO
.
builder
()
.
name
(
customerProjectEntity
.
getName
())
.
type
(
customerProjectEntity
.
getType
())
.
result
(
"响应体为空"
)
.
url
(
customerProjectEntity
.
getUrl
()).
build
());
continue
;
}
try
{
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
());
}
}
catch
(
Exception
e
)
{
result
.
add
(
CustomerProjectVO
.
builder
()
.
name
(
customerProjectEntity
.
getName
())
.
type
(
customerProjectEntity
.
getType
())
.
result
(
"失败"
)
.
url
(
customerProjectEntity
.
getUrl
()).
build
());
}
}
//结果反馈
return
result
;
}
/**
/**
* 使用 Apache HttpClient 发送 GET 请求
* 使用 Apache HttpClient 发送 GET 请求
*/
*/
...
...
src/main/resources/com/ruzhoukj/sms/dao/CustomerProjectMapper.xml
View file @
55efc423
...
@@ -3,4 +3,32 @@
...
@@ -3,4 +3,32 @@
<mapper
namespace=
"com.ruzhoukj.sms.dao.CustomerProjectMapper"
>
<mapper
namespace=
"com.ruzhoukj.sms.dao.CustomerProjectMapper"
>
<select
id=
"jg"
resultType=
"com.ruzhoukj.sms.model.vo.CustomerProjectVO"
>
select
id,
project,
name,
url,
type,
param
from
customer_project
where
project = '经管'
limit 10;
</select>
<select
id=
"sc"
resultType=
"com.ruzhoukj.sms.model.vo.CustomerProjectVO"
>
select
id,
project,
name,
url,
type,
param
from
customer_project
where
project = '生产'
limit 10;
</select>
</mapper>
</mapper>
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