diff --git a/pom.xml b/pom.xml index 3e68d52..d91c8b2 100644 --- a/pom.xml +++ b/pom.xml @@ -140,6 +140,12 @@ log4j-core 2.8.2 + + + org.xerial + sqlite-jdbc + 3.28.0 + diff --git a/sqlite.db b/sqlite.db new file mode 100644 index 0000000..e758ab3 Binary files /dev/null and b/sqlite.db differ diff --git a/src/main/java/com/yutou/controller/test.java b/src/main/java/com/yutou/controller/test.java index 9515e3b..c5d20b9 100644 --- a/src/main/java/com/yutou/controller/test.java +++ b/src/main/java/com/yutou/controller/test.java @@ -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 list= daoServier.selectById(-1); + return JSON.toJSONString(list); } diff --git a/src/main/java/com/yutou/databases/JianrDataSourceConfig.java b/src/main/java/com/yutou/databases/JianrDataSourceConfig.java new file mode 100644 index 0000000..f2a7acb --- /dev/null +++ b/src/main/java/com/yutou/databases/JianrDataSourceConfig.java @@ -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); + } +} diff --git a/src/main/java/com/yutou/databases/MainDataSourceConfig.java b/src/main/java/com/yutou/databases/MainDataSourceConfig.java new file mode 100644 index 0000000..2e41da0 --- /dev/null +++ b/src/main/java/com/yutou/databases/MainDataSourceConfig.java @@ -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); + } +} diff --git a/src/main/java/com/yutou/databases/SQLiteDataSourceConfig.java b/src/main/java/com/yutou/databases/SQLiteDataSourceConfig.java new file mode 100644 index 0000000..852a030 --- /dev/null +++ b/src/main/java/com/yutou/databases/SQLiteDataSourceConfig.java @@ -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); + } +} diff --git a/src/main/java/com/yutou/jianrdb/Bean/GameInfoLog.java b/src/main/java/com/yutou/jianrdb/Bean/GameInfoLog.java new file mode 100644 index 0000000..4c76ec0 --- /dev/null +++ b/src/main/java/com/yutou/jianrdb/Bean/GameInfoLog.java @@ -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; + } +} diff --git a/src/main/java/com/yutou/jianrdb/Dao/GameInfoLogDao.java b/src/main/java/com/yutou/jianrdb/Dao/GameInfoLogDao.java new file mode 100644 index 0000000..22cbf29 --- /dev/null +++ b/src/main/java/com/yutou/jianrdb/Dao/GameInfoLogDao.java @@ -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 getAllByType(@Param("type")String type); +} diff --git a/src/main/java/com/yutou/jianrdb/Mapper/GameInfoLogService.java b/src/main/java/com/yutou/jianrdb/Mapper/GameInfoLogService.java new file mode 100644 index 0000000..8f2eabc --- /dev/null +++ b/src/main/java/com/yutou/jianrdb/Mapper/GameInfoLogService.java @@ -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); + } +} diff --git a/src/main/java/com/yutou/maptop/Bean/MapTop.java b/src/main/java/com/yutou/maptop/Bean/MapTop.java new file mode 100644 index 0000000..c09f43a --- /dev/null +++ b/src/main/java/com/yutou/maptop/Bean/MapTop.java @@ -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; + } +} diff --git a/src/main/java/com/yutou/maptop/Bean/UserTeam.java b/src/main/java/com/yutou/maptop/Bean/UserTeam.java new file mode 100644 index 0000000..96b1714 --- /dev/null +++ b/src/main/java/com/yutou/maptop/Bean/UserTeam.java @@ -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; + } +} diff --git a/src/main/java/com/yutou/maptop/Dao/MapDao.java b/src/main/java/com/yutou/maptop/Dao/MapDao.java new file mode 100644 index 0000000..20b01ae --- /dev/null +++ b/src/main/java/com/yutou/maptop/Dao/MapDao.java @@ -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 selectMapByMapId(@Param("id") int id); + + @Insert("insert into maptop(mapId,mapNode,shipTeam,teamId) values(#{mapId},#{mapNode},#{shipTeam},#{teamId})") + void insertMapTop(MapTop top); +} diff --git a/src/main/java/com/yutou/maptop/Dao/UserTeamDao.java b/src/main/java/com/yutou/maptop/Dao/UserTeamDao.java new file mode 100644 index 0000000..da935c3 --- /dev/null +++ b/src/main/java/com/yutou/maptop/Dao/UserTeamDao.java @@ -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 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 selectAll(); +} diff --git a/src/main/java/com/yutou/maptop/services/UserTeamService.java b/src/main/java/com/yutou/maptop/services/UserTeamService.java new file mode 100644 index 0000000..6271b88 --- /dev/null +++ b/src/main/java/com/yutou/maptop/services/UserTeamService.java @@ -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 selectById(int id){ + if(id==-1){ + return dao.selectAll(); + } + return dao.selectTeamById(id); + } +}