Browse Source

元宇宙排行榜

lidongze 3 năm trước cách đây
mục cha
commit
0f4f232a0d

+ 5 - 0
src/main/java/com/izouma/nineth/dto/MetaGoldTopDTO.java

@@ -1,5 +1,6 @@
 package com.izouma.nineth.dto;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -11,14 +12,18 @@ import lombok.NoArgsConstructor;
 public class MetaGoldTopDTO {
 
     @ApiModelProperty("用户Id")
+    @ExcelProperty("用户ID")
     private Long userId;
 
     @ApiModelProperty("用户头像")
+    @ExcelProperty("头像")
     private String head;
 
     @ApiModelProperty("用户昵称")
+    @ExcelProperty("昵称")
     private String nickName;
 
     @ApiModelProperty("用户金币数量")
+    @ExcelProperty("金币数量")
     private Long num;
 }

+ 1 - 0
src/main/java/com/izouma/nineth/repo/MetaUserGoldRecordRepo.java

@@ -2,6 +2,7 @@ package com.izouma.nineth.repo;
 
 import com.izouma.nineth.domain.MetaUserGoldRecord;
 import com.izouma.nineth.dto.MetaGoldTopDTO;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;

+ 2 - 0
src/main/java/com/izouma/nineth/service/MetaUserGoldRecordService.java

@@ -2,6 +2,8 @@ package com.izouma.nineth.service;
 
 import com.izouma.nineth.domain.MetaUserGoldRecord;
 import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.dto.PageWrapper;
+import com.izouma.nineth.dto.UserHoldDTO;
 import com.izouma.nineth.repo.MetaUserGoldRecordRepo;
 import com.izouma.nineth.utils.JpaUtils;
 import lombok.AllArgsConstructor;

+ 3 - 0
src/main/java/com/izouma/nineth/service/UserHoldCountService.java

@@ -22,8 +22,11 @@ public class UserHoldCountService {
         if (Boolean.FALSE.equals(redisTemplate.hasKey(Constants.USER_HOLD_CACHE_KEY))) {
             throw new BusinessException("key失效,请刷新!如果已经刷新,请等待!");
         }
+        // 当前页
         int page = pageQuery.getPage();
+        // pageSize 每页查询多少条数据
         int size = pageQuery.getSize();
+        // limit 开始偏移量
         int start = page * size;
         List<UserHoldDTO> userHoldDTOS = (List<UserHoldDTO>) redisTemplate.opsForValue().get(Constants.USER_HOLD_CACHE_KEY);
         int totalElements;

+ 38 - 8
src/main/java/com/izouma/nineth/web/MetaUserGoldRecordController.java

@@ -1,13 +1,12 @@
 package com.izouma.nineth.web;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.izouma.nineth.config.MetaConstants;
 import com.izouma.nineth.domain.MetaGameBoxPoints;
 import com.izouma.nineth.domain.MetaParamsConfig;
 import com.izouma.nineth.domain.MetaUserGoldRecord;
-import com.izouma.nineth.dto.MetaGoldTopDTO;
-import com.izouma.nineth.dto.MetaRestResult;
-import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.dto.*;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.MetaParamsConfigRepo;
 import com.izouma.nineth.repo.MetaUserGoldRecordRepo;
@@ -16,11 +15,13 @@ import com.izouma.nineth.service.MetaUserGoldRecordService;
 import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -29,7 +30,7 @@ import java.util.Map;
 @AllArgsConstructor
 public class MetaUserGoldRecordController extends BaseController {
     private MetaUserGoldRecordService metaUserGoldRecordService;
-    private MetaUserGoldRecordRepo    metaUserGoldRecordRepo;
+    private MetaUserGoldRecordRepo metaUserGoldRecordRepo;
     private MetaParamsConfigService metaParamsConfigService;
 
     //@PreAuthorize("hasRole('ADMIN')")
@@ -67,15 +68,44 @@ public class MetaUserGoldRecordController extends BaseController {
         ExcelUtils.export(response, data);
     }
 
-    @GetMapping("/goldTop")
-    public MetaRestResult<List<MetaGoldTopDTO>> top(){
+    @GetMapping("/excel/top")
+    @ResponseBody
+    public void excelTop(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<MetaGoldTopDTO> data = top(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+
+    @PostMapping("/goldTop")
+    public Page<MetaGoldTopDTO> top(@RequestBody PageQuery pageQuery) {
         String beginTime = metaParamsConfigService.getString(MetaConstants.META_GOLD_TOP_BEGIN_TIME);
         String endTime = metaParamsConfigService.getString(MetaConstants.META_GOLD_TOP_END_TIME);
-        List<Map<String,String>> map = metaUserGoldRecordRepo.top(beginTime, endTime);
+        List<Map<String, String>> map = metaUserGoldRecordRepo.top(beginTime, endTime);
         JSONArray jsonArray = new JSONArray();
         jsonArray.addAll(map);
         List<MetaGoldTopDTO> metaGoldTopDTOS = jsonArray.toJavaList(MetaGoldTopDTO.class);
-        return MetaRestResult.returnSuccess("查询成功",metaGoldTopDTOS);
+        // 当前页
+        int page = pageQuery.getPage();
+        // pageSize 每页查询多少条数据
+        int size = pageQuery.getSize();
+        // limit 开始偏移量
+        int start = page * size;
+        int totalElements = 0;
+        if (CollectionUtils.isEmpty(metaGoldTopDTOS)) {
+            totalElements = 0;
+            return new PageWrapper<>(new ArrayList<MetaGoldTopDTO>(), page,
+                    size, totalElements).toPage();
+        }
+        totalElements = metaGoldTopDTOS.size();
+        List<MetaGoldTopDTO> newMetaGoldTopDTOS;
+        if (metaGoldTopDTOS.size() < start + size) {
+            newMetaGoldTopDTOS = metaGoldTopDTOS.subList(start, metaGoldTopDTOS.size());
+            return new PageWrapper<>(newMetaGoldTopDTOS, page,
+                    size, totalElements).toPage();
+        }
+        newMetaGoldTopDTOS = metaGoldTopDTOS.subList(start, start + size);
+        return new PageWrapper<>(newMetaGoldTopDTOS, page,
+                size, totalElements).toPage();
+
     }
 }
 

+ 8 - 0
src/main/vue/src/router.js

@@ -2030,6 +2030,14 @@ const router = new Router({
                        title: '元宇宙排行榜管理',
                     },
                 },
+                {
+                    path: '/MetaTopDetailList',
+                    name: 'MetaTopDetailList',
+                    component: () => import(/* webpackChunkName: "metaTopList" */ '@/views/MetaTopDetailList.vue'),
+                    meta: {
+                       title: '元宇宙排行榜',
+                    },
+                },
                 {
                     path: '/metaUserTaskAwardReceivedRecordNewList',
                     name: 'MetaUserTaskAwardReceivedRecordNewList',

+ 132 - 0
src/main/vue/src/views/MetaTopDetailList.vue

@@ -0,0 +1,132 @@
+<template>
+    <div class="list-view">
+        <page-title>
+            <el-button
+                @click="download"
+                icon="el-icon-upload2"
+                :loading="downloading"
+                :disabled="fetchingData"
+                class="filter-item"
+            >
+                导出
+            </el-button>
+        </page-title>
+        <div class="filters-container">
+            <el-input
+                placeholder="搜索..."
+                v-model="search"
+                clearable
+                class="filter-item search"
+                @keyup.enter.native="getData"
+            >
+                <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+            </el-input>
+        </div>
+        <el-table
+            :data="tableData"
+            row-key="id"
+            ref="table"
+            header-row-class-name="table-header-row"
+            header-cell-class-name="table-header-cell"
+            row-class-name="table-row"
+            cell-class-name="table-cell"
+            :height="tableHeight"
+            v-loading="fetchingData"
+        >
+            <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+            <el-table-column prop="userId" label="用户Id" width="100"> </el-table-column>
+            <el-table-column prop="head" label="用户头像"> </el-table-column>
+            <el-table-column prop="nickName" label="用户昵称"> </el-table-column>
+            <el-table-column prop="num" label="金币数量"> </el-table-column>
+        </el-table>
+        <div class="pagination-wrapper">
+            <!-- <div class="multiple-mode-wrapper">
+                <el-button v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+                <el-button-group v-else>
+                    <el-button @click="operation1">批量操作1</el-button>
+                    <el-button @click="operation2">批量操作2</el-button>
+                    <el-button @click="toggleMultipleMode(false)">取消</el-button>
+                </el-button-group>
+            </div> -->
+            <el-pagination
+                background
+                @size-change="onSizeChange"
+                @current-change="onCurrentChange"
+                :current-page="page"
+                :page-sizes="[10, 20, 30, 40, 50]"
+                :page-size="pageSize"
+                layout="total, sizes, prev, pager, next, jumper"
+                :total="totalElements"
+            >
+            </el-pagination>
+        </div>
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import pageableTable from '@/mixins/pageableTable';
+
+export default {
+    name: 'MetaTopDetailList',
+    mixins: [pageableTable],
+    data() {
+        return {
+            multipleMode: false,
+            search: '',
+            url: '/metaUserGoldRecord/goldTop',
+            downloading: false
+        };
+    },
+    computed: {
+        selection() {
+            return this.$refs.table.selection.map(i => i.id);
+        }
+    },
+    methods: {
+        beforeGetData() {
+            return { search: this.search, query: { del: false } };
+        },
+        toggleMultipleMode(multipleMode) {
+            this.multipleMode = multipleMode;
+            if (!multipleMode) {
+                this.$refs.table.clearSelection();
+            }
+        },
+        download() {
+            this.downloading = true;
+            this.$axios
+                .get('/metaUserGoldRecord/excel/top', {
+                    responseType: 'blob',
+                    params: { size: 10000 }
+                })
+                .then(res => {
+                    console.log(res);
+                    this.downloading = false;
+                    const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+                    const link = document.createElement('a');
+                    link.href = downloadUrl;
+                    link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+                    document.body.appendChild(link);
+                    link.click();
+                    link.remove();
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.downloading = false;
+                    this.$message.error(e.error);
+                });
+        },
+        operation1() {
+            this.$notify({
+                title: '提示',
+                message: this.selection
+            });
+        },
+        operation2() {
+            this.$message('操作2');
+        }
+    }
+};
+</script>
+<style lang="less" scoped>
+</style>

+ 139 - 124
src/main/vue/src/views/MetaTopList.vue

@@ -1,52 +1,55 @@
 <template>
-    <div  class="list-view">
+    <div class="list-view">
         <page-title>
-            <el-button @click="addRow" type="primary" icon="el-icon-plus" :disabled="fetchingData || downloading" class="filter-item">
+            <el-button
+                @click="addRow"
+                type="primary"
+                icon="el-icon-plus"
+                :disabled="fetchingData || downloading"
+                class="filter-item"
+            >
                 新增
             </el-button>
         </page-title>
         <div class="filters-container">
             <el-input
-                    placeholder="搜索..."
-                    v-model="search"
-                    clearable
-                    class="filter-item search"
-                    @keyup.enter.native="getData"
+                placeholder="搜索..."
+                v-model="search"
+                clearable
+                class="filter-item search"
+                @keyup.enter.native="getData"
             >
                 <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
             </el-input>
         </div>
-        <el-table :data="tableData" row-key="id" ref="table"
-                  header-row-class-name="table-header-row"
-                  header-cell-class-name="table-header-cell"
-                  row-class-name="table-row" cell-class-name="table-cell"
-                  :height="tableHeight" v-loading="fetchingData">
-            <el-table-column v-if="multipleMode" align="center" type="selection"
-                             width="50">
-            </el-table-column>
-            <el-table-column prop="id" label="ID" width="100">
+        <el-table
+            :data="tableData"
+            row-key="id"
+            ref="table"
+            header-row-class-name="table-header-row"
+            header-cell-class-name="table-header-cell"
+            row-class-name="table-row"
+            cell-class-name="table-cell"
+            :height="tableHeight"
+            v-loading="fetchingData"
+        >
+            <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+            <el-table-column prop="id" label="ID" width="100"> </el-table-column>
+            <el-table-column prop="name" label="排行榜名称"> </el-table-column>
+            <el-table-column prop="rule" label="排行榜用途"> </el-table-column>
+            <el-table-column prop="pic" label="配置图片">
+                <template slot-scope="{ row }">
+                    <el-image
+                        style="width: 30px; height: 30px"
+                        :src="row.pic"
+                        fit="cover"
+                        :preview-src-list="[row.pic]"
+                    ></el-image>
+                </template>
             </el-table-column>
-                                <el-table-column prop="name" label="排行榜名称"
->
-                    </el-table-column>
-                    <el-table-column prop="rule" label="排行榜用途"
->
-                    </el-table-column>
-                    <el-table-column prop="pic" label="配置图片"
->
-                            <template slot-scope="{row}">
-                                <el-image style="width: 30px; height: 30px"
-                                          :src="row.pic" fit="cover"
-                                          :preview-src-list="[row.pic]"></el-image>
-                            </template>
-                    </el-table-column>
-            <el-table-column
-                    label="操作"
-                    align="center"
-                    fixed="right"
-                    width="150">
-                <template slot-scope="{row}">
-                    <el-button @click="editRow(row)" type="primary" size="mini" plain>查看</el-button>
+            <el-table-column label="操作" align="center" fixed="right" width="150">
+                <template slot-scope="{ row }">
+                    <el-button @click="MetaTopDetailList(row)" type="primary" size="mini" plain>查看</el-button>
                 </template>
             </el-table-column>
         </el-table>
@@ -59,112 +62,124 @@
                     <el-button @click="toggleMultipleMode(false)">取消</el-button>
                 </el-button-group>
             </div> -->
-            <el-pagination background @size-change="onSizeChange"
-                           @current-change="onCurrentChange" :current-page="page"
-                           :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize"
-                           layout="total, sizes, prev, pager, next, jumper"
-                           :total="totalElements">
+            <el-pagination
+                background
+                @size-change="onSizeChange"
+                @current-change="onCurrentChange"
+                :current-page="page"
+                :page-sizes="[10, 20, 30, 40, 50]"
+                :page-size="pageSize"
+                layout="total, sizes, prev, pager, next, jumper"
+                :total="totalElements"
+            >
             </el-pagination>
         </div>
-
     </div>
 </template>
 <script>
-    import { mapState } from "vuex";
-    import pageableTable from "@/mixins/pageableTable";
+import { mapState } from 'vuex';
+import pageableTable from '@/mixins/pageableTable';
 
-    export default {
-        name: 'MetaTopList',
-        mixins: [pageableTable],
-        data() {
-            return {
-                multipleMode: false,
-                search: "",
-                url: "/metaTop/all",
-                downloading: false,
-            }
+export default {
+    name: 'MetaTopList',
+    mixins: [pageableTable],
+    data() {
+        return {
+            multipleMode: false,
+            search: '',
+            url: '/metaTop/all',
+            downloading: false
+        };
+    },
+    computed: {
+        selection() {
+            return this.$refs.table.selection.map(i => i.id);
+        }
+    },
+    methods: {
+        beforeGetData() {
+            return { search: this.search, query: { del: false } };
         },
-        computed: {
-            selection() {
-                return this.$refs.table.selection.map(i => i.id);
+        toggleMultipleMode(multipleMode) {
+            this.multipleMode = multipleMode;
+            if (!multipleMode) {
+                this.$refs.table.clearSelection();
             }
         },
-        methods: {
-            beforeGetData() {
-                return { search: this.search, query: { del: false } };
-            },
-            toggleMultipleMode(multipleMode) {
-                this.multipleMode = multipleMode;
-                if (!multipleMode) {
-                    this.$refs.table.clearSelection();
+        addRow() {
+            this.$router.push({
+                path: '/metaTopEdit',
+                query: {
+                    ...this.$route.query
                 }
-            },
-            addRow() {
-                this.$router.push({
-                    path: "/metaTopEdit",
-                    query: {
-                        ...this.$route.query
-                    }
-                });
-            },
-            editRow(row) {
-                this.$router.push({
-                    path: "/metaTopEdit",
-                    query: {
+            });
+        },
+        MetaTopDetailList() {
+            this.$router.push({
+                path: '/MetaTopDetailList',
+                query: {
+                    
+                }
+            });
+        },
+        editRow(row) {
+            this.$router.push({
+                path: '/metaTopEdit',
+                query: {
                     id: row.id
-                    }
-                });
-            },
-            download() {
-                this.downloading = true;
-                this.$axios
-                    .get("/metaTop/excel", { 
-                        responseType: "blob",
-                        params: { size: 10000 }
-                    })
-                    .then(res => {
-                        console.log(res);
-                        this.downloading = false;
-                        const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
-                        const link = document.createElement("a");
-                        link.href = downloadUrl;
-                        link.setAttribute(
-                            "download",
-                            res.headers["content-disposition"].split("filename=")[1]
-                        );
-                        document.body.appendChild(link);
-                        link.click();
-                        link.remove();
-                    })
-                    .catch(e => {
-                        console.log(e);
-                        this.downloading = false;
-                        this.$message.error(e.error);
-                    });
-            },
-            operation1() {
-                this.$notify({
-                    title: '提示',
-                    message: this.selection
+                }
+            });
+        },
+        download() {
+            this.downloading = true;
+            this.$axios
+                .get('/metaTop/excel', {
+                    responseType: 'blob',
+                    params: { size: 10000 }
+                })
+                .then(res => {
+                    console.log(res);
+                    this.downloading = false;
+                    const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+                    const link = document.createElement('a');
+                    link.href = downloadUrl;
+                    link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+                    document.body.appendChild(link);
+                    link.click();
+                    link.remove();
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.downloading = false;
+                    this.$message.error(e.error);
                 });
-            },
-            operation2() {
-                this.$message('操作2');
-            },
-            deleteRow(row) {
-                this.$alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
-                    return this.$http.post(`/metaTop/del/${row.id}`)
-                }).then(() => {
+        },
+        operation1() {
+            this.$notify({
+                title: '提示',
+                message: this.selection
+            });
+        },
+        operation2() {
+            this.$message('操作2');
+        },
+        deleteRow(row) {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+                .then(() => {
+                    return this.$http.post(`/metaTop/del/${row.id}`);
+                })
+                .then(() => {
                     this.$message.success('删除成功');
                     this.getData();
-                }).catch(e => {
+                })
+                .catch(e => {
                     if (e !== 'cancel') {
                         this.$message.error(e.error);
                     }
-                })
-            },
+                });
         }
     }
+};
 </script>
 <style lang="less" scoped>
 </style>