update
@ -53,15 +53,15 @@ public class UrlAndCateController {
|
||||
UserDao userDao;
|
||||
//处理JSON
|
||||
@RequestMapping("/disposeJson")
|
||||
public String disposeJson(@RequestBody String data2 ,String email)
|
||||
public String disposeJson(@RequestBody String data2 ,Integer userId)
|
||||
{
|
||||
String jsonString;
|
||||
//先转换成ObjectMapper类型
|
||||
ObjectNode objectNode = objectMapper.createObjectNode();
|
||||
try {
|
||||
JsonNode rootNode = objectMapper.readTree(data2);
|
||||
disposeBookmarkFunction1(rootNode,"top",email);
|
||||
countCateContainUrlNumber(email);
|
||||
disposeBookmarkFunction1(rootNode,"top",userId);
|
||||
countCateContainUrlNumber(userId);
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("msg", "查询成功");
|
||||
@ -71,23 +71,24 @@ public class UrlAndCateController {
|
||||
}
|
||||
return jsonString;
|
||||
}
|
||||
public void disposeBookmarkFunction1(JsonNode rootNode,String parent,String email)
|
||||
public void disposeBookmarkFunction1(JsonNode rootNode,String parent,Integer userId)
|
||||
{
|
||||
|
||||
for(int i=0;i<rootNode.size();i++)
|
||||
{
|
||||
JsonNode sonNode = rootNode.get(i);
|
||||
if(String.valueOf(sonNode.get("folder")).equals("true")){
|
||||
urlCateListService.selectAndInsertUrlCate(email,String.valueOf(sonNode.get("name")),parent);
|
||||
if(String.valueOf(sonNode.get("type")).equals("\"folder\"")){
|
||||
System.out.println(1);
|
||||
urlCateListService.selectAndInsertUrlCate(userId,String.valueOf(sonNode.get("name")),parent,String.valueOf(sonNode.get("icon")));
|
||||
JsonNode children = sonNode.get("children");
|
||||
disposeBookmarkFunction1(children, String.valueOf(sonNode.get("name")),email);
|
||||
disposeBookmarkFunction1(children, String.valueOf(sonNode.get("name")),userId);
|
||||
|
||||
}else{
|
||||
String name = String.valueOf(sonNode.get("name"));
|
||||
String url = String.valueOf(sonNode.get("url"));
|
||||
String adddata = String.valueOf(sonNode.get("adddata"));
|
||||
urlListService.selectCateAndInsertUrl(parent,name,"123",url,email);
|
||||
System.out.println(name +"---" + url + "---" + adddata + "---" + parent );
|
||||
String url = String.valueOf(sonNode.get("href"));
|
||||
String icon = String.valueOf(sonNode.get("icon"));
|
||||
urlListService.selectCateAndInsertUrl(parent,name,icon , url,userId);
|
||||
System.out.println(name +"---" + url + "---" + parent );
|
||||
}
|
||||
|
||||
}
|
||||
@ -283,11 +284,11 @@ public class UrlAndCateController {
|
||||
}
|
||||
|
||||
|
||||
public String countCateContainUrlNumber(String email){
|
||||
public String countCateContainUrlNumber(Integer userId){
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("msg", "查询成功");
|
||||
result.put("data",urlCateListService.countCateContainUrlNumber(email));
|
||||
result.put("data",urlCateListService.countCateContainUrlNumber(userId));
|
||||
String jsonString = JSONObject.toJSONString(result);
|
||||
return jsonString;
|
||||
}
|
||||
@ -630,7 +631,7 @@ public class UrlAndCateController {
|
||||
|
||||
}
|
||||
|
||||
urlCateListService.countCateContainUrlNumber(userDao.selectByPrimaryKey(Integer.valueOf(userId)).getUserEmail());
|
||||
urlCateListService.countCateContainUrlNumber(userDao.selectByPrimaryKey(Integer.valueOf(userId)).getId());
|
||||
result.put("code", 200);
|
||||
result.put("msg", "处理成功");
|
||||
return JSONObject.toJSONString(result);
|
||||
|
@ -8,10 +8,10 @@ import java.util.List;
|
||||
public interface UrlCateListService {
|
||||
|
||||
|
||||
public int selectAndInsertUrlCate(String email , String cateName , String parent);
|
||||
public int selectAndInsertUrlCate(Integer userId , String cateName , String parent,String icon);
|
||||
public List<UrlCateList> selectUrListByUserId(Integer userId);
|
||||
|
||||
public String countCateContainUrlNumber(String userId);
|
||||
public String countCateContainUrlNumber(Integer userId);
|
||||
|
||||
public JSONArray getUrl(String userId);
|
||||
public String selectUrListCateByUrlCateId(Integer cateId);
|
||||
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||
|
||||
public interface UrlListService {
|
||||
|
||||
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,String email );
|
||||
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,Integer userId );
|
||||
public List<UrlList> selectUrList();
|
||||
public UrlList selectUrListByInput(String input);
|
||||
public UrlList selectUrlListByUrlId(Long urlId);
|
||||
|
@ -27,22 +27,24 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
UrlListDao urlListDao;
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
public int selectAndInsertUrlCate(String email , String cateName , String parent )
|
||||
public int selectAndInsertUrlCate(Integer userId , String cateName , String parent,String icon )
|
||||
{
|
||||
//找用户ID
|
||||
User user = userDao.selectByEmail(email);
|
||||
int userId = user.getId();
|
||||
|
||||
|
||||
//找父标签有没有
|
||||
UrlCateList cateParent = urlCateListDao.selectCateByNameAnduserId(parent,userId);
|
||||
|
||||
UrlCateList targetCate = new UrlCateList();
|
||||
//设置属性
|
||||
targetCate.setName(cateName);
|
||||
targetCate.setName(cateName.substring(1,cateName.length()-1));
|
||||
targetCate.setUserId(userId);
|
||||
Date date = new Date();
|
||||
targetCate.setCreatetime(date.getTime());
|
||||
|
||||
targetCate.setWeigh(Long.valueOf(0));
|
||||
targetCate.setStatus(Byte.valueOf(0+""));
|
||||
targetCate.setNeedLogin(Byte.valueOf(0+""));
|
||||
targetCate.setIco(icon);
|
||||
if(cateParent != null)
|
||||
{
|
||||
targetCate.setRootCateId(cateParent.getId());
|
||||
@ -85,10 +87,9 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
return urlCateListDao.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public String countCateContainUrlNumber(String email){
|
||||
User user = userDao.selectByEmail(email);
|
||||
int userId = user.getId();
|
||||
List<UrlCateList> urlCateLists =urlCateListDao.selectUrListByUserId(userId);
|
||||
public String countCateContainUrlNumber(Integer userId){
|
||||
|
||||
List<UrlCateList> urlCateLists =urlCateListDao.selectUrListByUserId(3);
|
||||
List<UrlList> urlLists = urlListDao.selectUrList();
|
||||
HashMap<String,Integer> CateNumber = new HashMap<>();
|
||||
|
||||
@ -96,24 +97,26 @@ public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
{
|
||||
CateNumber.put(urlCateList.getName(),0);
|
||||
}
|
||||
for(UrlList urlList : urlLists){
|
||||
Long id = Long.valueOf(urlList.getCateId());
|
||||
|
||||
while(id!= 0)
|
||||
for(UrlList urlList : urlLists){
|
||||
String parentString = urlCateListDao.selectUrListCateByUrlCateId(urlList.getCateId());
|
||||
String [] strings = parentString.split(",");
|
||||
|
||||
for(String str :strings)
|
||||
{
|
||||
if(str.equals("0")) continue;
|
||||
for(UrlCateList urlCateList :urlCateLists)
|
||||
{
|
||||
if(id == Long.valueOf(urlCateList.getId())){
|
||||
if(urlCateList.getId() == Integer.valueOf(str)){
|
||||
int cateNum = CateNumber.get(urlCateList.getName())+1;
|
||||
CateNumber.put(urlCateList.getName(),cateNum);
|
||||
id=Long.valueOf(urlCateList.getRootCateId());
|
||||
System.out.println(urlCateList.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Iterator iterator = CateNumber.entrySet().iterator();
|
||||
while(iterator.hasNext()) {
|
||||
|
@ -25,22 +25,23 @@ public class UrlLiserServiceImpl implements UrlListService {
|
||||
UrlListDao urlListDao;
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,String email)
|
||||
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,Integer userId)
|
||||
{
|
||||
//找用户ID
|
||||
User user = userDao.selectByEmail(email);
|
||||
int userId = user.getId();
|
||||
|
||||
parent = parent.substring(1,parent.length()-1);
|
||||
UrlCateList urlCateList = urlCateListDao.selectCateByNameAnduserId(parent,userId);
|
||||
UrlList urlList = new UrlList();
|
||||
//设置属性
|
||||
urlList.setCateId(urlCateList.getId());
|
||||
urlList.setUrl(url);
|
||||
urlList.setIcon(icon);
|
||||
urlList.setName(name);
|
||||
urlList.setName(name.substring(1,name.length()-1));
|
||||
Date date = new Date();
|
||||
urlList.setCreatetime(date.getTime());
|
||||
urlList.setViews(Long.valueOf("0"));
|
||||
urlList.setIsNeedAgent(Byte.valueOf(0+""));
|
||||
urlList.setIsAd(Byte.valueOf(0+""));
|
||||
urlList.setIsTop(Byte.valueOf(0+""));
|
||||
Byte b = 0;
|
||||
urlList.setNeedLogin(b);
|
||||
int flag = urlListDao.insert(urlList);
|
||||
|
BIN
src/main/resources/static/icon/23161362.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/main/resources/static/icon/53548802.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/main/resources/static/icon/60945714.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/main/resources/static/icon/62202567.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/main/resources/static/icon/84361768.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/main/resources/static/icon/98088501.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/main/resources/static/qr/20949362.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/static/qr/26585916.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/static/qr/73600988.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/static/qr/83334762.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/static/qr/90551957.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/static/qr/95734068.jpg
Normal file
After Width: | Height: | Size: 21 KiB |