新增魔改客户端数据库支持
新增SQLite支持 地图排行榜初期准备
This commit is contained in:
parent
82278f1967
commit
e0233e5b9d
6
pom.xml
6
pom.xml
@ -140,6 +140,12 @@
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.28.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.yutou.controller;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.yutou.maptop.Bean.UserTeam;
|
||||
import com.yutou.maptop.services.UserTeamService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@ -34,11 +37,24 @@ public class test {
|
||||
TMod mod=modService.getMod(id,0);
|
||||
return JSON.toJSONString(mod);
|
||||
}
|
||||
private static int index=0;
|
||||
@Resource
|
||||
UserTeamService daoServier;
|
||||
@ResponseBody
|
||||
@RequestMapping("/search.do")
|
||||
public String searchMod(String search) {
|
||||
String json="{\"status\":1,\"isShow\":1,\"adModel\":[{\"modelFlag\":1,\"positionIds\":{\"0\":{\"agentFlag\":1,\"appId\":\"1106950165\",\"modelStyle\":-1,\"adPosition\":[\"2030330690179417\",\"9060530630473499\"],\"browserType\":1,\"closeFlag\":2},\"1\":{\"agentFlag\":2,\"appId\":\"1106950165\",\"modelStyle\":-1,\"adPosition\":[\"203033069017\",\"906053063047\"],\"browserType\":1,\"closeFlag\":2},\"num\":2}},{\"modelFlag\":6,\"positionIds\":{\"0\":{\"agentFlag\":1,\"appId\":\"1106930243\",\"modelStyle\":4,\"adPosition\":[\"7080651707725363\"],\"browserType\":1,\"closeFlag\":2},\"1\":{\"agentFlag\":1,\"appId\":\"1106930243\",\"modelStyle\":6,\"adPosition\":[\"2050252777728335\"],\"browserType\":1,\"closeFlag\":2},\"2\":{\"agentFlag\":1,\"appId\":\"1106930243\",\"modelStyle\":5,\"adPosition\":[\"2000751737222326\"],\"browserType\":1,\"closeFlag\":2},\"num\":3}}]}";
|
||||
return AESTools.aesEncrypt(json, "langtianaes20188");
|
||||
@RequestMapping("/team/insert.do")
|
||||
public String searchMod(String id) {
|
||||
UserTeam team=new UserTeam();
|
||||
team.setUname("名字"+(index++));
|
||||
team.setCreateTime(new Date());
|
||||
team.setShip("aaabbbccc"+index);
|
||||
daoServier.insertTeam(team);
|
||||
return "ok";
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping("/team/select.do")
|
||||
public String selectTeam(){
|
||||
List<UserTeam> list= daoServier.selectById(-1);
|
||||
return JSON.toJSONString(list);
|
||||
}
|
||||
|
||||
|
||||
|
42
src/main/java/com/yutou/databases/JianrDataSourceConfig.java
Normal file
42
src/main/java/com/yutou/databases/JianrDataSourceConfig.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.yutou.databases;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages ="com.yutou.jianrdb.Dao" ,sqlSessionTemplateRef = "db2SqlSessionTemplate")
|
||||
public class JianrDataSourceConfig {
|
||||
@Bean(name = "db2DataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.secondary")
|
||||
public DataSource testDataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Bean(name = "db2SqlSessionFactory")
|
||||
public SqlSessionFactory testSqlSessionFactory(@Qualifier("db2DataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dataSource);
|
||||
//bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/mapper/db2/*.xml"));
|
||||
return bean.getObject();
|
||||
}
|
||||
|
||||
@Bean(name = "db2TransactionManager")
|
||||
public DataSourceTransactionManager testTransactionManager(@Qualifier("db2DataSource") DataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
}
|
||||
|
||||
@Bean(name = "db2SqlSessionTemplate")
|
||||
public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("db2SqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
45
src/main/java/com/yutou/databases/MainDataSourceConfig.java
Normal file
45
src/main/java/com/yutou/databases/MainDataSourceConfig.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.yutou.databases;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages ="com.yutou.mybatis.dao" ,sqlSessionTemplateRef = "db1SqlSessionTemplate")
|
||||
public class MainDataSourceConfig {
|
||||
@Bean(name = "db1DataSource")
|
||||
@Primary
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public DataSource testDataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
@Primary
|
||||
@Bean(name = "db1SqlSessionFactory")
|
||||
public SqlSessionFactory testSqlSessionFactory(@Qualifier("db1DataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dataSource);
|
||||
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("/mybatis/mapping/*.xml"));
|
||||
return bean.getObject();
|
||||
}
|
||||
@Primary
|
||||
@Bean(name = "db1TransactionManager")
|
||||
public DataSourceTransactionManager testTransactionManager(@Qualifier("db1DataSource") DataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
}
|
||||
@Primary
|
||||
@Bean(name = "db1SqlSessionTemplate")
|
||||
public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("db1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.yutou.databases;
|
||||
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages = "com.yutou.maptop.Dao", sqlSessionTemplateRef = "sqliteTemplateRef")
|
||||
public class SQLiteDataSourceConfig {
|
||||
@Bean(name = "sqliteDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.sqlite")
|
||||
public DataSource buildDataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Bean(name = "sqliteFactory")
|
||||
public SqlSessionFactory createFactory(
|
||||
@Qualifier("sqliteDataSource") DataSource dataSource) throws Exception {
|
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dataSource);
|
||||
return bean.getObject();
|
||||
}
|
||||
|
||||
@Bean(name = "sqliteManager")
|
||||
public DataSourceTransactionManager createManager(@Qualifier("sqliteDataSource") DataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
}
|
||||
|
||||
@Bean(name = "sqliteTemplateRef")
|
||||
public SqlSessionTemplate createTemplate(@Qualifier("sqliteFactory") SqlSessionFactory sessionFactory) {
|
||||
return new SqlSessionTemplate(sessionFactory);
|
||||
}
|
||||
}
|
195
src/main/java/com/yutou/jianrdb/Bean/GameInfoLog.java
Normal file
195
src/main/java/com/yutou/jianrdb/Bean/GameInfoLog.java
Normal file
@ -0,0 +1,195 @@
|
||||
package com.yutou.jianrdb.Bean;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class GameInfoLog {
|
||||
private int id;
|
||||
private String ip;
|
||||
private String uid;
|
||||
private Date server_time;
|
||||
private Date client_time;
|
||||
private String sdk_ver;
|
||||
private String sdk_int;
|
||||
private String model;
|
||||
private String type;
|
||||
private String url;
|
||||
private String message;
|
||||
private String device_id;
|
||||
private String stub_ver;
|
||||
private String binder_ver;
|
||||
private String game_ver;
|
||||
private String username;
|
||||
private String server;
|
||||
private int retry;
|
||||
private String ext;
|
||||
private int server_id;
|
||||
private long client_mid;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public Date getServer_time() {
|
||||
return server_time;
|
||||
}
|
||||
|
||||
public void setServer_time(Date server_time) {
|
||||
this.server_time = server_time;
|
||||
}
|
||||
|
||||
public Date getClient_time() {
|
||||
return client_time;
|
||||
}
|
||||
|
||||
public void setClient_time(Date client_time) {
|
||||
this.client_time = client_time;
|
||||
}
|
||||
|
||||
public String getSdk_ver() {
|
||||
return sdk_ver;
|
||||
}
|
||||
|
||||
public void setSdk_ver(String sdk_ver) {
|
||||
this.sdk_ver = sdk_ver;
|
||||
}
|
||||
|
||||
public String getSdk_int() {
|
||||
return sdk_int;
|
||||
}
|
||||
|
||||
public void setSdk_int(String sdk_int) {
|
||||
this.sdk_int = sdk_int;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getDevice_id() {
|
||||
return device_id;
|
||||
}
|
||||
|
||||
public void setDevice_id(String device_id) {
|
||||
this.device_id = device_id;
|
||||
}
|
||||
|
||||
public String getStub_ver() {
|
||||
return stub_ver;
|
||||
}
|
||||
|
||||
public void setStub_ver(String stub_ver) {
|
||||
this.stub_ver = stub_ver;
|
||||
}
|
||||
|
||||
public String getBinder_ver() {
|
||||
return binder_ver;
|
||||
}
|
||||
|
||||
public void setBinder_ver(String binder_ver) {
|
||||
this.binder_ver = binder_ver;
|
||||
}
|
||||
|
||||
public String getGame_ver() {
|
||||
return game_ver;
|
||||
}
|
||||
|
||||
public void setGame_ver(String game_ver) {
|
||||
this.game_ver = game_ver;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public int getRetry() {
|
||||
return retry;
|
||||
}
|
||||
|
||||
public void setRetry(int retry) {
|
||||
this.retry = retry;
|
||||
}
|
||||
|
||||
public String getExt() {
|
||||
return ext;
|
||||
}
|
||||
|
||||
public void setExt(String ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
public int getServer_id() {
|
||||
return server_id;
|
||||
}
|
||||
|
||||
public void setServer_id(int server_id) {
|
||||
this.server_id = server_id;
|
||||
}
|
||||
|
||||
public long getClient_mid() {
|
||||
return client_mid;
|
||||
}
|
||||
|
||||
public void setClient_mid(long client_mid) {
|
||||
this.client_mid = client_mid;
|
||||
}
|
||||
}
|
18
src/main/java/com/yutou/jianrdb/Dao/GameInfoLogDao.java
Normal file
18
src/main/java/com/yutou/jianrdb/Dao/GameInfoLogDao.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.yutou.jianrdb.Dao;
|
||||
|
||||
import com.yutou.jianrdb.Bean.GameInfoLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Qualifier("db2SqlSessionTemplate")
|
||||
public interface GameInfoLogDao {
|
||||
@Select("select * from game_info_log where id=#{id}")
|
||||
GameInfoLog getLog(@Param("id")int id);
|
||||
|
||||
|
||||
@Select("select * from game_info_log where type=#{type}")
|
||||
List<GameInfoLog> getAllByType(@Param("type")String type);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.yutou.jianrdb.Mapper;
|
||||
|
||||
import com.yutou.jianrdb.Bean.GameInfoLog;
|
||||
import com.yutou.jianrdb.Dao.GameInfoLogDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class GameInfoLogService {
|
||||
@Resource
|
||||
GameInfoLogDao gameInfoLogDao;
|
||||
|
||||
public GameInfoLog selectGameInfoLogById(int id){
|
||||
return gameInfoLogDao.getLog(id);
|
||||
}
|
||||
}
|
49
src/main/java/com/yutou/maptop/Bean/MapTop.java
Normal file
49
src/main/java/com/yutou/maptop/Bean/MapTop.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.yutou.maptop.Bean;
|
||||
|
||||
public class MapTop {
|
||||
private int id;
|
||||
private int mapid;
|
||||
private String mapNode;
|
||||
private String shipTeam;
|
||||
private int teamId;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getMapid() {
|
||||
return mapid;
|
||||
}
|
||||
|
||||
public void setMapid(int mapid) {
|
||||
this.mapid = mapid;
|
||||
}
|
||||
|
||||
public String getMapNode() {
|
||||
return mapNode;
|
||||
}
|
||||
|
||||
public void setMapNode(String mapNode) {
|
||||
this.mapNode = mapNode;
|
||||
}
|
||||
|
||||
public String getShipTeam() {
|
||||
return shipTeam;
|
||||
}
|
||||
|
||||
public void setShipTeam(String shipTeam) {
|
||||
this.shipTeam = shipTeam;
|
||||
}
|
||||
|
||||
public int getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public void setTeamId(int teamId) {
|
||||
this.teamId = teamId;
|
||||
}
|
||||
}
|
42
src/main/java/com/yutou/maptop/Bean/UserTeam.java
Normal file
42
src/main/java/com/yutou/maptop/Bean/UserTeam.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.yutou.maptop.Bean;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class UserTeam {
|
||||
private int id;
|
||||
private String uname;
|
||||
private String ship;
|
||||
private Date createTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUname() {
|
||||
return uname;
|
||||
}
|
||||
|
||||
public void setUname(String uname) {
|
||||
this.uname = uname;
|
||||
}
|
||||
|
||||
public String getShip() {
|
||||
return ship;
|
||||
}
|
||||
|
||||
public void setShip(String ship) {
|
||||
this.ship = ship;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
16
src/main/java/com/yutou/maptop/Dao/MapDao.java
Normal file
16
src/main/java/com/yutou/maptop/Dao/MapDao.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.yutou.maptop.Dao;
|
||||
|
||||
import com.yutou.maptop.Bean.MapTop;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MapDao {
|
||||
@Select("select * from maptop where id=#{id}")
|
||||
List<MapTop> selectMapByMapId(@Param("id") int id);
|
||||
|
||||
@Insert("insert into maptop(mapId,mapNode,shipTeam,teamId) values(#{mapId},#{mapNode},#{shipTeam},#{teamId})")
|
||||
void insertMapTop(MapTop top);
|
||||
}
|
19
src/main/java/com/yutou/maptop/Dao/UserTeamDao.java
Normal file
19
src/main/java/com/yutou/maptop/Dao/UserTeamDao.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.yutou.maptop.Dao;
|
||||
|
||||
import com.yutou.maptop.Bean.UserTeam;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserTeamDao {
|
||||
@Select("select * from userTeam where id=#{id}")
|
||||
List<UserTeam> selectTeamById(@Param("id") int id);
|
||||
|
||||
@Insert("insert into userTeam(uname,ship,createTime) values(#{uname},#{ship},#{createTime})")
|
||||
void insertTeam( UserTeam param);
|
||||
|
||||
@Select("select * from userTeam")
|
||||
List<UserTeam> selectAll();
|
||||
}
|
25
src/main/java/com/yutou/maptop/services/UserTeamService.java
Normal file
25
src/main/java/com/yutou/maptop/services/UserTeamService.java
Normal file
@ -0,0 +1,25 @@
|
||||
package com.yutou.maptop.services;
|
||||
|
||||
import com.yutou.maptop.Bean.UserTeam;
|
||||
import com.yutou.maptop.Dao.UserTeamDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserTeamService {
|
||||
@Resource
|
||||
UserTeamDao dao;
|
||||
|
||||
public void insertTeam(UserTeam team){
|
||||
dao.insertTeam(team);
|
||||
}
|
||||
|
||||
public List<UserTeam> selectById(int id){
|
||||
if(id==-1){
|
||||
return dao.selectAll();
|
||||
}
|
||||
return dao.selectTeamById(id);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user