初始化 V1
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.report;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 项目的启动类
|
||||
*
|
||||
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class ReportServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
|
||||
SpringApplication.run(ReportServerApplication.class, args);
|
||||
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.ajreport;
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataGetBySqlReqVO;
|
||||
import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO;
|
||||
import cn.iocoder.yudao.module.report.service.goview.GoViewDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - GoView 数据", description = "提供 SQL、HTTP 等数据查询的能力")
|
||||
@RestController
|
||||
@RequestMapping("/report/go-view/data")
|
||||
@Validated
|
||||
public class GoViewDataController {
|
||||
|
||||
@Resource
|
||||
private GoViewDataService goViewDataService;
|
||||
|
||||
@RequestMapping("/get-by-sql")
|
||||
@Operation(summary = "使用 SQL 查询数据")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-sql')")
|
||||
public CommonResult<GoViewDataRespVO> getDataBySQL(@Valid @RequestBody GoViewDataGetBySqlReqVO reqVO) {
|
||||
return success(goViewDataService.getDataBySQL(reqVO.getSql()));
|
||||
}
|
||||
|
||||
@RequestMapping("/get-by-http")
|
||||
@Operation(summary = "使用 HTTP 查询数据", description = "这个只是示例接口,实际应该每个查询,都要写一个接口")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-http')")
|
||||
public CommonResult<GoViewDataRespVO> getDataByHttp(
|
||||
@RequestParam(required = false) Map<String, String> params,
|
||||
@RequestBody(required = false) String body) { // params、body 按照需要去接收,这里仅仅是示例
|
||||
GoViewDataRespVO respVO = new GoViewDataRespVO();
|
||||
// 1. 数据维度
|
||||
respVO.setDimensions(Arrays.asList("日期", "PV", "UV")); // PV 是每天访问次数;UV 是每天访问人数
|
||||
// 2. 明细数据列表
|
||||
// 目前通过随机的方式生成。一般来说,这里你可以写逻辑来实现数据的返回
|
||||
respVO.setSource(new LinkedList<>());
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
String date = "2021-" + (i < 10 ? "0" + i : i);
|
||||
Integer pv = RandomUtil.randomInt(1000, 10000);
|
||||
Integer uv = RandomUtil.randomInt(100, 1000);
|
||||
respVO.getSource().add(MapUtil.<String, Object>builder().put("日期", date)
|
||||
.put("PV", pv).put("UV", uv).build());
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO;
|
||||
import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO;
|
||||
import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert;
|
||||
import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO;
|
||||
import cn.iocoder.yudao.module.report.service.goview.GoViewProjectService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - GoView 项目")
|
||||
@RestController
|
||||
@RequestMapping("/report/go-view/project")
|
||||
@Validated
|
||||
public class GoViewProjectController {
|
||||
|
||||
@Resource
|
||||
private GoViewProjectService goViewProjectService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建项目")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-project:create')")
|
||||
public CommonResult<Long> createProject(@Valid @RequestBody GoViewProjectCreateReqVO createReqVO) {
|
||||
return success(goViewProjectService.createProject(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新项目")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-project:update')")
|
||||
public CommonResult<Boolean> updateProject(@Valid @RequestBody GoViewProjectUpdateReqVO updateReqVO) {
|
||||
goViewProjectService.updateProject(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除 GoView 项目")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-project:delete')")
|
||||
public CommonResult<Boolean> deleteProject(@RequestParam("id") Long id) {
|
||||
goViewProjectService.deleteProject(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得项目")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-project:query')")
|
||||
public CommonResult<GoViewProjectRespVO> getProject(@RequestParam("id") Long id) {
|
||||
GoViewProjectDO project = goViewProjectService.getProject(id);
|
||||
return success(GoViewProjectConvert.INSTANCE.convert(project));
|
||||
}
|
||||
|
||||
@GetMapping("/my-page")
|
||||
@Operation(summary = "获得我的项目分页")
|
||||
@PreAuthorize("@ss.hasPermission('report:go-view-project:query')")
|
||||
public CommonResult<PageResult<GoViewProjectRespVO>> getMyProjectPage(@Valid PageParam pageVO) {
|
||||
PageResult<GoViewProjectDO> pageResult = goViewProjectService.getMyProjectPage(
|
||||
pageVO, getLoginUserId());
|
||||
return success(GoViewProjectConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
@Schema(description = "管理后台 - GoView 使用 SQL 查询数据 Request VO")
|
||||
@Data
|
||||
public class GoViewDataGetBySqlReqVO {
|
||||
|
||||
@Schema(description = "SQL 语句", requiredMode = Schema.RequiredMode.REQUIRED, example = "SELECT * FROM user")
|
||||
@NotEmpty(message = "SQL 语句不能为空")
|
||||
private String sql;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - GoView 数据 Response VO")
|
||||
@Data
|
||||
public class GoViewDataRespVO {
|
||||
|
||||
@Schema(description = "数据维度", requiredMode = Schema.RequiredMode.REQUIRED, example = "['product', 'data1', 'data2']")
|
||||
private List<String> dimensions;
|
||||
|
||||
@Schema(description = "数据明细列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<Map<String, Object>> source;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - GoView 项目创建 Request VO")
|
||||
@Data
|
||||
public class GoViewProjectCreateReqVO {
|
||||
|
||||
@Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotEmpty(message = "项目名称不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - GoView 项目 Response VO")
|
||||
@Data
|
||||
public class GoViewProjectRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "报表内容") // JSON 格式
|
||||
private String content;
|
||||
|
||||
@Schema(description = "预览图片 URL", example = "https://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "项目备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - GoView 项目更新 Request VO")
|
||||
@Data
|
||||
public class GoViewProjectUpdateReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "发布状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "报表内容") // JSON 格式
|
||||
private String content;
|
||||
|
||||
@Schema(description = "预览图片 URL", example = "https://www.iocoder.cn")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "项目备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 提供 RESTful API 给前端:
|
||||
* 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目
|
||||
* 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分
|
||||
*/
|
||||
package cn.iocoder.yudao.module.report.controller;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user