瀏覽代碼

Merge remote-tracking branch 'origin/dev-lingfeng' into dev0.0.1

xufeng 2 年之前
父節點
當前提交
942dd980e5

+ 2 - 1
game-module/game-manage/src/main/java/com/zanxiang/manage/ManageApplication.java

@@ -5,8 +5,9 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.web.bind.annotation.CrossOrigin;
 
 
-
+@CrossOrigin
 @Slf4j
 @Slf4j
 @EnableDiscoveryClient
 @EnableDiscoveryClient
 @SpringBootApplication
 @SpringBootApplication

+ 31 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/config/CORSConfig.java

@@ -0,0 +1,31 @@
+package com.zanxiang.manage.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-06-16
+ * @description : 跨域配置
+ */
+@Configuration
+public class CORSConfig {
+
+    private CorsConfiguration buildConfig() {
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        corsConfiguration.addAllowedOrigin("*");
+        corsConfiguration.addAllowedHeader("*");
+        corsConfiguration.addAllowedMethod("*");
+        return corsConfiguration;
+    }
+
+    @Bean
+    public CorsFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        source.registerCorsConfiguration("/**", buildConfig());
+        return new CorsFilter(source);
+    }
+}

+ 2 - 2
game-module/game-manage/src/main/java/com/zanxiang/manage/controller/GameCategoryController.java

@@ -32,10 +32,10 @@ public class GameCategoryController {
     @Autowired
     @Autowired
     private GameCategoryService gameCategoryService;
     private GameCategoryService gameCategoryService;
 
 
-    @ApiOperation(value = "查询所父标签列表")
+    @ApiOperation(value = "查询所游戏分类或父标签列表")
     @GetMapping(value = "/parent/list")
     @GetMapping(value = "/parent/list")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameCategoryParentVO.class, responseContainer = "list")})
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GameCategoryParentVO.class, responseContainer = "list")})
-    public ResultVo<List<GameCategoryParentVO>> getGameCategoryParent(@RequestParam(required = false, defaultValue = "2") Integer type) {
+    public ResultVo<List<GameCategoryParentVO>> getGameCategoryParent(@RequestParam Integer type) {
         return ResultVo.ok(gameCategoryService.getGameCategoryParent(type));
         return ResultVo.ok(gameCategoryService.getGameCategoryParent(type));
     }
     }
 
 

+ 2 - 2
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/CpVO.java

@@ -47,13 +47,13 @@ public class CpVO {
      * 对接状态
      * 对接状态
      */
      */
     @ApiModelProperty(notes = "对接状态")
     @ApiModelProperty(notes = "对接状态")
-    private Integer status;
+    private String status;
 
 
     /**
     /**
      * 备注
      * 备注
      */
      */
     @ApiModelProperty(notes = "备注")
     @ApiModelProperty(notes = "备注")
-    private String describe;
+    private String remark;
 
 
     /**
     /**
      * 创建时间
      * 创建时间

+ 1 - 1
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/GameCategoryParentVO.java

@@ -15,7 +15,7 @@ public class GameCategoryParentVO {
      * 主键id
      * 主键id
      */
      */
     @ApiModelProperty(notes = "主键id")
     @ApiModelProperty(notes = "主键id")
-    private String id;
+    private Long id;
 
 
     /**
     /**
      * 名称
      * 名称

+ 32 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/filter/CORSFilter.java

@@ -0,0 +1,32 @@
+package com.zanxiang.manage.filter;
+
+import org.springframework.context.annotation.Configuration;
+
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-06-16
+ * @description : 过滤器
+ */
+@WebFilter(filterName = "CorsFilter ")
+@Configuration
+public class CORSFilter implements Filter {
+
+    @Override
+    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
+        HttpServletResponse response = (HttpServletResponse) res;
+        HttpServletRequest request = (HttpServletRequest) req;
+        response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
+        response.setHeader("Access-Control-Allow-Credentials", "true");
+        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT, OPTION");
+        response.setHeader("Access-Control-Max-Age", "3600");
+        response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, cookie, token, Authorization");
+        chain.doFilter(req, res);
+    }
+
+}

+ 12 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/GameService.java

@@ -0,0 +1,12 @@
+package com.zanxiang.manage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.mybatis.entity.Game;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-06-24
+ * @description : 游戏逻辑
+ */
+public interface GameService extends IService<Game> {
+}

+ 10 - 2
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameCategoryServiceImpl.java

@@ -40,7 +40,8 @@ public class GameCategoryServiceImpl extends ServiceImpl<GameCategoryMapper, Gam
     @Override
     @Override
     public List<GameCategoryParentVO> getGameCategoryParent(Integer type) {
     public List<GameCategoryParentVO> getGameCategoryParent(Integer type) {
         List<GameCategory> gameCategoryList = list(new LambdaQueryWrapper<GameCategory>()
         List<GameCategory> gameCategoryList = list(new LambdaQueryWrapper<GameCategory>()
-                .eq(GameCategory::getType, type));
+                .eq(GameCategory::getType, type)
+                .eq(GameCategory::getParentId, 0));
         return BeanUtils.copyList(gameCategoryList, GameCategoryParentVO.class);
         return BeanUtils.copyList(gameCategoryList, GameCategoryParentVO.class);
     }
     }
 
 
@@ -70,7 +71,14 @@ public class GameCategoryServiceImpl extends ServiceImpl<GameCategoryMapper, Gam
         if (Objects.isNull(gameCategory)) {
         if (Objects.isNull(gameCategory)) {
             return null;
             return null;
         }
         }
-        return BeanUtils.copy(gameCategory, GameCategoryVO.class);
+        GameCategoryVO categoryVO = BeanUtils.copy(gameCategory, GameCategoryVO.class);
+        if (Objects.equals(categoryVO.getParentId(), 0L)) {
+            categoryVO.setParentName(categoryVO.getName());
+        } else {
+            GameCategory category = super.getById(categoryVO.getParentId());
+            categoryVO.setParentName(category.getName());
+        }
+        return categoryVO;
     }
     }
 
 
     /**
     /**

+ 23 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/GameServiceImpl.java

@@ -0,0 +1,23 @@
+package com.zanxiang.manage.service.Impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.manage.service.GameService;
+import com.zanxiang.mybatis.entity.Game;
+import com.zanxiang.mybatis.mapper.GameMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author : lingfeng
+ * @time : 2022-06-24
+ * @description : 游戏逻辑
+ */
+@Slf4j
+@Service
+public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements GameService {
+
+    /**
+     * 新增游戏
+     */
+
+}