Browse Source

完善dashboard

zhou-hao 7 years ago
parent
commit
aaf821a685
18 changed files with 511 additions and 0 deletions
  1. 27 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/pom.xml
  2. 36 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardConfigEntity.java
  3. 6 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardService.java
  4. 8 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/executor/DashBoardExecutor.java
  5. 28 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/pom.xml
  6. 11 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DashBoardExecutorStrategy.java
  7. 29 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBoardService.java
  8. 29 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBordExecutor.java
  9. 7 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/dao/DashBoardConfigDao.java
  10. 52 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/strategy/ScriptExecutorStrategy.java
  11. 52 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dashboard/DashBoardConfigMapper.xml
  12. 77 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/pom.xml
  13. 16 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/java/org/hswebframework/web/dashboard/starter/DashboadAutoConfiguration.java
  14. 3 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/META-INF/spring.factories
  15. 48 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/hsweb-starter.js
  16. 31 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/pom.xml
  17. 44 0
      hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardConfigController.java
  18. 7 0
      hsweb-system/hsweb-system-dashboard/pom.xml

+ 27 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-dashboard</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-dashboard-api</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-commons-service-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-authorization-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 36 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardConfigEntity.java

@@ -0,0 +1,36 @@
+package org.hswebframework.web.dashboard;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.validator.constraints.NotBlank;
+import org.hswebframework.web.commons.entity.DataStatusEnum;
+import org.hswebframework.web.commons.entity.RecordCreationEntity;
+import org.hswebframework.web.commons.entity.SimpleGenericEntity;
+import org.hswebframework.web.validator.group.CreateGroup;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class DashBoardConfigEntity extends SimpleGenericEntity<String> implements RecordCreationEntity {
+
+    private static final long serialVersionUID = 3911748291957287662L;
+
+    @NotBlank(groups = CreateGroup.class)
+    private String name;
+
+    private String type;
+
+    private String template;
+
+    private String script;
+
+    private String scriptLanguage;
+
+    private DataStatusEnum status;
+
+    @NotBlank(groups = CreateGroup.class)
+    private String creatorId;
+
+    @NotBlank(groups = CreateGroup.class)
+    private Long createTime;
+
+}

+ 6 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardService.java

@@ -0,0 +1,6 @@
+package org.hswebframework.web.dashboard;
+
+import org.hswebframework.web.service.CrudService;
+
+public interface DashBoardService extends CrudService<DashBoardConfigEntity,String> {
+}

+ 8 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/executor/DashBoardExecutor.java

@@ -0,0 +1,8 @@
+package org.hswebframework.web.dashboard.executor;
+
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+
+public interface DashBoardExecutor {
+    Object execute(DashBoardConfigEntity entity, Authentication authentication);
+}

+ 28 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/pom.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-dashboard</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-dashboard-local</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-dashboard-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-commons-service-simple</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 11 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DashBoardExecutorStrategy.java

@@ -0,0 +1,11 @@
+package org.hswebframework.web.dashboard.local;
+
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+
+public interface DashBoardExecutorStrategy {
+
+    boolean support(DashBoardConfigEntity entity);
+
+    Object execute(DashBoardConfigEntity entity, Authentication authentication);
+}

+ 29 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBoardService.java

@@ -0,0 +1,29 @@
+package org.hswebframework.web.dashboard.local;
+
+import org.hswebframework.web.dao.CrudDao;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+import org.hswebframework.web.dashboard.DashBoardService;
+import org.hswebframework.web.dashboard.local.dao.DashBoardConfigDao;
+import org.hswebframework.web.id.IDGenerator;
+import org.hswebframework.web.service.EnableCacheGenericEntityService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.stereotype.Service;
+
+@Service
+@CacheConfig(cacheNames = "hsweb:dashboard-conf")
+public class DefaultDashBoardService extends EnableCacheGenericEntityService<DashBoardConfigEntity, String> implements DashBoardService {
+
+    @Autowired
+    private DashBoardConfigDao dashBoardConfigDao;
+
+    @Override
+    protected IDGenerator<String> getIDGenerator() {
+        return IDGenerator.MD5;
+    }
+
+    @Override
+    public CrudDao<DashBoardConfigEntity, String> getDao() {
+        return dashBoardConfigDao;
+    }
+}

+ 29 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBordExecutor.java

@@ -0,0 +1,29 @@
+package org.hswebframework.web.dashboard.local;
+
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+import org.hswebframework.web.dashboard.executor.DashBoardExecutor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.Assert;
+
+import java.util.List;
+
+@Component
+public class DefaultDashBordExecutor implements DashBoardExecutor {
+
+    @Autowired
+    private List<DashBoardExecutorStrategy> strategies;
+
+    @Override
+    public Object execute(DashBoardConfigEntity entity, Authentication authentication) {
+
+        Assert.notNull(entity, "配置不能为空");
+
+        return strategies.stream()
+                .filter(strategy -> strategy.support(entity))
+                .findFirst()
+                .map(strategy -> strategy.execute(entity, authentication))
+                .orElse(null);
+    }
+}

+ 7 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/dao/DashBoardConfigDao.java

@@ -0,0 +1,7 @@
+package org.hswebframework.web.dashboard.local.dao;
+
+import org.hswebframework.web.dao.CrudDao;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+
+public interface DashBoardConfigDao extends CrudDao<DashBoardConfigEntity,String> {
+}

+ 52 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/strategy/ScriptExecutorStrategy.java

@@ -0,0 +1,52 @@
+package org.hswebframework.web.dashboard.local.strategy;
+
+import lombok.SneakyThrows;
+import org.hswebframework.expands.script.engine.DynamicScriptEngine;
+import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory;
+import org.hswebframework.ezorm.rdb.executor.SqlExecutor;
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+import org.hswebframework.web.dashboard.local.DashBoardExecutorStrategy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.DigestUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class ScriptExecutorStrategy implements DashBoardExecutorStrategy {
+
+    @Autowired
+    private SqlExecutor sqlExecutor;
+
+    @Override
+    public boolean support(DashBoardConfigEntity entity) {
+        return "script".equals(entity.getType());
+    }
+
+    @Override
+    @SneakyThrows
+    public Object execute(DashBoardConfigEntity entity, Authentication authentication) {
+        Map<String, Object> scriptContext = new HashMap<>();
+
+        scriptContext.put("autz", authentication);
+
+        if ("sql".equals(entity.getScriptLanguage())) {
+            return sqlExecutor.list(entity.getScript(), scriptContext);
+        }
+
+        DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(entity.getScriptLanguage());
+        if (engine != null) {
+            String id = DigestUtils.md5DigestAsHex(entity.getScript().getBytes());
+
+            if (!engine.compiled(id)) {
+                engine.compile(id, entity.getScript());
+            }
+
+            return engine.execute(id, scriptContext).getIfSuccess();
+        }
+
+        return null;
+    }
+}

+ 52 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dashboard/DashBoardConfigMapper.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.hswebframework.web.dashboard.local.dao.DashBoardConfigDao">
+    <resultMap id="DashBoardConfigEntityResultMap" type="org.hswebframework.web.dashboard.DashBoardConfigEntity">
+        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
+        <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
+        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
+        <result property="template" column="template" javaType="String" jdbcType="CLOB"/>
+        <result property="script" column="script" javaType="String" jdbcType="CLOB"/>
+        <result property="scriptLanguage" column="script_lang" javaType="String" jdbcType="VARCHAR"/>
+        <result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_time" javaType="Date" jdbcType="TIMESTAMP"/>
+        <result property="status" column="status" javaType="org.hswebframework.web.commons.entity.DataStatusEnum" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <!--用于动态生成sql所需的配置-->
+    <sql id="config">
+        <bind name="resultMapId" value="'TemplateResultMap'"/>
+        <bind name="tableName" value="'s_dashboard_conf'"/>
+    </sql>
+
+    <insert id="insert" parameterType="org.hswebframework.web.dashboard.DashBoardConfigEntity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildInsertSql"/>
+    </insert>
+
+    <delete id="deleteByPk" parameterType="String">
+        delete from s_dashboard_conf where u_id =#{id}
+    </delete>
+
+    <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildDeleteSql"/>
+    </delete>
+
+    <update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
+    </update>
+
+    <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="DashBoardConfigEntityResultMap">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildSelectSql"/>
+    </select>
+
+    <select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildTotalSql"/>
+    </select>
+</mapper>

+ 77 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/pom.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-dashboard</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-dashboard-starter</artifactId>
+
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-dashboard-local</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-dashboard-web</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-spring</artifactId>
+            <version>1.3.0</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.0.26</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-spring-boot-starter</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-tests</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+</project>

+ 16 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/java/org/hswebframework/web/dashboard/starter/DashboadAutoConfiguration.java

@@ -0,0 +1,16 @@
+package org.hswebframework.web.dashboard.starter;
+
+import org.hswebframework.web.dao.Dao;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author zhouhao
+ */
+@Configuration
+@ComponentScan({"org.hswebframework.web.dashboard.local"
+        , "org.hswebframework.web.controller.dashboard"})
+@MapperScan(value = "org.hswebframework.web.dashboard.local.dao", markerInterface = Dao.class)
+public class DashboadAutoConfiguration {
+}

+ 3 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,3 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.hswebframework.web.dashboard.starter.DashboadAutoConfiguration

+ 48 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/hsweb-starter.js

@@ -0,0 +1,48 @@
+//组件信息
+var info = {
+    groupId: "${project.groupId}",
+    artifactId: "${project.artifactId}",
+    version: "${project.version}",
+    website: "https://github.com/hs-web/hsweb-framework",
+    author: "admin@hsweb.me",
+    comment: "仪表盘配置"
+};
+
+//版本更新信息
+var versions = [
+    // {
+    //     version: "3.0.2",
+    //     upgrade: function (context) {
+    //         java.lang.System.out.println("更新到3.0.2了");
+    //     }
+    // }
+];
+var JDBCType = java.sql.JDBCType;
+function install(context) {
+    var database = context.database;
+    database.createOrAlter("s_dashboard_conf")
+        .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit()
+        .addColumn().name("name").alias("name").comment("配置名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("type").alias("type").comment("配置类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("template").alias("template").comment("模板").jdbcType(java.sql.JDBCType.CLOB).commit()
+        .addColumn().name("script").alias("script").comment("脚本").jdbcType(java.sql.JDBCType.CLOB).commit()
+        .addColumn().name("script_lang").alias("scriptLanguage").comment("脚本语言").jdbcType(java.sql.JDBCType.CLOB).commit()
+        .addColumn().name("creator_id").alias("creatorId").comment("创建人").varchar(32).commit()
+        .addColumn().name("create_time").alias("createTime").comment("创建时间").datetime().commit()
+        .addColumn().name("status").alias("status").comment("状态").number(4).commit()
+
+        .comment("模板").commit();
+}
+//设置依赖
+dependency.setup(info)
+    .onInstall(install)
+    .onUpgrade(function (context) { //更新时执行
+        var upgrader = context.upgrader;
+        upgrader.filter(versions)
+            .upgrade(function (newVer) {
+                newVer.upgrade(context);
+            });
+    })
+    .onUninstall(function (context) { //卸载时执行
+
+    });

+ 31 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/pom.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-dashboard</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-dashboard-web</artifactId>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-dashboard-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-commons-controller</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 44 - 0
hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardConfigController.java

@@ -0,0 +1,44 @@
+package org.hswebframework.web.controller.dashboard;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.authorization.annotation.Authorize;
+import org.hswebframework.web.commons.entity.param.QueryParamEntity;
+import org.hswebframework.web.controller.SimpleGenericEntityController;
+import org.hswebframework.web.controller.message.ResponseMessage;
+import org.hswebframework.web.dashboard.DashBoardConfigEntity;
+import org.hswebframework.web.dashboard.DashBoardService;
+import org.hswebframework.web.dashboard.executor.DashBoardExecutor;
+import org.hswebframework.web.service.CrudService;
+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;
+
+@RestController
+@RequestMapping("/dashboard")
+@Api(tags = "仪表盘-配置", value = "仪表盘配置")
+@Authorize(permission = "dashboard", description = "仪表盘配置")
+public class DashBoardConfigController implements SimpleGenericEntityController<DashBoardConfigEntity, String, QueryParamEntity> {
+
+    @Autowired
+    DashBoardService dashBoardService;
+
+    @Autowired
+    DashBoardExecutor dashBoardExecutor;
+
+    @Override
+    public CrudService<DashBoardConfigEntity, String> getService() {
+        return dashBoardService;
+    }
+
+
+    @GetMapping("{id}/execute")
+    @Authorize
+    @ApiOperation("执行仪表盘配置")
+    public ResponseMessage<Object> execute(@PathVariable String id) {
+        return ResponseMessage.ok(dashBoardExecutor.execute(dashBoardService.selectByPk(id), Authentication.current().orElse(null)));
+    }
+}

+ 7 - 0
hsweb-system/hsweb-system-dashboard/pom.xml

@@ -10,6 +10,13 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>hsweb-system-dashboard</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>hsweb-system-dashboard-api</module>
+        <module>hsweb-system-dashboard-local</module>
+        <module>hsweb-system-dashboard-web</module>
+        <module>hsweb-system-dashboard-starter</module>
+    </modules>
 
 
 </project>