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

View File

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

View File

@ -1,12 +1,27 @@
package com.yutou.jianrdb.Dao;
import com.yutou.jianrdb.Bean.MapNode;
import com.yutou.maptop.Bean.UserTeam;
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 MapNodeDao {
@Select("select * from zs_node_info where id=#{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.Dao.MapNodeDao;
import com.yutou.maptop.Bean.UserTeam;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
public class MapNodeService implements MapNodeDao {
@Service
public class MapNodeService {
@Resource
MapNodeDao dao;
@Override
public MapNode selectNodeByNode(int 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 javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class MapTopService {
@ -35,25 +37,23 @@ public class MapTopService {
String tmp=mapTop.getShipTeam().replace("[","");
tmp=tmp.replace("]","");
String[] shipType=tmp.split(",");
int tid=-1;
int old=-1;
int index=0;
String stype="";
int mapId=mapTop.getId();
Map<String,Integer> types=new HashMap<>();
for (String type : shipType) {
index++;
if(tid!=Integer.parseInt(type)){
tid=Integer.parseInt(type);
if(old==-1){
old=tid;
}
stype+=index+shipTypeMapper.selectByPrimaryKey(tid).getShortname()+",";
old=tid;
index=0;
if (types.containsKey(type)) {
types.put(type, types.get(type) + 1);
} else {
types.put(type, 1);
}
}
if(stype.equals("")){
stype=index+shipTypeMapper.selectByPrimaryKey(tid).getShortname()+",";
for (String key : types.keySet()) {
try {
stype+=types.get(key)+shipTypeMapper.selectByPrimaryKey(Integer.parseInt(key)).getShortname()+",";
}catch (Exception e){
e.printStackTrace();
}
}
stype = stype.substring(0, stype.length() - 1);
mapTop.setShipTeamTo(stype);