瀏覽代碼

元宇宙相关

sunkean 3 年之前
父節點
當前提交
40542e4db8

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

@@ -20,7 +20,7 @@ import javax.persistence.Entity;
 @ApiModel("元宇宙销毁任务")
 public class MetaDestroyActivity extends BaseEntity{
 
-    @ApiModelProperty("铸造活动规则")
+    @ApiModelProperty("活动规则")
     @Convert(converter = MintRuleConverter.class)
     @Column(columnDefinition = "TEXT")
     private MintActivityRule rule;

+ 55 - 0
src/main/java/com/izouma/nineth/domain/MetaGame.java

@@ -0,0 +1,55 @@
+package com.izouma.nineth.domain;
+
+import com.izouma.nineth.converter.MintRuleConverter;
+import com.izouma.nineth.dto.MintActivityRule;
+import com.izouma.nineth.enums.EntryModeType;
+import com.izouma.nineth.enums.GameModeType;
+import com.izouma.nineth.enums.MetaGameType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@ApiModel("元宇宙游戏")
+public class MetaGame extends BaseEntity{
+
+    @ApiModelProperty("游戏")
+    @Enumerated(EnumType.STRING)
+    private MetaGameType name;
+
+    @ApiModelProperty("游戏模式")
+    @Enumerated(EnumType.STRING)
+    private GameModeType gameModeType;
+
+    @ApiModelProperty("入场方式")
+    @Enumerated(EnumType.STRING)
+    private EntryModeType entryModeType;
+
+    @ApiModelProperty("所需金币数量")
+    private int goldNum;
+
+    @ApiModelProperty("藏品规则")
+    @Convert(converter = MintRuleConverter.class)
+    @Column(columnDefinition = "TEXT")
+    private MintActivityRule rule;
+
+    @Column(columnDefinition = "tinyint unsigned default 0")
+    @ApiModelProperty("是否审核")
+    private boolean audit = false;
+
+    @ApiModelProperty("藏品名称")
+    private String collectionName;
+
+    @ApiModelProperty("所需nft数量")
+    private int num;
+
+    @ApiModelProperty("是否发布")
+    private boolean publish;
+}

+ 19 - 0
src/main/java/com/izouma/nineth/enums/EntryModeType.java

@@ -0,0 +1,19 @@
+package com.izouma.nineth.enums;
+
+
+public enum EntryModeType {
+
+    NFT("NFT"),
+
+    GOLD("金币");
+
+    private final String description;
+
+    EntryModeType(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 21 - 0
src/main/java/com/izouma/nineth/enums/GameModeType.java

@@ -0,0 +1,21 @@
+package com.izouma.nineth.enums;
+
+
+public enum GameModeType {
+
+    BRONZE("青铜"),
+
+    SILVER("白银"),
+
+    GOLD("黄金");
+
+    private final String description;
+
+    GameModeType(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 17 - 0
src/main/java/com/izouma/nineth/enums/MetaGameType.java

@@ -0,0 +1,17 @@
+package com.izouma.nineth.enums;
+
+
+public enum MetaGameType {
+
+    ZOMBIE("僵尸游戏");
+
+    private final String description;
+
+    MetaGameType(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

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

@@ -15,7 +15,7 @@ public interface MetaAdvertRecordRepo extends JpaRepository<MetaAdvertRecord, Lo
     @Transactional
     void softDelete(Long id);
 
-    MetaAdvertRecord findByApplicationAndPublishAndDel(int application, boolean used, boolean del);
+    MetaAdvertRecord findByApplicationAndPublishAndDel(int application, boolean publish, boolean del);
 
     List<MetaAdvertRecord> findByPublishAndDel(boolean used, boolean del);
 }

+ 21 - 0
src/main/java/com/izouma/nineth/repo/MetaGameRepo.java

@@ -0,0 +1,21 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.MetaGame;
+import com.izouma.nineth.enums.GameModeType;
+import com.izouma.nineth.enums.MetaGameType;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.transaction.Transactional;
+
+public interface MetaGameRepo extends JpaRepository<MetaGame, Long>, JpaSpecificationExecutor<MetaGame> {
+    @Query("update MetaGame t set t.del = true where t.id = ?1")
+    @Modifying
+    @Transactional
+    void softDelete(Long id);
+
+    MetaGame findByNameAndGameModeTypeAndPublishAndDel(MetaGameType name, GameModeType gameModeType, boolean publish, boolean del);
+
+}

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

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

+ 5 - 3
src/main/java/com/izouma/nineth/web/MetaAdvertRecordController.java

@@ -28,9 +28,11 @@ public class MetaAdvertRecordController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MetaAdvertRecord save(@RequestBody MetaAdvertRecord record) {
-        MetaAdvertRecord metaAdvertRecord = metaAdvertRecordRepo.findByApplicationAndPublishAndDel(record.getApplication(), true, false);
-        if (Objects.nonNull(metaAdvertRecord) && !Objects.equals(metaAdvertRecord.getId(), record.getId())) {
-            throw new BusinessException("当前用途下已存在发布状态的广告!");
+        if(record.isPublish()) {
+            MetaAdvertRecord metaAdvertRecord = metaAdvertRecordRepo.findByApplicationAndPublishAndDel(record.getApplication(), true, false);
+            if (Objects.nonNull(metaAdvertRecord) && !Objects.equals(metaAdvertRecord.getId(), record.getId())) {
+                throw new BusinessException("当前用途下已存在发布状态的广告!");
+            }
         }
         if (record.getId() != null) {
             MetaAdvertRecord orig = metaAdvertRecordRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));

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

@@ -34,9 +34,11 @@ public class MetaDestroyActivityController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MetaDestroyActivity save(@RequestBody MetaDestroyActivity record) {
-        MetaDestroyActivity metaDestroyActivity = metaDestroyActivityRepo.findByApplicationAndDelAndPublish(record.getApplication(), false, true);
-        if (Objects.nonNull(metaDestroyActivity) && !Objects.equals(metaDestroyActivity.getId(), record.getId())) {
-            throw new BusinessException("该用途已经发布过相关配置!");
+        if (record.isPublish()) {
+            MetaDestroyActivity metaDestroyActivity = metaDestroyActivityRepo.findByApplicationAndDelAndPublish(record.getApplication(), false, true);
+            if (Objects.nonNull(metaDestroyActivity) && !Objects.equals(metaDestroyActivity.getId(), record.getId())) {
+                throw new BusinessException("该用途已经发布过相关配置!");
+            }
         }
         if (record.getId() != null) {
             MetaDestroyActivity orig = metaDestroyActivityRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));

+ 67 - 0
src/main/java/com/izouma/nineth/web/MetaGameController.java

@@ -0,0 +1,67 @@
+package com.izouma.nineth.web;
+
+import com.izouma.nineth.domain.MetaGame;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.MetaGameRepo;
+import com.izouma.nineth.service.MetaGameService;
+import com.izouma.nineth.utils.ObjUtils;
+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;
+import java.util.Objects;
+
+@RestController
+@RequestMapping("/metaGame")
+@AllArgsConstructor
+public class MetaGameController extends BaseController {
+    private MetaGameService metaGameService;
+    private MetaGameRepo metaGameRepo;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/save")
+    public MetaGame save(@RequestBody MetaGame record) {
+        if (record.isPublish()) {
+            MetaGame metaGame = metaGameRepo.findByNameAndGameModeTypeAndPublishAndDel(record.getName(), record.getGameModeType(), true, false);
+            if (Objects.nonNull(metaGame) && !Objects.equals(metaGame.getId(), record.getId())) {
+                throw new BusinessException("已为该游戏配置过该模式参数!");
+            }
+        }
+        if (record.getId() != null) {
+            MetaGame orig = metaGameRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
+            ObjUtils.merge(orig, record);
+            return metaGameRepo.save(orig);
+        }
+        return metaGameRepo.save(record);
+    }
+
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<MetaGame> all(@RequestBody PageQuery pageQuery) {
+        return metaGameService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public MetaGame get(@PathVariable Long id) {
+        return metaGameRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @PostMapping("/del/{id}")
+    public void del(@PathVariable Long id) {
+        metaGameRepo.softDelete(id);
+    }
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<MetaGame> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+}
+

文件差異過大導致無法顯示
+ 0 - 0
src/main/resources/genjson/MetaGame.json


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

@@ -1260,6 +1260,22 @@ const router = new Router({
                     meta: {
                        title: '元宇宙展厅藏品',
                     },
+               },
+                {
+                    path: '/metaGameEdit',
+                    name: 'MetaGameEdit',
+                    component: () => import(/* webpackChunkName: "metaGameEdit" */ '@/views/MetaGameEdit.vue'),
+                    meta: {
+                       title: '元宇宙游戏模式配置编辑',
+                    },
+                },
+                {
+                    path: '/metaGameList',
+                    name: 'MetaGameList',
+                    component: () => import(/* webpackChunkName: "metaGameList" */ '@/views/MetaGameList.vue'),
+                    meta: {
+                       title: '元宇宙游戏模式配置',
+                    },
                }
                 /**INSERT_LOCATION**/
             ]
@@ -1320,4 +1336,4 @@ router.beforeEach((to, from, next) => {
     }
 });
 
-export default router;
+export default router;

+ 12 - 3
src/main/vue/src/views/MetaDestroyActivityList.vue

@@ -43,9 +43,7 @@
 			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="collectionName" label="藏品名称"> </el-table-column>
-			<el-table-column prop="num" label="藏品数量" width="80" align="center"> </el-table-column>
+			<el-table-column prop="id" label="ID" width="100"> </el-table-column>	
 			<el-table-column prop="detail" label="详情"> </el-table-column>
 			<el-table-column prop="awardPic" label="奖励图片">
 				<template slot-scope="{ row }">
@@ -64,6 +62,17 @@
                     <el-tag type="success" v-else>自动</el-tag>
                 </template>
             </el-table-column>
+			<el-table-column prop="collectionName" label="藏品名称"> </el-table-column>
+			<el-table-column prop="rule" label="藏品规则">
+				<template v-slot="{ row }">
+					<template v-if="row.rule">
+						<div v-for="item in row.rule.tags" :key="item.id">
+							{{ item.name }}
+						</div>
+					</template>
+				</template>
+			</el-table-column>
+			<el-table-column prop="num" label="藏品数量" width="80" align="center"> </el-table-column>
             <el-table-column prop="application" label="用途"> </el-table-column>
 			<el-table-column prop="publish" label="是否发布">
 				<template slot-scope="{ row }">

+ 300 - 0
src/main/vue/src/views/MetaGameEdit.vue

@@ -0,0 +1,300 @@
+<template>
+	<div class="edit-view">
+		<page-title>
+			<el-button @click="$router.go(-1)" :disabled="saving"> 取消 </el-button>
+			<el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id"> 删除 </el-button>
+			<el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
+		</page-title>
+		<div class="edit-view__content-wrapper">
+			<div class="edit-view__content-section">
+				<el-form
+					:model="formData"
+					:rules="rules"
+					ref="form"
+					label-width="108px"
+					label-position="right"
+					size="small"
+					style="max-width: 500px"
+				>
+                <el-form-item prop="name" label="游戏">
+						<el-select v-model="formData.name" clearable filterable placeholder="请选择">
+							<el-option
+								v-for="item in gameNameOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+					<el-form-item prop="gameModeType" label="游戏模式">
+						<el-select v-model="formData.gameModeType" clearable filterable placeholder="请选择">
+							<el-option
+								v-for="item in gameModeTypeOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+					<el-form-item prop="entryModeType" label="入场方式">
+						<el-select v-model="formData.entryModeType" clearable filterable placeholder="请选择">
+							<el-option
+								v-for="item in entryModeTypeOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+                    <el-form-item prop="goldNum" label="所需金币数量" v-if="formData.entryModeType === 'GOLD'">
+                        <el-input-number type="goldNum" v-model="formData.goldNum"> </el-input-number>
+                    </el-form-item>
+					<el-form-item prop="audit" label="是否需要审核" v-if="formData.entryModeType === 'NFT'">
+                        <el-radio-group v-model="formData.audit">
+                            <el-radio :label="true"> 人工审核 </el-radio>
+                            <el-radio :label="false"> 自动匹配 </el-radio>
+                        </el-radio-group>
+                    </el-form-item>
+                    <el-form-item prop="collectionName" label="藏品名称" v-if="formData.entryModeType === 'NFT' && formData.audit === true">
+                        <el-input v-model="formData.collectionName" :disabled="!canEdit" class="width"> </el-input>
+                    </el-form-item>
+                    <el-form-item prop="rule" label="匹配规则设置" v-if="formData.entryModeType === 'NFT' && formData.audit === false">
+                        <template v-if="formData.rule && formData.rule.and">
+                            <div v-for="(item, i) in formData.rule.and" class="rule-item">
+                                <el-select v-model="item.detail.tag" value-key="id" size="mini">
+                                    <el-option v-for="item in tags" :key="item.id" :value="item" :label="item.name">
+                                    </el-option>
+                                </el-select>
+                                <span style="padding: 0 10px; color: #606266; font-weight: bold"> ×&nbsp;1 </span>
+                                <i @click="delRule(i)" class="el-icon-delete icon-del"> </i>
+                            </div>
+                        </template>
+                        <el-button size="mini" @click="addRule"> 添加 </el-button>
+                    </el-form-item>
+                    <el-form-item prop="num" label="所需nft数量" v-if="formData.entryModeType === 'NFT'">
+                        <el-input-number
+                            type="number"
+                            v-model="formData.num"
+                            :disabled="!canEdit"
+                            :step="1"
+                            :min="0"
+                            class="width1"
+                        >
+                        </el-input-number>
+                        <div class="tip">0表示不限</div>
+                    </el-form-item>
+                    <el-form-item prop="publish" label="是否发布">
+						<el-switch v-model="formData.publish"> </el-switch>
+					</el-form-item>
+					<el-form-item class="form-submit">
+						<el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
+						<el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
+							删除
+						</el-button>
+						<el-button @click="$router.go(-1)" :disabled="saving"> 取消 </el-button>
+					</el-form-item>
+				</el-form>
+			</div>
+		</div>
+	</div>
+</template>
+<script>
+export default {
+	name: 'MetaGameEdit',
+	created() {
+		if (this.$route.query.id) {
+			this.$http
+				.get('metaGame/get/' + this.$route.query.id)
+				.then(res => {
+					this.formData = res;
+				})
+				.catch(e => {
+					console.log(e);
+					this.$message.error(e.error);
+				});
+		}
+        this.$http.post('/tag/all', { size: 10000 }, { body: 'json' }).then(res => {
+            this.tags = res.content;
+        });
+	},
+	data() {
+		return {
+            tags: [],
+			saving: false,
+			formData: {},
+			rules: {
+				name: [
+					{
+						required: true,
+						message: '请输入游戏名称',
+						trigger: 'blur'
+					}
+				],
+				gameModeType: [
+					{
+						required: true,
+						message: '请输入游戏模式',
+						trigger: 'blur'
+					}
+				],
+				entryModeType: [
+					{
+						required: true,
+						message: '请输入入场方式',
+						trigger: 'blur'
+					}
+				],
+				goldNum: [
+					{
+						required: true,
+						message: '请输入所需金币数量',
+						trigger: 'blur'
+					}
+				],
+				rule: [
+                    { required: true, message: '请选择规则', trigger: 'blur' },
+                    {
+                        validator: (rule, value, callback) => {
+                            if (!this.formData.audit) {
+                                if (!this.formData.rule) {
+                                    callback(new Error('请填写规则'));
+                                } else if (!this.formData.rule.and) {
+                                    callback(new Error('请填写规则'));
+                                } else if (!this.formData.rule.and.length) {
+                                    callback(new Error('请填写规则'));
+                                } else {
+                                    for (let i = 0; i < this.formData.rule.and.length; i++) {
+                                        if (
+                                            !(this.formData.rule.and[i].detail && this.formData.rule.and[i].detail.tag)
+                                        ) {
+                                            callback(new Error('请选择'));
+                                            callback = null;
+                                            break;
+                                        }
+                                    }
+                                    if (callback) {
+                                        callback();
+                                    }
+                                }
+                            } else {
+                                callback();
+                            }
+                        }
+                    }
+                ],
+				audit: [
+					{
+						required: true,
+						message: '请输入是否审核',
+						trigger: 'blur'
+					}
+				],
+				collectionName: [
+					{
+						required: true,
+						message: '请输入藏品名称',
+						trigger: 'blur'
+					}
+				],
+				num: [
+					{
+						required: true,
+						message: '请输入所需nft数量',
+						trigger: 'blur'
+					}
+				]
+			},
+            gameNameOptions: [
+				{ label: '僵尸', value: 'ZOMBIE' }
+			],
+			gameModeTypeOptions: [
+				{ label: '青铜', value: 'BRONZE' },
+				{ label: '白银', value: 'SILVER' },
+				{ label: '黄金', value: 'GOLD' }
+			],
+			entryModeTypeOptions: [
+				{ label: 'NFT', value: 'NFT' },
+				{ label: '金币', value: 'GOLD' }
+			]
+		};
+	},
+    computed: {
+        canEdit() {
+            return !!!this.$route.query.id;
+        }
+    },
+	methods: {
+		onSave() {
+			this.$refs.form.validate(valid => {
+				if (valid) {
+					this.submit();
+				} else {
+					return false;
+				}
+			});
+		},
+		submit() {
+			let data = { ...this.formData };
+
+			this.saving = true;
+			this.$http
+				.post('/metaGame/save', data, { body: 'json' })
+				.then(res => {
+					this.saving = false;
+					this.$message.success('成功');
+					this.$router.go(-1);
+				})
+				.catch(e => {
+					console.log(e);
+					this.saving = false;
+					this.$message.error(e.error);
+				});
+		},
+		onDelete() {
+			this.$confirm('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+				.then(() => {
+					return this.$http.post(`/metaGame/del/${this.formData.id}`);
+				})
+				.then(() => {
+					this.$message.success('删除成功');
+					this.$router.go(-1);
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						console.log(e);
+						this.$message.error((e || {}).error || '删除失败');
+					}
+				});
+		},
+        addRule() {
+            if (!(this.formData.rule && this.formData.rule.and)) {
+                this.$set(this.formData, 'rule', { and: [] });
+            }
+            this.formData.rule.and.push({ detail: { tag: null, num: 1 } });
+        },
+        delRule(i) {
+            this.formData.rule.and.splice(i, 1);
+        }
+	}
+};
+</script>
+<style lang="less" scoped>
+.width1 {
+	width: 150px;
+}
+
+.rule-item {
+	display: flex;
+	align-items: center;
+	margin-bottom: 10px;
+
+	.icon-del {
+		color: #f56c6c;
+		cursor: pointer;
+		font-size: 18px;
+	}
+}
+</style>

+ 220 - 0
src/main/vue/src/views/MetaGameList.vue

@@ -0,0 +1,220 @@
+<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="name" label="游戏名称"> </el-table-column>
+			<el-table-column prop="gameModeType" label="游戏模式" :formatter="gameModeTypeFormatter"> </el-table-column>
+			<el-table-column prop="entryModeType" label="入场方式" :formatter="entryModeTypeFormatter">
+			</el-table-column>
+			<el-table-column prop="goldNum" label="所需金币数量"> </el-table-column>
+			<el-table-column prop="rule" label="藏品规则">
+				<template v-slot="{ row }">
+					<template v-if="row.rule">
+						<div v-for="item in row.rule.tags" :key="item.id">
+							{{ item.name }}
+						</div>
+					</template>
+				</template>
+			</el-table-column>
+			<el-table-column prop="audit" label="审核" width="80" align="center">
+				<template v-slot="{ row }">
+					<template v-if="row.entryModeType === 'NFT'">
+						<el-tag type="warning" v-if="row.audit"> 人工 </el-tag>
+						<el-tag type="success" v-else> 自动 </el-tag>
+					</template>
+				</template>
+			</el-table-column>
+			<el-table-column prop="collectionName" label="藏品名称"> </el-table-column>
+			<el-table-column prop="num" label="所需nft数量"> </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">
+			<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: 'MetaGameList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			multipleMode: false,
+			search: '',
+			url: '/metaGame/all',
+			downloading: false,
+			gameModeTypeOptions: [
+				{ label: '青铜', value: 'BRONZE' },
+				{ label: '白银', value: 'SILVER' },
+				{ label: '黄金', value: 'GOLD' }
+			],
+			entryModeTypeOptions: [
+				{ label: 'NFT', value: 'NFT' },
+				{ label: '金币', value: 'GOLD' }
+			]
+		};
+	},
+	computed: {
+		selection() {
+			return this.$refs.table.selection.map(i => i.id);
+		}
+	},
+	methods: {
+		gameModeTypeFormatter(row, column, cellValue, index) {
+			let selectedOption = this.gameModeTypeOptions.find(i => i.value === cellValue);
+			if (selectedOption) {
+				return selectedOption.label;
+			}
+			return '';
+		},
+		entryModeTypeFormatter(row, column, cellValue, index) {
+			let selectedOption = this.entryModeTypeOptions.find(i => i.value === cellValue);
+			if (selectedOption) {
+				return selectedOption.label;
+			}
+			return '';
+		},
+		beforeGetData() {
+			return { search: this.search, query: { del: false } };
+		},
+		toggleMultipleMode(multipleMode) {
+			this.multipleMode = multipleMode;
+			if (!multipleMode) {
+				this.$refs.table.clearSelection();
+			}
+		},
+		addRow() {
+			this.$router.push({
+				path: '/metaGameEdit',
+				query: {
+					...this.$route.query
+				}
+			});
+		},
+		editRow(row) {
+			this.$router.push({
+				path: '/metaGameEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		download() {
+			this.downloading = true;
+			this.$axios
+				.get('/metaGame/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(`/metaGame/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>

+ 195 - 195
src/main/vue/src/views/MetaTaskEdit.vue

@@ -1,203 +1,203 @@
 <template>
-    <div class="edit-view">
-        <page-title>
-            <el-button @click="$router.go(-1)" :disabled="saving"> 取消 </el-button>
-            <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id"> 删除 </el-button>
-            <el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
-        </page-title>
-        <div class="edit-view__content-wrapper">
-            <div class="edit-view__content-section">
-                <el-form
-                    :model="formData"
-                    :rules="rules"
-                    ref="form"
-                    label-width="130px"
-                    label-position="right"
-                    size="small"
-                    style="max-width: 500px"
-                >
-                    <el-form-item prop="name" label="任务名称">
-                        <el-input v-model="formData.name"> </el-input>
-                    </el-form-item>
-                    <el-form-item prop="detail" label="详情" style="width: calc(100vw - 450px)">
-                        <el-input
-                            v-model="formData.detail"
-                            type="textarea"
-                            :autosize="{ minRows: 3, maxRows: 20 }"
-                            placeholder="请输入任务详情"
-                        >
-                        </el-input>
-                    </el-form-item>
-                    <el-form-item prop="awardPic" label="奖励图片">
-                        <single-upload v-model="formData.awardPic"> </single-upload>
-                    </el-form-item>
-                    <el-form-item prop="type" label="任务类型">
-                        <el-select v-model="formData.type" clearable filterable placeholder="请选择" @change="change">
-                            <el-option
-                                v-for="item in typeOptions"
-                                :key="item.value"
-                                :label="item.label"
-                                :value="item.value"
-                            >
-                            </el-option>
-                        </el-select>
-                    </el-form-item>
-                    <template v-if="formData.type">
-                        <el-form-item v-if="formData.type === 'SIGN_IN_SINGLE_DAY'" prop="value" label="签到日期">
-                            <el-date-picker
-                                v-model="formData.value"
-                                type="date"
-                                value-format="yyyy-MM-dd"
-                                placeholder="指定签到日期"
-                            >
-                            </el-date-picker>
-                        </el-form-item>
-                        <el-form-item v-if="formData.type === 'SIGN_IN_CONTINUOUS'" prop="value" label="开始日期">
-                            <el-date-picker
-                                v-model="formData.value"
-                                type="date"
-                                value-format="yyyy-MM-dd"
-                                placeholder="指定开始日期"
-                            >
-                            </el-date-picker>
-                        </el-form-item>
-                        <el-form-item prop="value" label="藏品id" v-if="formData.type === 'COLLECT_COLLECTION'">
-                            <el-input v-model="formData.value" placeholder="请输入定藏品id"> </el-input>
-                            <div class="tip">多个藏品id请用空格隔开 例如 111 222 333</div>
-                        </el-form-item>
-                        <el-form-item prop="value" label="次数" v-if="formData.type === 'ACCUMULATE'">
-                            <el-input-number v-model="formData.value" :min="0"> </el-input-number>
-                        </el-form-item>
-                        <el-form-item prop="value" label="在线时长(min)" v-if="formData.type === 'ON_LINE_TIME_DAILY'">
-                            <el-input-number v-model="formData.value" :min="0"> </el-input-number>
-                        </el-form-item>
-                    </template>
-                    <el-form-item prop="publish" label="是否发布">
-                        <el-switch v-model="formData.publish"> </el-switch>
-                    </el-form-item>
-                    <el-form-item prop="mark" label="是否展示角标">
-                        <el-switch v-model="formData.mark"> </el-switch>
-                    </el-form-item>
-                    <el-form-item class="form-submit">
-                        <el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
-                        <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
-                            删除
-                        </el-button>
-                        <el-button @click="$router.go(-1)" :disabled="saving"> 取消 </el-button>
-                    </el-form-item>
-                </el-form>
-            </div>
-        </div>
-    </div>
+	<div class="edit-view">
+		<page-title>
+			<el-button @click="$router.go(-1)" :disabled="saving"> 取消 </el-button>
+			<el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id"> 删除 </el-button>
+			<el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
+		</page-title>
+		<div class="edit-view__content-wrapper">
+			<div class="edit-view__content-section">
+				<el-form
+					:model="formData"
+					:rules="rules"
+					ref="form"
+					label-width="130px"
+					label-position="right"
+					size="small"
+					style="max-width: 500px"
+				>
+					<el-form-item prop="name" label="任务名称">
+						<el-input v-model="formData.name"> </el-input>
+					</el-form-item>
+					<el-form-item prop="detail" label="详情" style="width: calc(100vw - 450px)">
+						<el-input
+							v-model="formData.detail"
+							type="textarea"
+							:autosize="{ minRows: 3, maxRows: 20 }"
+							placeholder="请输入任务详情"
+						>
+						</el-input>
+					</el-form-item>
+					<el-form-item prop="awardPic" label="奖励图片">
+						<single-upload v-model="formData.awardPic"> </single-upload>
+					</el-form-item>
+					<el-form-item prop="type" label="任务类型">
+						<el-select v-model="formData.type" clearable filterable placeholder="请选择" @change="change">
+							<el-option
+								v-for="item in typeOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+					<template v-if="formData.type">
+						<el-form-item v-if="formData.type === 'SIGN_IN_SINGLE_DAY'" prop="value" label="签到日期">
+							<el-date-picker
+								v-model="formData.value"
+								type="date"
+								value-format="yyyy-MM-dd"
+								placeholder="指定签到日期"
+							>
+							</el-date-picker>
+						</el-form-item>
+						<el-form-item v-if="formData.type === 'SIGN_IN_CONTINUOUS'" prop="value" label="开始日期">
+							<el-date-picker
+								v-model="formData.value"
+								type="date"
+								value-format="yyyy-MM-dd"
+								placeholder="指定开始日期"
+							>
+							</el-date-picker>
+						</el-form-item>
+						<el-form-item prop="value" label="藏品id" v-if="formData.type === 'COLLECT_COLLECTION'">
+							<el-input v-model="formData.value" placeholder="请输入定藏品id"> </el-input>
+							<div class="tip">多个藏品id请用空格隔开 例如 111 222 333</div>
+						</el-form-item>
+						<el-form-item prop="value" label="次数" v-if="formData.type === 'ACCUMULATE'">
+							<el-input-number v-model="formData.value" :min="0"> </el-input-number>
+						</el-form-item>
+						<el-form-item prop="value" label="在线时长(min)" v-if="formData.type === 'ON_LINE_TIME_DAILY'">
+							<el-input-number v-model="formData.value" :min="0"> </el-input-number>
+						</el-form-item>
+					</template>
+					<el-form-item prop="publish" label="是否发布">
+						<el-switch v-model="formData.publish"> </el-switch>
+					</el-form-item>
+					<el-form-item prop="mark" label="是否展示角标">
+						<el-switch v-model="formData.mark"> </el-switch>
+					</el-form-item>
+					<el-form-item class="form-submit">
+						<el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
+						<el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
+							删除
+						</el-button>
+						<el-button @click="$router.go(-1)" :disabled="saving"> 取消 </el-button>
+					</el-form-item>
+				</el-form>
+			</div>
+		</div>
+	</div>
 </template>
 <script>
 export default {
-    name: 'MetaTaskEdit',
-    created() {
-        if (this.$route.query.id) {
-            this.$http
-                .get('metaTask/get/' + this.$route.query.id)
-                .then(res => {
-                    this.formData = res;
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.$message.error(e.error);
-                });
-        }
-    },
-    data() {
-        return {
-            saving: false,
-            formData: {},
-            rules: {
-                name: [
-                    {
-                        required: true,
-                        message: '请输入任务名称',
-                        trigger: 'blur'
-                    }
-                ],
-                description: [
-                    {
-                        required: true,
-                        message: '请输入任务详情',
-                        trigger: 'blur'
-                    }
-                ],
-                type: [
-                    {
-                        required: true,
-                        message: '请输入任务类型',
-                        trigger: 'blur'
-                    }
-                ],
-                value: [
-                    {
-                        required: true,
-                        message: '请指定参数配置',
-                        trigger: 'blur'
-                    }
-                ]
-            },
-            typeOptions: [
-                { label: '单日签到', value: 'SIGN_IN_SINGLE_DAY' },
-                { label: '连续多日签到', value: 'SIGN_IN_CONTINUOUS' },
-                { label: '收集藏品', value: 'COLLECT_COLLECTION' },
-                { label: '每日在线时长', value: 'ON_LINE_TIME_DAILY' },
-                { label: '累计', value: 'ACCUMULATE' }
-            ]
-        };
-    },
-    methods: {
-        change() {
-            if (this.formData.value) {
-                this.formData.value = undefined;
-            }
-        },
-        onSave() {
-            this.$refs.form.validate(valid => {
-                if (valid) {
-                    this.submit();
-                } else {
-                    return false;
-                }
-            });
-        },
-        submit() {
-            let data = { ...this.formData };
+	name: 'MetaTaskEdit',
+	created() {
+		if (this.$route.query.id) {
+			this.$http
+				.get('metaTask/get/' + this.$route.query.id)
+				.then(res => {
+					this.formData = res;
+				})
+				.catch(e => {
+					console.log(e);
+					this.$message.error(e.error);
+				});
+		}
+	},
+	data() {
+		return {
+			saving: false,
+			formData: {},
+			rules: {
+				name: [
+					{
+						required: true,
+						message: '请输入任务名称',
+						trigger: 'blur'
+					}
+				],
+				detail: [
+					{
+						required: true,
+						message: '请输入任务详情',
+						trigger: 'blur'
+					}
+				],
+				type: [
+					{
+						required: true,
+						message: '请输入任务类型',
+						trigger: 'blur'
+					}
+				],
+				value: [
+					{
+						required: true,
+						message: '请指定参数配置',
+						trigger: 'blur'
+					}
+				]
+			},
+			typeOptions: [
+				{ label: '单日签到', value: 'SIGN_IN_SINGLE_DAY' },
+				{ label: '连续多日签到', value: 'SIGN_IN_CONTINUOUS' },
+				{ label: '收集藏品', value: 'COLLECT_COLLECTION' },
+				{ label: '每日在线时长', value: 'ON_LINE_TIME_DAILY' },
+				{ label: '累计', value: 'ACCUMULATE' }
+			]
+		};
+	},
+	methods: {
+		change() {
+			if (this.formData.value) {
+				this.formData.value = undefined;
+			}
+		},
+		onSave() {
+			this.$refs.form.validate(valid => {
+				if (valid) {
+					this.submit();
+				} else {
+					return false;
+				}
+			});
+		},
+		submit() {
+			let data = { ...this.formData };
 
-            this.saving = true;
-            this.$http
-                .post('/metaTask/save', data, { body: 'json' })
-                .then(res => {
-                    this.saving = false;
-                    this.$message.success('成功');
-                    this.$router.go(-1);
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.saving = false;
-                    this.$message.error(e.error);
-                });
-        },
-        onDelete() {
-            this.$confirm('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
-                .then(() => {
-                    return this.$http.post(`/metaTask/del/${this.formData.id}`);
-                })
-                .then(() => {
-                    this.$message.success('删除成功');
-                    this.$router.go(-1);
-                })
-                .catch(e => {
-                    if (e !== 'cancel') {
-                        console.log(e);
-                        this.$message.error((e || {}).error || '删除失败');
-                    }
-                });
-        }
-    }
+			this.saving = true;
+			this.$http
+				.post('/metaTask/save', data, { body: 'json' })
+				.then(res => {
+					this.saving = false;
+					this.$message.success('成功');
+					this.$router.go(-1);
+				})
+				.catch(e => {
+					console.log(e);
+					this.saving = false;
+					this.$message.error(e.error);
+				});
+		},
+		onDelete() {
+			this.$confirm('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+				.then(() => {
+					return this.$http.post(`/metaTask/del/${this.formData.id}`);
+				})
+				.then(() => {
+					this.$message.success('删除成功');
+					this.$router.go(-1);
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						console.log(e);
+						this.$message.error((e || {}).error || '删除失败');
+					}
+				});
+		}
+	}
 };
 </script>
 <style lang="less" scoped>

部分文件因文件數量過多而無法顯示