This commit is contained in:
Yutousama 2020-01-19 18:30:46 +08:00
parent a496f9c780
commit 93c2461a60
5 changed files with 75 additions and 78 deletions

View File

@ -3,6 +3,8 @@ package com.yutou.controller.MapTop;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yutou.enums.UserEnum; import com.yutou.enums.UserEnum;
import com.yutou.jianrdb.Bean.MapNode;
import com.yutou.jianrdb.Mapper.MapNodeService;
import com.yutou.maptop.Bean.MapTop; import com.yutou.maptop.Bean.MapTop;
import com.yutou.maptop.Bean.UserTeam; import com.yutou.maptop.Bean.UserTeam;
import com.yutou.maptop.services.MapTopService; import com.yutou.maptop.services.MapTopService;
@ -23,13 +25,15 @@ public class AndroidMapController {
UserTeamService userTeamService; UserTeamService userTeamService;
@Resource @Resource
MapTopService mapTopService; MapTopService mapTopService;
@Resource
MapNodeService mapNodeService;
/** /**
* 全部数据 * 全部数据
*/ */
@ResponseBody @ResponseBody
@RequestMapping("/android/map/all.do") @RequestMapping("/android/map/all.do")
public String getMapTop(HttpServletRequest request,int limit){ public String getMap(HttpServletRequest request){
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
if(Tools.getUidOfToken(request)<=0){ if(Tools.getUidOfToken(request)<=0){
@ -37,22 +41,17 @@ public class AndroidMapController {
json.put("code", UserEnum.LOGIN_NOT_LOGIN.code); json.put("code", UserEnum.LOGIN_NOT_LOGIN.code);
return json.toString(); return json.toString();
} }
int count=100;
List<MapTop> list=mapTopService.selectMap(limit,count); List<String> list=mapNodeService.selectMapName();
json.put("count",list.size()); json.put("count",list.size());
json.put("data", JSONArray.toJSON(list)); json.put("data", JSONArray.toJSON(list));
if(list.size()==count){
json.put("next",true);
}else{
json.put("next",false);
}
return json.toJSONString(); return json.toJSONString();
} }
@ResponseBody @ResponseBody
@RequestMapping("/android/map/mid.do") @RequestMapping("/android/map/node.do")
public String getMapId(HttpServletRequest request,int id,int limit){ public String getMapNode(HttpServletRequest request,String levelName){
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
if(Tools.getUidOfToken(request)<=0){ if(Tools.getUidOfToken(request)<=0){
json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg); json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg);
@ -60,20 +59,14 @@ public class AndroidMapController {
return json.toString(); return json.toString();
} }
int count=100; List<String> list=mapNodeService.selectNodeName(levelName);
List<MapTop> list=mapTopService.selectMapByMapId(id,limit,count);
json.put("count",list.size()); json.put("count",list.size());
json.put("data", JSONArray.toJSON(list)); json.put("data", JSONArray.toJSON(list));
if(list.size()==count){
json.put("next",true);
}else{
json.put("next",false);
}
return json.toJSONString(); return json.toJSONString();
} }
@ResponseBody @ResponseBody
@RequestMapping("/android/map/team/node.do") @RequestMapping("/android/map/data.do")
public String getTeamByMapNode(HttpServletRequest request,int node,int limit){ public String getMapData(HttpServletRequest request,String chapterName, String levelName){
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
if(Tools.getUidOfToken(request)<=0){ if(Tools.getUidOfToken(request)<=0){
json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg); json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg);
@ -81,19 +74,13 @@ public class AndroidMapController {
return json.toString(); return json.toString();
} }
int count=100; List<MapNode> list=mapNodeService.selectMapByNode(chapterName, levelName);
List<UserTeam> list=userTeamService.searchMapNode(node,limit,count);
json.put("count",list.size()); json.put("count",list.size());
json.put("data", JSONArray.toJSON(list)); json.put("data", JSONArray.toJSON(list));
if(list.size()==count){
json.put("next",true);
}else{
json.put("next",false);
}
return json.toJSONString(); return json.toJSONString();
} }
@ResponseBody @ResponseBody
@RequestMapping("/android/map/team/nodeAndLike.do") @RequestMapping("/android/map/team/data.do")
public String getTeamByMapNodeAndLike(HttpServletRequest request,int node,int limit,String likeArray){ public String getTeamByMapNodeAndLike(HttpServletRequest request,int node,int limit,String likeArray){
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
if(Tools.getUidOfToken(request)<=0){ if(Tools.getUidOfToken(request)<=0){
@ -102,30 +89,8 @@ public class AndroidMapController {
return json.toString(); return json.toString();
} }
int count=100; int count=50;
JSONArray array=new JSONArray(); List<UserTeam> list=mapNodeService.selectNodeByMid(node,limit,count);
array.addAll(Arrays.asList(likeArray.split(",")));
List<UserTeam> list=userTeamService.searchType(node,array,limit,count);
json.put("count",list.size());
json.put("data", JSONArray.toJSON(list));
if(list.size()==count){
json.put("next",true);
}else{
json.put("next",false);
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping("/android/map/team/topid.do")
public String getTeamByMapTop(HttpServletRequest request,int id,int limit){
JSONObject json=new JSONObject();
if(Tools.getUidOfToken(request)<=0){
json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg);
json.put("code", UserEnum.LOGIN_NOT_LOGIN.code);
return json.toString();
}
int count=100;
List<UserTeam> list=userTeamService.selectByMapTopId(id,limit,count);
json.put("count",list.size()); json.put("count",list.size());
json.put("data", JSONArray.toJSON(list)); json.put("data", JSONArray.toJSON(list));
if(list.size()==count){ if(list.size()==count){
@ -135,4 +100,5 @@ public class AndroidMapController {
} }
return json.toJSONString(); return json.toJSONString();
} }
} }

View File

@ -6,6 +6,7 @@ import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.yutou.jianrdb.Mapper.MapNodeService;
import com.yutou.maptop.Bean.UserTeam; import com.yutou.maptop.Bean.UserTeam;
import com.yutou.maptop.services.UserTeamService; import com.yutou.maptop.services.UserTeamService;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -23,19 +24,14 @@ import com.yutou.utlis.RedisUtlis;
public class test { public class test {
@Resource @Resource
ModService modService; ModService modService;
@Resource
MapNodeService service;
@ResponseBody @ResponseBody
@RequestMapping("/mod.do") @RequestMapping("/map/test.do")
public String getMod(HttpServletRequest request) { public String getMod(HttpServletRequest request) {
String str=request.getParameter("id");
int id=-1; return JSON.toJSONString(service.selectMapName());
try {
id=Integer.valueOf(str);
} catch (Exception e) {
// TODO: handle exception
}
TMod mod=modService.getMod(id,0);
return JSON.toJSONString(mod);
} }
private static int index=0; private static int index=0;

View File

@ -1,12 +1,27 @@
package com.yutou.jianrdb.Dao; package com.yutou.jianrdb.Dao;
import com.yutou.jianrdb.Bean.MapNode; import com.yutou.jianrdb.Bean.MapNode;
import com.yutou.maptop.Bean.UserTeam;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import java.util.List;
@Qualifier("db2SqlSessionTemplate") @Qualifier("db2SqlSessionTemplate")
public interface MapNodeDao { public interface MapNodeDao {
@Select("select * from zs_node_info where id=#{node}") @Select("select * from zs_node_info where id=#{node}")
MapNode selectNodeByNode(@Param("node")int node); MapNode selectNodeByNode(@Param("node")int node);
@Select("select distinct level_name from zs_node_info;")
List<String> selectMapName();
@Select("select distinct chapter_name from zs_node_info where level_name=#{name};")
List<String> selectNodeName(@Param("name")String name);
@Select("SELECT * FROM jrmbdb.zs_node_info where chapter_name=#{chapterName} and level_name=#{lievelName};")
List<MapNode> selectMapByNode(@Param("chapterName")String chapterName,@Param("lievelName")String levelName);
@Select("SELECT * FROM jrmbdb.game_info_log where `type`='DealNode' and ext like '%pve%' and ext like '%#{nid}%' order by id desc limit #{limit},#{count};")
List<UserTeam> selectNodeByMid(@Param("nid")int nodeId,@Param("limit")int limit,@Param("count")int count);
} }

View File

@ -2,15 +2,35 @@ package com.yutou.jianrdb.Mapper;
import com.yutou.jianrdb.Bean.MapNode; import com.yutou.jianrdb.Bean.MapNode;
import com.yutou.jianrdb.Dao.MapNodeDao; import com.yutou.jianrdb.Dao.MapNodeDao;
import com.yutou.maptop.Bean.UserTeam;
import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
public class MapNodeService implements MapNodeDao { @Service
public class MapNodeService {
@Resource @Resource
MapNodeDao dao; MapNodeDao dao;
@Override
public MapNode selectNodeByNode(int node) { public MapNode selectNodeByNode(int node) {
return dao.selectNodeByNode(node); return dao.selectNodeByNode(node);
} }
public List<String> selectMapName() {
return dao.selectMapName();
}
public List<String> selectNodeName(String level_name) {
return dao.selectNodeName(level_name);
}
public List<MapNode> selectMapByNode(String chapterName, String levelName) {
return dao.selectMapByNode(chapterName, levelName);
}
public List<UserTeam> selectNodeByMid(int nodeId, int limit, int count) {
return dao.selectNodeByMid(nodeId, limit, count);
}
} }

View File

@ -8,7 +8,9 @@ import com.yutou.mybatis.dao.ZsShipTypeMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
public class MapTopService { public class MapTopService {
@ -35,25 +37,23 @@ public class MapTopService {
String tmp=mapTop.getShipTeam().replace("[",""); String tmp=mapTop.getShipTeam().replace("[","");
tmp=tmp.replace("]",""); tmp=tmp.replace("]","");
String[] shipType=tmp.split(","); String[] shipType=tmp.split(",");
int tid=-1;
int old=-1;
int index=0;
String stype=""; String stype="";
int mapId=mapTop.getId(); Map<String,Integer> types=new HashMap<>();
for (String type : shipType) { for (String type : shipType) {
index++; if (types.containsKey(type)) {
if(tid!=Integer.parseInt(type)){ types.put(type, types.get(type) + 1);
tid=Integer.parseInt(type); } else {
if(old==-1){ types.put(type, 1);
old=tid;
}
stype+=index+shipTypeMapper.selectByPrimaryKey(tid).getShortname()+",";
old=tid;
index=0;
} }
} }
if(stype.equals("")){ for (String key : types.keySet()) {
stype=index+shipTypeMapper.selectByPrimaryKey(tid).getShortname()+","; try {
stype+=types.get(key)+shipTypeMapper.selectByPrimaryKey(Integer.parseInt(key)).getShortname()+",";
}catch (Exception e){
e.printStackTrace();
}
} }
stype = stype.substring(0, stype.length() - 1); stype = stype.substring(0, stype.length() - 1);
mapTop.setShipTeamTo(stype); mapTop.setShipTeamTo(stype);