Parcourir la source

删除websocket相关内容,新增道具相关

sunkean il y a 2 ans
Parent
commit
d16c33cf7c
26 fichiers modifiés avec 896 ajouts et 784 suppressions
  1. 0 15
      src/main/java/com/izouma/nineth/config/WebSocketConfig.java
  2. 7 43
      src/main/java/com/izouma/nineth/domain/MetaMMOLoginInfo.java
  3. 40 0
      src/main/java/com/izouma/nineth/domain/MetaUserProp.java
  4. 77 0
      src/main/java/com/izouma/nineth/domain/MetaUserPropRecord.java
  5. 0 29
      src/main/java/com/izouma/nineth/dto/MMOMessage.java
  6. 0 20
      src/main/java/com/izouma/nineth/dto/MMOSingleMessage.java
  7. 19 0
      src/main/java/com/izouma/nineth/enums/MetaPropOperationType.java
  8. 0 5
      src/main/java/com/izouma/nineth/repo/MetaMMOLoginInfoRepo.java
  9. 9 0
      src/main/java/com/izouma/nineth/repo/MetaUserPropRecordRepo.java
  10. 13 0
      src/main/java/com/izouma/nineth/repo/MetaUserPropRepo.java
  11. 39 0
      src/main/java/com/izouma/nineth/service/MetaUserPropRecordService.java
  12. 96 0
      src/main/java/com/izouma/nineth/service/MetaUserPropService.java
  13. 0 21
      src/main/java/com/izouma/nineth/web/MetaCacheable.java
  14. 0 2
      src/main/java/com/izouma/nineth/web/MetaMMOLoginInfoController.java
  15. 54 0
      src/main/java/com/izouma/nineth/web/MetaUserPropController.java
  16. 42 0
      src/main/java/com/izouma/nineth/web/MetaUserPropRecordController.java
  17. 0 188
      src/main/java/com/izouma/nineth/websocket/PublicScreenChatWebsocket.java
  18. 0 410
      src/main/java/com/izouma/nineth/websocket/WebSocket.java
  19. 0 51
      src/main/java/com/izouma/nineth/websocket/WebsocketCommon.java
  20. 1 0
      src/main/resources/genjson/MetaUserProp.json
  21. 0 0
      src/main/resources/genjson/MetaUserPropRecord.json
  22. 32 0
      src/main/vue/src/router.js
  23. 67 0
      src/main/vue/src/views/MetaUserPropEdit.vue
  24. 131 0
      src/main/vue/src/views/MetaUserPropList.vue
  25. 110 0
      src/main/vue/src/views/MetaUserPropRecordEdit.vue
  26. 159 0
      src/main/vue/src/views/MetaUserPropRecordList.vue

+ 0 - 15
src/main/java/com/izouma/nineth/config/WebSocketConfig.java

@@ -1,15 +0,0 @@
-package com.izouma.nineth.config;
-
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.server.standard.ServerEndpointExporter;
-
-@Configuration
-public class WebSocketConfig {
-
-    @Bean
-    public ServerEndpointExporter serverEndpointExporter() {
-        return new ServerEndpointExporter();
-    }
-}

+ 7 - 43
src/main/java/com/izouma/nineth/domain/MetaMMOLoginInfo.java

@@ -16,7 +16,6 @@ import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.persistence.Table;
 import java.time.LocalDateTime;
-import java.util.Objects;
 
 @Data
 @AllArgsConstructor
@@ -104,47 +103,12 @@ public class MetaMMOLoginInfo extends BaseEntity {
     @Enumerated(EnumType.STRING)
     private MoveType moveType;
 
-    /**
-     * 根据玩家历史登陆信息初始化本次登陆信息
-     *
-     * @param metaMMOLoginInfo 历史登陆信息
-     * @return 本次登陆默认信息
-     */
-    public static MetaMMOLoginInfo initMetaMMOLoginInfo(MetaMMOLoginInfo metaMMOLoginInfo) {
-        MetaMMOLoginInfo newMetaMMOLoginInfo = new MetaMMOLoginInfo();
-        if (Objects.isNull(metaMMOLoginInfo)) {
-            newMetaMMOLoginInfo.setRegionId(0L);
-            newMetaMMOLoginInfo.setCityId(0L);
-            newMetaMMOLoginInfo.setAxisX(0F);
-            newMetaMMOLoginInfo.setAxisY(0F);
-            newMetaMMOLoginInfo.setAxisZ(0F);
-            newMetaMMOLoginInfo.setEulerX(0F);
-            newMetaMMOLoginInfo.setEulerY(0F);
-            newMetaMMOLoginInfo.setEulerZ(0F);
-            newMetaMMOLoginInfo.setTop(0);
-            newMetaMMOLoginInfo.setHat(0);
-            newMetaMMOLoginInfo.setDown(0);
-            newMetaMMOLoginInfo.setShoes(0);
-            newMetaMMOLoginInfo.setAnim(0);
-            newMetaMMOLoginInfo.setEmoji(0);
-            return newMetaMMOLoginInfo;
-        }
-        newMetaMMOLoginInfo.setCityId(metaMMOLoginInfo.getCityId());
-        newMetaMMOLoginInfo.setRegionId(metaMMOLoginInfo.getRegionId());
-        newMetaMMOLoginInfo.setAxisX(metaMMOLoginInfo.getAxisX());
-        newMetaMMOLoginInfo.setAxisY(metaMMOLoginInfo.getAxisY());
-        newMetaMMOLoginInfo.setAxisZ(metaMMOLoginInfo.getAxisZ());
-        newMetaMMOLoginInfo.setEulerX(metaMMOLoginInfo.getEulerX());
-        newMetaMMOLoginInfo.setEulerY(metaMMOLoginInfo.getEulerY());
-        newMetaMMOLoginInfo.setEulerZ(metaMMOLoginInfo.getEulerZ());
-        newMetaMMOLoginInfo.setTop(metaMMOLoginInfo.getTop());
-        newMetaMMOLoginInfo.setHat(metaMMOLoginInfo.getHat());
-        newMetaMMOLoginInfo.setDown(metaMMOLoginInfo.getDown());
-        newMetaMMOLoginInfo.setShoes(metaMMOLoginInfo.getShoes());
-        newMetaMMOLoginInfo.setAnim(metaMMOLoginInfo.getAnim());
-        newMetaMMOLoginInfo.setEmoji(metaMMOLoginInfo.getEmoji());
-        newMetaMMOLoginInfo.setRole(metaMMOLoginInfo.getRole());
-        return newMetaMMOLoginInfo;
-    }
+    @ApiModelProperty("载具id")
+    @ExcelProperty("载具id")
+    private Long vehicleId;
+
+    @ApiModelProperty("变身id")
+    @ExcelProperty("变身id")
+    private Long turnedId;
 
 }

+ 40 - 0
src/main/java/com/izouma/nineth/domain/MetaUserProp.java

@@ -0,0 +1,40 @@
+package com.izouma.nineth.domain;
+
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@ApiModel("元宇宙玩家道具")
+public class MetaUserProp extends BaseEntity {
+
+    @ApiModelProperty("用户id")
+    @ExcelProperty("用户id")
+    private Long userId;
+
+    @ApiModelProperty("道具id")
+    @ExcelProperty("道具id")
+    private Long metaPropId;
+
+    @ApiModelProperty("名称")
+    @ExcelProperty("名称")
+    private String name;
+
+    @ApiModelProperty("图片")
+    @ExcelProperty("图片")
+    private String pic;
+
+    @ApiModelProperty("数量")
+    @ExcelProperty("数量")
+    private int num;
+
+}

+ 77 - 0
src/main/java/com/izouma/nineth/domain/MetaUserPropRecord.java

@@ -0,0 +1,77 @@
+package com.izouma.nineth.domain;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.izouma.nineth.enums.MetaPropOperationType;
+import com.izouma.nineth.enums.MetaPropUsedType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import java.time.LocalDateTime;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Builder
+@ApiModel("元宇宙玩家道具记录")
+public class MetaUserPropRecord extends BaseEntity {
+
+    @ApiModelProperty("用户id")
+    @ExcelProperty("用户id")
+    private Long userId;
+
+    @ApiModelProperty("操作类型")
+    @ExcelProperty("操作类型")
+    @Enumerated(EnumType.STRING)
+    private MetaPropOperationType operationType;
+
+    @ApiModelProperty("操作时间")
+    @ExcelProperty("操作时间")
+    private LocalDateTime operatingTime;
+
+    @ApiModelProperty("使用类型")
+    @ExcelProperty("使用类型")
+    @Enumerated(EnumType.STRING)
+    private MetaPropUsedType usedType;
+
+    @ApiModelProperty("道具id")
+    @ExcelProperty("道具id")
+    private Long metaPropId;
+
+    @ApiModelProperty("名称")
+    @ExcelProperty("名称")
+    private String name;
+
+    @ApiModelProperty("图片")
+    @ExcelProperty("图片")
+    private String pic;
+
+    @ApiModelProperty("限时道具时间,单位小时")
+    @ExcelProperty("限时道具时间,单位小时")
+    private int times;
+
+    @ApiModelProperty("限时道具是否失效")
+    @ExcelProperty("限时道具是否失效")
+    private boolean finish;
+
+    public static MetaUserPropRecord create(Long userId, MetaProp metaProp, MetaPropOperationType operationType) {
+        return MetaUserPropRecord.builder()
+                .userId(userId)
+                .metaPropId(metaProp.getId())
+                .name(metaProp.getName())
+                .pic(metaProp.getPic())
+                .operationType(operationType)
+                .operatingTime(LocalDateTime.now())
+                .usedType(metaProp.getUsedType())
+                .times(metaProp.getUsedType().equals(MetaPropUsedType.LIMITED) ? metaProp.getTimes() : 0)
+                .finish(Boolean.TRUE)
+                .build();
+    }
+}

+ 0 - 29
src/main/java/com/izouma/nineth/dto/MMOMessage.java

@@ -1,29 +0,0 @@
-package com.izouma.nineth.dto;
-
-import com.izouma.nineth.domain.MetaMMOLoginInfo;
-import io.swagger.annotations.ApiModel;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@ApiModel("单个消息")
-public class MMOMessage {
-
-    /**
-     * 1.地图玩家信息
-     * 2.移动
-     * 3.下线
-     * 4.玩家加入
-     * 5.自生位置信息
-     */
-    private Integer messageType;
-
-    private MetaMMOLoginInfo message;
-
-    private List<MetaMMOLoginInfo> map;
-}

+ 0 - 20
src/main/java/com/izouma/nineth/dto/MMOSingleMessage.java

@@ -1,20 +0,0 @@
-package com.izouma.nineth.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@ApiModel("单个消息")
-public class MMOSingleMessage {
-
-    @ApiModelProperty("消息类型")
-    private Integer messageType;
-
-    @ApiModelProperty("消息体")
-    private String message;
-}

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

@@ -0,0 +1,19 @@
+package com.izouma.nineth.enums;
+
+
+public enum MetaPropOperationType {
+
+    RECEIVE("领取/获得"),
+
+    USE("使用");
+
+    private final String description;
+
+    MetaPropOperationType(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 0 - 5
src/main/java/com/izouma/nineth/repo/MetaMMOLoginInfoRepo.java

@@ -3,12 +3,7 @@ package com.izouma.nineth.repo;
 import com.izouma.nineth.domain.MetaMMOLoginInfo;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.jpa.repository.Query;
 
 public interface MetaMMOLoginInfoRepo extends JpaRepository<MetaMMOLoginInfo, Long>, JpaSpecificationExecutor<MetaMMOLoginInfo> {
 
-    @Query(value = "select * from meta_mmo_login_info a where a.user_id = ?1 order by a.created_at desc limit 1",nativeQuery = true)
-    MetaMMOLoginInfo findLastByUserId(Long userId);
-
-    MetaMMOLoginInfo findByUserIdAndSessionIdAndDel(Long userId, String sessionId, boolean del);
 }

+ 9 - 0
src/main/java/com/izouma/nineth/repo/MetaUserPropRecordRepo.java

@@ -0,0 +1,9 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.MetaUserPropRecord;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MetaUserPropRecordRepo extends JpaRepository<MetaUserPropRecord, Long>, JpaSpecificationExecutor<MetaUserPropRecord> {
+
+}

+ 13 - 0
src/main/java/com/izouma/nineth/repo/MetaUserPropRepo.java

@@ -0,0 +1,13 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.MetaUserProp;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MetaUserPropRepo extends JpaRepository<MetaUserProp, Long>, JpaSpecificationExecutor<MetaUserProp> {
+
+    MetaUserProp findByUserIdAndMetaPropIdAndDel(Long userId, Long metaPropId, boolean del);
+
+    void deleteByUserIdAndMetaPropId(Long userId, Long metaPropId);
+
+}

+ 39 - 0
src/main/java/com/izouma/nineth/service/MetaUserPropRecordService.java

@@ -0,0 +1,39 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.domain.MetaProp;
+import com.izouma.nineth.domain.MetaUserPropRecord;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.enums.MetaPropOperationType;
+import com.izouma.nineth.enums.MetaPropUsedType;
+import com.izouma.nineth.repo.MetaUserPropRecordRepo;
+import com.izouma.nineth.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+@Service
+@AllArgsConstructor
+public class MetaUserPropRecordService {
+
+    private MetaUserPropRecordRepo metaUserPropRecordRepo;
+
+    public Page<MetaUserPropRecord> all(PageQuery pageQuery) {
+        return metaUserPropRecordRepo.findAll(JpaUtils.toSpecification(pageQuery, MetaUserPropRecord.class), JpaUtils.toPageRequest(pageQuery));
+    }
+
+    public MetaUserPropRecord save(Long userId, MetaProp metaProp, MetaPropOperationType operationType) {
+        MetaUserPropRecord metaUserPropRecord = MetaUserPropRecord.create(userId, metaProp, operationType);
+        // 永久道具 finish(该道具是否失效)设置为false
+        if (MetaPropUsedType.PERMANENT.equals(metaProp.getUsedType())) {
+            metaUserPropRecord.setFinish(false);
+            return metaUserPropRecordRepo.save(metaUserPropRecord);
+        }
+        // 限时类道具 finish(该道具是否失效)设置为false
+        if (MetaPropOperationType.USE.equals(operationType) && MetaPropUsedType.LIMITED.equals(metaProp.getUsedType())) {
+            metaUserPropRecord.setFinish(false);
+            return metaUserPropRecordRepo.save(metaUserPropRecord);
+        }
+        // 其他道具一经使用 finish(该道具是否失效)true
+        return metaUserPropRecordRepo.save(metaUserPropRecord);
+    }
+}

+ 96 - 0
src/main/java/com/izouma/nineth/service/MetaUserPropService.java

@@ -0,0 +1,96 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.domain.MetaProp;
+import com.izouma.nineth.domain.MetaUserProp;
+import com.izouma.nineth.dto.MetaRestResult;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.enums.MetaPropOperationType;
+import com.izouma.nineth.enums.MetaPropUsedType;
+import com.izouma.nineth.repo.MetaPropRepo;
+import com.izouma.nineth.repo.MetaUserPropRepo;
+import com.izouma.nineth.utils.JpaUtils;
+import com.izouma.nineth.utils.SecurityUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+import javax.transaction.Transactional;
+import java.util.Objects;
+
+@Service
+@AllArgsConstructor
+public class MetaUserPropService {
+
+    private MetaUserPropRepo metaUserPropRepo;
+
+    private MetaPropRepo metaPropRepo;
+
+    private MetaUserPropRecordService metaUserPropRecordService;
+
+    public Page<MetaUserProp> all(PageQuery pageQuery) {
+        return metaUserPropRepo.findAll(JpaUtils.toSpecification(pageQuery, MetaUserProp.class), JpaUtils.toPageRequest(pageQuery));
+    }
+
+    public MetaRestResult<MetaUserProp> operate(Long metaPropId, MetaPropOperationType operationType) {
+        if (Objects.isNull(metaPropId)) {
+            return MetaRestResult.returnError("Illegal parameter : metaPropId can not be null");
+        }
+        MetaProp metaProp = metaPropRepo.findById(metaPropId).orElse(null);
+        if (Objects.isNull(metaProp)) {
+            return MetaRestResult.returnError("道具不存在!");
+        }
+        Long userId = SecurityUtils.getAuthenticatedUser().getId();
+        MetaUserProp dbMetaUserProp = metaUserPropRepo.findByUserIdAndMetaPropIdAndDel(userId, metaPropId, false);
+        if (MetaPropOperationType.RECEIVE.equals(operationType)) {
+            return receive(dbMetaUserProp, metaProp);
+        }
+        return use(dbMetaUserProp, metaProp);
+    }
+
+    @Transactional
+    public MetaRestResult<MetaUserProp> receive(MetaUserProp dbMetaUserProp, MetaProp metaProp) {
+        if (Objects.isNull(dbMetaUserProp)) {
+            dbMetaUserProp = new MetaUserProp();
+            dbMetaUserProp.setMetaPropId(metaProp.getId());
+            dbMetaUserProp.setUserId(dbMetaUserProp.getUserId());
+            dbMetaUserProp.setName(metaProp.getName());
+            dbMetaUserProp.setPic(metaProp.getPic());
+            dbMetaUserProp.setNum(0);
+        } else {
+            dbMetaUserProp.setNum(dbMetaUserProp.getNum() + 1);
+        }
+        MetaUserProp save = metaUserPropRepo.save(dbMetaUserProp);
+        metaUserPropRecordService.save(dbMetaUserProp.getUserId(), metaProp, MetaPropOperationType.RECEIVE);
+        return MetaRestResult.returnSuccess(save);
+    }
+
+    @Transactional
+    public MetaRestResult<MetaUserProp> use(MetaUserProp dbMetaUserProp, MetaProp metaProp) {
+        if (Objects.isNull(dbMetaUserProp)) {
+            return MetaRestResult.returnError("玩家未拥有该道具!");
+        }
+        // 永久道具 不对背包做操作,增加一条操作记录
+        if (MetaPropUsedType.PERMANENT.equals(metaProp.getUsedType())) {
+            metaUserPropRecordService.save(dbMetaUserProp.getUserId(), metaProp, MetaPropOperationType.USE);
+            return MetaRestResult.returnSuccess(dbMetaUserProp);
+        }
+        // 某些原因导致数量小于1的非永久道具还存在数据库中,删除背包中该道具数据,返回错误信息
+        if (1 > dbMetaUserProp.getNum()) {
+            metaUserPropRepo.deleteByUserIdAndMetaPropId(dbMetaUserProp.getUserId(), metaProp.getId());
+            return MetaRestResult.returnError("玩家未拥有该道具,请重试!");
+        }
+        // 数量为1的非永久道具,成功使用后直接删除背包中该道具数据,增加一条操作记录
+        if (1 == dbMetaUserProp.getNum()) {
+            dbMetaUserProp.setNum(0);
+            metaUserPropRecordService.save(dbMetaUserProp.getUserId(), metaProp, MetaPropOperationType.USE);
+            metaUserPropRepo.deleteByUserIdAndMetaPropId(dbMetaUserProp.getUserId(), metaProp.getId());
+            return MetaRestResult.returnSuccess(dbMetaUserProp);
+        }
+        // 数量大于1的非永久道具,背包中该道具数量减1,增加一条操作记录
+        dbMetaUserProp.setNum(dbMetaUserProp.getNum() - 1);
+        MetaUserProp save = metaUserPropRepo.save(dbMetaUserProp);
+        metaUserPropRecordService.save(dbMetaUserProp.getUserId(), metaProp, MetaPropOperationType.USE);
+        return MetaRestResult.returnSuccess(save);
+    }
+
+}

+ 0 - 21
src/main/java/com/izouma/nineth/web/MetaCacheable.java

@@ -1,21 +0,0 @@
-package com.izouma.nineth.web;
-
-import com.izouma.nineth.dto.MetaRestResult;
-import com.izouma.nineth.websocket.WebSocket;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-@RequestMapping("/metaCacheable")
-@AllArgsConstructor
-public class MetaCacheable {
-
-    private WebSocket webSocket;
-
-    @PostMapping("/clearMMO")
-    public MetaRestResult clearMMO(String userId, String regionId, String cityId) {
-        return webSocket.clearMMO(userId, regionId, cityId);
-    }
-}

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

@@ -18,14 +18,12 @@ import java.util.List;
 public class MetaMMOLoginInfoController extends BaseController {
     private MetaMMOLoginInfoService metaMMOLoginInfoService;
 
-
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     public Page<MetaMMOLoginInfo> all(@RequestBody PageQuery pageQuery) {
         return metaMMOLoginInfoService.all(pageQuery);
     }
 
-
     @GetMapping("/excel")
     @ResponseBody
     public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {

+ 54 - 0
src/main/java/com/izouma/nineth/web/MetaUserPropController.java

@@ -0,0 +1,54 @@
+package com.izouma.nineth.web;
+
+import com.izouma.nineth.domain.MetaUserProp;
+import com.izouma.nineth.dto.MetaRestResult;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.enums.MetaPropOperationType;
+import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.MetaUserPropRepo;
+import com.izouma.nineth.service.MetaUserPropService;
+import com.izouma.nineth.utils.excel.ExcelUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/metaUserProp")
+@AllArgsConstructor
+public class MetaUserPropController extends BaseController {
+    private MetaUserPropService metaUserPropService;
+    private MetaUserPropRepo metaUserPropRepo;
+
+    @PostMapping("/receive")
+    public MetaRestResult<MetaUserProp> receive(Long metaPropId) {
+        return metaUserPropService.operate(metaPropId, MetaPropOperationType.RECEIVE);
+    }
+
+    @PostMapping("/use")
+    public MetaRestResult<MetaUserProp> use(Long metaPropId) {
+        return metaUserPropService.operate(metaPropId, MetaPropOperationType.USE);
+    }
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<MetaUserProp> all(@RequestBody PageQuery pageQuery) {
+        return metaUserPropService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public MetaUserProp get(@PathVariable Long id) {
+        return metaUserPropRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<MetaUserProp> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+}
+

+ 42 - 0
src/main/java/com/izouma/nineth/web/MetaUserPropRecordController.java

@@ -0,0 +1,42 @@
+package com.izouma.nineth.web;
+
+import com.izouma.nineth.domain.MetaUserPropRecord;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.MetaUserPropRecordRepo;
+import com.izouma.nineth.service.MetaUserPropRecordService;
+import com.izouma.nineth.utils.excel.ExcelUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/metaUserPropRecord")
+@AllArgsConstructor
+public class MetaUserPropRecordController extends BaseController {
+    private MetaUserPropRecordService metaUserPropRecordService;
+    private MetaUserPropRecordRepo metaUserPropRecordRepo;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<MetaUserPropRecord> all(@RequestBody PageQuery pageQuery) {
+        return metaUserPropRecordService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public MetaUserPropRecord get(@PathVariable Long id) {
+        return metaUserPropRecordRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<MetaUserPropRecord> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+}
+

+ 0 - 188
src/main/java/com/izouma/nineth/websocket/PublicScreenChatWebsocket.java

@@ -1,188 +0,0 @@
-package com.izouma.nineth.websocket;
-
-import com.alibaba.fastjson.JSON;
-import com.izouma.nineth.domain.PublicScreenChat;
-import com.izouma.nineth.domain.PurchaseLevel;
-import com.izouma.nineth.domain.User;
-import com.izouma.nineth.dto.PublicScreenChatExceptionMsg;
-import com.izouma.nineth.exception.BusinessException;
-import com.izouma.nineth.repo.PublicScreenChatRepo;
-import com.izouma.nineth.repo.UserRepo;
-import com.izouma.nineth.service.ContentAuditService;
-import com.izouma.nineth.service.PurchaseLevelService;
-import com.izouma.nineth.utils.ApplicationContextUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Service;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-import java.time.LocalDateTime;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-@Service
-@ServerEndpoint(value = "/websocket/public/screen/{nickName}/{userId}")
-@Slf4j
-public class PublicScreenChatWebsocket extends WebsocketCommon {
-
-    /**
-     * 当前在线的客户端map
-     */
-    private static final Map<String, Session> clients = new ConcurrentHashMap();
-
-    private PublicScreenChatRepo publicScreenChatRepo;
-
-    private final String PREFIX = "meta-chat:";
-
-    private UserRepo userRepo;
-
-    private PurchaseLevelService purchaseLevelService;
-
-    private ContentAuditService contentAuditService;
-
-    private void init() {
-        if (Objects.isNull(publicScreenChatRepo)) {
-            publicScreenChatRepo = (PublicScreenChatRepo) ApplicationContextUtil.getBean("publicScreenChatRepo");
-        }
-        if (Objects.isNull(userRepo)) {
-            userRepo = (UserRepo) ApplicationContextUtil.getBean("userRepo");
-        }
-        if (Objects.isNull(purchaseLevelService)) {
-            purchaseLevelService = (PurchaseLevelService) ApplicationContextUtil.getBean("purchaseLevelService");
-        }
-        if (Objects.isNull(contentAuditService)) {
-            contentAuditService = (ContentAuditService) ApplicationContextUtil.getBean("contentAuditService");
-        }
-    }
-
-    @OnOpen
-    public void onOpen(@PathParam("nickName") String nickName, @PathParam("userId") String userId, Session session) {
-        init();
-        // 判断当前玩家是否在其他地方登陆
-        if (clients.containsKey(PREFIX.concat(userId))) {
-            String msg = String.format("已在别处登陆,sessionId为[%S],正在为您关闭本连接", session.getId());
-            exceptionHandle(userId, new PublicScreenChatExceptionMsg(1, msg));
-            try {
-                log.info("关闭session连接");
-                clients.get(PREFIX.concat(userId)).close();
-            } catch (Exception e) {
-                exceptionHandle(userId, new PublicScreenChatExceptionMsg(1, String.format("session close throw exception[%S]", e)));
-                return;
-            }
-        }
-        log.info("现在来连接的sessionId:" + session.getId() + "玩家id:" + userId + "玩家昵称" + nickName);
-        clients.put(PREFIX.concat(userId), session);
-        String format = String.format("玩家[%S][%S]进入大厅", userId, nickName);
-        PublicScreenChat publicScreenChat;
-        try {
-            publicScreenChat = savePublicScreenChat(userId, format, true);
-        } catch (Exception e) {
-            String errMsg = String.format("玩家进入大厅,保存信息发生异常[%S]", e);
-            exceptionHandle(userId, new PublicScreenChatExceptionMsg(2, errMsg));
-            return;
-        }
-        sendMessageToOther(clients, JSON.toJSONString(publicScreenChat), PREFIX.concat(userId));
-    }
-
-    @OnError
-    public void onError(Session session, Throwable error) {
-        // 异常处理
-        log.error(String.format("sessionId[%S]的服务端发生了错误:[%S]", session.getId(), error.getMessage()));
-    }
-
-    @OnClose
-    public void onClose(@PathParam("nickName") String nickName, @PathParam("userId") String userId, Session session) {
-        init();
-        log.info(String.format("sessionId:[%S] userId:[%S] is closed", session.getId(), userId));
-        String format = String.format("玩家[%S][%S]离开大厅", userId, nickName);
-        PublicScreenChat publicScreenChat;
-        try {
-            publicScreenChat = savePublicScreenChat(userId, format, true);
-        } catch (Exception e) {
-            String errMsg = String.format("玩家离开大厅,保存信息发生异常[%S]", e);
-            exceptionHandle(userId, new PublicScreenChatExceptionMsg(2, errMsg));
-            return;
-        }
-        sendMessageToOther(clients, JSON.toJSONString(publicScreenChat), PREFIX.concat(userId));
-        clients.remove(PREFIX.concat(userId));
-    }
-
-    @OnMessage
-    public void onMessage(@PathParam("userId") String userId, String message, Session session) {
-        init();
-        if (StringUtils.isBlank(message)) {
-            String errMsg = "Illegal parameter : message can not be null";
-            exceptionHandle(userId, new PublicScreenChatExceptionMsg(4, errMsg));
-            return;
-        }
-        if ("META_PING".equals(message)) {
-            log.info(String.format("sessionId:[%S] userId:[%S] 连接正常", session.getId(), userId));
-            sendMessageTo(clients, "META_PONG", PREFIX.concat(userId));
-            return;
-        }
-        if (!contentAuditService.auditText(message)) {
-            savePublicScreenChat(userId, message, false);
-            exceptionHandle(userId, new PublicScreenChatExceptionMsg(3, "消息包含非法内容"));
-            return;
-        }
-        PublicScreenChat publicScreenChat;
-        try {
-            publicScreenChat = savePublicScreenChat(userId, message, true);
-        } catch (Exception e) {
-            String errMsg = String.format("玩家发送消息,保存信息发生异常[%S]", e);
-            exceptionHandle(userId, new PublicScreenChatExceptionMsg(2, errMsg));
-            return;
-        }
-        sendMessageToAll(clients, JSON.toJSONString(publicScreenChat), PREFIX.concat(userId));
-    }
-
-    /**
-     * 给所有用户发消息
-     *
-     * @param clients 在线客户端
-     * @param message 消息
-     */
-    public void sendMessageToAll(Map<String, Session> clients, String message, String userId) {
-        PublicScreenChat publicScreenChat = JSON.parseObject(message, PublicScreenChat.class);
-        Set<String> userIds = clients.keySet();
-        userIds.forEach(id -> {
-            try {
-                publicScreenChat.setMyself(id.equals(userId));
-                log.info(String.format("服务器给所有在线用户发送消息,当前在线人员为[%S]。消息:[%S]", id, JSON.toJSONString(publicScreenChat)));
-                clients.get(id).getBasicRemote().sendText(JSON.toJSONString(publicScreenChat));
-            } catch (Exception e) {
-                log.error(String.format("send message [%S] to [%S] throw exception [%S]:", JSON.toJSONString(publicScreenChat), id, e));
-            }
-        });
-    }
-
-    private PublicScreenChat savePublicScreenChat(String userId, String messageInfo, boolean illegal) {
-        User user = userRepo.findById(Long.parseLong(userId)).orElse(null);
-        if (Objects.isNull(user)) {
-            throw new BusinessException("用户信息不存在");
-        }
-        PublicScreenChat publicScreenChat = new PublicScreenChat();
-        publicScreenChat.setUserId(userId);
-        publicScreenChat.setAvatar(user.getAvatar());
-        publicScreenChat.setNickname(user.getNickname());
-        publicScreenChat.setLevel(user.getLevel());
-        PurchaseLevel purchaseLevel = purchaseLevelService.findPurchaseLevelByLevel(publicScreenChat.getLevel());
-        publicScreenChat.setRealm(purchaseLevel.getRealm());
-        publicScreenChat.setTitle(purchaseLevel.getTitle());
-        publicScreenChat.setMessageInfo(messageInfo);
-        publicScreenChat.setTime(LocalDateTime.now());
-        publicScreenChat.setIllegal(illegal);
-        return publicScreenChatRepo.save(publicScreenChat);
-    }
-
-    private void exceptionHandle(String userId, PublicScreenChatExceptionMsg msg) {
-        log.error(JSON.toJSONString(msg));
-        // 推送消息给该玩家
-        sendMessageTo(clients, JSON.toJSONString(msg), PREFIX.concat(userId));
-    }
-}
-

+ 0 - 410
src/main/java/com/izouma/nineth/websocket/WebSocket.java

@@ -1,410 +0,0 @@
-package com.izouma.nineth.websocket;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.izouma.nineth.domain.MetaMMOLoginInfo;
-import com.izouma.nineth.dto.MMOMessage;
-import com.izouma.nineth.dto.MMOSingleMessage;
-import com.izouma.nineth.dto.MetaRestResult;
-import com.izouma.nineth.dto.MetaServiceResult;
-import com.izouma.nineth.repo.MetaMMOLoginInfoRepo;
-import com.izouma.nineth.utils.ApplicationContextUtil;
-import com.izouma.nineth.utils.ObjUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-@Service
-@ServerEndpoint(value = "/websocket/mmo/{nickName}/{userId}")
-@Slf4j
-public class WebSocket extends WebsocketCommon {
-
-    /**
-     * 当前在线的客户端map
-     */
-    private static final Map<String, Session> clients = new ConcurrentHashMap();
-
-    private final String REDIS_PREFIX = "meta:";
-
-    private RedisTemplate redisTemplate;
-
-    private MetaMMOLoginInfoRepo metaMMOLoginInfoRepo;
-
-    private void init() {
-        if (Objects.isNull(redisTemplate)) {
-            redisTemplate = (RedisTemplate) ApplicationContextUtil.getBean("redisTemplate");
-        }
-        if (Objects.isNull(metaMMOLoginInfoRepo)) {
-            metaMMOLoginInfoRepo = (MetaMMOLoginInfoRepo) ApplicationContextUtil.getBean("metaMMOLoginInfoRepo");
-        }
-    }
-
-    @OnOpen
-    public void onOpen(@PathParam("nickName") String nickName, @PathParam("userId") String userId, Session session) {
-        init();
-        // 判断当前玩家是否在其他地方登陆
-        if (clients.containsKey(REDIS_PREFIX.concat(userId))) {
-            log.info(String.format("当前玩家[%S]已经在别处登陆,sessionId为[%S]", userId, session.getId()));
-            // 关闭连接
-            MMOSingleMessage mmoSingleMessage = new MMOSingleMessage();
-            mmoSingleMessage.setMessageType(6);
-            mmoSingleMessage.setMessage("您已在其他地方登录,已为您关闭上次登陆信息");
-            sendMessageTo(clients, JSON.toJSONString(mmoSingleMessage), REDIS_PREFIX.concat(userId));
-            try {
-                log.info("关闭上次登陆的session连接");
-                clients.get(REDIS_PREFIX.concat(userId)).close();
-            } catch (Exception e) {
-                log.error("session close throw exception:", e);
-            }
-        }
-        log.info("现在来连接的sessionId:" + session.getId() + "玩家id:" + userId + "玩家昵称" + nickName);
-        clients.put(REDIS_PREFIX.concat(userId), session);
-        // 获取上次登录的信息
-        MetaMMOLoginInfo dbMetaMMOLoginInfo = metaMMOLoginInfoRepo.findLastByUserId(Long.parseLong(userId));
-        // 玩家登陆信息入库
-        MetaMMOLoginInfo metaMMOLoginInfo = MetaMMOLoginInfo.initMetaMMOLoginInfo(dbMetaMMOLoginInfo);
-        metaMMOLoginInfo.setNickname(nickName);
-        metaMMOLoginInfo.setUserId(Long.parseLong(userId));
-        metaMMOLoginInfo.setOnLineTime(LocalDateTime.now());
-        metaMMOLoginInfo.setSessionId(session.getId());
-        MetaMMOLoginInfo save = metaMMOLoginInfoRepo.save(metaMMOLoginInfo);
-        MMOMessage mmoMessage = new MMOMessage();
-        mmoMessage.setMessageType(5);
-        mmoMessage.setMessage(save);
-        log.info(String.format("通知玩家[%S],本次登陆信息[%S]", userId, JSON.toJSONString(mmoMessage)));
-        sendMessageTo(clients, JSON.toJSONString(mmoMessage), REDIS_PREFIX.concat(userId));
-    }
-
-    @OnError
-    public void onError(Session session, Throwable error) {
-        // 异常处理
-        log.error(String.format("sessionId[%S]的服务端发生了错误:[%S]", session.getId(), error.getMessage()));
-    }
-
-    @OnClose
-    public void onClose(@PathParam("userId") String userId) {
-        init();
-        // 查询地图中玩家信息
-        MetaMMOLoginInfo metaMMOLoginInfo = (MetaMMOLoginInfo) redisTemplate.opsForValue().get(REDIS_PREFIX.concat(userId));
-        if (Objects.isNull(metaMMOLoginInfo)) {
-            // 如果缓存中玩家信息为空,根据userId和sessionId查询数据库
-            MetaMMOLoginInfo dbMetaMMOLoginInfo = metaMMOLoginInfoRepo.findByUserIdAndSessionIdAndDel(Long.parseLong(userId), clients.get(REDIS_PREFIX.concat(userId)).getId(), false);
-            dbMetaMMOLoginInfo.setOffLineTime(LocalDateTime.now());
-            // 更新离线时间
-            metaMMOLoginInfoRepo.save(dbMetaMMOLoginInfo);
-            clients.remove(REDIS_PREFIX.concat(userId));
-            return;
-        }
-        String key = String.valueOf(metaMMOLoginInfo.getCityId()).concat(":").concat(String.valueOf(metaMMOLoginInfo.getRegionId()));
-        List<String> otherUserIds = remove(key, userId);
-        if (CollectionUtils.isNotEmpty(otherUserIds)) {
-            // 分发下线消息给区域内其他玩家
-            buildMessageForSendingToAllOther(otherUserIds, 3, metaMMOLoginInfo);
-        }
-        MetaMMOLoginInfo dbMetaMMOLoginInfo = metaMMOLoginInfoRepo.findById(metaMMOLoginInfo.getId()).orElse(null);
-        if (Objects.isNull(dbMetaMMOLoginInfo)) {
-            log.error(String.format("数据库中不存在id[%S]的记录", metaMMOLoginInfo.getId()));
-            return;
-        }
-        ObjUtils.merge(dbMetaMMOLoginInfo, metaMMOLoginInfo);
-        dbMetaMMOLoginInfo.setOffLineTime(LocalDateTime.now());
-        metaMMOLoginInfoRepo.save(dbMetaMMOLoginInfo);
-        clients.remove(REDIS_PREFIX.concat(userId));
-        // 删除redis中自己的信息
-        redisTemplate.delete(REDIS_PREFIX.concat(userId));
-        // 移除地图中自己的信息
-        redisTemplate.opsForList().remove(REDIS_PREFIX.concat(key), 0, REDIS_PREFIX.concat(userId));
-    }
-
-    @OnMessage
-    public void onMessage(@PathParam("nickName") String nickName, @PathParam("userId") String userId, String message, Session session) {
-        init();
-        if (StringUtils.isBlank(message)) {
-            log.error("Illegal parameter : message can not be null");
-            return;
-        }
-        if ("META_PING".equals(message)) {
-            log.info(String.format("sessionId:[%S] userId:[%S] 连接正常", session.getId(), userId));
-            sendMessageTo(clients, "META_PONG", REDIS_PREFIX.concat(userId));
-            return;
-        }
-        JSONObject jsonObject = JSON.parseObject(message);
-        MetaServiceResult result = checkParams(jsonObject);
-        if (!result.isSuccess()) {
-            log.error(result.getMessage());
-            return;
-        }
-        log.info("来自客户端消息:" + message + "客户端的id是:" + session.getId());
-        int type = Integer.parseInt(jsonObject.getString("type"));
-        String cityId = jsonObject.getString("cityId");
-        String regionId = jsonObject.getString("regionId");
-        String key = cityId.concat(":").concat(regionId);
-        List<String> otherUserIds = remove(key, userId);
-        MetaMMOLoginInfo metaMMOLoginInfo;
-        List<MetaMMOLoginInfo> metaMMOLoginInfos = redisTemplate.opsForValue().multiGet(otherUserIds);
-        switch (type) {
-            case 1:
-                log.info("当前操作类型为1 -> 玩家进入地图");
-                metaMMOLoginInfo = buildMetaMMOLoginInfo(jsonObject, Long.parseLong(cityId), Long.parseLong(regionId), nickName, userId);
-                if (CollectionUtils.isNotEmpty(otherUserIds)) {
-                    if (CollectionUtils.isNotEmpty(metaMMOLoginInfos)) {
-                        // 分发区域内其他玩家信息给自己
-                        buildMessageForSendingToUser(REDIS_PREFIX.concat(userId), 1, metaMMOLoginInfos);
-                        // 分发自己信息给区域内其他玩家
-                        buildMessageForSendingToAllOther(otherUserIds, 4, metaMMOLoginInfo);
-                    }
-                }
-                // 将自己信息存到redis中
-                redisTemplate.opsForValue().set(REDIS_PREFIX.concat(userId), metaMMOLoginInfo);
-                redisTemplate.opsForList().leftPush(REDIS_PREFIX.concat(key), REDIS_PREFIX.concat(userId));
-                break;
-            case 2:
-                log.info(String.format("当前操作类型为[%S] -> 玩家切换区域", type));
-                metaMMOLoginInfo = buildMetaMMOLoginInfo(jsonObject, Long.parseLong(cityId), Long.parseLong(regionId), nickName, userId);
-                if (CollectionUtils.isNotEmpty(otherUserIds)) {
-                    // 分发自己信息给区域内其他玩家
-                    buildMessageForSendingToAllOther(otherUserIds, 4, metaMMOLoginInfo);
-                    // 分发区域内其他玩家信息给自己
-                    buildMessageForSendingToUser(REDIS_PREFIX.concat(userId), 1, metaMMOLoginInfos);
-                }
-                MetaMMOLoginInfo oldMetaMMOLoginInfo = (MetaMMOLoginInfo) redisTemplate.opsForValue().get(REDIS_PREFIX.concat(userId));
-                if (Objects.isNull(oldMetaMMOLoginInfo)) {
-                    log.error("缺失玩家上次区域的地图缓存信息");
-                    break;
-                }
-                String oldKey = String.valueOf(oldMetaMMOLoginInfo.getCityId()).concat(":").concat(String.valueOf(oldMetaMMOLoginInfo.getRegionId()));
-                List<String> oldUserIds = redisTemplate.opsForList().range(REDIS_PREFIX.concat(oldKey), 0, -1);
-                if (CollectionUtils.isEmpty(oldUserIds)) {
-                    log.error("查询不到上次所进入的区域的玩家信息");
-                    break;
-                }
-                // 分发消息给之前区域的玩家
-                buildMessageForSendingToAllOther(oldUserIds, 3, oldMetaMMOLoginInfo);
-                // 清除玩家上次缓存的地图信息
-                redisTemplate.opsForList().remove(REDIS_PREFIX.concat(oldKey), 0, REDIS_PREFIX.concat(userId));
-                // 缓存玩家新的地图信息
-                redisTemplate.opsForValue().set(REDIS_PREFIX.concat(userId), metaMMOLoginInfo);
-                redisTemplate.opsForList().leftPush(REDIS_PREFIX.concat(key), REDIS_PREFIX.concat(userId));
-                break;
-            case 3:
-                log.info(String.format("当前操作类型为[%S] -> 玩家在地图内移动", type));
-                metaMMOLoginInfo = (MetaMMOLoginInfo) redisTemplate.opsForValue().get(REDIS_PREFIX.concat(userId));
-                if (Objects.isNull(metaMMOLoginInfo)) {
-                    log.error("缓存中不存在本玩家信息");
-                    break;
-                }
-                // 更新玩家位置信息
-                buildCommonProperty(metaMMOLoginInfo, jsonObject);
-                // 分发玩家信息给区域内其他玩家
-                buildMessageForSendingToAllOther(otherUserIds, 2, metaMMOLoginInfo);
-                redisTemplate.opsForValue().set(REDIS_PREFIX.concat(userId), metaMMOLoginInfo);
-                break;
-            case 4:
-                log.info(String.format("当前操作类型为[%S] -> 玩家进入大厅", type));
-                metaMMOLoginInfo = (MetaMMOLoginInfo) redisTemplate.opsForValue().get(REDIS_PREFIX.concat(userId));
-                if (Objects.isNull(metaMMOLoginInfo)) {
-                    log.error("缓存中不存在本玩家信息");
-                    break;
-                }
-                // 分发玩家信息给区域内其他玩家
-                buildMessageForSendingToAllOther(otherUserIds, 3, metaMMOLoginInfo);
-                // 更新库中玩家位置信息
-                MetaMMOLoginInfo dbMetaMMOLoginInfo = metaMMOLoginInfoRepo.findById(metaMMOLoginInfo.getId()).orElse(null);
-                if (Objects.isNull(dbMetaMMOLoginInfo)) {
-                    log.error(String.format("数据库不存在id[%S]的记录", metaMMOLoginInfo.getId()));
-                    break;
-                }
-                dbMetaMMOLoginInfo.setAxisX(metaMMOLoginInfo.getAxisX());
-                dbMetaMMOLoginInfo.setAxisY(metaMMOLoginInfo.getAxisY());
-                dbMetaMMOLoginInfo.setAxisZ(metaMMOLoginInfo.getAxisZ());
-                dbMetaMMOLoginInfo.setEulerX(metaMMOLoginInfo.getEulerX());
-                dbMetaMMOLoginInfo.setEulerY(metaMMOLoginInfo.getEulerY());
-                dbMetaMMOLoginInfo.setEulerZ(metaMMOLoginInfo.getEulerZ());
-                dbMetaMMOLoginInfo.setCityId(metaMMOLoginInfo.getCityId());
-                dbMetaMMOLoginInfo.setRegionId(metaMMOLoginInfo.getRegionId());
-                dbMetaMMOLoginInfo.setTop(metaMMOLoginInfo.getTop());
-                dbMetaMMOLoginInfo.setHat(metaMMOLoginInfo.getHat());
-                dbMetaMMOLoginInfo.setShoes(metaMMOLoginInfo.getShoes());
-                dbMetaMMOLoginInfo.setDown(metaMMOLoginInfo.getDown());
-                dbMetaMMOLoginInfo.setEmoji(metaMMOLoginInfo.getEmoji());
-                dbMetaMMOLoginInfo.setAnim(metaMMOLoginInfo.getAnim());
-                dbMetaMMOLoginInfo.setRole(metaMMOLoginInfo.getRole());
-                metaMMOLoginInfoRepo.save(dbMetaMMOLoginInfo);
-                break;
-            default:
-                log.error(String.format("不存在的操作类型[%S]", type));
-        }
-
-    }
-
-    /**
-     * 分发玩家信息给区域内其他玩家
-     *
-     * @param userIds          玩家id集合
-     * @param messageType      消息类型
-     * @param metaMMOLoginInfo 消息体
-     */
-    private void buildMessageForSendingToAllOther(List<String> userIds, int messageType, MetaMMOLoginInfo metaMMOLoginInfo) {
-        MMOMessage mmoMessage = new MMOMessage();
-        mmoMessage.setMessageType(messageType);
-        mmoMessage.setMessage(metaMMOLoginInfo);
-        if (!clients.containsKey(REDIS_PREFIX.concat(String.valueOf(metaMMOLoginInfo.getUserId())))) {
-            log.error("session信息不存在");
-            return;
-        }
-        userIds.forEach(id -> {
-            try {
-                log.info(String.format("服务器给所有当前区域内在线用户发送消息,当前在线人员为[%S]。消息:[%S]", id, JSON.toJSONString(mmoMessage)));
-                clients.get(id).getBasicRemote().sendText(JSON.toJSONString(mmoMessage));
-            } catch (Exception e) {
-                log.error(String.format("send message [%S] to [%S] throw exception [%S]:", JSON.toJSONString(mmoMessage), id, e));
-            }
-        });
-    }
-
-    /**
-     * 分发区域内其他玩家信息给自己
-     *
-     * @param userId            玩家id
-     * @param messageType       消息类型
-     * @param metaMMOLoginInfos 消息体(其他玩家信息)
-     */
-    private void buildMessageForSendingToUser(String userId, int messageType, List<MetaMMOLoginInfo> metaMMOLoginInfos) {
-        MMOMessage mmoMessage = new MMOMessage();
-        mmoMessage.setMessageType(messageType);
-        mmoMessage.setMap(metaMMOLoginInfos);
-        sendMessageTo(clients, JSON.toJSONString(mmoMessage), userId);
-    }
-
-    /**
-     * 构建玩家登陆信息
-     *
-     * @param jsonObject 玩家位置等信息json对象
-     * @param cityId     城市id
-     * @param regionId   区域id
-     * @return 玩家位置信息
-     */
-    private MetaMMOLoginInfo buildMetaMMOLoginInfo(JSONObject jsonObject, Long cityId, Long regionId, String nickName, String userId) {
-        // 获取到进入地图时自己的信息
-        MetaMMOLoginInfo metaMMOLoginInfo = new MetaMMOLoginInfo();
-        buildCommonProperty(metaMMOLoginInfo, jsonObject);
-        metaMMOLoginInfo.setCityId(cityId);
-        metaMMOLoginInfo.setRegionId(regionId);
-        metaMMOLoginInfo.setUserId(Long.parseLong(userId));
-        metaMMOLoginInfo.setNickname(nickName);
-        if (Objects.nonNull(jsonObject.getString("role"))) {
-            metaMMOLoginInfo.setRole(jsonObject.getString("role"));
-        }
-        if (Objects.nonNull(jsonObject.getString("id"))) {
-            metaMMOLoginInfo.setId(Long.parseLong(jsonObject.getString("id")));
-        }
-        metaMMOLoginInfo.setCityId(cityId);
-        return metaMMOLoginInfo;
-    }
-
-    /**
-     * 根据jsonObject构建玩家位置信息
-     *
-     * @param metaMMOLoginInfo 玩家登陆信息
-     * @param jsonObject       玩家位置信息json对象
-     */
-    private void buildCommonProperty(MetaMMOLoginInfo metaMMOLoginInfo, JSONObject jsonObject) {
-        if (Objects.nonNull(jsonObject.getString("axisX"))) {
-            metaMMOLoginInfo.setAxisX(Float.parseFloat(jsonObject.getString("axisX")));
-        }
-        if (Objects.nonNull(jsonObject.getString("axisY"))) {
-            metaMMOLoginInfo.setAxisY(Float.parseFloat(jsonObject.getString("axisY")));
-        }
-        if (Objects.nonNull(jsonObject.getString("axisZ"))) {
-            metaMMOLoginInfo.setAxisZ(Float.parseFloat(jsonObject.getString("axisZ")));
-        }
-        if (Objects.nonNull(jsonObject.getString("eulerX"))) {
-            metaMMOLoginInfo.setEulerX(Float.parseFloat(jsonObject.getString("eulerX")));
-        }
-        if (Objects.nonNull(jsonObject.getString("eulerY"))) {
-            metaMMOLoginInfo.setEulerY(Float.parseFloat(jsonObject.getString("eulerY")));
-        }
-        if (Objects.nonNull(jsonObject.getString("eulerZ"))) {
-            metaMMOLoginInfo.setEulerZ(Float.parseFloat(jsonObject.getString("eulerZ")));
-        }
-        if (Objects.nonNull(jsonObject.getString("top"))) {
-            metaMMOLoginInfo.setTop(Integer.parseInt(jsonObject.getString("top")));
-        }
-        if (Objects.nonNull(jsonObject.getString("hat"))) {
-            metaMMOLoginInfo.setHat(Integer.parseInt(jsonObject.getString("hat")));
-        }
-        if (Objects.nonNull(jsonObject.getString("down"))) {
-            metaMMOLoginInfo.setDown(Integer.parseInt(jsonObject.getString("down")));
-        }
-        if (Objects.nonNull(jsonObject.getString("shoes"))) {
-            metaMMOLoginInfo.setShoes(Integer.parseInt(jsonObject.getString("shoes")));
-        }
-        if (Objects.nonNull(jsonObject.getString("anim"))) {
-            metaMMOLoginInfo.setAnim(Integer.parseInt(jsonObject.getString("anim")));
-        }
-        if (Objects.nonNull(jsonObject.getString("emoji"))) {
-            metaMMOLoginInfo.setEmoji(Integer.parseInt(jsonObject.getString("emoji")));
-        }
-    }
-
-    /**
-     * 校验参数
-     *
-     * @param jsonObject 参数
-     * @return 校验结果
-     */
-    private MetaServiceResult checkParams(JSONObject jsonObject) {
-        if (Objects.isNull(jsonObject)) {
-            return MetaServiceResult.returnError("Illegal parameter : jsonObject can not be null");
-        }
-        if (Objects.isNull(jsonObject.getString("type"))) {
-            return MetaServiceResult.returnError("Illegal parameter : type can not be null");
-        }
-        if (Objects.isNull(jsonObject.getString("cityId"))) {
-            return MetaServiceResult.returnError("Illegal parameter : cityId can not be null");
-        }
-        if (Objects.isNull(jsonObject.getString("regionId"))) {
-            return MetaServiceResult.returnError("Illegal parameter : regionId can not be null");
-        }
-        if (Objects.isNull(jsonObject.getString("id"))) {
-            return MetaServiceResult.returnError("Illegal parameter : id can not be null");
-        }
-        return MetaServiceResult.returnSuccess("check success");
-    }
-
-    private List<String> remove(String key, String userId) {
-        List<String> userIds = redisTemplate.opsForList().range(REDIS_PREFIX.concat(key), 0, -1);
-        //  去除当前玩家id
-        List<String> otherUserIds = new ArrayList<>();
-        if (CollectionUtils.isNotEmpty(userIds)) {
-            otherUserIds = userIds.stream().filter(id -> !Objects.equals(id, REDIS_PREFIX.concat(userId))).collect(Collectors.toList());
-        }
-        return otherUserIds;
-    }
-
-    public MetaRestResult clearMMO(String userId, String regionId, String cityId) {
-        init();
-        if (clients.containsKey(REDIS_PREFIX.concat(userId))) {
-            String errMsg = String.format("userId[%S]用户mmo连接正常,无法清除缓存!", userId);
-            log.info(errMsg);
-            return MetaRestResult.returnError(errMsg);
-        }
-        String key = cityId.concat(":").concat(regionId);
-        redisTemplate.delete(REDIS_PREFIX.concat(userId));
-        redisTemplate.opsForList().remove(REDIS_PREFIX.concat(key), 0, REDIS_PREFIX.concat(userId));
-        return MetaRestResult.returnSuccess("清除成功");
-    }
-}

+ 0 - 51
src/main/java/com/izouma/nineth/websocket/WebsocketCommon.java

@@ -1,51 +0,0 @@
-package com.izouma.nineth.websocket;
-
-
-import lombok.extern.slf4j.Slf4j;
-
-import javax.websocket.Session;
-import java.util.Map;
-import java.util.Set;
-
-@Slf4j
-public class WebsocketCommon {
-
-    /**
-     * 给指定用户分发消息
-     *
-     * @param message  消息体
-     * @param toUserId 用户id
-     */
-    public void sendMessageTo(Map<String, Session> clients, String message, String toUserId) {
-        if (!clients.containsKey(toUserId)) {
-            log.error("session信息不存在");
-            return;
-        }
-        log.info(String.format("给指定的在线用户发送消息,当前在线人员为[%S]。消息:[%S]", toUserId, message));
-        try {
-            clients.get(toUserId).getBasicRemote().sendText(message);
-        } catch (Exception e) {
-            log.error(String.format("send message [%S] to [%S] throw exception [%S]:", message, toUserId, e));
-        }
-    }
-
-    /**
-     * 给所有用户发消息
-     *
-     * @param clients 在线客户端
-     * @param message 消息
-     */
-    public void sendMessageToOther(Map<String, Session> clients, String message, String userId) {
-        Set<String> userIds = clients.keySet();
-        userIds.forEach(id -> {
-            try {
-                if (!id.equals(userId)) {
-                    log.info(String.format("服务器给所有在线用户发送消息,当前在线人员为[%S]。消息:[%S]", id, message));
-                    clients.get(id).getBasicRemote().sendText(message);
-                }
-            } catch (Exception e) {
-                log.error(String.format("send message [%S] to [%S] throw exception [%S]:", message, id, e));
-            }
-        });
-    }
-}

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

@@ -0,0 +1 @@
+{"tableName":"MetaUserProp","className":"MetaUserProp","remark":"玩家道具背包","genTable":true,"genClass":true,"genList":true,"genForm":true,"genRouter":true,"javaPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/java/com/izouma/nineth","viewPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/vue/src/views","routerPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/vue/src","resourcesPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"userId","modelName":"userId","remark":"用户id","showInList":true,"showInForm":true,"formType":"number"},{"name":"metaPropId","modelName":"metaPropId","remark":"道具id","showInList":true,"showInForm":true,"formType":"number"},{"name":"name","modelName":"name","remark":"名称","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"pic","modelName":"pic","remark":"图片","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"num","modelName":"num","remark":"数量","showInList":true,"showInForm":true,"formType":"singleLineText"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.nineth","tablePackage":"com.izouma.nineth.domain.MetaUserProp"}

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
src/main/resources/genjson/MetaUserPropRecord.json


+ 32 - 0
src/main/vue/src/router.js

@@ -1733,6 +1733,38 @@ const router = new Router({
                     meta: {
                        title: '抽奖活动奖励记录',
                     },
+               },
+                {
+                    path: '/metaUserPropEdit',
+                    name: 'MetaUserPropEdit',
+                    component: () => import(/* webpackChunkName: "metaUserPropEdit" */ '@/views/MetaUserPropEdit.vue'),
+                    meta: {
+                       title: '玩家道具背包编辑',
+                    },
+                },
+                {
+                    path: '/metaUserPropList',
+                    name: 'MetaUserPropList',
+                    component: () => import(/* webpackChunkName: "metaUserPropList" */ '@/views/MetaUserPropList.vue'),
+                    meta: {
+                       title: '玩家道具背包',
+                    },
+               },
+                {
+                    path: '/metaUserPropRecordEdit',
+                    name: 'MetaUserPropRecordEdit',
+                    component: () => import(/* webpackChunkName: "metaUserPropRecordEdit" */ '@/views/MetaUserPropRecordEdit.vue'),
+                    meta: {
+                       title: '用户道具记录编辑',
+                    },
+                },
+                {
+                    path: '/metaUserPropRecordList',
+                    name: 'MetaUserPropRecordList',
+                    component: () => import(/* webpackChunkName: "metaUserPropRecordList" */ '@/views/MetaUserPropRecordList.vue'),
+                    meta: {
+                       title: '用户道具记录',
+                    },
                }
                 /**INSERT_LOCATION**/
             ]

+ 67 - 0
src/main/vue/src/views/MetaUserPropEdit.vue

@@ -0,0 +1,67 @@
+<template>
+	<div class="edit-view">
+		<page-title>
+			<el-button @click="$router.go(-1)" :disabled="saving"> 返回 </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="65px"
+					label-position="right"
+					size="small"
+					style="max-width: 500px"
+				>
+					<el-form-item prop="userId" label="用户id">
+						<el-input-number type="number" v-model="formData.userId"> </el-input-number>
+					</el-form-item>
+					<el-form-item prop="metaPropId" label="道具id">
+						<el-input-number type="number" v-model="formData.metaPropId"> </el-input-number>
+					</el-form-item>
+					<el-form-item prop="name" label="名称">
+						<el-input v-model="formData.name"> </el-input>
+					</el-form-item>
+					<el-form-item prop="pic" label="图片">
+						<el-input v-model="formData.pic"> </el-input>
+					</el-form-item>
+					<el-form-item prop="num" label="数量">
+						<el-input v-model="formData.num"> </el-input>
+					</el-form-item>
+					<el-form-item class="form-submit">
+						<el-button @click="$router.go(-1)" :disabled="saving"> 返回 </el-button>
+					</el-form-item>
+				</el-form>
+			</div>
+		</div>
+	</div>
+</template>
+<script>
+export default {
+	name: 'MetaUserPropEdit',
+	created() {
+		if (this.$route.query.id) {
+			this.$http
+				.get('metaUserProp/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: {}
+		};
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>

+ 131 - 0
src/main/vue/src/views/MetaUserPropList.vue

@@ -0,0 +1,131 @@
+<template>
+	<div class="list-view">
+		<page-title>
+			<el-button
+				@click="download"
+				icon="el-icon-upload2"
+				:loading="downloading"
+				:disabled="fetchingData"
+				class="filter-item"
+			>
+				导出
+			</el-button>
+		</page-title>
+		<div class="filters-container">
+			<el-input
+				placeholder="搜索..."
+				v-model="search"
+				clearable
+				class="filter-item search"
+				@keyup.enter.native="getData"
+			>
+				<el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+			</el-input>
+		</div>
+		<el-table
+			:data="tableData"
+			row-key="id"
+			ref="table"
+			header-row-class-name="table-header-row"
+			header-cell-class-name="table-header-cell"
+			row-class-name="table-row"
+			cell-class-name="table-cell"
+			:height="tableHeight"
+			v-loading="fetchingData"
+		>
+			<el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+			<el-table-column prop="id" label="ID" width="100"> </el-table-column>
+			<el-table-column prop="userId" label="用户id"> </el-table-column>
+			<el-table-column prop="metaPropId" label="道具id"> </el-table-column>
+			<el-table-column prop="name" label="名称"> </el-table-column>
+			<el-table-column prop="pic" label="图片"> </el-table-column>
+			<el-table-column prop="num" label="数量"> </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>
+				</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: 'MetaUserPropList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			multipleMode: false,
+			search: '',
+			url: '/metaUserProp/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();
+			}
+		},
+		editRow(row) {
+			this.$router.push({
+				path: '/metaUserPropEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		download() {
+			this.downloading = true;
+			this.$axios
+				.get('/metaUserProp/excel', {
+					responseType: 'blob',
+					params: { size: 10000 }
+				})
+				.then(res => {
+					console.log(res);
+					this.downloading = false;
+					const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+					const link = document.createElement('a');
+					link.href = downloadUrl;
+					link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+					document.body.appendChild(link);
+					link.click();
+					link.remove();
+				})
+				.catch(e => {
+					console.log(e);
+					this.downloading = false;
+					this.$message.error(e.error);
+				});
+		}
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>

+ 110 - 0
src/main/vue/src/views/MetaUserPropRecordEdit.vue

@@ -0,0 +1,110 @@
+<template>
+	<div class="edit-view">
+		<page-title>
+			<el-button @click="$router.go(-1)" :disabled="saving"> 返回 </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="178px"
+					label-position="right"
+					size="small"
+					style="max-width: 500px"
+				>
+					<el-form-item prop="userId" label="用户id">
+						<el-input-number type="number" v-model="formData.userId"> </el-input-number>
+					</el-form-item>
+					<el-form-item prop="operationType" label="操作类型">
+						<el-select v-model="formData.operationType" clearable filterable placeholder="请选择">
+							<el-option
+								v-for="item in operationTypeOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+					<el-form-item prop="operatingTime" label="操作时间">
+						<el-date-picker
+							v-model="formData.operatingTime"
+							type="datetime"
+							value-format="yyyy-MM-dd HH:mm:ss"
+							placeholder="选择日期时间"
+						>
+						</el-date-picker>
+					</el-form-item>
+					<el-form-item prop="usedType" label="使用类型">
+						<el-select v-model="formData.usedType" clearable filterable placeholder="请选择">
+							<el-option
+								v-for="item in usedTypeOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+					<el-form-item prop="metaPropId" label="道具id">
+						<el-input-number type="number" v-model="formData.metaPropId"> </el-input-number>
+					</el-form-item>
+					<el-form-item prop="name" label="名称">
+						<el-input v-model="formData.name"> </el-input>
+					</el-form-item>
+					<el-form-item prop="pic" label="图片">
+						<el-input v-model="formData.pic"> </el-input>
+					</el-form-item>
+					<el-form-item prop="times" label="限时道具时间,单位小时">
+						<el-input v-model="formData.times"> </el-input>
+					</el-form-item>
+					<el-form-item prop="finish" label="限时道具是否失效">
+						<el-input v-model="formData.finish"> </el-input>
+					</el-form-item>
+					<el-form-item class="form-submit">
+						<el-button @click="$router.go(-1)" :disabled="saving"> 返回 </el-button>
+					</el-form-item>
+				</el-form>
+			</div>
+		</div>
+	</div>
+</template>
+<script>
+export default {
+	name: 'MetaUserPropRecordEdit',
+	created() {
+		if (this.$route.query.id) {
+			this.$http
+				.get('metaUserPropRecord/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: {},
+			operationTypeOptions: [
+				{ label: '领取/获得', value: 'RECEIVE' },
+				{ label: '使用', value: 'USE' }
+			],
+			usedTypeOptions: [
+				{ label: '永久', value: 'PERMANENT' },
+				{ label: '一次性', value: 'DISPOSABLE' },
+				{ label: '限时', value: 'LIMITED' }
+			]
+		};
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>

+ 159 - 0
src/main/vue/src/views/MetaUserPropRecordList.vue

@@ -0,0 +1,159 @@
+<template>
+	<div class="list-view">
+		<page-title>
+			<el-button
+				@click="download"
+				icon="el-icon-upload2"
+				:loading="downloading"
+				:disabled="fetchingData"
+				class="filter-item"
+			>
+				导出
+			</el-button>
+		</page-title>
+		<div class="filters-container">
+			<el-input
+				placeholder="搜索..."
+				v-model="search"
+				clearable
+				class="filter-item search"
+				@keyup.enter.native="getData"
+			>
+				<el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+			</el-input>
+		</div>
+		<el-table
+			:data="tableData"
+			row-key="id"
+			ref="table"
+			header-row-class-name="table-header-row"
+			header-cell-class-name="table-header-cell"
+			row-class-name="table-row"
+			cell-class-name="table-cell"
+			:height="tableHeight"
+			v-loading="fetchingData"
+		>
+			<el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+			<el-table-column prop="id" label="ID" width="100"> </el-table-column>
+			<el-table-column prop="userId" label="用户id"> </el-table-column>
+			<el-table-column prop="operationType" label="操作类型" :formatter="operationTypeFormatter">
+			</el-table-column>
+			<el-table-column prop="operatingTime" label="操作时间"> </el-table-column>
+			<el-table-column prop="usedType" label="使用类型" :formatter="usedTypeFormatter"> </el-table-column>
+			<el-table-column prop="metaPropId" label="道具id"> </el-table-column>
+			<el-table-column prop="name" label="名称"> </el-table-column>
+			<el-table-column prop="pic" label="图片"> </el-table-column>
+			<el-table-column prop="times" label="限时道具时间,单位小时"> </el-table-column>
+			<el-table-column prop="finish" label="限时道具是否失效"> </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>
+				</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: 'MetaUserPropRecordList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			multipleMode: false,
+			search: '',
+			url: '/metaUserPropRecord/all',
+			downloading: false,
+			operationTypeOptions: [
+				{ label: '领取/获得', value: 'RECEIVE' },
+				{ label: '使用', value: 'USE' }
+			],
+			usedTypeOptions: [
+				{ label: '永久', value: 'PERMANENT' },
+				{ label: '一次性', value: 'DISPOSABLE' },
+				{ label: '限时', value: 'LIMITED' }
+			]
+		};
+	},
+	computed: {
+		selection() {
+			return this.$refs.table.selection.map(i => i.id);
+		}
+	},
+	methods: {
+		operationTypeFormatter(row, column, cellValue, index) {
+			let selectedOption = this.operationTypeOptions.find(i => i.value === cellValue);
+			if (selectedOption) {
+				return selectedOption.label;
+			}
+			return '';
+		},
+		usedTypeFormatter(row, column, cellValue, index) {
+			let selectedOption = this.usedTypeOptions.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();
+			}
+		},
+		editRow(row) {
+			this.$router.push({
+				path: '/metaUserPropRecordEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		download() {
+			this.downloading = true;
+			this.$axios
+				.get('/metaUserPropRecord/excel', {
+					responseType: 'blob',
+					params: { size: 10000 }
+				})
+				.then(res => {
+					console.log(res);
+					this.downloading = false;
+					const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+					const link = document.createElement('a');
+					link.href = downloadUrl;
+					link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+					document.body.appendChild(link);
+					link.click();
+					link.remove();
+				})
+				.catch(e => {
+					console.log(e);
+					this.downloading = false;
+					this.$message.error(e.error);
+				});
+		}
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff