userservice.java

来自「wmoa办公自动化系统 小型的JAVA项目 功能包括审批流 消息发布等」· Java 代码 · 共 72 行

JAVA
72
字号
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 + =
减小字号Ctrl + -
显示快捷键?