Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
modeng-service
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邢保振
modeng-service
Commits
09df89f4
Commit
09df89f4
authored
Dec 14, 2023
by
zhaoqingwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hotfix:#投放管理切换数据源
parent
0b8e2219
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
27 deletions
+159
-27
pom.xml
pom.xml
+8
-0
AdsUserBusiness.java
...java/com/ruoyi/adsdesk/business/user/AdsUserBusiness.java
+91
-12
AdsUserController.java
.../com/ruoyi/adsdesk/controller/user/AdsUserController.java
+1
-1
UserListParam.java
src/main/java/com/ruoyi/adsdesk/param/UserListParam.java
+3
-14
AdsUserVo.java
src/main/java/com/ruoyi/adsdesk/vo/AdsUserVo.java
+4
-0
ExpandFieldsVo.java
src/main/java/com/ruoyi/adsdesk/vo/ExpandFieldsVo.java
+18
-0
UserResponseDto.java
src/main/java/com/ruoyi/adsdesk/vo/UserResponseDto.java
+20
-0
StrConstants.java
src/main/java/com/ruoyi/common/constant/StrConstants.java
+14
-0
No files found.
pom.xml
View file @
09df89f4
...
...
@@ -37,6 +37,7 @@
<oshi.version>
6.4.8
</oshi.version>
<velocity.version>
2.3
</velocity.version>
<mybatis-plus.version>
3.5.2
</mybatis-plus.version>
<hutool.version>
5.7.22
</hutool.version>
</properties>
<dependencies>
...
...
@@ -248,6 +249,13 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
${mybatis-plus.version}
</version>
</dependency>
<!-- hutool 工具类 -->
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
${hutool.version}
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/ruoyi/adsdesk/business/user/AdsUserBusiness.java
View file @
09df89f4
package
com
.
ruoyi
.
adsdesk
.
business
.
user
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson2.JSON
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.ruoyi.adsdesk.domain.AdsUser
;
import
com.ruoyi.adsdesk.param.UserListParam
;
import
com.ruoyi.adsdesk.vo.AdsUserVo
;
import
com.ruoyi.adsdesk.vo.ExpandFieldsVo
;
import
com.ruoyi.adsdesk.vo.UserResponseDto
;
import
com.ruoyi.common.constant.StrConstants
;
import
org.apache.commons.compress.utils.Lists
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
org.springframework.web.client.RestTemplate
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.URLUtil
;
import
javax.annotation.Resource
;
import
java.net.URI
;
import
java.util.List
;
...
...
@@ -18,21 +34,84 @@ import java.util.List;
@Service
public
class
AdsUserBusiness
{
public
IPage
<
AdsUser
>
list
(
UserListParam
param
)
{
AdsUser
u1
=
new
AdsUser
();
u1
.
setId
(
1L
);
u1
.
setCustomerId
(
1L
);
u1
.
setName
(
"zqw"
);
u1
.
setRole
(
"MANAGER"
);
u1
.
setEmail
(
"zhaoqingwei@reyun.com"
);
public
IPage
<
AdsUserVo
>
list
(
UserListParam
param
)
{
UserResponseDto
responseDto
=
getUserPageList
(
param
.
getPageSize
(),
param
.
getPageNum
(),
param
);
List
<
AdsUser
>
list
=
Lists
.
newArrayList
();
list
.
add
(
u1
);
if
(
null
==
responseDto
){
return
new
Page
<>(
param
.
getPageNum
(),
param
.
getPageSize
());
}
Page
result
=
new
Page
<>(
1
,
10
,
1
);
List
<
AdsUserVo
>
list
=
responseDto
.
getRecords
();
Integer
total
=
responseDto
.
getTotal
();
Page
result
=
new
Page
<>(
param
.
getPageNum
(),
param
.
getPageSize
(),
total
);
result
.
setRecords
(
list
);
return
result
;
}
private
UserResponseDto
getUserPageList
(
int
size
,
int
page
,
UserListParam
userListParam
){
RestTemplate
restTemplate
=
new
RestTemplate
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"secret"
,
"20230000"
);
param
.
put
(
"current"
,
page
);
param
.
put
(
"size"
,
size
);
param
.
put
(
"userId"
,
userListParam
.
getUserId
());
param
.
put
(
"userName"
,
userListParam
.
getUserName
());
param
.
put
(
"userNick"
,
userListParam
.
getUserNick
());
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
<?>
requestEntity
=
new
HttpEntity
<>(
param
,
headers
);
String
url
=
"http://test-api2.adsdesk.cn/adsdesk/api/open_api/system/user/list"
;
String
responseStr
=
restTemplate
.
exchange
(
URI
.
create
(
url
),
HttpMethod
.
POST
,
requestEntity
,
String
.
class
).
getBody
();
responseStr
=
clearResponseStr
(
responseStr
);
if
(
Strings
.
isEmpty
(
responseStr
)){
return
null
;
}
UserResponseDto
dto
=
new
UserResponseDto
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseStr
);
int
code
=
(
int
)
jsonObject
.
get
(
"code"
);
JSONObject
data
=
(
JSONObject
)
jsonObject
.
get
(
"data"
);
List
<
AdsUserVo
>
records
=
(
List
<
AdsUserVo
>)
data
.
get
(
"records"
);
List
<
ExpandFieldsVo
>
expandFields
=
(
List
<
ExpandFieldsVo
>)
data
.
get
(
"expandFields"
);
Integer
current
=
(
Integer
)
data
.
get
(
"current"
);
Integer
pages
=
(
Integer
)
data
.
get
(
"pages"
);
Integer
pageSize
=
(
Integer
)
data
.
get
(
"size"
);
Integer
total
=
(
Integer
)
data
.
get
(
"total"
);
dto
.
setRecords
(
records
);
dto
.
setExpandFields
(
expandFields
);
dto
.
setCurrent
(
current
);
dto
.
setTotal
(
total
);
return
dto
;
}
private
String
clearResponseStr
(
String
responseStr
)
{
if
(
ObjectUtil
.
isNull
(
responseStr
))
{
return
null
;
}
// 双引号包括的字符串
if
(
StrUtil
.
startWith
(
responseStr
,
StrConstants
.
DOUBLE_QUOTES
)
&&
StrUtil
.
endWith
(
responseStr
,
StrConstants
.
DOUBLE_QUOTES
))
{
int
placeholderCount
=
StrUtil
.
count
(
responseStr
,
"\\\""
);
// 类似于"{\"en\":\"zhangsan\",\"cn\":\"张三\"}"转义之后的json字符串
if
(
placeholderCount
>
0
&&
placeholderCount
%
2
==
0
)
{
return
StrUtil
.
replace
(
StrUtil
.
removeSuffix
(
StrUtil
.
removePrefix
(
responseStr
,
StrConstants
.
DOUBLE_QUOTES
),
StrConstants
.
DOUBLE_QUOTES
),
"\\\""
,
StrConstants
.
DOUBLE_QUOTES
);
}
}
return
responseStr
;
}
}
src/main/java/com/ruoyi/adsdesk/controller/user/AdsUserController.java
View file @
09df89f4
...
...
@@ -29,7 +29,7 @@ public class AdsUserController{
private
AdsUserBusiness
userBusiness
;
@PostMapping
(
"/list"
)
public
IPage
<
AdsUser
>
list
(
@RequestBody
UserListParam
param
)
{
public
IPage
<
AdsUser
Vo
>
list
(
@RequestBody
UserListParam
param
)
{
return
userBusiness
.
list
(
param
);
}
}
src/main/java/com/ruoyi/adsdesk/param/UserListParam.java
View file @
09df89f4
...
...
@@ -14,21 +14,10 @@ import java.util.List;
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
UserListParam
extends
AdsListBaseParam
{
private
String
ids
;
private
String
userId
;
private
Long
customerId
;
private
String
userName
;
private
List
<
Long
>
customerIds
;
private
String
userNick
;
private
String
customerName
;
private
String
email
;
private
String
name
;
private
String
role
;
private
String
beginCreateTime
;
private
String
endCreateTime
;
}
src/main/java/com/ruoyi/adsdesk/vo/AdsUserVo.java
View file @
09df89f4
...
...
@@ -15,6 +15,10 @@ public class AdsUserVo extends AdsBaseEntity {
*/
private
Long
customerId
;
private
String
userName
;
private
String
userNick
;
private
Integer
userId
;
/**
* email
*/
...
...
src/main/java/com/ruoyi/adsdesk/vo/ExpandFieldsVo.java
0 → 100644
View file @
09df89f4
package
com
.
ruoyi
.
adsdesk
.
vo
;
import
lombok.Data
;
/**
* @author :zhaoqingwei
* @date :Created in 2023/12/14 17:13
* @description:${description}
*/
@Data
public
class
ExpandFieldsVo
{
String
field
;
String
name
;
}
\ No newline at end of file
src/main/java/com/ruoyi/adsdesk/vo/UserResponseDto.java
0 → 100644
View file @
09df89f4
package
com
.
ruoyi
.
adsdesk
.
vo
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author :zhaoqingwei
* @date :Created in 2023/12/14 17:19
* @description:${description}
*/
@Data
public
class
UserResponseDto
{
Integer
current
;
List
<
ExpandFieldsVo
>
expandFields
;
List
<
AdsUserVo
>
records
;
Integer
size
;
Integer
total
;
}
\ No newline at end of file
src/main/java/com/ruoyi/common/constant/StrConstants.java
0 → 100644
View file @
09df89f4
package
com
.
ruoyi
.
common
.
constant
;
import
cn.hutool.core.text.StrPool
;
/**
* 一些字符串常量
* @author Xingbz
* 2023/9/1
*/
public
interface
StrConstants
extends
StrPool
{
String
DOUBLE_QUOTES
=
"\""
;
}
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