generated from root/miduo_server
海外发货机
parent
501a37d37b
commit
286b12942d
|
@ -29,7 +29,7 @@ public class Application {
|
||||||
ThriftPoolUtils.getInstance().initContext(configurableApplicationContext);
|
ThriftPoolUtils.getInstance().initContext(configurableApplicationContext);
|
||||||
// ManagerManager handlerManager = ManagerManager.getInstance();
|
// ManagerManager handlerManager = ManagerManager.getInstance();
|
||||||
// KProducer kProducer = configurableApplicationContext.getBean(KProducer.class);
|
// KProducer kProducer = configurableApplicationContext.getBean(KProducer.class);
|
||||||
KProducer.init();
|
// KProducer.init();
|
||||||
//redis初始化
|
//redis初始化
|
||||||
RedisAutoConfiguration redisAutoConfiguration = configurableApplicationContext.getBean(RedisAutoConfiguration.class);
|
RedisAutoConfiguration redisAutoConfiguration = configurableApplicationContext.getBean(RedisAutoConfiguration.class);
|
||||||
RedisUtil.getInstence().init(redisAutoConfiguration.getRedisProperties());
|
RedisUtil.getInstence().init(redisAutoConfiguration.getRedisProperties());
|
||||||
|
|
|
@ -1,17 +1,37 @@
|
||||||
package com.jmfy.controller;
|
package com.jmfy.controller;
|
||||||
|
|
||||||
|
import com.jmfy.dto.FindPlayerResult;
|
||||||
|
import com.jmfy.dto.JsonResult;
|
||||||
|
import com.jmfy.dto.PlayerInfo;
|
||||||
|
import com.jmfy.util.JsonUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Controller
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
public class HealthController {
|
public class HealthController {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class);
|
||||||
@RequestMapping(value = "health")
|
@RequestMapping(value = "/health")
|
||||||
public String getStatus(){
|
public String deliveryGoods(HttpServletRequest request){
|
||||||
return "deliveryGoods.html";
|
JsonResult jsonResult = new JsonResult();
|
||||||
|
jsonResult.setRet(1000);
|
||||||
|
jsonResult.setMsg("ok");
|
||||||
|
LOGGER.info("======> end midas request...");
|
||||||
|
|
||||||
|
List<PlayerInfo> playerInfos = new ArrayList<>();
|
||||||
|
playerInfos.add(new PlayerInfo("阿斯蒂芬",12,"1000001","1"));
|
||||||
|
|
||||||
|
FindPlayerResult findPlayerResult = new FindPlayerResult("1000","success",playerInfos);
|
||||||
|
|
||||||
|
String result = JsonUtil.getInstence().getGson().toJson(findPlayerResult);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.jmfy.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FindPlayerResult {
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private List<PlayerInfo> list;
|
||||||
|
|
||||||
|
public FindPlayerResult(String code, String message, List<PlayerInfo> list){
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlayerInfo> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<PlayerInfo> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,4 +22,12 @@ public class JsonResult {
|
||||||
public void setRet(int ret) {
|
public void setRet(int ret) {
|
||||||
this.ret = ret;
|
this.ret = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JsonResult{" +
|
||||||
|
"ret=" + ret +
|
||||||
|
", msg='" + msg + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.jmfy.dto;
|
||||||
|
|
||||||
|
public class PlayerInfo {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private int level;
|
||||||
|
|
||||||
|
private String roleid;
|
||||||
|
|
||||||
|
private String serverCode;
|
||||||
|
|
||||||
|
public PlayerInfo(String name, int level, String roleid, String serverCode){
|
||||||
|
this.name = name;
|
||||||
|
this.level = level;
|
||||||
|
this.roleid = roleid;
|
||||||
|
this.serverCode = serverCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(int level) {
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleid() {
|
||||||
|
return roleid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleid(String roleid) {
|
||||||
|
this.roleid = roleid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerCode() {
|
||||||
|
return serverCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerCode(String serverCode) {
|
||||||
|
this.serverCode = serverCode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.jmfy.util;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
public class JsonUtil {
|
||||||
|
|
||||||
|
|
||||||
|
private static JsonUtil jsonUtil;
|
||||||
|
|
||||||
|
private Gson gson = new Gson();
|
||||||
|
|
||||||
|
private static class InnerClass {
|
||||||
|
private static final JsonUtil SINGLETON = new JsonUtil();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonUtil getInstence() {
|
||||||
|
if (jsonUtil == null) {
|
||||||
|
jsonUtil = JsonUtil.InnerClass.SINGLETON;
|
||||||
|
}
|
||||||
|
return jsonUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gson getGson() {
|
||||||
|
return gson;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,39 +1,32 @@
|
||||||
package com.jmfy.util;
|
package com.jmfy.util;
|
||||||
|
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
|
||||||
import org.apache.kafka.clients.producer.Producer;
|
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import org.springframework.stereotype.Component;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class KProducer {
|
public class KProducer {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(KProducer.class);
|
// private static final Logger LOGGER = LoggerFactory.getLogger(KProducer.class);
|
||||||
private static Producer<String, String> producer;
|
// private static Producer<String, String> producer;
|
||||||
public static void init() {
|
// public static void init() {
|
||||||
Properties props = new Properties();
|
// Properties props = new Properties();
|
||||||
props.put("bootstrap.servers", "192.168.0.169:9092");
|
// props.put("bootstrap.servers", "192.168.0.169:9092");
|
||||||
// props.put("bootstrap.servers", "118.89.130.188:9092");//服务器ip:端口号,集群用逗号分隔
|
//// props.put("bootstrap.servers", "118.89.130.188:9092");//服务器ip:端口号,集群用逗号分隔
|
||||||
props.put("acks", "all");
|
// props.put("acks", "all");
|
||||||
props.put("retries", 0);
|
// props.put("retries", 0);
|
||||||
props.put("batch.size", 16384);
|
// props.put("batch.size", 16384);
|
||||||
props.put("linger.ms", 1);
|
// props.put("linger.ms", 1);
|
||||||
props.put("buffer.memory", 33554432);
|
// props.put("buffer.memory", 33554432);
|
||||||
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
|
// props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
|
||||||
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
|
// props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
|
||||||
producer = new KafkaProducer<>(props);
|
// producer = new KafkaProducer<>(props);
|
||||||
LOGGER.info("KProducer init...");
|
// LOGGER.info("KProducer init...");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void sendMsgToKafka(String topic, String msg) {
|
// public static void sendMsgToKafka(String topic, String msg) {
|
||||||
String key = "tlog_msg";
|
// String key = "tlog_msg";
|
||||||
producer.send(new ProducerRecord<>(topic, key, msg));
|
// producer.send(new ProducerRecord<>(topic, key, msg));
|
||||||
LOGGER.info("send kafka success.. ");
|
// LOGGER.info("send kafka success.. ");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.jmfy.util;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
public class MD5Util {
|
||||||
|
|
||||||
|
public static String encrypByMd5(String context) {
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
md.update(context.getBytes());//update处理
|
||||||
|
byte [] encryContext = md.digest();//调用该方法完成计算
|
||||||
|
|
||||||
|
int i;
|
||||||
|
StringBuffer buf = new StringBuffer("");
|
||||||
|
for (int offset = 0; offset < encryContext.length; offset++) {//做相应的转化(十六进制)
|
||||||
|
i = encryContext[offset];
|
||||||
|
if (i < 0) i += 256;
|
||||||
|
if (i < 16) buf.append("0");
|
||||||
|
buf.append(Integer.toHexString(i));
|
||||||
|
}
|
||||||
|
System.out.println("32result: " + buf.toString());// 32位的加密
|
||||||
|
System.out.println("16result: " + buf.toString().substring(8, 24));// 16位的加密
|
||||||
|
|
||||||
|
return buf.toString();
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String str = encrypByMd5(YsjConstant.TW_GameKey+"11231231"+"1");
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,4 +23,11 @@ public class YsjConstant {
|
||||||
|
|
||||||
public static String protocol_https = "https";
|
public static String protocol_https = "https";
|
||||||
|
|
||||||
|
//海外相关
|
||||||
|
public static String TW_GameKey= "DB9191DCD40233D18E1DDE8382204AD9";
|
||||||
|
|
||||||
|
public static String TW_IOS_GameCode= "twysjios";
|
||||||
|
|
||||||
|
public static String TW_ANDROID_GameCode= "twysj";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue