Forráskód Böngészése

Merge branch 'dev-meta' of xiongzhu/raex_back into master

sunkean 3 éve
szülő
commit
2495c30071

+ 6 - 0
src/main/java/com/izouma/nineth/domain/DestroyRecord.java

@@ -1,6 +1,8 @@
 package com.izouma.nineth.domain;
 
+import com.izouma.nineth.enums.OperationSource;
 import com.izouma.nineth.enums.RecordType;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -32,4 +34,8 @@ public class DestroyRecord extends BaseEntity {
 
     @Column(columnDefinition = "bigint default 1 not null")
     private Long companyId;
+
+    @ApiModelProperty("操作来源")
+    @Enumerated(EnumType.STRING)
+    private OperationSource source;
 }

+ 6 - 0
src/main/java/com/izouma/nineth/domain/MetaDestroyActivity.java

@@ -18,9 +18,15 @@ public class MetaDestroyActivity extends BaseEntity{
     @ApiModelProperty("藏品id")
     private Long collectionId;
 
+    @ApiModelProperty("图片")
+    private String pic;
+
     @ApiModelProperty("销毁数量配置")
     private int num;
 
+    @ApiModelProperty("用途")
+    private int application;
+
     @ApiModelProperty("是否发布")
     private boolean publish;
 }

+ 18 - 0
src/main/java/com/izouma/nineth/enums/OperationSource.java

@@ -0,0 +1,18 @@
+package com.izouma.nineth.enums;
+
+public enum OperationSource {
+
+    META("元宇宙"),
+
+    RAEX("绿洲");
+
+    private final String description;
+
+    OperationSource(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 2 - 2
src/main/java/com/izouma/nineth/repo/MetaDestroyActivityRepo.java

@@ -16,7 +16,7 @@ public interface MetaDestroyActivityRepo extends JpaRepository<MetaDestroyActivi
     @Transactional
     void softDelete(Long id);
 
-    List<MetaDestroyActivity> findAllByDelAndPublish(boolean del, boolean publish);
+    List<MetaDestroyActivity> findAllByApplicationAndDelAndPublish(int appliation, boolean del, boolean publish);
 
-    MetaDestroyActivity findByCollectionIdAndDel(Long collectionId, boolean del);
+    MetaDestroyActivity findByCollectionIdAndApplicationAndDel(Long collectionId, int application, boolean del);
 }

+ 1 - 1
src/main/java/com/izouma/nineth/security/WebSecurityConfig.java

@@ -160,7 +160,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/metaTaskToUser/**").permitAll()
                 .antMatchers("/metaTaskActivity/queryPublishActivity").permitAll()
                 .antMatchers("/metaAdvertRecord/**").permitAll()
-                .antMatchers("/metaDestroyActivity/metaQuery").permitAll()
+                .antMatchers("/metaDestroyActivity/*/metaQuery").permitAll()
                 .antMatchers("/metaResourceVersion/**").permitAll()
                 .antMatchers("/asset/topTen").permitAll()
                 .antMatchers("/metaUser/internalTest").permitAll()

+ 2 - 1
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -892,7 +892,7 @@ public class AssetService {
         }
     }
 
-    public void destroy(Long id, Long userId, String tradeCode) {
+    public void destroy(Long id, Long userId, String tradeCode, OperationSource source) {
         Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
         if (!asset.getUserId().equals(userId)) {
             throw new BusinessException("此藏品不属于你");
@@ -945,6 +945,7 @@ public class AssetService {
                 .record(1)
                 .type(RecordType.OBTAIN)
                 .companyId(asset.getCompanyId())
+                .source(source)
                 .build());
 
         //加积分

+ 3 - 2
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -10,6 +10,7 @@ import com.izouma.nineth.domain.GiftOrder;
 import com.izouma.nineth.dto.*;
 import com.izouma.nineth.enums.CollectionSource;
 import com.izouma.nineth.enums.CollectionType;
+import com.izouma.nineth.enums.OperationSource;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.AssetRepo;
 import com.izouma.nineth.repo.CollectionRepo;
@@ -201,8 +202,8 @@ public class AssetController extends BaseController {
 
     @ApiOperation("销毁")
     @PostMapping("/destroy")
-    public void destroy(@RequestParam Long id, @RequestParam String tradeCode) {
-        assetService.destroy(id, SecurityUtils.getAuthenticatedUser().getId(), tradeCode);
+    public void destroy(@RequestParam Long id, @RequestParam String tradeCode, @RequestParam OperationSource source) {
+        assetService.destroy(id, SecurityUtils.getAuthenticatedUser().getId(), tradeCode, source);
     }
 
     @ApiOperation("开盲盒")

+ 14 - 5
src/main/java/com/izouma/nineth/web/MetaDestroyActivityController.java

@@ -1,9 +1,11 @@
 package com.izouma.nineth.web;
 
+import com.izouma.nineth.domain.Collection;
 import com.izouma.nineth.domain.MetaDestroyActivity;
 import com.izouma.nineth.dto.MetaRestResult;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.CollectionRepo;
 import com.izouma.nineth.repo.MetaDestroyActivityRepo;
 import com.izouma.nineth.service.MetaDestroyActivityService;
 import com.izouma.nineth.utils.ObjUtils;
@@ -25,16 +27,23 @@ public class MetaDestroyActivityController extends BaseController {
     private MetaDestroyActivityService metaDestroyActivityService;
     private MetaDestroyActivityRepo metaDestroyActivityRepo;
 
+    private CollectionRepo collectionRepo;
+
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MetaDestroyActivity save(@RequestBody MetaDestroyActivity record) {
-        MetaDestroyActivity metaDestroyActivity = metaDestroyActivityRepo.findByCollectionIdAndDel(record.getCollectionId(), false);
+        Collection collection = collectionRepo.findById(record.getCollectionId()).orElseThrow(new BusinessException("不存在该藏品"));
+        MetaDestroyActivity metaDestroyActivity = metaDestroyActivityRepo.findByCollectionIdAndApplicationAndDel(record.getCollectionId(), record.getApplication(), false);
         if (Objects.nonNull(metaDestroyActivity) && !Objects.equals(metaDestroyActivity.getId(), record.getId())) {
-            throw new BusinessException("已经存在该collectionId的相关配置!");
+            throw new BusinessException("该用途已经存在此藏品的相关配置!");
+        }
+        if (CollectionUtils.isNotEmpty(collection.getPic())) {
+            record.setPic(collection.getPic().get(0).getUrl());
         }
         if (record.getId() != null) {
             MetaDestroyActivity orig = metaDestroyActivityRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
             ObjUtils.merge(orig, record);
+            orig.setPic(collection.getPic().get(0).getUrl());
             return metaDestroyActivityRepo.save(orig);
         }
         return metaDestroyActivityRepo.save(record);
@@ -64,9 +73,9 @@ public class MetaDestroyActivityController extends BaseController {
         ExcelUtils.export(response, data);
     }
 
-    @GetMapping("/metaQuery")
-    public MetaRestResult<List<MetaDestroyActivity>> metaQuery() {
-        List<MetaDestroyActivity> metaDestroyActivities = metaDestroyActivityRepo.findAllByDelAndPublish(false, true);
+    @GetMapping("/{application}/metaQuery")
+    public MetaRestResult<List<MetaDestroyActivity>> metaQuery(@PathVariable int application) {
+        List<MetaDestroyActivity> metaDestroyActivities = metaDestroyActivityRepo.findAllByApplicationAndDelAndPublish(application, false, true);
         if (CollectionUtils.isEmpty(metaDestroyActivities)) {
             return MetaRestResult.returnError("查询不到销毁活动的配置");
         }

+ 3 - 0
src/main/vue/src/views/MetaDestroyActivityEdit.vue

@@ -22,6 +22,9 @@
 					<el-form-item prop="num" label="数量配置">
 						<el-input-number type="number" v-model="formData.num"> </el-input-number>
 					</el-form-item>
+					<el-form-item prop="application" label="用途">
+						<el-input-number type="application" v-model="formData.application"> </el-input-number>
+					</el-form-item>
 					<el-form-item prop="publish" label="是否发布">
 						<el-switch v-model="formData.publish"> </el-switch>
 					</el-form-item>

+ 185 - 162
src/main/vue/src/views/MetaDestroyActivityList.vue

@@ -1,172 +1,195 @@
 <template>
-    <div  class="list-view">
-        <page-title>
-            <el-button @click="addRow" type="primary" icon="el-icon-plus" :disabled="fetchingData || downloading" class="filter-item">
-                新增
-            </el-button>
-            <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="id" label="ID" width="100">
-            </el-table-column>
-                                <el-table-column prop="collectionId" label="藏品id"
->
-                    </el-table-column>
-                    <el-table-column prop="num" label="数量配置"
->
-                    </el-table-column>
-                    <el-table-column prop="publish" label="是否发布"
->
-                            <template slot-scope="{row}">
-                                <el-tag :type="row.publish?'':'info'">{{row.publish}}</el-tag>
-                            </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-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
-                </template>
-            </el-table-column>
-        </el-table>
-        <div class="pagination-wrapper">
-            <!-- <div class="multiple-mode-wrapper">
-                <el-button v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+	<div class="list-view">
+		<page-title>
+			<el-button
+				@click="addRow"
+				type="primary"
+				icon="el-icon-plus"
+				:disabled="fetchingData || downloading"
+				class="filter-item"
+			>
+				新增
+			</el-button>
+			<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="id" label="ID" width="100"> </el-table-column>
+			<el-table-column prop="collectionId" label="藏品id"> </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="num" label="数量配置"> </el-table-column>
+            <el-table-column prop="application" label="用途"> </el-table-column>
+			<el-table-column prop="publish" label="是否发布">
+				<template slot-scope="{ row }">
+					<el-tag :type="row.publish ? '' : 'info'"> {{ row.publish }} </el-tag>
+				</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-button @click="deleteRow(row)" type="danger" size="mini" plain> 删除 </el-button>
+				</template>
+			</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 @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>
+			<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: 'MetaDestroyActivityList',
-        mixins: [pageableTable],
-        data() {
-            return {
-                multipleMode: false,
-                search: "",
-                url: "/metaDestroyActivity/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();
-                }
-            },
-            addRow() {
-                this.$router.push({
-                    path: "/metaDestroyActivityEdit",
-                    query: {
-                        ...this.$route.query
-                    }
-                });
-            },
-            editRow(row) {
-                this.$router.push({
-                    path: "/metaDestroyActivityEdit",
-                    query: {
-                    id: row.id
-                    }
-                });
-            },
-            download() {
-                this.downloading = true;
-                this.$axios
-                    .get("/metaDestroyActivity/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
-                });
-            },
-            operation2() {
-                this.$message('操作2');
-            },
-            deleteRow(row) {
-                this.$alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
-                    return this.$http.post(`/metaDestroyActivity/del/${row.id}`)
-                }).then(() => {
-                    this.$message.success('删除成功');
-                    this.getData();
-                }).catch(e => {
-                    if (e !== 'cancel') {
-                        this.$message.error(e.error);
-                    }
-                })
-            },
-        }
-    }
+export default {
+	name: 'MetaDestroyActivityList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			multipleMode: false,
+			search: '',
+			url: '/metaDestroyActivity/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();
+			}
+		},
+		addRow() {
+			this.$router.push({
+				path: '/metaDestroyActivityEdit',
+				query: {
+					...this.$route.query
+				}
+			});
+		},
+		editRow(row) {
+			this.$router.push({
+				path: '/metaDestroyActivityEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		download() {
+			this.downloading = true;
+			this.$axios
+				.get('/metaDestroyActivity/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
+			});
+		},
+		operation2() {
+			this.$message('操作2');
+		},
+		deleteRow(row) {
+			this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+				.then(() => {
+					return this.$http.post(`/metaDestroyActivity/del/${row.id}`);
+				})
+				.then(() => {
+					this.$message.success('删除成功');
+					this.getData();
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						this.$message.error(e.error);
+					}
+				});
+		}
+	}
+};
 </script>
 <style lang="less" scoped>
+
 </style>