diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java index 7a41a7fa..3a8cdab9 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/service/impl/ReportDashboardServiceImpl.java @@ -13,7 +13,7 @@ import com.anjiplus.template.gaea.business.modules.dashboard.controller.dto.Repo import com.anjiplus.template.gaea.business.modules.dashboard.dao.ReportDashboardMapper; import com.anjiplus.template.gaea.business.modules.dashboard.service.ChartStrategy; import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashboardService; -import com.anjiplus.template.gaea.business.modules.dashboard.util.DateUtil; +import com.anjiplus.template.gaea.business.util.DateUtil; import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetDto; import com.anjiplus.template.gaea.business.modules.dashboardwidget.controller.dto.ReportDashboardWidgetValueDto; import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard; diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java new file mode 100644 index 00000000..1b8ff5ee --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/ReportShareController.java @@ -0,0 +1,66 @@ + +package com.anjiplus.template.gaea.business.modules.reportshare.controller; + +import com.anji.plus.gaea.annotation.AccessKey; +import com.anji.plus.gaea.annotation.Permission; +import com.anji.plus.gaea.bean.ResponseBean; +import com.anji.plus.gaea.curd.controller.GaeaBaseController; +import com.anji.plus.gaea.curd.service.GaeaBaseService; +import com.anji.plus.gaea.utils.GaeaBeanUtils; +import com.anji.plus.gaea.utils.GaeaUtils; +import com.anjiplus.template.gaea.business.modules.reportshare.controller.dto.ReportShareDto; +import com.anjiplus.template.gaea.business.modules.reportshare.controller.param.ReportShareParam; +import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.ReportShare; +import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @desc 报表分享 controller +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +@RestController +@Api(tags = "报表分享管理") +@RequestMapping("/reportShare") +@Permission(code = "ReportShare", name = "报表分享管理") +public class ReportShareController extends GaeaBaseController { + + @Autowired + private ReportShareService reportShareService; + + @Override + public GaeaBaseService getService() { + return reportShareService; + } + + @Override + public ReportShare getEntity() { + return new ReportShare(); + } + + @Override + public ReportShareDto getDTO() { + return new ReportShareDto(); + } + + + @GetMapping({"/{id}"}) + @AccessKey + @Override + @Permission(code = "detail", name = "明细") + public ResponseBean detail(@PathVariable("id") Long id) { + this.logger.info("{}根据ID查询服务开始,id为:{}", this.getClass().getSimpleName(), id); + ReportShare result = reportShareService.getDetail(id); + ReportShareDto dto = this.getDTO(); + GaeaBeanUtils.copyAndFormatter(result, dto); + ResponseBean responseBean = this.responseSuccessWithData(this.resultDtoHandle(dto)); + this.logger.info("{}根据ID查询结束,结果:{}", this.getClass().getSimpleName(), GaeaUtils.toJSONString(responseBean)); + return responseBean; + } + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java new file mode 100644 index 00000000..a8495e2d --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/dto/ReportShareDto.java @@ -0,0 +1,46 @@ + +package com.anjiplus.template.gaea.business.modules.reportshare.controller.dto; + +import java.io.Serializable; +import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +/** +* +* @description 报表分享 dto +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +@Data +public class ReportShareDto extends GaeaBaseDTO implements Serializable { + /** 分享编码,系统生成,默认UUID */ + @ApiModelProperty(value = "分享编码,系统生成,默认UUID") + private String shareCode; + + /** 分享有效期类型,DIC_NAME=SHARE_VAILD */ + @ApiModelProperty(value = "分享有效期类型,DIC_NAME=SHARE_VAILD") + private Integer shareValidType; + + /** 分享有效期 */ + @ApiModelProperty(value = "分享有效期") + private Date shareValidTime; + + /** 分享url */ + @ApiModelProperty(value = "分享url") + private String shareUrl; + + /** 报表编码 */ + @ApiModelProperty(value = "报表编码") + private String reportCode; + + /** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */ + @ApiModelProperty(value = "0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG") + private Integer enableFlag; + + /** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */ + @ApiModelProperty(value = "0--未删除 1--已删除 DIC_NAME=DELETE_FLAG") + private Integer deleteFlag; + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/param/ReportShareParam.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/param/ReportShareParam.java new file mode 100644 index 00000000..293f8b02 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/controller/param/ReportShareParam.java @@ -0,0 +1,16 @@ +/**/ +package com.anjiplus.template.gaea.business.modules.reportshare.controller.param; + +import com.anji.plus.gaea.curd.params.PageParam; +import lombok.Data; + +import java.io.Serializable; + +/** +* @desc ReportShare 报表分享查询输入类 +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +@Data +public class ReportShareParam extends PageParam implements Serializable{ +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/ReportShareMapper.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/ReportShareMapper.java new file mode 100644 index 00000000..852490fe --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/ReportShareMapper.java @@ -0,0 +1,15 @@ +package com.anjiplus.template.gaea.business.modules.reportshare.dao; + +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.ReportShare; +import org.apache.ibatis.annotations.Mapper; +/** +* ReportShare Mapper +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +@Mapper +public interface ReportShareMapper extends GaeaBaseMapper { + + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java new file mode 100644 index 00000000..08ba3009 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/dao/entity/ReportShare.java @@ -0,0 +1,40 @@ + +package com.anjiplus.template.gaea.business.modules.reportshare.dao.entity; + +import lombok.Data; +import io.swagger.annotations.ApiModelProperty; +import com.anji.plus.gaea.curd.entity.GaeaBaseEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import javax.validation.constraints.*; +import java.util.Date; +/** +* @description 报表分享 entity +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +@TableName(value="gaea_report_share") +@Data +public class ReportShare extends GaeaBaseEntity { + /** 分享编码,系统生成,默认UUID */ + private String shareCode; + + /** 分享有效期类型,DIC_NAME=SHARE_VAILD */ + private Integer shareValidType; + + /** 分享有效期 */ + private Date shareValidTime; + + /** 分享url */ + private String shareUrl; + + /** 报表编码 */ + private String reportCode; + + /** 0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG */ + private Integer enableFlag; + + /** 0--未删除 1--已删除 DIC_NAME=DELETE_FLAG */ + private Integer deleteFlag; + + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/ReportShareService.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/ReportShareService.java new file mode 100644 index 00000000..8c03ac33 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/ReportShareService.java @@ -0,0 +1,23 @@ + +package com.anjiplus.template.gaea.business.modules.reportshare.service; + +import com.anji.plus.gaea.curd.service.GaeaBaseService; +import com.anjiplus.template.gaea.business.modules.reportshare.controller.param.ReportShareParam; +import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.ReportShare; + +/** +* @desc ReportShare 报表分享服务接口 +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +public interface ReportShareService extends GaeaBaseService { + + /*** + * 查询详情 + * + * @param id + * @return + */ + ReportShare getDetail(Long id); + +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java new file mode 100644 index 00000000..5b1fa781 --- /dev/null +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportshare/service/impl/ReportShareServiceImpl.java @@ -0,0 +1,64 @@ + +package com.anjiplus.template.gaea.business.modules.reportshare.service.impl; + +import com.anji.plus.gaea.constant.BaseOperationEnum; +import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; +import com.anji.plus.gaea.exception.BusinessException; +import com.anjiplus.template.gaea.business.modules.reportshare.dao.ReportShareMapper; +import com.anjiplus.template.gaea.business.modules.reportshare.dao.entity.ReportShare; +import com.anjiplus.template.gaea.business.modules.reportshare.service.ReportShareService; +import com.anjiplus.template.gaea.business.util.DateUtil; +import com.anjiplus.template.gaea.business.util.MD5Util; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.UUID; + +/** +* @desc ReportShare 报表分享服务实现 +* @author Raod +* @date 2021-08-18 13:37:26.663 +**/ +@Service +public class ReportShareServiceImpl implements ReportShareService { + + @Autowired + private ReportShareMapper reportShareMapper; + + @Override + public GaeaBaseMapper getMapper() { + return reportShareMapper; + } + + @Override + public ReportShare getDetail(Long id) { + ReportShare reportShare = this.selectOne(id); + return reportShare; + } + + @Override + public void processBeforeOperation(ReportShare entity, BaseOperationEnum operationEnum) throws BusinessException { + switch (operationEnum) { + case INSERT: + //前端地址 window.location.href https://report.anji-plus.com/index.html#/report/bigscreen + //截取#之前的内容 + //http://localhost:9528/#/bigscreen/viewer?reportCode=bigScreen2 + //http://127.0.0.1:9095/reportDashboard/getData + String shareCode = UUID.randomUUID().toString(); + entity.setShareCode(shareCode); + if (StringUtils.isNotBlank(entity.getShareUrl())) { + String prefix = entity.getShareUrl().substring(0, entity.getShareUrl().indexOf("#")); + entity.setShareUrl(prefix + "#/bigscreen/viewer?reportCode=" + entity.getReportCode()); + } + entity.setShareValidTime(DateUtil.getFutureDateTmdHms(entity.getShareValidType())); + break; + case UPDATE: + break; + default: + + break; + } + } +} diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/util/DateUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/DateUtil.java similarity index 64% rename from report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/util/DateUtil.java rename to report-core/src/main/java/com/anjiplus/template/gaea/business/util/DateUtil.java index 3f8403bf..a8e40ea4 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dashboard/util/DateUtil.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/util/DateUtil.java @@ -1,7 +1,8 @@ -package com.anjiplus.template.gaea.business.modules.dashboard.util; +package com.anjiplus.template.gaea.business.util; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; /** @@ -44,4 +45,25 @@ public class DateUtil { return null; } } + + /** + * 获取未来第几天的日期 + * + * @param day + * @return + */ + public static Date getFutureDateTmdHms(int day) { + if (day <= 0) { + //默认2099年 + return parse("2099-01-01", defaultDatePattern); + } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + day); + return calendar.getTime(); + } + + public static void main(String[] args) { + Date futureDateTmdHms = getFutureDateTmdHms(7); + System.out.println(futureDateTmdHms); + } } diff --git a/report-core/src/main/resources/mapper/ReportShareMapper.xml b/report-core/src/main/resources/mapper/ReportShareMapper.xml new file mode 100644 index 00000000..b26b7923 --- /dev/null +++ b/report-core/src/main/resources/mapper/ReportShareMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + id,share_code,share_valid_type,share_valid_time,share_url,report_code,enable_flag,delete_flag,create_by,create_time,update_by,update_time,version + + +