From f4566b0628ad2b6f1a8a4a66d935f9387d193764 Mon Sep 17 00:00:00 2001 From: Alawn Date: Tue, 6 Sep 2022 10:33:11 +0800 Subject: [PATCH] add index module --- aladmin-index/pom.xml | 26 ++++ .../aladmin/modules/idx/domain/Dimension.java | 81 ++++++++++++ .../idx/domain/DimensionAttribute.java | 83 ++++++++++++ .../aladmin/modules/idx/domain/Fact.java | 86 ++++++++++++ .../modules/idx/domain/FactAttribute.java | 67 ++++++++++ .../aladmin/modules/idx/domain/Index.java | 68 ++++++++++ .../aladmin/modules/idx/domain/Measure.java | 69 ++++++++++ .../aladmin/modules/idx/domain/Model.java | 67 ++++++++++ .../modules/idx/mapper/FactMapper.java | 29 ++++ .../idx/repository/FactRepository.java | 27 ++++ .../modules/idx/rest/DimensionController.java | 57 ++++++++ .../modules/idx/rest/FactController.java | 57 ++++++++ .../modules/idx/service/FactService.java | 37 ++++++ .../idx/service/impl/FactServiceImpl.java | 51 +++++++ pom.xml | 1 + sql/aladmin.index.h2.sql | 125 ++++++++++++++++++ 16 files changed, 931 insertions(+) create mode 100644 aladmin-index/pom.xml create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Dimension.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/DimensionAttribute.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Fact.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/FactAttribute.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Index.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Measure.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Model.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/mapper/FactMapper.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/repository/FactRepository.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/DimensionController.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/FactController.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/FactService.java create mode 100644 aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/impl/FactServiceImpl.java create mode 100644 sql/aladmin.index.h2.sql diff --git a/aladmin-index/pom.xml b/aladmin-index/pom.xml new file mode 100644 index 0000000..7d9bc08 --- /dev/null +++ b/aladmin-index/pom.xml @@ -0,0 +1,26 @@ + + + + aladmin + priv.alawn + 1.0 + + 4.0.0 + + aladmin-index + 指标管理模块 + + + + + + + + priv.alawn + aladmin-logging + 1.0 + + + diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Dimension.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Dimension.java new file mode 100644 index 0000000..3d60985 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Dimension.java @@ -0,0 +1,81 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.Hibernate; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name="idx_dimension") +public class Dimension extends BaseEntity implements Serializable { + + @Id + @Column(name = "dimension_id") + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) + private Long id; + + private String dimensionCode; + private String dimensionName; + private String dimensionDescription; + private Boolean indexDimension; + private Boolean timeDimension; + + @OneToMany(mappedBy = "dimension") + private List attributes; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; + Dimension dimension = (Dimension) o; + return id != null && Objects.equals(id, dimension.id) && + Objects.equals(dimensionCode, dimension.dimensionCode); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } + + @Override + public String toString() { + return getClass().getSimpleName() + "(" + + "id = " + id + ", " + + "dimensionCode = " + dimensionCode + ", " + + "dimensionName = " + dimensionName + ", " + + "dimensionDescription = " + dimensionDescription + ", " + + "indexDimension = " + indexDimension + ", " + + "timeDimension = " + timeDimension + ")"; + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/DimensionAttribute.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/DimensionAttribute.java new file mode 100644 index 0000000..f2488ce --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/DimensionAttribute.java @@ -0,0 +1,83 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.Hibernate; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Objects; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name="idx_dimension_attribute") +public class DimensionAttribute extends BaseEntity implements Serializable { + + @Id + @Column(name = "dimension_attribute_id") + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) + private Long id; + + @ManyToOne + @JoinColumn(name = "dimension_id") +// @JsonBackReference + private Dimension dimension; + + private String attributeCode; + private String attributeName; + private String attributeDescription; + private Boolean keyAttribute; + private Boolean codeAttribute = false; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; + DimensionAttribute that = (DimensionAttribute) o; + return id != null && Objects.equals(id, that.id) && + Objects.equals(attributeCode,that.attributeCode) ; + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } + + @Override + public String toString() { + return getClass().getSimpleName() + "(" + + "id = " + id + ", " + + "dimension = " + dimension + ", " + + "attributeCode = " + attributeCode + ", " + + "attributeName = " + attributeName + ", " + + "attributeDescription = " + attributeDescription + ", " + + "keyAttribute = " + keyAttribute + ", " + + "codeAttribute = " + codeAttribute + ")"; + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Fact.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Fact.java new file mode 100644 index 0000000..9fe69a9 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Fact.java @@ -0,0 +1,86 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +//import com.baomidou.mybatisplus.annotation.IdType; +//import com.baomidou.mybatisplus.annotation.TableField; +//import com.baomidou.mybatisplus.annotation.TableId; +//import com.baomidou.mybatisplus.annotation.TableName; +//import com.fasterxml.jackson.annotation.JsonBackReference; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.Hibernate; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; +import java.util.Objects; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name = "idx_fact", uniqueConstraints = { + @UniqueConstraint(name = "uc_fact_factcode", columnNames = {"factCode"}) +}) +@TableName("idx_fact") +public class Fact extends BaseEntity implements Serializable { + + @Id +// @ApiModelProperty(value = "ID", hidden = true) +// @TableField("fact_id") + @Column(name = "fact_id") + @TableId(value = "fact_id",type = IdType.ASSIGN_ID) + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + +// @TableField("fact_code") + private String factCode; + private String factName; + private String factDescription; + +// @JsonBackReference +// @OneToMany(mappedBy = "fact") +// private List measures; +// +// @JsonBackReference +// @OneToMany(mappedBy = "fact") +// private List attributes; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; + Fact fact = (Fact) o; + return id != null && Objects.equals(id, fact.id) && Objects.equals(factCode, fact.factCode); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/FactAttribute.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/FactAttribute.java new file mode 100644 index 0000000..961516c --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/FactAttribute.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.Hibernate; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Objects; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name="idx_fact_attribute") +public class FactAttribute extends BaseEntity implements Serializable { + + @Id + @Column(name = "fact_attribute_id") + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) + private Long id; + private String attributeCode; + private String attributeName; + private String attributeDescription; + + @ManyToOne + @JoinColumn(name = "fact_id") + private Fact fact; + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; + FactAttribute that = (FactAttribute) o; + return id != null && Objects.equals(id, that.id) && + Objects.equals(attributeCode, that.attributeCode); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Index.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Index.java new file mode 100644 index 0000000..615fda9 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Index.java @@ -0,0 +1,68 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.Hibernate; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Objects; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name="idx_indexes") +public class Index extends BaseEntity implements Serializable { + + @Id + @Column(name = "index_id") + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) + private Long id; + private String indexCode; + private String indexName; + private String indexType; + private String indexCategory; + private String indexDescription; + private Boolean enabled; + private Boolean based; + private String indexFolderId; + private String indexCalculeType; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false; + Index index = (Index) o; + return id != null && Objects.equals(id, index.id) && + Objects.equals(indexCode, index.indexCode); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Measure.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Measure.java new file mode 100644 index 0000000..ed07457 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Measure.java @@ -0,0 +1,69 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Objects; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name="idx_measure") +public class Measure extends BaseEntity implements Serializable { + + @Id + @Column(name = "measure_id") + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) + private Long id; + private String measureCode; + private String measureName; + private String measureDescription; + private String measureType; + + @ManyToOne + @JoinColumn(name = "fact_id") + private Fact fact; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Measure obj = (Measure) o; + return Objects.equals(id, obj.id) && Objects.equals(measureCode, obj.measureCode) ; + } + + @Override + public int hashCode() { + return Objects.hash(id, measureCode); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Model.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Model.java new file mode 100644 index 0000000..5baa074 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/domain/Model.java @@ -0,0 +1,67 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import priv.alawn.aladmin.base.BaseEntity; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Objects; + +/** + * @author Alawn + * @date 2018-11-22 + */ +@Entity +@Getter +@Setter +@Table(name="idx_model") +public class Model extends BaseEntity implements Serializable { + + @Id + @Column(name = "dimension_id") + @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) + private Long id; + + private String dimensionCode; + private String dimensionName; + private String dimensionDescription; + private Boolean indexDimension; + private Boolean timeDimension; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model obj = (Model) o; + return Objects.equals(id, obj.id) && Objects.equals(dimensionCode, obj.dimensionCode) ; + } + + @Override + public int hashCode() { + return Objects.hash(id, dimensionCode); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/mapper/FactMapper.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/mapper/FactMapper.java new file mode 100644 index 0000000..c44ec73 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/mapper/FactMapper.java @@ -0,0 +1,29 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import priv.alawn.aladmin.modules.idx.domain.Fact; + +/** +* @author Alawn +* @date 2019-03-25 +*/ + +@Mapper +public interface FactMapper extends BaseMapper { +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/repository/FactRepository.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/repository/FactRepository.java new file mode 100644 index 0000000..d548aac --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/repository/FactRepository.java @@ -0,0 +1,27 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import priv.alawn.aladmin.modules.idx.domain.Fact; + +/** +* @author Alawn +* @date 2019-03-25 +*/ +public interface FactRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/DimensionController.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/DimensionController.java new file mode 100644 index 0000000..d983e47 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/DimensionController.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import priv.alawn.aladmin.annotation.Log; +import priv.alawn.aladmin.exception.BadRequestException; +import priv.alawn.aladmin.modules.idx.domain.Fact; +import priv.alawn.aladmin.modules.idx.service.FactService; + +/** +* @author Alawn +* @date 2019-03-25 +*/ +@RestController +@RequiredArgsConstructor +@Api(tags = "指标:维度") +@RequestMapping("/api/idx/dim") +public class DimensionController { + + private final FactService factService; + private static final String ENTITY_NAME = "dept"; + + @Log("新增事实") + @ApiOperation("新增事实") + @PostMapping +// @PreAuthorize("@perm.check('dept:add')") + public ResponseEntity createFact(@Validated @RequestBody Fact resources){ + if (resources.getId() != null) { + throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); + } + factService.create(resources); + return new ResponseEntity<>(HttpStatus.CREATED); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/FactController.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/FactController.java new file mode 100644 index 0000000..c3f36f4 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/rest/FactController.java @@ -0,0 +1,57 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import priv.alawn.aladmin.annotation.Log; +import priv.alawn.aladmin.exception.BadRequestException; +import priv.alawn.aladmin.modules.idx.domain.Fact; +import priv.alawn.aladmin.modules.idx.service.FactService; + +/** +* @author Alawn +* @date 2019-03-25 +*/ +@RestController +@RequiredArgsConstructor +@Api(tags = "指标:事实") +@RequestMapping("/api/idx/fact") +public class FactController { + + private final FactService factService; + private static final String ENTITY_NAME = "dept"; + + @Log("新增事实") + @ApiOperation("新增事实") + @PostMapping +// @PreAuthorize("@perm.check('dept:add')") + public ResponseEntity createFact(@Validated @RequestBody Fact resources){ + if (resources.getId() != null) { + throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); + } + factService.create(resources); + return new ResponseEntity<>(HttpStatus.CREATED); + } +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/FactService.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/FactService.java new file mode 100644 index 0000000..630a4c1 --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/FactService.java @@ -0,0 +1,37 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.service; + +import priv.alawn.aladmin.modules.idx.domain.Fact; + +/** +* @author Alawn +* @date 2019-03-25 +*/ +public interface FactService { + + /** + * 创建 + * @param resources / + */ + void create(Fact resources); + + /** + * 编辑 + * @param resources / + */ + void update(Fact resources); +} \ No newline at end of file diff --git a/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/impl/FactServiceImpl.java b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/impl/FactServiceImpl.java new file mode 100644 index 0000000..11fa69c --- /dev/null +++ b/aladmin-index/src/main/java/priv/alawn/aladmin/modules/idx/service/impl/FactServiceImpl.java @@ -0,0 +1,51 @@ +/* + * Copyright 2019-2020 Alawn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package priv.alawn.aladmin.modules.idx.service.impl; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.stereotype.Service; +import priv.alawn.aladmin.modules.idx.domain.Fact; +import priv.alawn.aladmin.modules.idx.mapper.FactMapper; +import priv.alawn.aladmin.modules.idx.repository.FactRepository; +import priv.alawn.aladmin.modules.idx.service.FactService; + +/** +* @author Alawn +* @date 2019-03-25 +*/ + +@Slf4j +@Service +@RequiredArgsConstructor +@CacheConfig(cacheNames = "fact") +public class FactServiceImpl implements FactService { + private final FactRepository factRepository; + private final FactMapper factMapper; + + @Override + public void create(Fact resources) { + log.info("Creating FactService"); +// factRepository.save(resources); + factMapper.insert(resources); + } + + @Override + public void update(Fact resources) { + + } +} diff --git a/pom.xml b/pom.xml index c0ef7cf..60740c9 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ aladmin-system aladmin-tools aladmin-generator + aladmin-index ALADMIN 后台管理 diff --git a/sql/aladmin.index.h2.sql b/sql/aladmin.index.h2.sql new file mode 100644 index 0000000..fba8ab9 --- /dev/null +++ b/sql/aladmin.index.h2.sql @@ -0,0 +1,125 @@ +SET MODE MYSQL; +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- auto-generated definition +create table IDX_DIMENSION +( + DIMENSION_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + DIMENSION_CODE CHARACTER, + DIMENSION_DESCRIPTION CHARACTER, + DIMENSION_NAME CHARACTER, + INDEX_DIMENSION BOOLEAN, + TIME_DIMENSION BOOLEAN +); + + +create table IDX_DIMENSION_ATTRIBUTE +( + DIMENSION_ATTRIBUTE_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + ATTRIBUTE_CODE CHARACTER, + ATTRIBUTE_DESCRIPTION CHARACTER, + ATTRIBUTE_NAME CHARACTER, + CODE_ATTRIBUTE BOOLEAN, + KEY_ATTRIBUTE BOOLEAN, + DIMENSION_ID BIGINT, + constraint FK3PC4BATJ2JBLUJNRUHGFIV63G + foreign key (DIMENSION_ID) references IDX_DIMENSION +); + +create table IDX_FACT +( + FACT_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + FACT_CODE CHARACTER, + FACT_DESCRIPTION CHARACTER, + FACT_NAME CHARACTER +); + +create table IDX_FACT_ATTRIBUTE +( + FACT_ATTRIBUTE_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + ATTRIBUTE_CODE CHARACTER, + ATTRIBUTE_DESCRIPTION CHARACTER, + ATTRIBUTE_NAME CHARACTER, + FACT_ID BIGINT, + constraint FKS9HIC1SGFVP7J0NTA5LIOECD3 + foreign key (FACT_ID) references IDX_FACT +); + +create table IDX_INDEXES +( + INDEX_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + BASED BOOLEAN, + ENABLED BOOLEAN, + INDEX_CALCULE_TYPE CHARACTER, + INDEX_CATEGORY CHARACTER, + INDEX_CODE CHARACTER, + INDEX_DESCRIPTION CHARACTER, + INDEX_FOLDER_ID CHARACTER, + INDEX_NAME CHARACTER, + INDEX_TYPE CHARACTER +); + +create table IDX_MEASURE +( + MEASURE_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + MEASURE_CODE CHARACTER, + MEASURE_DESCRIPTION CHARACTER, + MEASURE_NAME CHARACTER, + MEASURE_TYPE CHARACTER, + FACT_ID BIGINT, + constraint FK5LVBNRVJGJLN15PQ2C37FLEYJ + foreign key (FACT_ID) references IDX_FACT +); + +create table IDX_MODEL +( + DIMENSION_ID BIGINT auto_increment + primary key, + CREATE_BY CHARACTER, + CREATE_TIME TIMESTAMP, + UPDATE_BY CHARACTER, + UPDATE_TIME TIMESTAMP, + DIMENSION_CODE CHARACTER, + DIMENSION_DESCRIPTION CHARACTER, + DIMENSION_NAME CHARACTER, + INDEX_DIMENSION BOOLEAN, + TIME_DIMENSION BOOLEAN +); + + + +BEGIN; +COMMIT; +SET FOREIGN_KEY_CHECKS = 1; +