Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-bi
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
林锐标
slm-bi
Commits
9f89f026
Commit
9f89f026
authored
Apr 26, 2021
by
linruibiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口编写
parent
b0407853
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
0 deletions
+63
-0
BaseRestController.java
...java/com/syc/slm/slmbi/controller/BaseRestController.java
+2
-0
BusinessConfigController.java
...om/syc/slm/slmbi/controller/BusinessConfigController.java
+12
-0
BusinessConfigService.java
...java/com/syc/slm/slmbi/service/BusinessConfigService.java
+15
-0
BusinessConfigServiceImpl.java
...syc/slm/slmbi/service/impl/BusinessConfigServiceImpl.java
+34
-0
No files found.
src/main/java/com/syc/slm/slmbi/controller/BaseRestController.java
View file @
9f89f026
...
...
@@ -58,6 +58,8 @@ public class BaseRestController {
protected
String
variableHistoryDataList
;
@Value
(
"${dc_client.interfaces.variableRealTimeDataList}"
)
protected
String
variableRealTimeDataList
;
@Value
(
"${dc_client.interfaces.filedValue}"
)
protected
String
filedValue
;
...
...
src/main/java/com/syc/slm/slmbi/controller/BusinessConfigController.java
View file @
9f89f026
package
com
.
syc
.
slm
.
slmbi
.
controller
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.syc.slm.common.core.util.R
;
import
com.syc.slm.slmbi.dto.BusinessDTO
;
import
com.syc.slm.slmbi.entity.CurrentUser
;
...
...
@@ -57,4 +58,15 @@ public class BusinessConfigController extends BaseRestController{
return
businessConfigService
.
getBusinessData
(
dto
,
dcClientHost
+
businessFiledData
,
currentUser
);
});
}
@GetMapping
(
"/filed-value/{tableName}/{filed}"
)
@ApiOperation
(
"根据字段以及表名查询对应的字段"
)
@ApiImplicitParam
(
name
=
"appId"
,
value
=
"租户id"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
public
R
<
IPage
<
String
>>
filedValue
(
HttpServletRequest
request
,
@PathVariable
String
appId
,
@PathVariable
String
tableName
,
@PathVariable
String
filed
,
@RequestParam
(
value
=
"current"
,
defaultValue
=
"1"
)
Integer
current
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"100"
)
Integer
size
,
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
)
{
return
call
(()
->
{
CurrentUser
currentUser
=
getCurrentUser
(
request
);
return
businessConfigService
.
filedValue
(
currentUser
,
tableName
,
filed
,
current
,
size
,
name
,
dcClientHost
+
filedValue
);
});
}
}
src/main/java/com/syc/slm/slmbi/service/BusinessConfigService.java
View file @
9f89f026
package
com
.
syc
.
slm
.
slmbi
.
service
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.syc.slm.slmbi.dto.BusinessDTO
;
import
com.syc.slm.slmbi.entity.BusinessConfig
;
...
...
@@ -37,4 +38,18 @@ public interface BusinessConfigService extends IService<BusinessConfig> {
* @return
*/
List
<
Map
<
String
,
Object
>>
getBusinessData
(
BusinessDTO
dto
,
String
uri
,
CurrentUser
user
);
/**
* 根据字段以及表名查询对应的字段
* @param currentUser
* @param tableName
* @param filed
* @param current
* @param size
* @param name
* @param uri
* @return
*/
IPage
<
String
>
filedValue
(
CurrentUser
currentUser
,
String
tableName
,
String
filed
,
Integer
current
,
Integer
size
,
String
name
,
String
uri
);
}
src/main/java/com/syc/slm/slmbi/service/impl/BusinessConfigServiceImpl.java
View file @
9f89f026
package
com
.
syc
.
slm
.
slmbi
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.ObjectUtils
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
...
...
@@ -22,6 +24,7 @@ import com.syc.slm.slmbi.vo.BusinessConfigVo;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.net.URLDecoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
...
...
@@ -110,4 +113,35 @@ public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper,
R
<
List
<
Map
<
String
,
Object
>>>
result
=
RestTemplateUtils
.
post
(
uri
,
heads
,
dto
,
new
TypeToken
<
R
<
List
<
Map
<
String
,
Object
>>>>()
{}.
getType
(),
uriVariables
);
return
result
.
detach
();
}
@Override
@Transactional
(
readOnly
=
true
)
public
IPage
<
String
>
filedValue
(
CurrentUser
currentUser
,
String
tableName
,
String
filed
,
Integer
current
,
Integer
size
,
String
name
,
String
uri
)
{
if
(
StringUtils
.
isBlank
(
tableName
)){
throw
new
SysException
(
"表名必填"
);
}
if
(
StringUtils
.
isBlank
(
filed
)){
throw
new
SysException
(
"对应检索字段必填"
);
}
Map
<
String
,
String
>
heads
=
Maps
.
newHashMap
();
heads
.
put
(
"X-Token"
,
currentUser
.
getToken
());
Map
<
String
,
Object
>
uriVariables
=
Maps
.
newHashMap
();
uriVariables
.
put
(
"appId"
,
currentUser
.
getAppId
());
uriVariables
.
put
(
"filed"
,
filed
);
uriVariables
.
put
(
"tableName"
,
tableName
);
uriVariables
.
put
(
"current"
,
current
);
uriVariables
.
put
(
"size"
,
size
);
uriVariables
.
put
(
"name"
,
name
);
IPage
<
String
>
page
=
new
Page
<>(
current
,
size
);
R
<
Map
<
String
,
Object
>>
result
=
RestTemplateUtils
.
get
(
uri
,
heads
,
new
TypeToken
<
R
<
Map
<
String
,
Object
>>>()
{}.
getType
(),
uriVariables
);
Map
<
String
,
Object
>
resultMaps
=
result
.
detach
();
if
(
CollectionUtils
.
isNotEmpty
(
resultMaps
)){
page
.
setTotal
(
new
BigDecimal
(
resultMaps
.
get
(
"total"
)+
""
).
longValue
());
List
<
String
>
records
=
SlmConstants
.
gson
.
fromJson
(
SlmConstants
.
gson
.
toJson
(
resultMaps
.
get
(
"records"
)),
new
TypeToken
<
List
<
String
>>()
{}.
getType
());
page
.
setRecords
(
records
);
}
else
{
page
.
setTotal
(
0L
);
}
return
page
;
}
}
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