Ver código fonte

赔率同步

kk 1 mês atrás
pai
commit
6ec85918c1

+ 56 - 0
game-business/src/main/java/com/game/business/controller/AppGameItemController.java

@@ -7,6 +7,7 @@ import java.util.Comparator;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.game.business.domain.*;
 import com.game.business.dto.AppGameItemDTO;
 import com.game.business.service.IAppGameClassifyService;
@@ -234,4 +235,59 @@ public class AppGameItemController extends BaseController
         }
         return R.ok("同步成功");
     }
+
+    /**
+     * 获取游戏选项
+     */
+    @ApiOperation(value = "获取游戏选项", notes = "获取游戏选项")
+    @PostMapping("/getSynItem")
+    public R getSynItem(@RequestBody AppGameItemDTO appGameItemDTO)
+    {
+        if(StringUtils.isBlank(appGameItemDTO.getClassId())){
+            return R.fail("平台ID为空");
+        }
+
+        AppGameClassify appGameClassify = appGameClassifyService.getByCode(appGameItemDTO.getClassId());
+
+        if(appGameClassify == null){
+            return R.fail("平台ID不正确");
+        }
+
+        if(StringUtils.isBlank(appGameItemDTO.getGameId())){
+            return R.fail("平台不存在");
+        }
+
+        AppGame appGame = appGameService.selectAppGameByClassIdAndCode(appGameClassify.getId(), appGameItemDTO.getGameId());
+
+        if(appGame == null){
+            return R.fail("游戏不存在");
+        }
+
+        if(StringUtils.isBlank(appGameItemDTO.getConfig())){
+            return R.fail("游戏赔率配置为空");
+        }
+
+        AppGameItem appGameItem = new AppGameItem();
+        appGameItem.setGameId(appGame.getId());
+        List<AppGameItem> itemList = appGameItemService.selectAppGameItemList(appGameItem);
+        if(itemList == null || itemList.isEmpty()){
+            return R.fail("游戏未配置选项设置");
+        }
+
+        // 升序排序
+        Collections.sort(itemList, Comparator.comparing(AppGameItem::getItemLocation));
+        String config = "";
+        for (int i = 0; i < itemList.size(); i++) {
+            AppGameItem gameItem = itemList.get(i);
+            if(StringUtils.isBlank(config)){
+                config = gameItem.getItemMultiple() + "";
+            }else{
+                config = config + "," + gameItem.getItemMultiple() + "";
+            }
+        }
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("config", config);
+        return R.ok(jsonObject);
+    }
 }

+ 1 - 1
game-framework/src/main/java/com/game/framework/config/SecurityConfig.java

@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // 过滤请求
                 .authorizeRequests()
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
-                .antMatchers("/login", "/register", "/captchaImage","/business/game_item/synItem").permitAll()
+                .antMatchers("/login", "/register", "/captchaImage", "/business/game_item/getSynItem").permitAll()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()