📄 userservice.java
字号:
package com.xuntian.material.model.service.user;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import com.xuntian.material.bean.UserBean;
import com.xuntian.material.bean.entity.UserEntity;
import com.xuntian.material.exception.ConnectPoolException;
import com.xuntian.material.exception.UserException;
import com.xuntian.material.model.iservice.user.IUserService;
import com.xuntian.material.util.Constants;
/**
* @author hanyx
* @email hanyx@xun-tian.com
*
*/
public final class UserService implements IUserService {
public static IUserService getInstance() {
return new UserService();
}
private UserService() {
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#list()
*/
public List<List<String>> list() throws UserException {
List<List<String>> list = null;
try {
list = new UserEntity(null).queryAll();
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return list;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#list()
*/
public List<List<String>> search(ActionForm form) throws UserException {
List<List<String>> list = null;
try {
list = new UserEntity((UserBean) form).queryAll();
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return list;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#fill(org.apache.struts.action.ActionForm)
*/
public UserBean fill(ActionForm form) throws UserException {
UserBean user = (UserBean) form;
UserEntity userEntity = new UserEntity(user);
try {
userEntity.fill();
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
} catch (SQLException sqle) {
throw new UserException(Constants.ERRMSG_SELECT, sqle);
}
return userEntity.getUserBean();
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#save(org.apache.struts.action.ActionForm)
*/
public int save(HttpServletRequest request, ActionForm form)
throws UserException {
String itemID = request.getParameter("userItemID");
String groupID = request.getParameter("userGroupID");
UserBean user = (UserBean) form;
UserEntity userEntity = new UserEntity(user);
int result = 0;
try {
result = userEntity.save(itemID, groupID);
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return result;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#delete(javax.servlet.http.HttpServletRequest)
*/
public int delete(HttpServletRequest request) throws UserException {
String[] UserIDs = request.getParameterValues("userID");
int result = 0;
try {
result = new UserEntity(null).delete(UserIDs);
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return result;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#saveGroup(javax.servlet.http.HttpServletRequest,
* org.apache.struts.action.ActionForm)
*/
public int saveGroup(HttpServletRequest request, ActionForm form)
throws UserException {
UserEntity entity = new UserEntity((UserBean) form);
String[] groupIDs = request.getParameterValues("groupID");
int result = 0;
try {
result = entity.saveGroup(groupIDs);
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_EDIT, cpe);
}
return result;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#saveRole(javax.servlet.http.HttpServletRequest,
* org.apache.struts.action.ActionForm)
*/
public int saveRole(HttpServletRequest request, ActionForm form)
throws UserException {
UserEntity entity = new UserEntity((UserBean) form);
String[] menuIDs = request.getParameterValues("menuID");
String[] itemIDs = request.getParameterValues("itemID");
int result = 0;
try {
result = entity.saveRole(menuIDs, itemIDs);
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_EDIT, cpe);
}
return result;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#getUserMenu(org.apache.struts.action.ActionForm)
*/
public List<List<String>> getUserMenu(ActionForm form) throws UserException {
List<List<String>> list = null;
UserBean user = (UserBean) form;
UserEntity entity = new UserEntity(user);
try {
list = entity.queryMenuRole();
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return list;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#getUserItem(org.apache.struts.action.ActionForm)
*/
public List<List<String>> getUserItem(ActionForm form) throws UserException {
List<List<String>> list = null;
UserBean user = (UserBean) form;
UserEntity entity = new UserEntity(user);
try {
list = entity.queryItemRole();
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return list;
}
/*
* (non-Javadoc)
*
* @see com.xuntian.material.model.service.user.UserIService#getUserGroup(org.apache.struts.action.ActionForm)
*/
public List<List<String>> getUserGroup(ActionForm form)
throws UserException {
List<List<String>> list = null;
UserBean user = (UserBean) form;
UserEntity entity = new UserEntity(user);
try {
list = entity.queryGroup();
} catch (ConnectPoolException cpe) {
throw new UserException(Constants.ERRMSG_SELECT, cpe);
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -