Browse Source

报表分享

rsbi 4 năm trước cách đây
mục cha
commit
2307b55c35

+ 88 - 0
src/main/java/com/ruisitech/bi/entity/portal/ShareUrl.java

@@ -0,0 +1,88 @@
+/*
+ * Copyright 2018 本系统版权归成都睿思商智科技有限公司所有 
+ * 用户不能删除系统源码上的版权信息, 使用许可证地址:
+ * https://www.ruisitech.com/licenses/index.html
+ */
+package com.ruisitech.bi.entity.portal;
+
+import com.ruisitech.bi.entity.common.BaseEntity;
+import com.ruisitech.bi.util.RSBIUtils;
+
+import java.util.Date;
+
+public class ShareUrl extends BaseEntity {
+
+    private String token;//
+
+    private Integer islogin;// 1true, 0 false
+
+    private Integer yxq;//小时为单位, -1表示不限制
+    
+    private Date crtdate;
+    
+    private String reportId;
+    
+    private Integer crtUser; //创建人
+
+    private Integer rType; //类型,1 报表, 2 仪表盘
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token == null ? null : token.trim();
+    }
+
+    public Integer getIslogin() {
+        return islogin;
+    }
+
+    public void setIslogin(Integer islogin) {
+        this.islogin = islogin;
+    }
+
+    public Integer getYxq() {
+        return yxq;
+    }
+
+    public void setYxq(Integer yxq) {
+        this.yxq = yxq;
+    }
+
+	public Date getCrtdate() {
+		return crtdate;
+	}
+
+	public void setCrtdate(Date crtdate) {
+		this.crtdate = crtdate;
+	}
+
+	public String getReportId() {
+		return reportId;
+	}
+
+	public void setReportId(String reportId) {
+		this.reportId = reportId;
+	}
+
+	public Integer getCrtUser() {
+		return crtUser;
+	}
+
+	public void setCrtUser(Integer crtUser) {
+		this.crtUser = crtUser;
+	}
+	public Integer getrType() {
+		return rType;
+	}
+	public void setrType(Integer rType) {
+		this.rType = rType;
+	}
+
+	@Override
+	public void validate() {
+		this.token = RSBIUtils.htmlEscape(this.token);
+		this.reportId = RSBIUtils.htmlEscape(this.reportId);
+	}
+}

+ 20 - 0
src/main/java/com/ruisitech/bi/mapper/portal/ShareUrlMapper.java

@@ -0,0 +1,20 @@
+/*
+ * Copyright 2018 本系统版权归成都睿思商智科技有限公司所有 
+ * 用户不能删除系统源码上的版权信息, 使用许可证地址:
+ * https://www.ruisitech.com/licenses/index.html
+ */
+package com.ruisitech.bi.mapper.portal;
+
+import com.ruisitech.bi.entity.portal.ShareUrl;
+import org.apache.ibatis.annotations.Param;
+
+public interface ShareUrlMapper {
+	
+    int deleteByPrimaryKey(@Param("token") String token);
+
+    int insert(ShareUrl record);
+
+    ShareUrl selectByPrimaryKey(@Param("token") String token);
+
+    int updateByPrimaryKey(ShareUrl record);
+}

+ 42 - 0
src/main/java/com/ruisitech/bi/service/portal/ShareUrlService.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018 本系统版权归成都睿思商智科技有限公司所有 
+ * 用户不能删除系统源码上的版权信息, 使用许可证地址:
+ * https://www.ruisitech.com/licenses/index.html
+ */
+package com.ruisitech.bi.service.portal;
+
+import com.ruisitech.bi.entity.portal.ShareUrl;
+import com.ruisitech.bi.mapper.portal.ShareUrlMapper;
+import com.ruisitech.bi.util.RSBIUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+
+/**
+ * 复制url service
+ * 复制的 url 可以发给别人
+ * @author hq
+ *
+ */
+@Service
+public class ShareUrlService {
+	
+	@Autowired
+	private ShareUrlMapper mapper;
+
+	private String sysUser = RSBIUtils.getConstant("sysUser");
+	
+	public void saveShareUrl(ShareUrl vo){
+		//生成token
+		String token = UUID.randomUUID().toString().replaceAll("-", "");
+		Integer userId = RSBIUtils.getLoginUserInfo().getUserId();
+		vo.setCrtUser(userId);
+		vo.setToken(token);
+		mapper.insert(vo);
+	}
+	
+	public ShareUrl getByToken(String token){
+		return mapper.selectByPrimaryKey(token);
+	}
+}

+ 3 - 0
src/main/java/com/ruisitech/bi/web/portal/PortalIndexController.java

@@ -36,6 +36,9 @@ public class PortalIndexController extends BaseController {
 	public @ResponseBody
 	Object get(String pageId) {
 		String str = portalService.getPortalCfg(pageId);
+		if(str == null){
+			return this.buildError("报表不存在");
+		}
 		return this.buildSucces(str);
 	}
 

+ 44 - 0
src/main/java/com/ruisitech/bi/web/portal/ShareController.java

@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018 本系统版权归成都睿思商智科技有限公司所有 
+ * 用户不能删除系统源码上的版权信息, 使用许可证地址:
+ * https://www.ruisitech.com/licenses/index.html
+ */
+package com.ruisitech.bi.web.portal;
+
+import com.ruisitech.bi.entity.portal.ShareUrl;
+import com.ruisitech.bi.service.portal.ShareUrlService;
+import com.ruisitech.bi.util.BaseController;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+
+
+/**
+ * 报表分享
+ * @author gdp
+ *
+ */
+@Controller
+@RequestMapping(value = "/portal")
+public class ShareController extends BaseController {
+	
+	private static Logger log = Logger.getLogger(ShareController.class);
+	
+
+	
+	@Autowired
+	private ShareUrlService urlService;
+	
+	@RequestMapping(value="/copyUrl.action", method = RequestMethod.POST)
+	public @ResponseBody
+    Object copyUrl(ShareUrl dto) {
+		dto.setrType(1);
+		urlService.saveShareUrl(dto);
+		return super.buildSucces();
+	}
+
+}

+ 101 - 0
src/main/resources/mybatis/ShareUrlMapper.xml

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ruisitech.bi.mapper.portal.ShareUrlMapper" >
+  <resultMap id="BaseResultMap" type="com.ruisitech.bi.entity.portal.ShareUrl" >
+    <id column="token" property="token" />
+    <result column="islogin" property="islogin" />
+    <result column="yxq" property="yxq" />
+    <result column="crtdate" property="crtdate" />
+    <result column="report_id" property="reportId" />
+    <result column="crt_user" property="crtUser" />
+    <result column="r_type" property="rType" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    token, islogin, yxq,crtdate,report_id,crt_user, r_type
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    select 
+    <include refid="Base_Column_List" />
+    from report_share_url
+    where token = #{token}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from report_share_url
+    where token = #{token}
+  </delete>
+ 
+  <insert id="insert" parameterType="com.ruisitech.bi.entity.portal.ShareUrl" >
+    insert into report_share_url
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="token != null" >
+        token,
+      </if>
+      <if test="islogin != null" >
+        islogin,
+      </if>
+      <if test="yxq != null" >
+        yxq,
+      </if>
+       <if test="reportId != null" >
+        report_id,
+      </if>
+      <if test="rType != null" >
+        r_type,
+      </if>
+      crt_user,
+      crtdate,
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="token != null" >
+        #{token},
+      </if>
+      <if test="islogin != null" >
+        #{islogin},
+      </if>
+      <if test="yxq != null" >
+        #{yxq},
+      </if>
+      <if test="reportId != null" >
+        #{reportId},
+      </if>
+      <if test="rType != null" >
+        #{rType},
+      </if>
+      #{crtUser},
+  		<if test="dbName == 'mysql'">
+    	now()
+    	</if> 
+    	<if test="dbName == 'oracle'">
+    	sysdate
+    	</if> 
+    	<if test="dbName == 'sqlser'">
+    	getdate()
+    	</if> 
+    	<if test="dbName == 'db2'">
+    	current timestamp
+    	</if> 
+    	<if test="dbName == 'psql'">
+    		current_timestamp
+    	</if> 
+    	,
+    </trim>
+  </insert>
+  <update id="update" parameterType="com.ruisitech.bi.entity.portal.ShareUrl" >
+    update report_share_url
+    <set >
+      <if test="islogin != null" >
+        islogin = #{islogin},
+      </if>
+      <if test="yxq != null" >
+        yxq = #{yxq},
+      </if>
+      <if test="reportId != null" >
+        report_id = #{reportId},
+      </if>
+       <if test="crtUser != null" >
+        crt_user = #{crtUser},
+      </if>
+    </set>
+    where token = #{token}
+  </update>
+</mapper>