📄 userservice.java
字号:
package com.dudu.moa.service.sys;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import com.dudu.moa.dao.sys.UserDao;
import com.dudu.moa.domain.sys.User;
import com.dudu.moa.service.BaseService;
import com.dudu.moa.service.BizException;
@Transactional
public class UserService extends BaseService {
private UserDao userDao;
@Required
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
public void createUser(User user) throws BizException {
Assert.notNull(user);
if (StringUtils.isNotBlank(user.getUserId())) {
user.setUserId(null);
}
userDao.save(user);
}
public void updateUser(User user) throws BizException {
userDao.update(user);
}
public void removeUser(User user) throws BizException {
userDao.delete(user);
}
public void removeUser(String userId) throws BizException {
userDao.delete(userId);
}
public User getUser(String userId) throws BizException {
return userDao.get(userId);
}
public User getUserByLoginName(String loginName) throws BizException {
return userDao.findUniqueByProperty("loginName", loginName);
}
@Transactional(readOnly = true)
public List<User> getAllUser() throws BizException {
return userDao.findAll(-1, -1);
}
public List<User> getAllUser(int... startAndCount) throws BizException {
return userDao.findAll(startAndCount);
}
@SuppressWarnings("unchecked")
public List<User> getAllUserWithAvail() throws BizException {
return (List<User>)userDao.findPaged("from User where state=?", -1 , -1, "00A");
}
@SuppressWarnings("unchecked")
public List<User> getAllUserWithAvail(int start, int count) throws BizException {
return (List<User>)userDao.findPaged("from User where state=?", start , count, "00A");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -