Browse Source

fix: ams 用户和系统参数模块

cjwen 1 year ago
parent
commit
a36e9e9ff2

+ 1 - 0
.gitignore

@@ -314,3 +314,4 @@ target/
 !/super-whale-log/plumelog-server-3.5.jar
 
 /src/main/resources/static/
+/home/ams/wallet/

+ 17 - 0
front/admin-front/src/styles/sidebar.scss

@@ -366,3 +366,20 @@
   font-size: 21px;
   line-height: 28px;
 }
+
+.must {
+  color: #F56C6C;
+  margin-right: 4px;
+}
+
+.el-table th, .el-table tr {
+  background-color: #F9FBFF;
+}
+
+
+.logolabel {
+  margin-left: 30px;
+  margin-top: 0;
+  position: relative;
+  bottom: 10px;
+}

+ 5 - 3
front/admin-front/src/views/address/download.vue

@@ -136,6 +136,9 @@ export default {
       this.resetForm();
     },
     downloadAddress() {
+      console.log("laile");
+      console.log(AES.decryptAes("661257b279cc92750ca94b9513850f06"));
+      console.log("laodi");
       this.$refs["ruleForm"].validate((valid) => {
         if (valid) {
           console.log("url:::" + this.url);
@@ -166,13 +169,12 @@ export default {
                 this.downloadFile(response.data);
               } else {
                 const data = JSON.parse(str);
-                console.log(data);
-                console.log(data.message);
                 this.$message.error(data.message);
               }
             })
             .catch((e) => {
-              alert(e);
+              console.log(e);
+              this.$message.error(e);
             });
         } else {
           this.$message.error("请填写必填字段!");

+ 192 - 0
front/admin-front/src/views/sys-param/SaveOrUpdate.vue

@@ -0,0 +1,192 @@
+<template>
+  <div>
+    <el-drawer
+      :wrapperClosable="false"
+      size="700px"
+      :visible.sync="paramModal"
+      :withHeader="false"
+      :modal-append-to-body="false"
+    >
+      <el-row style="padding-top: 20px; border-bottom: 1px solid #f0f0f0">
+        <el-col :span="13" class="mb-18">
+          <span
+            class="block-title"
+            style="line-height: 2.5;margin:20px"
+            v-if="this.isSave === true"
+            >添加系统参数</span
+          >
+          <span class="fs-18 fw-bold pd-l-r-40" style="line-height: 2.5" v-else
+            >修改系统参数</span
+          >
+        </el-col>
+        <el-col :span="10">
+          <el-button
+            type="danger"
+            plain
+            class="float-right mg-l-r-10 close-btn"
+            @click="close"
+            >关闭
+          </el-button>
+          <el-button
+            class="float-right mg-l-r-10 confirm-btn pd-2"
+            @click="saveOrUpdate"
+            >确认</el-button
+          >
+        </el-col>
+      </el-row>
+
+      <el-form
+        :model="param"
+        label-width="110px"
+        inline
+        :rules="paramValidate"
+        ref="param"
+        class="flex-normal flex-wrap flex-between"
+      >
+        <el-row style="margin-top: 20px; margin-left: 30px">
+          <el-col :span="24">
+            <el-form-item prop="paramName" class="">
+              <p class="formlabel"><span class="must">*</span>参数名称</p>
+              <el-input
+                v-model="param.paramName"
+                required="true"
+                style="width: 640px"
+                placeholder="请输入参数名称"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row style="margin-left: 30px">
+          <el-col :span="24">
+            <el-form-item prop="paramValue">
+              <p class="formlabel"><span class="must">*</span>参数值</p>
+              <el-input
+                v-model="param.paramValue"
+                required="true"
+                style="width: 640px"
+                placeholder="请输入参数值"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row style="margin-left: 30px">
+          <el-col :span="24">
+            <el-form-item prop="paramNote">
+              <p class="formlabel">备注</p>
+              <el-input
+                type="textarea"
+                :rows="6"
+                placeholder="请输入系统备注"
+                v-model="param.paramNote"
+                style="width: 640px"
+              >
+              </el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </el-drawer>
+  </div>
+</template>
+<style scope>
+</style>
+
+<script>
+import { saveParam, updateParam } from "@/api/param";
+import constant from "@/api/constant"
+export default {
+  data() {
+    return {
+      paramList: [],
+      paramModal: false,
+      isSave: false,
+      tempParam: undefined,
+      param: {
+        systemParamId: undefined,
+        paramName: undefined,
+        paramValue: undefined,
+        systemId: constant.systemId,
+        paramNote: undefined,
+      },
+      paramValidate: {
+        paramName: [
+          {
+            required: true,
+            message: "参数名称不能为空",
+            trigger: "blur",
+          },
+        ],
+        paramValue: [
+          {
+            required: true,
+            message: "参数值不能为空",
+            trigger: "blur",
+          },
+        ],
+      },
+    };
+  },
+  methods: {
+    resetForm() {
+      this.resetValidate();
+
+      this.param = {
+        systemParamId: undefined,
+        paramName: undefined,
+        paramValue: undefined,
+        systemId: constant.systemId,
+        paramNote: undefined,
+      };
+    },
+    resetValidate() {
+      this.$nextTick(() => {
+        this.$refs["param"].resetFields();
+      });
+    },
+    saveOrUpdate() {
+      this.$refs["param"].validate((valid) => {
+        if (valid) {
+          if (this.isSave) {
+            this.saveparam();
+          } else {
+            this.updateparam();
+          }
+          this.paramModal = false;
+        } else {
+          this.$message.error("请填写必填字段!");
+        }
+      });
+    },
+    saveparam() {
+      saveParam(JSON.stringify(this.param), {
+        headers: {
+          "content-type": "application/json",
+        },
+      }).then((res) => {
+        this.$message.success("添加成功");
+        this.$parent.getParamList();
+        this.resetForm();
+      });
+    },
+    updateparam() {
+      updateParam(JSON.stringify(this.param), {
+        headers: {
+          "content-type": "application/json",
+        },
+      }).then((res) => {
+        this.$message.success("更新成功");
+        this.$parent.getParamList();
+        this.resetForm();
+      });
+    },
+    close() {
+      this.paramModal = false;
+      this.resetForm();
+    },
+  },
+  created() {},
+};
+</script>
+<style lang="less" scoped>
+</style>

+ 162 - 74
front/admin-front/src/views/sys-param/index.vue

@@ -1,85 +1,173 @@
 <template>
-  <div class="app-container">
-    <el-form ref="form" :model="form" label-width="120px">
-      <el-form-item label="Activity name">
-        <el-input v-model="form.name" />
-      </el-form-item>
-      <el-form-item label="Activity zone">
-        <el-select v-model="form.region" placeholder="please select your zone">
-          <el-option label="Zone one" value="shanghai" />
-          <el-option label="Zone two" value="beijing" />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="Activity time">
-        <el-col :span="11">
-          <el-date-picker v-model="form.date1" type="date" placeholder="Pick a date" style="width: 100%;" />
-        </el-col>
-        <el-col :span="2" class="line">-</el-col>
-        <el-col :span="11">
-          <el-time-picker v-model="form.date2" type="fixed-time" placeholder="Pick a time" style="width: 100%;" />
-        </el-col>
-      </el-form-item>
-      <el-form-item label="Instant delivery">
-        <el-switch v-model="form.delivery" />
-      </el-form-item>
-      <el-form-item label="Activity type">
-        <el-checkbox-group v-model="form.type">
-          <el-checkbox label="Online activities" name="type" />
-          <el-checkbox label="Promotion activities" name="type" />
-          <el-checkbox label="Offline activities" name="type" />
-          <el-checkbox label="Simple brand exposure" name="type" />
-        </el-checkbox-group>
-      </el-form-item>
-      <el-form-item label="Resources">
-        <el-radio-group v-model="form.resource">
-          <el-radio label="Sponsor" />
-          <el-radio label="Venue" />
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item label="Activity form">
-        <el-input v-model="form.desc" type="textarea" />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" @click="onSubmit">Create</el-button>
-        <el-button @click="onCancel">Cancel</el-button>
-      </el-form-item>
-    </el-form>
+  <div>
+    <el-row class="ml-5" style="margin-bottom: 20px">
+      <el-col :span="2">
+        <div class="">
+          <div class="block-title">系统参数</div>
+          <div class="totalCount-text">
+            参数数量:{{ this.tableData.length }}
+          </div>
+        </div>
+      </el-col>
+      <!-- <el-col :span="5">
+        <el-input
+          clearable
+          prefix-icon="el-icon-search"
+          type="text"
+          placeholder="搜索系统参数"
+          style="width: 275px; border-radius: 30px"
+          v-model="searchParam"
+        >
+        </el-input>
+      </el-col>
+      <el-col :span="14">
+        <el-button
+          icon="el-icon-search"
+          class="btn-filter"
+          @click="getParamList"
+        >
+          筛选
+        </el-button>
+      </el-col> -->
+      <el-col :span="3" :offset="19">
+        <el-button type="primary" class="btn-add" @click="addParamBtn">
+          添加参数
+        </el-button>
+      </el-col>
+    </el-row>
+    <el-row>
+      <el-col>
+        <el-table
+          :data="tableData"
+          style="width: 100%"
+          :header-cell-style="{
+            fontSize: '12px',
+            fontFamily: 'hm-regular',
+            fontWeight: 400,
+            textAlign: 'LEFT',
+            color: '#888888',
+            lineHeight: '12px',
+          }"
+        >
+          <el-table-column prop="paramName" label="参数名称" width="">
+          </el-table-column>
+          <el-table-column prop="paramValue" label="参数值"> </el-table-column>
+          <el-table-column prop="systemName" label="系统名称">
+          </el-table-column>
+          <el-table-column prop="createTime" label="创建时间">
+          </el-table-column>
+          <el-table-column prop="updateTime" label="修改时间">
+          </el-table-column>
+          <el-table-column prop="paramNote" label="备注"> </el-table-column>
+          <el-table-column label="操作">
+            <template slot-scope="scope">
+              <el-button
+                type="text"
+                @click="handleEdit(scope.$index, scope.row)"
+                class="fs-14 bold blue"
+                >编辑
+              </el-button>
+              <el-button
+                type="text"
+                @click="handleDelete(scope.$index, scope.row)"
+                class="fs-14 bold color-red"
+                >删除
+              </el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-pagination
+          style="margin-top: 20px"
+          class="float-right"
+          @size-change="handleSizeChange"
+          @current-change="handleCurrentChange"
+          :current-page.sync="page"
+          :page-sizes="[10, 20, 30, 40]"
+          :page-size.sync="pageSize"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="totalCount"
+        >
+        </el-pagination>
+      </el-col>
+    </el-row>
+    <save-or-update ref="SaveOrUpdate" />
   </div>
 </template>
-
 <script>
+import SaveOrUpdate from "./SaveOrUpdate.vue";
+import { pageParam, deleteParam } from "@/api/param";
+import constant from "@/api/constant";
 export default {
+  components: { SaveOrUpdate },
   data() {
     return {
-      form: {
-        name: '',
-        region: '',
-        date1: '',
-        date2: '',
-        delivery: false,
-        type: [],
-        resource: '',
-        desc: ''
-      }
-    }
+      page: 1,
+      pageSize: 10,
+      totalCount: 0,
+      searchParam: undefined,
+      systemId: constant.systemId,
+      param: {},
+      tableData: [],
+    };
   },
   methods: {
-    onSubmit() {
-      this.$message('submit!')
+    handleSizeChange(val) {
+      this.pageSize = val;
+      this.page = 1;
+      this.getParamList();
     },
-    onCancel() {
-      this.$message({
-        message: 'cancel!',
-        type: 'warning'
+    handleCurrentChange(val) {
+      this.page = val;
+      this.getParamList();
+    },
+    getParamList() {
+      pageParam({
+        page: this.page,
+        pageSize: this.pageSize,
+        paramName: this.searchParam,
+        systemId: this.systemId,
+      }).then((res) => {
+        this.tableData = res.records;
+        this.totalCount = res.total;
+      });
+    },
+    addParamBtn() {
+      this.$refs.SaveOrUpdate.isSave = true;
+      this.$refs.SaveOrUpdate.paramModal = true;
+      // this.$refs.SaveOrUpdate.resetForm();
+      this.$refs.SaveOrUpdate.param.systemParamId = undefined;
+      this.$refs.SaveOrUpdate.param.paramName = undefined;
+      this.$refs.SaveOrUpdate.param.paramValue = undefined;
+      this.$refs.SaveOrUpdate.param.systemId = constant.systemId;
+      this.$refs.SaveOrUpdate.param.paramNote = undefined;
+    },
+    handleEdit(index, row) {
+      this.$refs.SaveOrUpdate.isSave = false;
+      this.$refs.SaveOrUpdate.paramModal = true;
+      Object.assign(this.$refs.SaveOrUpdate.param, row);
+    },
+    handleDelete(index, row) {
+      this.$confirm("此操作将永久删除此系统参数信息, 是否继续?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
       })
-    }
-  }
-}
-</script>
-
-<style scoped>
-.line{
-  text-align: center;
-}
-</style>
-
+        .then(() => {
+          deleteParam(row.systemParamId).then(() => {
+            this.$message.success("删除成功");
+            this.getParamList();
+          });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消删除",
+          });
+        });
+    },
+  },
+  created() {
+    this.getParamList();
+  },
+};
+</script>

+ 5 - 10
front/admin-front/src/views/user/SaveOrUpdate.vue

@@ -10,12 +10,14 @@
       <el-row style="padding-top: 20px; border-bottom: 1px solid #f0f0f0">
         <el-col :span="13" class="mb-18">
           <span
-            class="fs-18 fw-bold pd-l-r-40"
-            style="line-height: 2.5"
+            class="block-title"
+            style="line-height: 2.5;margin:20px"
             v-if="this.isSave === true"
             >添加用户</span
           >
-          <span class="fs-18 fw-bold pd-l-r-40" style="line-height: 2.5" v-else
+          <span 
+            class="block-title"
+            style="line-height: 2.5;margin:20px" v-else
             >修改用户</span
           >
         </el-col>
@@ -255,13 +257,6 @@ export default {
             trigger: "blur",
           },
         ],
-        systemIds: [
-          {
-            required: true,
-            message: "系统不能为空",
-            trigger: "change",
-          },
-        ],
       },
     };
   },

+ 15 - 18
front/admin-front/src/views/user/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="app-container" ref="user">
+  <div ref="user">
     <!-- <div>
       <el-input
         clearable
@@ -10,22 +10,22 @@
         v-model="likeValue"
       >
       </el-input> -->
-      <!-- <el-col :span="14">
+    <!-- <el-col :span="14">
         <el-button icon="el-icon-search" class="btn-filter" @click="getUsers">
           筛选
         </el-button>
       </el-col> 
     </div> -->
     <div>
-      <el-row class="ml-5" style="margin: 30px">
+      <el-row class="ml-5" style="margin-bottom: 20px">
         <el-col :span="2">
           <div class="">
             <div class="block-title">用户管理</div>
-            <div class="totalCount">用户数量:{{ this.totalCount }}</div>
+            <div class="totalCount-text">用户数量:{{ this.totalCount }}</div>
           </div>
         </el-col>
 
-        <el-col :span="3">
+        <el-col :span="3" :offset="18">
           <el-button type="primary" class="btn-add" @click="addUserBtn">
             添加用户
           </el-button>
@@ -33,12 +33,13 @@
       </el-row>
       <el-table
         :data="tableData"
-        style="width: 98%; margin-left: 20px"
+        style="width: 100%"
         :header-cell-style="{
           fontSize: '12px',
           fontFamily: 'hm-regular',
           fontWeight: 400,
           textAlign: 'LEFT',
+          backgroundColor:'#F9FBFF',
           color: '#888888',
           lineHeight: '12px',
         }"
@@ -62,11 +63,6 @@
         </el-table-column>
         <el-table-column prop="createTime" label="注册时间" width="">
         </el-table-column>
-        <el-table-column prop="totalDvs" label="DVS余额" width="">
-          <template slot-scope="{ row }">
-            <span>{{ row.totalDvs }} $DVS</span>
-          </template>
-        </el-table-column>
         <el-table-column label="操作">
           <template slot-scope="scope">
             <el-button
@@ -83,16 +79,17 @@
               style="color: #ff6f61"
               >删除
             </el-button>
-            <el-button
+            <!-- <el-button
               type="text"
               @click="handleDetail(scope.$index, scope.row)"
               class="fs-14 bold blue"
               >详情
-            </el-button>
+            </el-button> -->
           </template>
         </el-table-column>
       </el-table>
       <el-pagination
+        style="margin-top: 20px"
         class="float-right"
         @size-change="handleSizeChange"
         @current-change="handleCurrentChange"
@@ -253,11 +250,11 @@ export default {
       });
     },
     getSearchData(query) {
-    if (this.isCurrentModule) {
-      // 调用 API 获取数据
-      alert("lailelaodi")
-    }
-  }
+      if (this.isCurrentModule) {
+        // 调用 API 获取数据
+        alert("lailelaodi");
+      }
+    },
   },
   created() {
     this.getUsers(undefined);

+ 1 - 1
src/main/java/com/ichaoj/ams/constant/AmsConstant.java

@@ -15,7 +15,7 @@ public class AmsConstant {
     public static final String CACHE_ADDRESS_PREFIX = "ams:address";
 
     public static final String WALLET_FILE_PATH =
-            StrUtil.format("C:{}ams-keystore{}Wallets{}ETH{}", File.separator, File.separator, File.separator, File.separator);
+            StrUtil.format("home{}ams{}wallet{}", File.separator, File.separator, File.separator);
 
     public enum TaskType {
         /**

+ 60 - 40
src/main/java/com/ichaoj/ams/service/impl/AmsAddressAccountServiceImpl.java

@@ -151,54 +151,74 @@ public class AmsAddressAccountServiceImpl extends SuperWhaleServiceImpl<AmsAddre
     }
 
     @Override
-    @SneakyThrows
     public void batchKeystore(String groupName, String password, HttpServletResponse response) {
-        String userId = SuperWhaleContext.getContext(PublicUserInfo.class).getUserId();
-        boolean existGroup = this.checkGroupName(groupName, userId);
-        if (!existGroup) {
-            throw new ErrorServiceException("The address group name is incorrect");
-        }
-        LambdaQueryWrapper<AmsAddressAccount> wrapper = Wrappers.lambdaQuery();
-        wrapper.eq(AmsAddressAccount::getUserId, userId)
-                .eq(AmsAddressAccount::getGroupName, groupName);
-        List<AmsAddressAccount> list = this.list(wrapper);
-        String keystoreJson = list.get(0).getKeystore();
-        EthWalletPrivate ethWalletPrivate = JSONObject.parseObject(keystoreJson, EthWalletPrivate.class);
-        if (!password.equals(ethWalletPrivate.getPassword())) {
-            throw new ErrorServiceException("PASSWORD OR GROUP NAME ERROR!");
-        }
+        InputStream inputStream = null;
+        OutputStream outputStream = null;
+        File zipFile = null;
+        try {
+            String userId = SuperWhaleContext.getContext(PublicUserInfo.class).getUserId();
+            boolean existGroup = this.checkGroupName(groupName, userId);
+            if (!existGroup) {
+                throw new ErrorServiceException("The address group name is incorrect");
+            }
+            LambdaQueryWrapper<AmsAddressAccount> wrapper = Wrappers.lambdaQuery();
+            wrapper.eq(AmsAddressAccount::getUserId, userId)
+                    .eq(AmsAddressAccount::getGroupName, groupName);
+            List<AmsAddressAccount> list = this.list(wrapper);
+            String keystoreJson = list.get(0).getKeystore();
+            EthWalletPrivate ethWalletPrivate = JSONObject.parseObject(keystoreJson, EthWalletPrivate.class);
+            if (!password.equals(ethWalletPrivate.getPassword())) {
+                throw new ErrorServiceException("PASSWORD OR GROUP NAME ERROR!");
+            }
 
-        // 将json_files目录下的所有文件打包成zip
-        File zipFile = new File(WalletUtil.getEncryptPwd(groupName) + ".zip");
-        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
+            // 将json_files目录下的所有文件打包成zip
+            zipFile = new File(WalletUtil.getEncryptPwd(groupName) + ".zip");
+            ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
+
+            File fileDir = new File(WALLET_FILE_PATH + userId + File.separator + WalletUtil.getEncryptPwd(groupName));
+            File[] files = fileDir.listFiles();
+            for (File file : files) {
+                ZipEntry entry = new ZipEntry(file.getName());
+                zos.putNextEntry(entry);
+                FileInputStream fis = new FileInputStream(file);
+                byte[] buffer = new byte[1024];
+                int len;
+                while ((len = fis.read(buffer)) > 0) {
+                    zos.write(buffer, 0, len);
+                }
+                fis.close();
+            }
+            zos.close();
 
-        File fileDir = new File(WALLET_FILE_PATH + userId + File.separator + WalletUtil.getEncryptPwd(groupName));
-        File[] files = fileDir.listFiles();
-        for (File file : files) {
-            ZipEntry entry = new ZipEntry(file.getName());
-            zos.putNextEntry(entry);
-            FileInputStream fis = new FileInputStream(file);
+            // 设置响应头,使浏览器下载该zip文件
+            response.addHeader("Content-Disposition", "attachment;filename=" + WalletUtil.getEncryptPwd(groupName) + ".zip");
+            inputStream = new FileInputStream(zipFile);
             byte[] buffer = new byte[1024];
+            outputStream = response.getOutputStream();
             int len;
-            while ((len = fis.read(buffer)) > 0) {
-                zos.write(buffer, 0, len);
+            while ((len = inputStream.read(buffer)) > 0) {
+                outputStream.write(buffer, 0, len);
+            }
+        } catch (IOException ex) {
+            log.error("batchKeystore 方法报错: {}", ex.getMessage());
+            ex.printStackTrace();
+        } finally {
+            try {
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+                if (outputStream != null) {
+                    outputStream.close();
+                }
+                if (zipFile != null) {
+                    zipFile.delete();
+                }
+            } catch (Exception e) {
+                log.info(e.getMessage());
             }
-            fis.close();
-        }
-        zos.close();
-
-        // 设置响应头,使浏览器下载该zip文件
-        response.addHeader("Content-Disposition", "attachment;filename=" + WalletUtil.getEncryptPwd(groupName) + ".zip");
-        InputStream inputStream = new FileInputStream(zipFile);
-        byte[] buffer = new byte[1024];
-        OutputStream outputStream = response.getOutputStream();
-        int len;
-        while ((len = inputStream.read(buffer)) > 0) {
-            outputStream.write(buffer, 0, len);
         }
-        inputStream.close();
-        outputStream.close();
     }
+
     private void getFiles(BatchKeyStoreRequest keyStoreRequest, Set<File> files, List<AmsAddressAccount> list) {
         try {
             String userId = SuperWhaleContext.getContext(PublicUserInfo.class).getUserId();