update
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user