当前位置: 首页 > news >正文

怎样开网站卖东西网站开发使用什么软件

怎样开网站卖东西,网站开发使用什么软件,重生做网站小说,店铺运营方案策划每次要多传一个bot_id 判网关的时候判127.0.0.1所以最好改localhost 创建SpringCloud的子项目 BotRunningSystem 在BotRunningSystem项目中添加依赖#xff1a; joor-java-8 可动态编译Java代码 2. 修改前端#xff0c;传入对Bot的选择操作 package com.kob.botrunningsy… 每次要多传一个bot_id  判网关的时候判127.0.0.1所以最好改localhost 创建SpringCloud的子项目 BotRunningSystem 在BotRunningSystem项目中添加依赖 joor-java-8 可动态编译Java代码 2. 修改前端传入对Bot的选择操作 package com.kob.botrunningsystem.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate;Configuration public class RestTemplateConfig {Beanpublic RestTemplate getRestTemplate() {return new RestTemplate();} }package com.kob.botrunningsystem.config;import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy;Configuration EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter {Overrideprotected void configure(HttpSecurity http) throws Exception {http.csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests().antMatchers(/bot/add/).hasIpAddress(127.0.0.1).antMatchers(HttpMethod.OPTIONS).permitAll().anyRequest().authenticated();} } package com.kob.botrunningsystem.controller;import com.kob.botrunningsystem.service.BotRunningService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;import java.util.Objects;RestController public class BotRunningController {Autowiredprivate BotRunningService botRunningService;PostMapping(/bot/add/)public String addBot(RequestParam MultiValueMapString, String data) {Integer userId Integer.parseInt(Objects.requireNonNull(data.getFirst(user_id)));String botCode data.getFirst(bot_code);String input data.getFirst(input);return botRunningService.addBot(userId, botCode, input);} }package com.kob.botrunningsystem.service.impl.utils;import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor;Data AllArgsConstructor NoArgsConstructor public class Bot {Integer userId;String botCode;String input; }package com.kob.botrunningsystem.service.impl.utils;import com.kob.botrunningsystem.utils.BotInterface; import org.joor.Reflect; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate;import java.util.UUID;Component public class Consumer extends Thread {private Bot bot;private static RestTemplate restTemplate;private final static String receiveBotMoveUrl http://127.0.0.1:8080/pk/receive/bot/move/;Autowiredpublic void setRestTemplate(RestTemplate restTemplate) {Consumer.restTemplate restTemplate;}public void startTimeout(long timeout, Bot bot) {this.bot bot;this.start();try {this.join(timeout); // 最多等待timeout秒} catch (InterruptedException e) {e.printStackTrace();} finally {this.interrupt(); // 终端当前线程}}private String addUid(String code, String uid) { // 在code中的Bot类名后添加uidint k code.indexOf( implements com.kob.botrunningsystem.utils.BotInterface);return code.substring(0, k) uid code.substring(k);}Overridepublic void run() {UUID uuid UUID.randomUUID();String uid uuid.toString().substring(0, 8);BotInterface botInterface Reflect.compile(com.kob.botrunningsystem.utils.Bot uid,addUid(bot.getBotCode(), uid)).create().get();Integer direction botInterface.nextMove(bot.getInput());System.out.println(move-direction: bot.getUserId() direction);MultiValueMapString, String data new LinkedMultiValueMap();data.add(user_id, bot.getUserId().toString());data.add(direction, direction.toString());restTemplate.postForObject(receiveBotMoveUrl, data, String.class);} }package com.kob.botrunningsystem.service.impl;import com.kob.botrunningsystem.service.BotRunningService; import com.kob.botrunningsystem.service.impl.utils.BotPool; import org.springframework.stereotype.Service;Service public class BotRunningServiceImpl implements BotRunningService {public final static BotPool botPool new BotPool();Overridepublic String addBot(Integer userId, String botCode, String input) {System.out.println(add bot: userId botCode input);botPool.addBot(userId, botCode, input);return add bot success;} }package com.kob.botrunningsystem.service;public interface BotRunningService {String addBot(Integer userId, String botCode, String input); }package com.kob.botrunningsystem.utils;import java.util.ArrayList; import java.util.List;public class Bot implements com.kob.botrunningsystem.utils.BotInterface {static class Cell {public int x, y;public Cell(int x, int y) {this.x x;this.y y;}}private boolean check_tail_increasing(int step) { // 检验当前回合蛇的长度是否增加if (step 10) return true;return step % 3 1;}public ListCell getCells(int sx, int sy, String steps) {steps steps.substring(1, steps.length() - 1);ListCell res new ArrayList();int[] dx {-1, 0, 1, 0}, dy {0, 1, 0, -1};int x sx, y sy;int step 0;res.add(new Cell(x, y));for (int i 0; i steps.length(); i ) {int d steps.charAt(i) - 0;x dx[d];y dy[d];res.add(new Cell(x, y));if (!check_tail_increasing( step)) {res.remove(0);}}return res;}Overridepublic Integer nextMove(String input) {String[] strs input.split(#);int[][] g new int[15][16];for (int i 0, k 0; i 15; i ) {for (int j 0; j 16; j , k ) {if (strs[0].charAt(k) 1) {g[i][j] 1;}}}int aSx Integer.parseInt(strs[1]), aSy Integer.parseInt(strs[2]);int bSx Integer.parseInt(strs[4]), bSy Integer.parseInt(strs[5]);ListCell aCells getCells(aSx, aSy, strs[3]);ListCell bCells getCells(bSx, bSy, strs[6]);for (Cell c: aCells) g[c.x][c.y] 1;for (Cell c: bCells) g[c.x][c.y] 1;int[] dx {-1, 0, 1, 0}, dy {0, 1, 0, -1};for (int i 0; i 4; i ) {int x aCells.get(aCells.size() - 1).x dx[i];int y aCells.get(aCells.size() - 1).y dy[i];if (x 0 x 15 y 0 y 16 g[x][y] 0) {return i;}}return 0;} }package com.kob.botrunningsystem.utils;public interface BotInterface {Integer nextMove(String input); }package com.kob.botrunningsystem;import com.kob.botrunningsystem.service.impl.BotRunningServiceImpl; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication public class BotRunningSystemApplication {public static void main(String[] args) {BotRunningServiceImpl.botPool.start();SpringApplication.run(BotRunningSystemApplication.class, args);} } 终极流程
http://www.hkea.cn/news/14369206/

相关文章:

  • 建设网站怎么建设分类公众号排版
  • 怎么做虚拟网站wordpress删除dux主题
  • 深圳手机网站制作湖南城乡建设厅官方网站
  • 黑色网站模版xml的文档打开乱码程序打开
  • 网站开发搭建植物提取网站做的比较好的厂家
  • 网站公告栏设计时间管理系统 网站开发
  • 网站做得好的公司网站自适应宽度
  • 建设小说网站用什么软件五大建设的内容
  • 永久免费网站虚拟主机网站源码修改后怎么提交
  • 网站开发毕设参考文献汕头多语种网站制作
  • 淘宝网站首页怎么做建设网站服务器怎么选
  • 厅网站集约化建设seo外包公司怎么样
  • 公司内部网站如何备案电商网络营销是干什么的
  • 国外做连接器平台网站泰兴网站建设公司
  • 沧州网站建设哪家专业wordpress模板安装后效果和预览不同
  • 手机网站建设图片外贸渠道有哪些
  • 宁波手机建站模板wordpress中文案例
  • 山东省建行企业网站茶叶外贸网站建设
  • 企业年底做网站的好处app开发哪个公司好
  • 中山做网站比较好免费的网站软件正能量推荐
  • 协会网站建设哪里实惠微商商城官网
  • 网站添加微信支付百度官方电话人工服务电话
  • 哪个网站做网站方便做国际网站要多少钱
  • 公司网站 用 个人备案域名用 可以做网站软件吗
  • 电子商务商城网站建设免费seo快速排名工具
  • 网站链接优化做鲜榨果汁店网站
  • 做兼职网站企业网络营销策划与分析
  • 国外创意网站设计欣赏wordpress已计划
  • 公司软件网站开发怎么入账我的世界封面制作网站
  • 摄影网站参考文献徐州建站程序