|
@@ -3,6 +3,9 @@ package com.anyway.favor.service.impl;
|
|
|
import com.anyway.favor.dao.UserDao;
|
|
|
import com.anyway.favor.model.User;
|
|
|
import com.anyway.favor.service.UserService;
|
|
|
+import com.anyway.util.PageQuery;
|
|
|
+import com.anyway.util.PageUtils;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -18,7 +21,7 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class UserServiceImpl implements UserService {
|
|
|
@Autowired
|
|
|
- private UserDao userMapper;
|
|
|
+ private UserDao userDao;
|
|
|
|
|
|
@Override
|
|
|
public List<User> findAll() {
|
|
@@ -26,22 +29,50 @@ public class UserServiceImpl implements UserService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<User> findPage(PageQuery<Map<String, Object>> pageQuery) {
|
|
|
+ PageUtils.startPage(pageQuery.getPage());
|
|
|
+ List<User> userList = userDao.findByCondition(pageQuery.getTerms());
|
|
|
+ PageUtils.setPageTotal(userList, pageQuery.getPage());
|
|
|
+ return userList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public User findByUserName(String userName) {
|
|
|
+ return userDao.findByUserName(userName);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<User> findByCondition(Map<String, Object> map) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean add(User favor) {
|
|
|
- return false;
|
|
|
+ public boolean save(User user) {
|
|
|
+ if (user.getId() != null) {
|
|
|
+ return this.update(user);
|
|
|
+ } else {
|
|
|
+ return this.add(user);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean update(User favor) {
|
|
|
- return false;
|
|
|
+ public boolean add(User user) {
|
|
|
+ return userDao.add(user) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean update(User user) {
|
|
|
+ return userDao.update(user) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean deleteById(Long id) {
|
|
|
+ return userDao.deleteById(id) > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public User findById(Long id) {
|
|
|
- return userMapper.findById(id);
|
|
|
+ return userDao.findById(id);
|
|
|
}
|
|
|
}
|