一系列接口
This commit is contained in:
12
src/main/java/com/lovenav/service/UrlCateListService.java
Normal file
12
src/main/java/com/lovenav/service/UrlCateListService.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.lovenav.service;
|
||||
|
||||
import com.lovenav.entity.UrlCateList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UrlCateListService {
|
||||
|
||||
|
||||
public int selectAndInsertUrlCate(String email , String cateName , String parent);
|
||||
public List<UrlCateList> selectUrListByUserId(Integer userId);
|
||||
}
|
13
src/main/java/com/lovenav/service/UrlListService.java
Normal file
13
src/main/java/com/lovenav/service/UrlListService.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.lovenav.service;
|
||||
|
||||
import com.lovenav.entity.UrlList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UrlListService {
|
||||
|
||||
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,String email );
|
||||
public List<UrlList> selectUrList();
|
||||
public UrlList selectUrListByInput(String input);
|
||||
public UrlList selectUrlListByUrlId(Long urlId);
|
||||
}
|
@@ -4,6 +4,7 @@ import com.lovenav.entity.User;
|
||||
|
||||
|
||||
|
||||
|
||||
public interface UserService {
|
||||
|
||||
public String sendEmailActivecode(User user);
|
||||
|
@@ -119,7 +119,8 @@ public class RedisServiceImpl implements RedisService {
|
||||
if (result.size() > HOT_SEARCH_NUMBER) {
|
||||
break;
|
||||
}
|
||||
Long time = Long.valueOf(Objects.requireNonNull(valueOperations.get(val)));
|
||||
|
||||
Long time = Long.valueOf(Objects.requireNonNull(valueOperations.get("search:search-time:"+val)));
|
||||
//返回最近一个月的数据
|
||||
if ((now - time) < HOT_SEARCH_TIME) {
|
||||
result.add(val);
|
||||
@@ -134,7 +135,8 @@ public class RedisServiceImpl implements RedisService {
|
||||
if (result.size() > HOT_SEARCH_NUMBER) {
|
||||
break;
|
||||
}
|
||||
Long time = Long.valueOf(Objects.requireNonNull(valueOperations.get(val)));
|
||||
System.out.println(valueOperations.get(val));
|
||||
Long time = Long.valueOf(Objects.requireNonNull(valueOperations.get("search:search-time:"+val)));
|
||||
//返回最近一个月的数据
|
||||
if ((now - time) < HOT_SEARCH_TIME) {
|
||||
result.add(val);
|
||||
@@ -186,6 +188,7 @@ public class RedisServiceImpl implements RedisService {
|
||||
// 没有的话就插入,有的话的直接更新;add是有就覆盖,没有就插入
|
||||
zSetOperations.incrementScore(RedisKeyUtils.getHotSearchKey(), searchKey, 1);
|
||||
valueOperations.getAndSet(RedisKeyUtils.getSearchTimeKey(searchKey), String.valueOf(now));
|
||||
|
||||
return 1L;
|
||||
}catch (Exception e){
|
||||
logger.error("redis发生异常,异常原因:",e);
|
||||
|
@@ -0,0 +1,56 @@
|
||||
package com.lovenav.service.serviceImpl;
|
||||
|
||||
import com.lovenav.dao.UrlCateListDao;
|
||||
import com.lovenav.dao.UserDao;
|
||||
import com.lovenav.entity.UrlCateList;
|
||||
import com.lovenav.entity.User;
|
||||
import com.lovenav.service.UrlCateListService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Transactional
|
||||
@Service("urlCateListService")
|
||||
public class UrlCateListServiceImpl implements UrlCateListService {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
UrlCateListDao urlCateListDao;
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
public int selectAndInsertUrlCate(String email , String cateName , String parent )
|
||||
{
|
||||
//找用户ID
|
||||
User user = userDao.selectByEmail(email);
|
||||
int userId = user.getId();
|
||||
|
||||
//找父标签有没有
|
||||
UrlCateList cateParent = urlCateListDao.selectCateByNameAnduserId(parent,userId);
|
||||
|
||||
UrlCateList targetCate = new UrlCateList();
|
||||
//设置属性
|
||||
targetCate.setName(cateName);
|
||||
targetCate.setUserId(userId);
|
||||
Date date = new Date();
|
||||
targetCate.setCreatetime(date.getTime());
|
||||
|
||||
if(cateParent != null)
|
||||
{
|
||||
targetCate.setRootCateId(cateParent.getId());
|
||||
}else{
|
||||
targetCate.setRootCateId(0);
|
||||
}
|
||||
//插入
|
||||
int flag = urlCateListDao.insert(targetCate);
|
||||
return flag;
|
||||
}
|
||||
|
||||
public List<UrlCateList> selectUrListByUserId(Integer userId){
|
||||
return urlCateListDao.selectUrListByUserId(userId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package com.lovenav.service.serviceImpl;
|
||||
|
||||
import com.lovenav.dao.UrlCateListDao;
|
||||
import com.lovenav.dao.UrlListDao;
|
||||
import com.lovenav.dao.UserDao;
|
||||
import com.lovenav.entity.UrlCateList;
|
||||
import com.lovenav.entity.UrlList;
|
||||
import com.lovenav.entity.User;
|
||||
import com.lovenav.service.UrlListService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Transactional
|
||||
@Service("urlListService")
|
||||
public class UrlLiserServiceImpl implements UrlListService {
|
||||
|
||||
@Autowired
|
||||
UrlCateListDao urlCateListDao;
|
||||
|
||||
@Autowired
|
||||
UrlListDao urlListDao;
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
public int selectCateAndInsertUrl(String parent,String name , String icon ,String url ,String email)
|
||||
{
|
||||
//找用户ID
|
||||
User user = userDao.selectByEmail(email);
|
||||
int userId = user.getId();
|
||||
|
||||
UrlCateList urlCateList = urlCateListDao.selectCateByNameAnduserId(parent,userId);
|
||||
UrlList urlList = new UrlList();
|
||||
//设置属性
|
||||
urlList.setCateId(urlCateList.getId());
|
||||
urlList.setUrl(url);
|
||||
urlList.setIcon(icon);
|
||||
urlList.setName(name);
|
||||
Date date = new Date();
|
||||
urlList.setCreatetime(date.getTime());
|
||||
urlList.setViews(Long.valueOf("0"));
|
||||
int flag = urlListDao.insert(urlList);
|
||||
return flag;
|
||||
}
|
||||
|
||||
public List<UrlList> selectUrList(){
|
||||
return urlListDao.selectUrList();
|
||||
}
|
||||
|
||||
public UrlList selectUrListByInput(String input)
|
||||
{
|
||||
return urlListDao.selectUrListByInput(input);
|
||||
}
|
||||
public UrlList selectUrlListByUrlId(Long urlId)
|
||||
{
|
||||
UrlList urlList = urlListDao.selectUrlListByUrlId(urlId);
|
||||
urlList.setViews(urlList.getViews()+1);
|
||||
urlListDao.updateByPrimaryKeySelective(urlList);
|
||||
return urlList;
|
||||
}
|
||||
}
|
@@ -8,43 +8,18 @@ import com.lovenav.service.UserService;
|
||||
import com.lovenav.utils.MD5Utils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
@Service("userService")
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
UserDao userDao;
|
||||
@Override
|
||||
public String sendEmailActivecode(User user) {
|
||||
return EmailUtils.sendEmail(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int UserRegister(User user) {
|
||||
|
||||
user.setRoleId(Byte.valueOf("1"));
|
||||
user.setUserStatus(Byte.valueOf("1"));
|
||||
user.setUserPassword(MD5Utils.md5(user.getUserPassword()));
|
||||
Date date=new Date();
|
||||
user.setUserRegistered(date);
|
||||
|
||||
|
||||
|
||||
return userDao.insert(user);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public User selectUserAlreadyExist(User user) {
|
||||
System.out.println(user.getUserEmail());
|
||||
User user1=userDao.selectByEmail(user.getUserEmail());
|
||||
return user1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User userLogin(User user) {
|
||||
boolean result;
|
||||
@@ -82,5 +57,32 @@ public class UserServiceImpl implements UserService {
|
||||
return userDao.updateByEmail(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendEmailActivecode(User user) {
|
||||
return EmailUtils.sendEmail(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int UserRegister(User user) {
|
||||
|
||||
user.setRoleId(Byte.valueOf("1"));
|
||||
user.setUserStatus(Byte.valueOf("1"));
|
||||
user.setUserPassword(MD5Utils.md5(user.getUserPassword()));
|
||||
Date date=new Date();
|
||||
user.setUserRegistered(date);
|
||||
|
||||
|
||||
|
||||
return userDao.insert(user);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public User selectUserAlreadyExist(User user) {
|
||||
System.out.println(user.getUserEmail());
|
||||
User user1=userDao.selectByEmail(user.getUserEmail());
|
||||
return user1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user