Quellcode durchsuchen

元宇宙万岛相关协议

sunkean vor 3 Jahren
Ursprung
Commit
719d0e1f61

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

@@ -3,6 +3,7 @@ package com.izouma.nineth.domain;
 import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.izouma.nineth.converter.CoordinateConverter;
+import com.izouma.nineth.converter.StringArrayConverter;
 import com.izouma.nineth.dto.CoordinateDTO;
 import com.izouma.nineth.enums.MetaIsLandTypeEnum;
 import io.swagger.annotations.ApiModel;
@@ -12,6 +13,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.persistence.*;
+import java.util.List;
 
 @Data
 @AllArgsConstructor
@@ -35,6 +37,10 @@ public class MetaBoatPosition extends BaseEntity {
     @Convert(converter = CoordinateConverter.class)
     private CoordinateDTO boatRot;
 
+    @Column(columnDefinition = "TEXT")
+    @Convert(converter = StringArrayConverter.class)
+    private List<String> boatType;
+
     @Transient
     @ExcelIgnore
     private MetaSpatialWharf boatInfo;

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

@@ -137,6 +137,6 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     @Query("select count(id) from Asset where name like ?1 and status = 'NORMAL' and ownerId <> 1435297")
     Long countNameLikeNotDestroyed(String name);
 
-    @Query(value = "select * from asset where name like ?1 and status in ?2 and id not in ?3 and del = false", nativeQuery = true)
-    List<Asset> findAllBoats(String name, List<AssetStatus> status, List<Long> boatIds);
+    @Query(value = "select a from Asset a where a.userId = ?6 and a.name like ?1 and a.name like ?4 and a.name not like ?5 and a.status in ?2 and a.id not in ?3 and a.del = false")
+    List<Asset> findAllBoats(String name, List<AssetStatus> status, List<Long> boatIds, String like, String unLike, Long userId);
 }

+ 35 - 16
src/main/java/com/izouma/nineth/service/MetaSpatialWharfService.java

@@ -6,12 +6,12 @@ import com.izouma.nineth.domain.MetaSpatialWharf;
 import com.izouma.nineth.dto.MetaBoatDTO;
 import com.izouma.nineth.dto.MetaRestResult;
 import com.izouma.nineth.dto.PageQuery;
-import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.AssetRepo;
 import com.izouma.nineth.repo.MetaSpatialWharfRepo;
 import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import lombok.AllArgsConstructor;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
@@ -28,6 +28,8 @@ public class MetaSpatialWharfService {
 
     private AssetRepo assetRepo;
 
+    private final String BOAT_NAME = "%僵尸%";
+
     public Page<MetaSpatialWharf> all(PageQuery pageQuery) {
         return metaSpatialWharfRepo.findAll(JpaUtils.toSpecification(pageQuery, MetaSpatialWharf.class), JpaUtils.toPageRequest(pageQuery));
     }
@@ -67,7 +69,9 @@ public class MetaSpatialWharfService {
             return MetaRestResult.returnError(String.format("藏品[%S]不存在", metaSpatialWharf.getBoatId()));
         }
         metaSpatialWharf.setBoatImg(asset.getPic().get(0).getUrl());
-        return MetaRestResult.returnSuccess("停靠成功", metaSpatialWharfRepo.save(metaSpatialWharf));
+        MetaSpatialWharf save = metaSpatialWharfRepo.save(metaSpatialWharf);
+        save.setMeUse(true);
+        return MetaRestResult.returnSuccess("停靠成功", save);
     }
 
     private String getRarityType(String name) {
@@ -92,21 +96,36 @@ public class MetaSpatialWharfService {
         return null;
     }
 
-    public MetaRestResult<List<MetaBoatDTO>> queryBoats() {
-        List<Long> parkingBoatIds = metaSpatialWharfRepo.findParkingBoatIds(SecurityUtils.getAuthenticatedUser().getId());
-        List<Asset> assets = assetRepo.findAllBoats("僵尸动物园", Constants.META_NORMAL_STATUS, parkingBoatIds);
-        List<MetaBoatDTO> metaBoatDTOS = new ArrayList<>();
-        try {
-            assets.forEach(asset -> {
-                String rarityType = getRarityType(asset.getName());
-                if (StringUtils.isBlank(rarityType)) {
-                    throw new BusinessException("船只类型查询失败!");
-                }
-                metaBoatDTOS.add(new MetaBoatDTO(asset.getId(), asset.getPic().get(0).getUrl(), rarityType));
-            });
-        } catch (Exception e) {
-            return MetaRestResult.returnError(e.getMessage());
+    public MetaRestResult<List<MetaBoatDTO>> queryBoats(List<String> boatTypes) {
+        if (CollectionUtils.isEmpty(boatTypes)) {
+            return MetaRestResult.returnError("船只类型为空");
         }
+        List<MetaBoatDTO> metaBoatDTOS = new ArrayList<>();
+        boatTypes.forEach(type -> {
+            List<Long> parkingBoatIds = metaSpatialWharfRepo.findParkingBoatIds(SecurityUtils.getAuthenticatedUser().getId());
+            List<Asset> assets = findAllBoatsByType(type, parkingBoatIds);
+            if (CollectionUtils.isNotEmpty(assets)) {
+                assets.forEach(asset -> {
+                    metaBoatDTOS.add(new MetaBoatDTO(asset.getId(), asset.getPic().get(0).getUrl(), type));
+                });
+            }
+        });
         return MetaRestResult.returnSuccess(metaBoatDTOS);
     }
+
+    private List<Asset> findAllBoatsByType(String type, List<Long> parkingBoatIds) {
+        Long id = SecurityUtils.getAuthenticatedUser().getId();
+        switch (type) {
+            case Constants.Rarity.U:
+                return assetRepo.findAllBoats(BOAT_NAME, Constants.META_NORMAL_STATUS, parkingBoatIds, Constants.Rarity.U_LIKE, Constants.Rarity.UR_LIKE, id);
+            case Constants.Rarity.SR:
+                return assetRepo.findAllBoats(BOAT_NAME, Constants.META_NORMAL_STATUS, parkingBoatIds, Constants.Rarity.SR_LIKE, Constants.Rarity.SSR_LIKE, id);
+            case Constants.Rarity.SSR:
+                return assetRepo.findAllBoats(BOAT_NAME, Constants.META_NORMAL_STATUS, parkingBoatIds, Constants.Rarity.SSR_LIKE, Constants.Rarity.U_LIKE, id);
+            case Constants.Rarity.UR:
+                return assetRepo.findAllBoats(BOAT_NAME, Constants.META_NORMAL_STATUS, parkingBoatIds, Constants.Rarity.UR_LIKE, Constants.Rarity.U_LIKE, id);
+            default:
+                return null;
+        }
+    }
 }

+ 0 - 7
src/main/java/com/izouma/nineth/web/MetaBoatPositionController.java

@@ -5,8 +5,6 @@ import com.izouma.nineth.dto.MetaRestResult;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.MetaBoatPositionRepo;
-import com.izouma.nineth.repo.MetaSpatialInfoRepo;
-import com.izouma.nineth.repo.MetaSpatialWharfRepo;
 import com.izouma.nineth.service.MetaBoatPositionService;
 import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
@@ -25,11 +23,6 @@ public class MetaBoatPositionController extends BaseController {
     private MetaBoatPositionService metaBoatPositionService;
     private MetaBoatPositionRepo metaBoatPositionRepo;
 
-    private MetaSpatialInfoRepo metaSpatialInfoRepo;
-
-    private MetaSpatialWharfRepo metaSpatialWharfRepo;
-
-
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MetaBoatPosition save(@RequestBody MetaBoatPosition record) {

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

@@ -75,8 +75,8 @@ public class MetaSpatialWharfController extends BaseController {
     }
 
     @GetMapping("/queryBoats")
-    public MetaRestResult<List<MetaBoatDTO>> queryBoatsNotParking() {
-        return metaSpatialWharfService.queryBoats();
+    public MetaRestResult<List<MetaBoatDTO>> queryBoatsNotParking(@RequestParam List<String> boatTypes) {
+        return metaSpatialWharfService.queryBoats(boatTypes);
     }
 }
 

+ 28 - 1
src/main/vue/src/views/MetaBoatPositionEdit.vue

@@ -37,6 +37,19 @@
 						<el-input v-model="formData.boatRot.y" placeholder="请输入旋转值 -> x"> </el-input>
 						<el-input v-model="formData.boatRot.z" placeholder="请输入旋转值 -> x"> </el-input>
 					</el-form-item>
+					<el-form-item prop="boatType" label="可停靠船只类型">
+						<template>
+							<el-select v-model="formData.boatType" multiple clearable filterable placeholder="请选择">
+								<el-option
+									v-for="item in boatTypeOptions"
+									:key="item.value"
+									:label="item.name"
+									:value="item.value"
+								>
+								</el-option>
+							</el-select>
+						</template>
+					</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">
@@ -85,7 +98,15 @@ export default {
 				{ label: '60000m²空间岛', value: 'SIX_THOUSAND' },
 				{ label: '90000m²空间岛', value: 'NINE_THOUSAND' }
 			],
+			boatTypeOptions: [{"name":"UR","value":"UR"},{"name":"SSR","value":"SSR"},{"name":"SR","value":"SR"},{"name":"R","value":"R"},{"name":"U","value":"U"}],
 			rules: {
+				type: [
+					{
+						required: true,
+						message: '请选择岛屿类型',
+						trigger: 'blur'
+					}
+				],
 				isLandId: [
 					{
 						required: true,
@@ -93,6 +114,13 @@ export default {
 						trigger: 'blur'
 					}
 				],
+				boatType: [
+					{
+						required: true,
+						message: '请选择可停靠船只类型',
+						trigger: 'blur'
+					}
+				],
 				boatPos: [
 					{
 						required: true,
@@ -154,7 +182,6 @@ export default {
 		},
 		submit() {
 			let data = { ...this.formData };
-
 			this.saving = true;
 			this.$http
 				.post('/metaBoatPosition/save', data, { body: 'json' })

+ 9 - 0
src/main/vue/src/views/MetaBoatPositionList.vue

@@ -55,6 +55,15 @@
 					{{ 'x=' + row.boatRot.x + ' , ' + 'y=' + row.boatRot.y + ' , ' + 'z=' + row.boatRot.z }}
 				</template>
 			</el-table-column>
+			<el-table-column align="center" prop="boatType" label="可停靠船只类型">
+                <template v-slot="{ row }">
+                    <template v-if="row.boatType">
+                        <div v-for="item in row.boatType">
+                            {{ item }}
+                        </div>
+                    </template>
+                </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>

+ 1 - 11
src/main/vue/src/views/MetaSpatialWharfList.vue

@@ -34,8 +34,8 @@
             v-loading="fetchingData"
         >
             <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
-            <el-table-column prop="id" align="center" label="ID" width="100"> </el-table-column>
             <el-table-column prop="isLandId" align="center" label="岛屿ID"> </el-table-column>
+            <el-table-column prop="metaBoatPositionId" align="center" label="船位ID"> </el-table-column>            
             <el-table-column prop="boatId" align="center" label="船只ID"> </el-table-column>
 			<el-table-column prop="userId" align="center" label="所属用户"> </el-table-column>
             <el-table-column prop="boatImg" align="center" label="船只图片">
@@ -51,16 +51,6 @@
             </el-table-column>
             <el-table-column prop="boatType" align="center" label="船只类型">
             </el-table-column>
-            <el-table-column prop="boatPos" align="center" label="位置信息">
-                <template slot-scope="{ row }">
-                    {{ 'x=' + row.boatPos.x + ' , ' + 'y=' + row.boatPos.y + ' , ' + 'z=' + row.boatPos.z }}
-                </template>
-            </el-table-column>
-            <el-table-column prop="boatRot" align="center" label="旋转值">
-                <template slot-scope="{ row }">
-                    {{ 'x=' + row.boatRot.x + ' , ' + 'y=' + row.boatRot.y + ' , ' + 'z=' + row.boatRot.z }}
-                </template>
-            </el-table-column>
         </el-table>
         <div class="pagination-wrapper">
             <el-pagination

+ 149 - 137
src/main/vue/src/views/RarityLabelEdit.vue

@@ -1,141 +1,153 @@
 <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="61px" label-position="right"
-                         size="small"
-                         style="max-width: 500px;">
-                        <el-form-item prop="name" label="name">
-                                    <el-input v-model="formData.name"></el-input>
-                        </el-form-item>
-                        <el-form-item prop="label" label="label">
-                                    <template>
-                                        <el-select v-model="formData.label" multiple clearable filterable
-                                                   placeholder="请选择">
-                                            <el-option
-                                                    v-for="item in labelOptions"
-                                                    :key="item.value"
-                                                    :label="item.name"
-                                                    :value="item.value">
-                                            </el-option>
-                                        </el-select>
-                                    </template>
-                        </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="61px"
+					label-position="right"
+					size="small"
+					style="max-width: 500px"
+				>
+					<el-form-item prop="name" label="name">
+						<el-input v-model="formData.name"> </el-input>
+					</el-form-item>
+					<el-form-item prop="label" label="label">
+						<template>
+							<el-select v-model="formData.label" multiple clearable filterable placeholder="请选择">
+								<el-option
+									v-for="item in labelOptions"
+									:key="item.value"
+									:label="item.name"
+									:value="item.value"
+								>
+								</el-option>
+							</el-select>
+						</template>
+					</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: 'RarityLabelEdit',
-        created() {
-            if (this.$route.query.id) {
-                this.$http
-                    .get('rarityLabel/get/' + this.$route.query.id)
-                    .then(res => {
-                        var label = []
-                        if (res.label) {
-                            for(var i=0;i<res.label.length;i++){
-                                label.push(res.label[i].name)
-                            }
-                            res.label = label;
-                        } else {
-                            res.label = [];
-                        }
-                        this.formData = res;
-                    })
-                    .catch(e => {
-                        console.log(e);
-                        this.$message.error(e.error);
-                    });
-            }
-        },
-        data() {
-            return {
-                saving: false,
-                formData: {
-                },
-                rules: {
-                    name: [
-                        {
-                            required: true,
-                            message: '请输入name',
-                            trigger: 'blur'
-                        },
-                    ],
-                    label: [
-                        {
-                            required: true,
-                            message: '请输入label',
-                            trigger: 'blur'
-                        },
-                    ],
-                },
-                labelOptions: [{"name":"UR","value":"UR"},{"name":"SSR","value":"SSR"},{"name":"SR","value":"SR"},{"name":"R","value":"R"},{"name":"U","value":"U"}],
-            }
-        },
-        methods: {
-            onSave() {
-                this.$refs.form.validate((valid) => {
-                    if (valid) {
-                        this.submit();
-                    } else {
-                        return false;
-                    }
-                });
-            },
-            submit() {
-                let data = {...this.formData};
-                var labels = []
-                for(var i=0;i<data.label.length;i++){
-                    labels.push({name:data.label[i], value:data.label[i]})
-                }
-                data.label = labels;
-                this.saving = true;
-                this.$http
-                    .post('/rarityLabel/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(`/rarityLabel/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 || '删除失败');
-                    }
-                })
-            },
-        }
-    }
+export default {
+	name: 'RarityLabelEdit',
+	created() {
+		if (this.$route.query.id) {
+			this.$http
+				.get('rarityLabel/get/' + this.$route.query.id)
+				.then(res => {
+					var label = [];
+					if (res.label) {
+						for (var i = 0; i < res.label.length; i++) {
+							label.push(res.label[i].name);
+						}
+						res.label = label;
+					} else {
+						res.label = [];
+					}
+					this.formData = res;
+				})
+				.catch(e => {
+					console.log(e);
+					this.$message.error(e.error);
+				});
+		}
+	},
+	data() {
+		return {
+			saving: false,
+			formData: {},
+			rules: {
+				name: [
+					{
+						required: true,
+						message: '请输入name',
+						trigger: 'blur'
+					}
+				],
+				label: [
+					{
+						required: true,
+						message: '请输入label',
+						trigger: 'blur'
+					}
+				]
+			},
+			labelOptions: [
+				{ name: 'UR', value: 'UR' },
+				{ name: 'SSR', value: 'SSR' },
+				{ name: 'SR', value: 'SR' },
+				{ name: 'R', value: 'R' },
+				{ name: 'U', value: 'U' }
+			]
+		};
+	},
+	methods: {
+		onSave() {
+			this.$refs.form.validate(valid => {
+				if (valid) {
+					this.submit();
+				} else {
+					return false;
+				}
+			});
+		},
+		submit() {
+			let data = { ...this.formData };
+			var labels = [];
+			for (var i = 0; i < data.label.length; i++) {
+				labels.push({ name: data.label[i], value: data.label[i] });
+			}
+			data.label = labels;
+			this.saving = true;
+			this.$http
+				.post('/rarityLabel/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(`/rarityLabel/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></style>
+<style lang="less" scoped>
+
+</style>