Authored by 王涛

请求接口参数优化;

@@ -132,6 +132,12 @@ @@ -132,6 +132,12 @@
132 <artifactId>poi-ooxml-schemas</artifactId> 132 <artifactId>poi-ooxml-schemas</artifactId>
133 <version>4.1.2</version> 133 <version>4.1.2</version>
134 </dependency> 134 </dependency>
  135 +
  136 + <dependency>
  137 + <groupId>cn.hutool</groupId>
  138 + <artifactId>hutool-all</artifactId>
  139 + <version>5.7.1</version>
  140 + </dependency>
135 </dependencies> 141 </dependencies>
136 142
137 <developers> 143 <developers>
1 1
2 package com.anjiplus.template.gaea.business.modules.dataset.service.impl; 2 package com.anjiplus.template.gaea.business.modules.dataset.service.impl;
3 3
  4 +import cn.hutool.json.JSONUtil;
4 import com.alibaba.fastjson.JSONArray; 5 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject; 6 import com.alibaba.fastjson.JSONObject;
6 import com.anji.plus.gaea.constant.Enabled; 7 import com.anji.plus.gaea.constant.Enabled;
@@ -41,10 +42,10 @@ import java.util.Map; @@ -41,10 +42,10 @@ import java.util.Map;
41 import java.util.stream.Collectors; 42 import java.util.stream.Collectors;
42 43
43 /** 44 /**
44 -* @desc DataSet 数据集服务实现  
45 -* @author Raod  
46 -* @date 2021-03-18 12:11:31.150755900  
47 -**/ 45 + * @desc DataSet 数据集服务实现
  46 + * @author Raod
  47 + * @date 2021-03-18 12:11:31.150755900
  48 + **/
48 @Service 49 @Service
49 //@RequiredArgsConstructor 50 //@RequiredArgsConstructor
50 @Slf4j 51 @Slf4j
@@ -64,7 +65,7 @@ public class DataSetServiceImpl implements DataSetService { @@ -64,7 +65,7 @@ public class DataSetServiceImpl implements DataSetService {
64 65
65 @Override 66 @Override
66 public GaeaBaseMapper<DataSet> getMapper() { 67 public GaeaBaseMapper<DataSet> getMapper() {
67 - return dataSetMapper; 68 + return dataSetMapper;
68 } 69 }
69 70
70 /** 71 /**
@@ -115,9 +116,9 @@ public class DataSetServiceImpl implements DataSetService { @@ -115,9 +116,9 @@ public class DataSetServiceImpl implements DataSetService {
115 116
116 List<DataSetTransform> dataSetTransformList = dataSetTransformService.list( 117 List<DataSetTransform> dataSetTransformList = dataSetTransformService.list(
117 new QueryWrapper<DataSetTransform>() 118 new QueryWrapper<DataSetTransform>()
118 - .lambda()  
119 - .eq(DataSetTransform::getSetCode, setCode)  
120 - .orderByAsc(DataSetTransform::getOrderNum) 119 + .lambda()
  120 + .eq(DataSetTransform::getSetCode, setCode)
  121 + .orderByAsc(DataSetTransform::getOrderNum)
121 ); 122 );
122 List<DataSetTransformDto> dataSetTransformDtoList = new ArrayList<>(); 123 List<DataSetTransformDto> dataSetTransformDtoList = new ArrayList<>();
123 dataSetTransformList.forEach(dataSetTransform -> { 124 dataSetTransformList.forEach(dataSetTransform -> {
@@ -129,8 +130,23 @@ public class DataSetServiceImpl implements DataSetService { @@ -129,8 +130,23 @@ public class DataSetServiceImpl implements DataSetService {
129 130
130 if (StringUtils.isNotBlank(dto.getCaseResult())) { 131 if (StringUtils.isNotBlank(dto.getCaseResult())) {
131 try { 132 try {
132 - JSONArray jsonArray = JSONArray.parseArray(dto.getCaseResult());  
133 - JSONObject jsonObject = jsonArray.getJSONObject(0); 133 + String caseResult = dto.getCaseResult();
  134 + boolean isObj = JSONUtil.isJsonObj(caseResult);
  135 + JSONArray jsonArray = null;
  136 + JSONObject jsonObject = null;
  137 + if(isObj){
  138 + JSONObject result = JSONObject.parseObject(caseResult);
  139 + Object data = result.get("data");
  140 + if (data instanceof JSONObject) {
  141 + jsonObject = (JSONObject)data;
  142 + } else {
  143 + jsonArray = jsonObject.getJSONArray("data");
  144 + jsonObject = jsonArray.getJSONObject(0);
  145 + }
  146 + } else {
  147 + jsonArray = JSONArray.parseArray(caseResult);
  148 + jsonObject = jsonArray.getJSONObject(0);
  149 + }
134 dto.setSetParamList(jsonObject.keySet()); 150 dto.setSetParamList(jsonObject.keySet());
135 } catch (Exception e) { 151 } catch (Exception e) {
136 log.error("error",e); 152 log.error("error",e);
@@ -299,7 +315,7 @@ public class DataSetServiceImpl implements DataSetService { @@ -299,7 +315,7 @@ public class DataSetServiceImpl implements DataSetService {
299 } 315 }
300 316
301 }else { 317 }else {
302 - dataSource = dataSourceService.selectOne("source_code", sourceCode); 318 + dataSource = dataSourceService.selectOne("source_code", sourceCode);
303 } 319 }
304 320
305 //3.参数替换 321 //3.参数替换
1 1
2 package com.anjiplus.template.gaea.business.modules.reportshare.dao.entity; 2 package com.anjiplus.template.gaea.business.modules.reportshare.dao.entity;
3 3
  4 +import com.alibaba.fastjson.JSONObject;
4 import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; 5 import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
5 import com.baomidou.mybatisplus.annotation.TableField; 6 import com.baomidou.mybatisplus.annotation.TableField;
6 import com.baomidou.mybatisplus.annotation.TableName; 7 import com.baomidou.mybatisplus.annotation.TableName;
@@ -8,10 +9,10 @@ import lombok.Data; @@ -8,10 +9,10 @@ import lombok.Data;
8 9
9 import java.util.Date; 10 import java.util.Date;
10 /** 11 /**
11 -* @description 报表分享 entity  
12 -* @author Raod  
13 -* @date 2021-08-18 13:37:26.663  
14 -**/ 12 + * @description 报表分享 entity
  13 + * @author Raod
  14 + * @date 2021-08-18 13:37:26.663
  15 + **/
15 @TableName(keepGlobalPrefix=true, value="gaea_report_share") 16 @TableName(keepGlobalPrefix=true, value="gaea_report_share")
16 @Data 17 @Data
17 public class ReportShare extends GaeaBaseEntity { 18 public class ReportShare extends GaeaBaseEntity {
@@ -46,5 +47,13 @@ public class ReportShare extends GaeaBaseEntity { @@ -46,5 +47,13 @@ public class ReportShare extends GaeaBaseEntity {
46 @TableField(exist = false) 47 @TableField(exist = false)
47 private boolean sharePasswordFlag; 48 private boolean sharePasswordFlag;
48 49
  50 + /**
  51 + * 通过分享连接传递过来的参数 &a=1&b=2
  52 + * <p>
  53 + * 作者: Wang
  54 + * 时间:2022/2/17 11:42
  55 + */
  56 + @TableField(exist = false)
  57 + private JSONObject params;
49 58
50 } 59 }
1 1
2 package com.anjiplus.template.gaea.business.modules.reportshare.service.impl; 2 package com.anjiplus.template.gaea.business.modules.reportshare.service.impl;
3 3
  4 +import com.alibaba.fastjson.JSONObject;
4 import com.anji.plus.gaea.constant.BaseOperationEnum; 5 import com.anji.plus.gaea.constant.BaseOperationEnum;
5 import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; 6 import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
6 import com.anji.plus.gaea.exception.BusinessException; 7 import com.anji.plus.gaea.exception.BusinessException;
@@ -23,10 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -23,10 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.stereotype.Service; 24 import org.springframework.stereotype.Service;
24 25
25 /** 26 /**
26 -* @desc ReportShare 报表分享服务实现  
27 -* @author Raod  
28 -* @date 2021-08-18 13:37:26.663  
29 -**/ 27 + * @desc ReportShare 报表分享服务实现
  28 + * @author Raod
  29 + * @date 2021-08-18 13:37:26.663
  30 + **/
30 @Service 31 @Service
31 public class ReportShareServiceImpl implements ReportShareService { 32 public class ReportShareServiceImpl implements ReportShareService {
32 33
@@ -42,7 +43,7 @@ public class ReportShareServiceImpl implements ReportShareService { @@ -42,7 +43,7 @@ public class ReportShareServiceImpl implements ReportShareService {
42 43
43 @Override 44 @Override
44 public GaeaBaseMapper<ReportShare> getMapper() { 45 public GaeaBaseMapper<ReportShare> getMapper() {
45 - return reportShareMapper; 46 + return reportShareMapper;
46 } 47 }
47 48
48 @Override 49 @Override
@@ -70,6 +71,21 @@ public class ReportShareServiceImpl implements ReportShareService { @@ -70,6 +71,21 @@ public class ReportShareServiceImpl implements ReportShareService {
70 71
71 @Override 72 @Override
72 public ReportShare detailByCode(String shareCode) { 73 public ReportShare detailByCode(String shareCode) {
  74 +
  75 + JSONObject params = new JSONObject();
  76 + if(shareCode.indexOf("&") != -1){
  77 + String[] split = shareCode.split("&");
  78 + shareCode = split[0];
  79 +
  80 + if(split.length > 0){
  81 + for (int i = 1; i < split.length; i++) {
  82 + String[] param = split[i].split("=");
  83 + params.put(param[0],param[1]);
  84 + }
  85 + }
  86 +
  87 + }
  88 +
73 LambdaQueryWrapper<ReportShare> wrapper = Wrappers.lambdaQuery(); 89 LambdaQueryWrapper<ReportShare> wrapper = Wrappers.lambdaQuery();
74 wrapper.eq(ReportShare::getShareCode, shareCode); 90 wrapper.eq(ReportShare::getShareCode, shareCode);
75 wrapper.eq(ReportShare::getEnableFlag, EnableFlagEnum.ENABLE.getCodeValue()); 91 wrapper.eq(ReportShare::getEnableFlag, EnableFlagEnum.ENABLE.getCodeValue());
@@ -83,6 +99,7 @@ public class ReportShareServiceImpl implements ReportShareService { @@ -83,6 +99,7 @@ public class ReportShareServiceImpl implements ReportShareService {
83 //md5加密返回 99 //md5加密返回
84 reportShare.setSharePassword(MD5Util.encrypt(password)); 100 reportShare.setSharePassword(MD5Util.encrypt(password));
85 } 101 }
  102 + reportShare.setParams(params);
86 return reportShare; 103 return reportShare;
87 } 104 }
88 105
@@ -17,9 +17,9 @@ @@ -17,9 +17,9 @@
17 <el-button @click="dialogVisible = false">取 消</el-button> 17 <el-button @click="dialogVisible = false">取 消</el-button>
18 <el-button type="primary" @click="checkPassword()">确 定</el-button> 18 <el-button type="primary" @click="checkPassword()">确 定</el-button>
19 </span> 19 </span>
20 - </el-dialog> 20 + </el-dialog>
21 21
22 -</div> 22 + </div>
23 </template> 23 </template>
24 <script> 24 <script>
25 import { reportShareDetailByCode} from '@/api/reportShare' 25 import { reportShareDetailByCode} from '@/api/reportShare'
@@ -34,7 +34,8 @@ export default { @@ -34,7 +34,8 @@ export default {
34 sharePassword: '', 34 sharePassword: '',
35 dialogVisible: false, 35 dialogVisible: false,
36 reportCode: '', 36 reportCode: '',
37 - shareToken: '' 37 + shareToken: '',
  38 + params:{}
38 }; 39 };
39 }, 40 },
40 41
@@ -46,13 +47,22 @@ export default { @@ -46,13 +47,22 @@ export default {
46 const url = window.location.href 47 const url = window.location.href
47 const shareCode = url.substring(url.lastIndexOf("/") + 1); 48 const shareCode = url.substring(url.lastIndexOf("/") + 1);
48 console.log(shareCode) 49 console.log(shareCode)
49 -  
50 const {code, data} = await reportShareDetailByCode(shareCode) 50 const {code, data} = await reportShareDetailByCode(shareCode)
51 if (code != '200') return 51 if (code != '200') return
52 console.log(data) 52 console.log(data)
53 this.reportCode = data.reportCode 53 this.reportCode = data.reportCode
54 this.sharePassword = data.sharePassword 54 this.sharePassword = data.sharePassword
55 this.shareToken = data.shareToken 55 this.shareToken = data.shareToken
  56 +
  57 + let params = data.params;
  58 + if(params && Object.keys(params).length > 0){
  59 + params['reportCode'] = data.reportCode
  60 + this.params = params;
  61 + } else {
  62 + this.params = {
  63 + reportCode:data.reportCode
  64 + };
  65 + }
56 if (this.sharePassword) { 66 if (this.sharePassword) {
57 console.log(this.sharePassword) 67 console.log(this.sharePassword)
58 this.dialogVisible = true 68 this.dialogVisible = true
@@ -73,11 +83,15 @@ export default { @@ -73,11 +83,15 @@ export default {
73 }, 83 },
74 pushAj(){ 84 pushAj(){
75 setShareToken(this.shareToken) 85 setShareToken(this.shareToken)
  86 + // this.$router.push({
  87 + // path: `/bigscreen/viewer`,
  88 + // query: {
  89 + // reportCode: this.reportCode,
  90 + // },
  91 + // })
76 this.$router.push({ 92 this.$router.push({
77 - path: '/bigscreen/viewer',  
78 - query: {  
79 - reportCode: this.reportCode  
80 - }, 93 + path: `/bigscreen/viewer`,
  94 + query: this.params,
81 }) 95 })
82 }, 96 },
83 handleClose(done) { 97 handleClose(done) {