This commit is contained in:
landaiqing 2023-12-25 02:02:30 +08:00
parent 65f76703b8
commit c4762a33af
4 changed files with 59 additions and 13 deletions

View File

@ -78,17 +78,28 @@ public class UrlAndCateController {
{
JsonNode sonNode = rootNode.get(i);
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")));
String icon = String.valueOf(sonNode.get("icon"));
System.out.println(icon.length());
if (icon.length() == 2) icon ="https://imgbed.landaiqing.space/img/1/2023/12/25/1_6588644cb1f03_1703437387965_20231225.webp";
else{
icon=icon.substring(1,icon.length()-1);
}
urlCateListService.selectAndInsertUrlCate(userId,String.valueOf(sonNode.get("name")),parent,icon);
JsonNode children = sonNode.get("children");
disposeBookmarkFunction1(children, String.valueOf(sonNode.get("name")),userId);
}else{
String name = String.valueOf(sonNode.get("name"));
String url = String.valueOf(sonNode.get("href"));
String url = String.valueOf(sonNode.get("href")).substring(1,String.valueOf(sonNode.get("href")).length()-1);
String icon = String.valueOf(sonNode.get("icon"));
if (icon.length() == 2 )
{
icon="https://imgbed.landaiqing.space/img/1/2023/12/25/1_6588644cb1f03_1703437387965_20231225.webp";
}else{
icon =icon.substring(1,String.valueOf(sonNode.get("icon")).length()-1);
}
urlListService.selectCateAndInsertUrl(parent,name,icon , url,userId);
System.out.println(name +"---" + url + "---" + parent );
// System.out.println(name +"---" + url + "---" + parent );
}
}
@ -111,13 +122,14 @@ public class UrlAndCateController {
cateAndUrl.setName(urlCateList.getName());
cateAndUrl.setParentId(urlCateList.getRootCateId());
cateAndUrl.setCateId(urlCateList.getId());
cateAndUrl.setNumber(urlCateList.getUrlNumber());
cateAndUrlList.add(cateAndUrl);
}
for( int i = 0 ; i < urlLists.size() ; i++){
UrlList urlList = urlLists.get(i);
if(urlList.getStatus() == 0 ) continue;
if(urlList.getStatus() == 1 ) continue;
for(CateAndUrl cateAndUrl1 : cateAndUrlList) {
if (urlList.getCateId() == cateAndUrl1.getCateId())
if (String.valueOf(urlList.getCateId()).equals(cateAndUrl1.getCateId()+""))
{
CateAndUrl cateAndUrl = new CateAndUrl();
cateAndUrl.setFloder("false");
@ -174,7 +186,6 @@ public class UrlAndCateController {
{
String parentString = urlCateListService.selectUrListCateByUrlCateId(urlLists.get(i).getCateId());
String [] parentList = parentString.split(",");
System.out.println(parentString);
for(String parent : parentList)
{
if(parent.equals("0")){
@ -445,10 +456,12 @@ public class UrlAndCateController {
public String disposeBookmarkExhibitedToJsonNew(){
List<UrlList> urlLists = urlListService.selectUrListByNeedLogin();
List<CateAndUrl> cateAndUrlList = new ArrayList<>();
CateAndUrl pub = new CateAndUrl();
Set<String> parentSet = new HashSet<>();
for( int i = 0 ; i < urlLists.size() ; i++)
{
String parentString = urlCateListService.selectUrListCateByUrlCateId(urlLists.get(i).getCateId());
if(parentString == null) continue;
String [] parentList = parentString.split(",");
System.out.println(parentString);
for(String parent : parentList)
@ -466,11 +479,12 @@ public class UrlAndCateController {
cateAndUrl.setName(urlCateList.getName());
cateAndUrl.setParentId(urlCateList.getRootCateId());
cateAndUrl.setCateId(urlCateList.getId());
cateAndUrl.setNumber(urlCateList.getUrlNumber());
cateAndUrlList.add(cateAndUrl);
}
for( int i = 0 ; i < urlLists.size() ; i++){
UrlList urlList = urlLists.get(i);
if(urlList.getStatus() == 0 ) continue ;
if(urlList.getStatus() == 1 ) continue ;
CateAndUrl cateAndUrl = new CateAndUrl();
cateAndUrl.setFloder("false");
cateAndUrl.setName(urlList.getName());
@ -490,13 +504,27 @@ public class UrlAndCateController {
cateAndUrl.setIsAd(urlList.getIsAd());
cateAndUrl.setIsTop(urlList.getIsTop());
cateAndUrl.setIsEncrypt(urlList.getIsEncrypt());
int flag =0 ;
for(CateAndUrl cateAndUrl1 : cateAndUrlList){
if(cateAndUrl.getParentId() == cateAndUrl1.getCateId())
if(String.valueOf(cateAndUrl.getParentId()).equals(cateAndUrl1.getCateId()+""))
{
flag = 1;
cateAndUrl1.getChildUC().add(cateAndUrl);
break;
}
}
if(flag == 0)
{
pub.setName("默认文件夹");
pub.getChildUC().add(cateAndUrl);
}
}
if(pub.getChildUC().size()!=0)
{
pub.setNumber(Long.valueOf(pub.getChildUC().size()));
cateAndUrlList.add(pub);
}
return JSONObject.toJSONString(cateAndUrlList);
@ -530,6 +558,7 @@ public class UrlAndCateController {
cateAndUrl.setName(urlCateList.getName());
cateAndUrl.setParentId(urlCateList.getRootCateId());
cateAndUrl.setCateId(urlCateList.getId());
cateAndUrl.setNumber(urlCateList.getUrlNumber());
cateAndUrlList.add(cateAndUrl);
}

View File

@ -31,11 +31,11 @@ public class UrlCateListServiceImpl implements UrlCateListService {
{
//找用户ID
parent = parent.substring(1,parent.length()-1);
//找父标签有没有
UrlCateList cateParent = urlCateListDao.selectCateByNameAnduserId(parent,userId);
UrlCateList targetCate = new UrlCateList();
//设置属性
targetCate.setName(cateName.substring(1,cateName.length()-1));
targetCate.setUserId(userId);
@ -100,6 +100,7 @@ public class UrlCateListServiceImpl implements UrlCateListService {
for(UrlList urlList : urlLists){
String parentString = urlCateListDao.selectUrListCateByUrlCateId(urlList.getCateId());
if (parentString == null) continue;
String [] strings = parentString.split(",");
for(String str :strings)

View File

@ -27,12 +27,17 @@ public class UrlLiserServiceImpl implements UrlListService {
UserDao userDao;
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,Integer userId)
{
parent = parent.substring(1,parent.length()-1);
UrlCateList urlCateList = urlCateListDao.selectCateByNameAnduserId(parent,userId);
UrlList urlList = new UrlList();
//设置属性
if (urlCateList == null)
{
urlList.setCateId(0);
}else{
urlList.setCateId(urlCateList.getId());
}
//设置属性
urlList.setUrl(url);
urlList.setIcon(icon);
urlList.setName(name.substring(1,name.length()-1));
@ -42,6 +47,7 @@ public class UrlLiserServiceImpl implements UrlListService {
urlList.setIsNeedAgent(Byte.valueOf(0+""));
urlList.setIsAd(Byte.valueOf(0+""));
urlList.setIsTop(Byte.valueOf(0+""));
urlList.setStatus(Byte.valueOf(0+""));
Byte b = 0;
urlList.setNeedLogin(b);
int flag = urlListDao.insert(urlList);

View File

@ -250,4 +250,14 @@ public class CateAndUrl {
public void setIsEncrypt(Byte isEncrypt) {
this.isEncrypt = isEncrypt;
}
Long number ;
public Long getNumber() {
return number;
}
public void setNumber(Long number) {
this.number = number;
}
}