Drew 6 ani în urmă
părinte
comite
0dc7d909e2

+ 71 - 0
src/main/java/com/izouma/awesomeAdmin/domain/AuditedEntity.java

@@ -0,0 +1,71 @@
+package com.izouma.awesomeAdmin.domain;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.hibernate.envers.Audited;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedBy;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.EntityListeners;
+import javax.persistence.MappedSuperclass;
+import java.time.LocalDateTime;
+
+@MappedSuperclass
+@Audited
+@EntityListeners(AuditingEntityListener.class)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public abstract class AuditedEntity {
+
+    @JsonIgnore
+    @CreatedBy
+    private String createdBy;
+
+    @JsonIgnore
+    @CreatedDate
+    private LocalDateTime createdAt;
+
+    @JsonIgnore
+    @LastModifiedBy
+    private String modifiedBy;
+
+    @JsonIgnore
+    @LastModifiedDate
+    private LocalDateTime modifiedAt;
+
+    public String getCreatedBy() {
+        return createdBy;
+    }
+
+    public void setCreatedBy(String createdBy) {
+        this.createdBy = createdBy;
+    }
+
+    public LocalDateTime getCreatedAt() {
+        return createdAt;
+    }
+
+    public void setCreatedAt(LocalDateTime createdAt) {
+        this.createdAt = createdAt;
+    }
+
+    public String getModifiedBy() {
+        return modifiedBy;
+    }
+
+    public void setModifiedBy(String modifiedBy) {
+        this.modifiedBy = modifiedBy;
+    }
+
+    public LocalDateTime getModifiedAt() {
+        return modifiedAt;
+    }
+
+    public void setModifiedAt(LocalDateTime modifiedAt) {
+        this.modifiedAt = modifiedAt;
+    }
+}

+ 3 - 2
src/main/java/com/izouma/awesomeAdmin/web/DevelopController.java

@@ -11,6 +11,7 @@ import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondit
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
 
 
+import javax.persistence.Entity;
 import java.util.*;
 import java.util.*;
 
 
 @RestController
 @RestController
@@ -24,8 +25,8 @@ public class DevelopController {
     public List entities() {
     public List entities() {
         List<Map<String, String>> entities = new ArrayList<>();
         List<Map<String, String>> entities = new ArrayList<>();
         Reflections reflections = new Reflections(this.getClass().getPackage().getName().replace(".web", ".domain"));
         Reflections reflections = new Reflections(this.getClass().getPackage().getName().replace(".web", ".domain"));
-        Set<Class<? extends BaseEntity>> entitySet = reflections.getSubTypesOf(BaseEntity.class);
-        for (Class<? extends BaseEntity> entity : entitySet) {
+        Set<Class<?>> entitySet = reflections.getTypesAnnotatedWith(Entity.class);
+        for (Class<?> entity : entitySet) {
             Map<String, String> map = new HashMap<>();
             Map<String, String> map = new HashMap<>();
             map.put("name", entity.getSimpleName());
             map.put("name", entity.getSimpleName());
             map.put("package", entity.getName());
             map.put("package", entity.getName());

+ 5 - 3
src/main/resources/templates/EditViewTemplate.ftl

@@ -84,9 +84,9 @@
                 </el-form-item>
                 </el-form-item>
             </#list>
             </#list>
             <el-form-item>
             <el-form-item>
-                <el-button @click="onSave" :loading="$store.state.fetchingData"
+                <el-button @click="onSave" :loading="saving"
                            type="primary">保存</el-button>
                            type="primary">保存</el-button>
-                <el-button @click="onDelete" :loading="$store.state.fetchingData"
+                <el-button @click="onDelete" :loading="saving"
                            type="danger" v-if="formData.id">删除
                            type="danger" v-if="formData.id">删除
                 </el-button>
                 </el-button>
                 <el-button @click="$router.go(-1)">取消</el-button>
                 <el-button @click="$router.go(-1)">取消</el-button>
@@ -271,15 +271,17 @@
                         }
                         }
                     </#if>
                     </#if>
                 </#list>
                 </#list>
-
+                this.saving = true;
                 this.$http
                 this.$http
                     .post('/${model.className?uncap_first}/save', data, {body: 'json'})
                     .post('/${model.className?uncap_first}/save', data, {body: 'json'})
                     .then(res => {
                     .then(res => {
+                        this.saving = false;
                         this.$message.success('成功');
                         this.$message.success('成功');
                         this.$router.go(-1);
                         this.$router.go(-1);
                     })
                     })
                     .catch(e => {
                     .catch(e => {
                         console.log(e);
                         console.log(e);
+                        this.saving = false;
                         this.$message.error(e.error);
                         this.$message.error(e.error);
                     });
                     });
             },
             },

+ 6 - 2
src/main/resources/templates/ListViewTemplate.ftl

@@ -16,7 +16,8 @@
         <el-table :data="tableData" row-key="id" ref="table"
         <el-table :data="tableData" row-key="id" ref="table"
                   header-row-class-name="table-header-row"
                   header-row-class-name="table-header-row"
                   header-cell-class-name="table-header-cell"
                   header-cell-class-name="table-header-cell"
-                  row-class-name="table-row" cell-class-name="table-cell">
+                  row-class-name="table-row" cell-class-name="table-cell"
+                  :height="tableHeight">
             <el-table-column v-if="multipleMode" align="center" type="selection"
             <el-table-column v-if="multipleMode" align="center" type="selection"
                              width="50">
                              width="50">
             </el-table-column>
             </el-table-column>
@@ -166,7 +167,10 @@
             download() {
             download() {
                 this.downloading = true;
                 this.downloading = true;
                 this.$axios
                 this.$axios
-                    .get("/${model.className?uncap_first}/excel", { responseType: "blob" })
+                    .get("/${model.className?uncap_first}/excel", { 
+                        responseType: "blob",
+                        params: { size: 10000 }
+                    })
                     .then(res => {
                     .then(res => {
                         console.log(res);
                         console.log(res);
                         this.downloading = false;
                         this.downloading = false;

+ 4 - 5
src/main/vue/src/components/SingleUpload.vue

@@ -4,8 +4,8 @@
         :before-upload="beforeUpload">
         :before-upload="beforeUpload">
         <div></div>
         <div></div>
         <div class="wrapper">
         <div class="wrapper">
-            <img v-if="imageUrl" :src="imageUrl" class="avatar" />
-            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+            <img v-if="imageUrl" :src="imageUrl" class="upload-image" />
+            <i v-else class="el-icon-plus single-uploader-icon"></i>
             <div v-if="loading" class="loading">
             <div v-if="loading" class="loading">
                 <i class="el-icon-loading"></i>
                 <i class="el-icon-loading"></i>
             </div>
             </div>
@@ -77,7 +77,7 @@ export default {
 };
 };
 </script>
 </script>
 <style lang="less" scoped>
 <style lang="less" scoped>
-.avatar-uploader-icon {
+.single-uploader-icon {
     font-size: 28px;
     font-size: 28px;
     color: #8c939d;
     color: #8c939d;
     width: 178px;
     width: 178px;
@@ -96,8 +96,7 @@ export default {
     }
     }
 }
 }
 
 
-.avatar {
-    width: 178px;
+.upload-image {
     height: 178px;
     height: 178px;
     display: block;
     display: block;
     border: 1px dashed #d9d9d9;
     border: 1px dashed #d9d9d9;

+ 6 - 1
src/main/vue/src/mixins/pageableTable.js

@@ -32,10 +32,15 @@ export default {
     },
     },
     methods: {
     methods: {
         getData() {
         getData() {
+            let urlQuery = { ...this.$route.query };
+            delete urlQuery.sort;
+            delete urlQuery.page;
+            delete urlQuery.size;
             let data = {
             let data = {
                 page: this.page - 1,
                 page: this.page - 1,
                 size: this.pageSize,
                 size: this.pageSize,
                 sort: this.sortStr,
                 sort: this.sortStr,
+                query: urlQuery,
             };
             };
             if (this.beforeGetData) {
             if (this.beforeGetData) {
                 let mergeData = this.beforeGetData();
                 let mergeData = this.beforeGetData();
@@ -161,7 +166,7 @@ export default {
             this.$router
             this.$router
                 .replace({
                 .replace({
                     query: {
                     query: {
-                        ...this.$router.query,
+                        ...this.$route.query,
                         sort: sortStr,
                         sort: sortStr,
                     },
                     },
                 })
                 })