|
|
@@ -1,11 +1,14 @@
|
|
|
package com.usoftchina.bi.server.service.dashboard;
|
|
|
|
|
|
import com.usoftchina.bi.core.exception.MyException;
|
|
|
+import com.usoftchina.bi.core.utils.EncryUtil;
|
|
|
+import com.usoftchina.bi.core.utils.JsonUtils;
|
|
|
import com.usoftchina.bi.server.dao.dashboard.DashboardsMapper;
|
|
|
import com.usoftchina.bi.server.dao.user.UserMapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.bi.server.model.bo.DashOrder;
|
|
|
+import com.usoftchina.bi.server.model.bo.ShareReqBO;
|
|
|
import com.usoftchina.bi.server.model.po.Dashboards;
|
|
|
import com.usoftchina.bi.core.base.RepCode;
|
|
|
import com.usoftchina.bi.core.base.RepEntity;
|
|
|
@@ -15,6 +18,8 @@ import com.usoftchina.bi.server.model.vo.configVo.DashboardsInfo;
|
|
|
import com.usoftchina.bi.server.model.vo.dataVo.DashboardOrderInfo;
|
|
|
import com.usoftchina.bi.server.service.chart.ChartsUtilService;
|
|
|
import com.usoftchina.bi.core.utils.GetTokenDataUtil;
|
|
|
+import org.bouncycastle.util.encoders.UrlBase64;
|
|
|
+import org.bouncycastle.util.encoders.UrlBase64Encoder;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -160,21 +165,63 @@ public class DashboardsService {
|
|
|
|
|
|
/**
|
|
|
* 通过code查看单个看板
|
|
|
- * @param token
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
- public RepEntity getDashboardByCode(String token, String code) {
|
|
|
- Map<String, String> stringMap = GetTokenDataUtil.getTokenData(token);
|
|
|
- int userId = Integer.parseInt(stringMap.get("id"));
|
|
|
- int id = dashboardsMapper.getIdByCode(code);
|
|
|
- Dashboards dashboards = dashboardsMapper.getDashboards(userId, id);
|
|
|
+ public RepEntity getDashboardByCode(String code) {
|
|
|
+ Dashboards dashboard = dashboardsMapper.getDashboardByCode(code);
|
|
|
+ Dashboards dashboards = dashboardsMapper.getDashboards(dashboard.getCreateId(), dashboard.getId());
|
|
|
if (dashboards == null){
|
|
|
return new RepEntity(RepCode.DashboardNonExistent);
|
|
|
}
|
|
|
return new RepEntity(RepCode.success, dashboards);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成分享链接参数
|
|
|
+ * @param shareReqBO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RepEntity shareDashBoard(ShareReqBO shareReqBO) {
|
|
|
+ Long endTime = new Double(System.currentTimeMillis() + shareReqBO.getDelay() * 24 * 60 * 60 * 1000).longValue();
|
|
|
+ String data = "id=" + shareReqBO.getId() + "&endTime=" + endTime;
|
|
|
+ String encodeData = new String(UrlBase64.encode(data.getBytes()));
|
|
|
+ return new RepEntity(RepCode.success, encodeData);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 链接参数解析
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, String> parseParams(String data) {
|
|
|
+ String decodeData = new String(UrlBase64.decode(data));
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ int firstEndIndex = decodeData.indexOf("&");
|
|
|
+ map.put("id", decodeData.substring(3, firstEndIndex));
|
|
|
+ map.put("endTime", decodeData.substring(firstEndIndex));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过分享链接获取看板信息
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RepEntity getSharedDashboard(String data){
|
|
|
+ Map<String, String> params = parseParams(data);
|
|
|
+ Long endTime = Long.valueOf(params.get("endTime"));
|
|
|
+ if (System.currentTimeMillis() > endTime) {
|
|
|
+ throw new MyException("分享链接已过期");
|
|
|
+ }
|
|
|
+ int id = Integer.valueOf(params.get("id"));
|
|
|
+ int creatorId = dashboardsMapper.getCreateIdById(id);
|
|
|
+ Dashboards dashboards = dashboardsMapper.getDashboards(creatorId, id);
|
|
|
+ if (dashboards == null){
|
|
|
+ return new RepEntity(RepCode.DashboardNonExistent);
|
|
|
+ }
|
|
|
+ return new RepEntity(RepCode.success, dashboards);
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
转交看板
|