Quellcode durchsuchen

feat: 流水线stage持久类

370774330@qq.com vor 5 Jahren
Ursprung
Commit
a234c9ccee

+ 27 - 0
web/src/main/java/seecoder/devcloud/web/dao/pipeline/StageMapper.java

@@ -0,0 +1,27 @@
+package seecoder.devcloud.web.dao.pipeline;
+
+import org.apache.ibatis.annotations.InsertProvider;
+import org.apache.ibatis.annotations.Options;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+import seecoder.devcloud.web.dao.provider.GeneralInsertUpdateSqlProvider;
+import seecoder.devcloud.web.model.po.pipeline.StageConfigPO;
+import seecoder.devcloud.web.model.po.pipeline.StagePO;
+
+import java.util.List;
+
+/**
+ * @author PuHong Weng
+ * @date 2021/4/14
+ * @description:
+ */
+@Repository
+public interface StageMapper {
+
+    @InsertProvider(type = GeneralInsertUpdateSqlProvider.class, method = "insert")
+    @Options(useGeneratedKeys = true, keyProperty = "param1.id", keyColumn = "id")
+    boolean insert(StagePO stagePO, String... ignoredCols);
+
+    @Select("select from stage_configs where stage_id = #{stageId}")
+    List<StageConfigPO> selectConfigs(String stageId);
+}

+ 20 - 0
web/src/main/java/seecoder/devcloud/web/model/po/pipeline/StageConfigPO.java

@@ -0,0 +1,20 @@
+package seecoder.devcloud.web.model.po.pipeline;
+
+import lombok.Data;
+
+/**
+ * @author PuHong Weng
+ * @date 2021/4/14
+ * @description:
+ */
+@Data
+public class StageConfigPO {
+    private Integer id;
+    private String name;
+    private String value;
+    /**
+     * true 则为学生可以配置的属性
+     * false 则为学生不可以配置的属性,仅作展示用
+     */
+    private Boolean fake;
+}

+ 50 - 0
web/src/main/java/seecoder/devcloud/web/model/po/pipeline/StagePO.java

@@ -0,0 +1,50 @@
+package seecoder.devcloud.web.model.po.pipeline;
+
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.HashMap;
+
+/**
+ * @author PuHong Weng
+ * @date 2021/4/14
+ * @description:
+ * 流水线步骤的种类
+ */
+@Data
+@Builder
+public class StagePO {
+
+    private Integer id;
+
+    /**
+     * 流水线步骤名称
+     */
+    private String title;
+
+    /**
+     * 描述信息
+     */
+    private String description;
+
+    /**
+     * 仅作展示用的字段
+     */
+    @Builder.Default
+    private HashMap<String,String> fakeConfigs = new HashMap<>();
+
+    /**
+     * 识别名称,用于转换成对应的流水线真实步骤Handler,见core包的 HandlerConfigTable
+     */
+    private String name;
+
+    /**
+     * 可以配置的字段属性
+     */
+    @Builder.Default
+    private HashMap<String,String> configs = new HashMap<>();
+
+
+
+
+}

+ 41 - 0
web/src/test/java/seecoder/devcloud/web/dao/pipeline/StageMapperTest.java

@@ -0,0 +1,41 @@
+package seecoder.devcloud.web.dao.pipeline;
+
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import seecoder.devcloud.web.model.po.pipeline.StagePO;
+
+import java.util.HashMap;
+
+/**
+ * @author PuHong Weng
+ * @date 2021/4/14
+ * @description:
+ */
+@SpringBootTest
+@RunWith(SpringRunner.class)
+@MapperScan(basePackages = {"seecoder.devcloud.web.dao"})
+class StageMapperTest {
+
+    private final StageMapper stageMapper;
+
+    @Autowired
+    StageMapperTest(StageMapper stageMapper) {
+        this.stageMapper = stageMapper;
+    }
+
+    @Test
+    void insert() {
+        StagePO stagePO = StagePO.builder()
+                .name("Maven测试并构建")
+                .description("构建打包过程")
+                .fakeConfigs(new HashMap<>())
+                .configs(new HashMap<>())
+                .title("Maven测试并构建")
+                .build();
+        stageMapper.insert(stagePO,"id","fakeConfigs","configs");
+    }
+}