licailing 3 lat temu
rodzic
commit
bfb1b441da

+ 0 - 2
src/main/java/com/izouma/nineth/domain/ShowCollection.java

@@ -1,7 +1,5 @@
 package com.izouma.nineth.domain;
 
-import com.izouma.nineth.enums.AssetStatus;
-import com.izouma.nineth.enums.CollectionStatus;
 import io.swagger.annotations.ApiModel;
 import lombok.AllArgsConstructor;
 import lombok.Builder;

+ 2 - 0
src/main/java/com/izouma/nineth/domain/Showroom.java

@@ -75,9 +75,11 @@ public class Showroom extends BaseEntity {
     @Transient
     private boolean liked;
 
+    @Column(columnDefinition = "int(11) default 0")
     @ApiModelProperty("热力值")
     private int heats;
 
+    @Column(columnDefinition = "int(11) default 0")
     private int registers;
 
 }

+ 19 - 9
src/main/java/com/izouma/nineth/service/ShowroomService.java

@@ -135,16 +135,19 @@ public class ShowroomService {
         return showroom;
     }
 
-    public Showroom save(Long userId) {
+    public Showroom save(Long userId, String type) {
         User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("无用户"));
         if (!user.isCompany()) {
             throw new BusinessException("无用户权限");
         }
-
-        if (showroomRepo.findByUserIdAndType(user.getId(), "COMPANY").isPresent()) {
-            throw new BusinessException("已创建过展厅");
+        int maxCollection = 1;
+        if ("COMPANY".equals(type)) {
+            if (showroomRepo.findByUserIdAndType(user.getId(), "COMPANY").isPresent()) {
+                throw new BusinessException("已创建过展厅");
+            }
+            maxCollection = sysConfigService.getInt("max_collection");
         }
-        int maxCollection = sysConfigService.getInt("max_collection");
+
 
         Showroom showroom = Showroom.builder()
                 .headBg("")
@@ -153,7 +156,7 @@ public class ShowroomService {
                 .publish(false)
                 .userId(user.getId())
                 .nickname(user.getNickname())
-                .type("COMPANY")
+                .type(type)
                 .status(AuthStatus.NOT_AUTH)
                 .build();
         showroom = showroomRepo.save(showroom);
@@ -177,6 +180,7 @@ public class ShowroomService {
 
         Set<Long> removeRecord = new HashSet<>(showCollectionMap.keySet());
 
+
         if (CollUtil.isNotEmpty(showCollections)) {
             showCollections = showCollections.stream().distinct().collect(Collectors.toList());
 
@@ -192,12 +196,13 @@ public class ShowroomService {
             List<Collection> collections = collectionRepo.findAllByIdIn(collectionIds);
             Map<Long, Collection> collectionMap = new HashMap<>();
             collections.forEach(collection -> {
-                if (!userId.equals(collection.getOwnerId())) {
-                    throw new BusinessException("该藏品不属于你");
-                }
+//                if (!userId.equals(collection.getOwnerId())) {
+//                    throw new BusinessException("该藏品不属于你");
+//                }
                 collectionMap.put(collection.getId(), collection);
             });
 
+
             showCollections.forEach(coll -> {
                 if (coll.getId() != null) {
                     ShowCollection showCollection = showCollectionMap.get(coll.getId());
@@ -216,6 +221,11 @@ public class ShowroomService {
                     } else {
                         Collection collection = collectionMap.get(coll.getCollectionId());
                         if (ObjectUtils.isNotEmpty(collection)) {
+                            if ("COMPANY_BOX".equals(recordRoom.getType())) {
+                                if (!CollectionType.BLIND_BOX.equals(collection.getType())) {
+                                    throw new BusinessException("盲盒展厅,只能添加盲盒");
+                                }
+                            }
                             FileObject pic = collection.getPic().get(0);
                             coll.setPic(pic.getUrl());
                             if ("video/mp4".equals(pic.getType())) {

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

@@ -918,7 +918,8 @@ public class UserService {
 
         List<Map<String, Object>> companyBoxNums = showroomRepo.countNum("COMPANY_BOX");
         Map<Long, Integer> boxNum = new HashMap<>();
-        companyBoxNums.forEach(value -> boxNum.put((Long) value.get("user_id"), (Integer) value.get("num")));
+        companyBoxNums.forEach(value -> boxNum.put(Convert.convert(Long.class, value.get("user_id")),
+                Convert.convert(Integer.class, value.get("num"))));
         return users.map(user -> {
             CompanyDTO dto = new CompanyDTO(user);
             dto.setShowroomNum(showroomNum.get(user.getId()) == null ? 0 : showroomNum.get(user.getId()));

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

@@ -46,8 +46,8 @@ public class ShowroomController extends BaseController {
     }
 
     @PostMapping("/create")
-    public Showroom create(@RequestParam Long userId) {
-        return showroomService.save(userId);
+    public Showroom create(@RequestParam Long userId, @RequestParam String type) {
+        return showroomService.save(userId, type);
     }
 
     @PostMapping("/all")

+ 56 - 26
src/main/vue/src/views/CompanyList.vue

@@ -41,7 +41,7 @@
             <el-table-column prop="boxShowroomNum" label="盲盒展厅数量"> </el-table-column>
             <el-table-column label="操作" align="center" fixed="right" width="180">
                 <template slot-scope="{ row }">
-                    <el-button @click="chooseShowroomType" type="success" size="mini" plain>发放展厅</el-button>
+                    <el-button @click="chooseShowroomType(row)" type="success" size="mini" plain>发放展厅</el-button>
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
                 </template>
             </el-table-column>
@@ -60,7 +60,7 @@
             </el-pagination>
         </div>
         <el-dialog :visible.sync="showDialog" title="选择类型" width="500px" center>
-            <el-form :model="addShowroom" label-width="100px" size="mini">
+            <el-form :model="addShowroom" label-width="100px" size="mini" :rules="rules" ref="form">
                 <el-form-item label="发放类型" prop="type">
                     <el-radio-group v-model="addShowroom.type">
                         <el-radio label="COMPANY">普通展厅</el-radio>
@@ -89,7 +89,16 @@ export default {
             url: '/user/companyAll',
             downloading: false,
             showDialog: false,
-            addShowroom: {}
+            addShowroom: {},
+            rules: {
+                type: [
+                    {
+                        required: true,
+                        message: '请选择类型',
+                        trigger: 'blur'
+                    }
+                ]
+            }
         };
     },
     computed: {
@@ -190,29 +199,50 @@ export default {
             this.addShowroom.id = row.id;
         },
         createShowroom() {
-            this.$confirm('确认发布展厅吗?', '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-            })
-                .then(() => {
-                    return this.$http.post('/showroom/create', {
-                        userId: this.addShowroom.id,
-                        type: this.addShowroom.type
-                    });
-                })
-                .then(() => {
-                    this.saving = false;
-                    this.$message.success('成功');
-                    this.getData();
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.saving = false;
-                    if (e !== 'cancel') {
-                        this.$message.error(e.error);
-                    }
-                });
+            // this.$confirm('确认发布展厅吗?', '提示', {
+            //     confirmButtonText: '确定',
+            //     cancelButtonText: '取消',
+            //     type: 'warning'
+            // })
+            //     .then(() => {
+            //         return this.$http.post('/showroom/create', {
+            //             userId: this.addShowroom.id,
+            //             type: this.addShowroom.type
+            //         });
+            //     })
+            //     .then(() => {
+            //         this.saving = false;
+            //         this.$message.success('成功');
+            //         this.getData();
+            //     })
+            //     .catch(e => {
+            //         console.log(e);
+            //         this.saving = false;
+            //         if (e !== 'cancel') {
+            //             this.$message.error(e.error);
+            //         }
+            //     });
+            this.$refs.form.validate(valid => {
+                if (valid) {
+                    this.$http
+                        .post('/showroom/create', {
+                            userId: this.addShowroom.id,
+                            type: this.addShowroom.type
+                        })
+                        .then(() => {
+                            this.$message.success('成功');
+                            this.showDialog = false;
+                            this.getData();
+                        })
+                        .catch(e => {
+                            this.$message.error(e.error);
+                            this.showDialog = false;
+                            console.log(e);
+                        });
+                } else {
+                    return false;
+                }
+            });
         }
     }
 };

+ 12 - 8
src/main/vue/src/views/company/CompanyRoomEdit.vue

@@ -178,7 +178,7 @@ export default {
         return {
             saving: false,
             formData: {
-                showCollections: []
+                collections: []
             },
             rules: {},
             statusOptions: [
@@ -256,11 +256,15 @@ export default {
             this.formData.showroomBg = data.description;
         },
         addCollection() {
-            this.showCollectionDialog = true;
-            if (this.$refs.collectionForm) {
-                this.$nextTick(() => {
-                    this.$refs.collectionForm.clearValidate();
-                });
+            if (this.formData.collections.length >= this.formData.maxCollection) {
+                this.$message.error('最多只能添加' + this.formData.maxCollection + '个!');
+            } else {
+                this.showCollectionDialog = true;
+                if (this.$refs.collectionForm) {
+                    this.$nextTick(() => {
+                        this.$refs.collectionForm.clearValidate();
+                    });
+                }
             }
         },
         delCollection(index) {
@@ -295,8 +299,8 @@ export default {
                 .catch(() => {});
         },
         preview() {
-            let url = "/9th/hall?id=" + this.formData.id;
-            window.open(url); 
+            let url = '/9th/hall?id=' + this.formData.id;
+            window.open(url);
         }
     }
 };