Преглед изворни кода

公屏聊天内容列表页面

sunkean пре 3 година
родитељ
комит
22224a7145

+ 10 - 2
src/main/java/com/izouma/nineth/domain/PublicScreenChat.java

@@ -1,5 +1,7 @@
 package com.izouma.nineth.domain;
 
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.izouma.nineth.annotations.Searchable;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -18,15 +20,21 @@ import java.time.LocalDateTime;
 public class PublicScreenChat extends BaseEntity {
 
     @ApiModelProperty("发送方姓名")
+    @ExcelProperty("发送方姓名")
+    @Searchable
     private String fromNickName;
 
     @ApiModelProperty("发送方id")
+    @ExcelProperty("发送方id")
+    @Searchable
     private String fromUserId;
 
-    @ApiModelProperty("消息")
+    @ApiModelProperty("消息内容")
+    @ExcelProperty("消息内容")
     private String messageInfo;
 
-    @ApiModelProperty("发送消息的时间")
+    @ApiModelProperty("消息发送时间")
+    @ExcelProperty("消息发送时间")
     private LocalDateTime time;
 
     @Transient

+ 20 - 0
src/main/java/com/izouma/nineth/service/PublicScreenChatService.java

@@ -0,0 +1,20 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.domain.PublicScreenChat;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.repo.PublicScreenChatRepo;
+import com.izouma.nineth.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+@Service
+@AllArgsConstructor
+public class PublicScreenChatService {
+
+    private PublicScreenChatRepo publicScreenChatRepo;
+
+    public Page<PublicScreenChat> all(PageQuery pageQuery) {
+        return publicScreenChatRepo.findAll(JpaUtils.toSpecification(pageQuery, PublicScreenChat.class), JpaUtils.toPageRequest(pageQuery));
+    }
+}

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

@@ -1,5 +1,6 @@
 package com.izouma.nineth.service;
 
+import com.izouma.nineth.annotations.RedisLock;
 import com.izouma.nineth.domain.Asset;
 import com.izouma.nineth.domain.UserAssetSummary;
 import com.izouma.nineth.dto.PageQuery;
@@ -32,6 +33,7 @@ public class UserAssetSummaryService {
     }
 
     @Transactional
+    @RedisLock("#userId")
     public void calculateNum(Long userId, Long companyId) {
         log.info("开始重新计算用户:{},companyId:{}的资产数量", userId, companyId);
         List<UserAssetSummary> userAssetSummaries = new ArrayList<>();

+ 35 - 0
src/main/java/com/izouma/nineth/web/PublicScreenChatController.java

@@ -0,0 +1,35 @@
+package com.izouma.nineth.web;
+
+import com.izouma.nineth.domain.PublicScreenChat;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.service.PublicScreenChatService;
+import com.izouma.nineth.utils.excel.ExcelUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/publicScreenChat")
+@AllArgsConstructor
+public class PublicScreenChatController extends BaseController {
+    private PublicScreenChatService publicScreenChatService;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<PublicScreenChat> all(@RequestBody PageQuery pageQuery) {
+        return publicScreenChatService.all(pageQuery);
+    }
+
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<PublicScreenChat> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+}
+

+ 1 - 0
src/main/resources/genjson/PublicScreenChat.json

@@ -0,0 +1 @@
+{"tableName":"PublicScreenChat","className":"PublicScreenChat","remark":"公屏对话","genTable":true,"genClass":true,"genList":true,"genForm":false,"genRouter":true,"javaPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/java/com/izouma/nineth","viewPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/vue/src/views","routerPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/vue/src","resourcesPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"fromNickName","modelName":"fromNickName","remark":"用户昵称","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"fromUserId","modelName":"fromUserId","remark":"用户id","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"messageInfo","modelName":"messageInfo","remark":"消息","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"time","modelName":"time","remark":"发送消息的时间","showInList":true,"showInForm":true,"formType":"datetime"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.nineth","tablePackage":"com.izouma.nineth.domain.PublicScreenChat"}

+ 9 - 1
src/main/vue/src/router.js

@@ -1228,7 +1228,15 @@ const router = new Router({
                     meta: {
                         title: '相册',
                     },
-                }
+                },
+                {
+                    path: '/publicScreenChatList',
+                    name: 'PublicScreenChatList',
+                    component: () => import(/* webpackChunkName: "publicScreenChatList" */ '@/views/PublicScreenChatList.vue'),
+                    meta: {
+                       title: '公屏对话',
+                    },
+               }
                 /**INSERT_LOCATION**/
             ]
         },

+ 116 - 0
src/main/vue/src/views/PublicScreenChatList.vue

@@ -0,0 +1,116 @@
+<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="fromNickName" label="用户昵称"> </el-table-column>
+			<el-table-column prop="fromUserId" label="用户id"> </el-table-column>
+			<el-table-column prop="messageInfo" label="消息内容"> </el-table-column>
+			<el-table-column prop="time" label="消息发送时间"> </el-table-column>
+		</el-table>
+		<div class="pagination-wrapper">
+			<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: 'PublicScreenChatList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			multipleMode: false,
+			search: '',
+			url: '/publicScreenChat/all',
+			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('/publicScreenChat/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);
+				});
+		}
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>