package cn.itcast.oa.view.action;
import java.util.HashSet;
import java.util.List;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import cn.itcast.oa.base.BaseAction;
import cn.itcast.oa.domain.Department;
import cn.itcast.oa.domain.Role;
import cn.itcast.oa.domain.User;
import cn.itcast.oa.util.DepartmentUtils;
import com.opensymphony.xwork2.ActionContext;
@Controller
@Scope("prototype")
public class UserAction extends BaseAction<User> {
private Long departmentId;
private Long[] roleIds;
/** 列表 */
public String list() throws Exception {
List<User> userList = userService.findAll();
ActionContext.getContext().put("userList", userList);
return "list";
}
/** 删除 */
public String delete() throws Exception {
userService.delete(model.getId());
return "toList";
}
/** 添加页面 */
public String addUI() throws Exception {
// 1,准备显树状结构的部门列表
List<Department> topList = departmentService.findTopList();
List<Department> departmentList = DepartmentUtils.getAllDepartments(topList, null);
ActionContext.getContext().put("departmentList", departmentList);
// 2,准备岗位列表
List<Role> roleList = roleService.findAll();
ActionContext.getContext().put("roleList", roleList);
return "saveUI";
}
/** 添加 */
public String add() throws Exception {
// 1,新建对象并设置属性(也可以使用model,但需要设置没有封装的属性)
List<Role> roleList = roleService.getByIds(roleIds);
model.setDepartment(departmentService.getById(departmentId));
model.setRoles(new HashSet<Role>(roleList));
// 要使用MD5摘要
String passwordMd5 = DigestUtils.md5Hex("1234");
model.setPassword(passwordMd5);
// 2,保存到数据库
userService.save(model);
return "toList";
}
/** 修改页面 */
public String editUI() throws Exception {
// 1,准备显树状结构的部门列表
List<Department> topList = departmentService.findTopList();
List<Department> departmentList = DepartmentUtils.getAllDepartments(topList, null);
ActionContext.getContext().put("departmentList", departmentList);
// 2,准备岗位列表
List<Role> roleList = roleService.findAll();
ActionContext.getContext().put("roleList", roleList);
// 3,准备回显的数据
User user = userService.getById(model.getId());
ActionContext.getContext().getValueStack().push(user);
if (user.getDepartment() != null) {
departmentId = user.getDepartment().getId();
}
int index = 0;
roleIds = new Long[user.getRoles().size()];
for (Role role : user.getRoles()) {
roleIds[index++] = role.getId();
}
return "saveUI";
}
/** 修改 */
public String edit() throws Exception {
// 1,从数据库中获取原对象
User user = userService.getById(model.getId());
// 2,设置要修改的属性
user.setLoginName(model.getLoginName());
user.setName(model.getName());
user.setGender(model.getGender());
user.setPhoneNumber(model.getPhoneNumber());
user.setEmail(model.getEmail());
user.setDescription(model.getDescription());
List<Role> roleList = roleService.getByIds(roleIds);
user.setDepartment(departmentService.getById(departmentId));
user.setRoles(new HashSet<Role>(roleList));
// 3,更新到数据库中
userService.update(user);
return "toList";
}
/** 初始化密码为1234 */
public String initPassword() throws Exception {
// 1,从数据库中获取原对象
User user = userService.getById(model.getId());
// 2,设置要修改的属性
String passwordMd5 = DigestUtils.md5Hex("1234");
user.setPassword(passwordMd5);
// 3,更新到数据库中
userService.update(user);
return "toList";
}
/** 登录页面 */
public String loginUI() throws Exception {
return "loginUI";
}
/** 登录 */
public String login() throws Exception {
// 根据用户名与密码查询一个用户,如果能查到,就是正确,就登录,如果不正确,就失败。
User user = userService.findByLoginNameAndPassword(model.getLoginName(), model.getPassword());
if (user == null) {
addFieldError("login", "用户名或密码不正确!");
// addFieldError("login", getText("message.login.error"));
return "loginUI";
} else {
// 登录用户
ActionContext.getContext().getSession().put("user", user);
return "toIndex";
}
}
/** 注销 */
public String logout() throws Exception {
ActionContext.getContext().getSession().remove("user");
return "logout";
}
// ====================================
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
public Long[] getRoleIds() {
return roleIds;
}
public void setRoleIds(Long[] roleIds) {
this.roleIds = roleIds;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ItcastOA.zip_itcastoa_itcastoa jbpm_java JBPM_jbpm_权限
共1314个文件
gif:736个
js:193个
png:53个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 174 浏览量
2022-09-23
11:39:57
上传
评论
收藏 17.59MB ZIP 举报
温馨提示
JBPm工作流,权限设计 JBPm工作流,权限设计
资源推荐
资源详情
资源评论
收起资源包目录
ItcastOA.zip_itcastoa_itcastoa jbpm_java JBPM_jbpm_权限 (1314个子文件)
config.ascx 5KB
class_upload.asp 10KB
io.asp 7KB
commands.asp 6KB
config.asp 6KB
connector.asp 2KB
upload.asp 2KB
basexml.asp 2KB
util.asp 1KB
connector.aspx 1KB
upload.aspx 1KB
ForumAction.java.bak 3KB
install.bat 79B
image.cfc 46KB
ImageObject.cfc 12KB
cf5_upload.cfm 11KB
cf5_connector.cfm 10KB
cf_io.cfm 10KB
cf_commands.cfm 8KB
config.cfm 8KB
spellchecker.cfm 5KB
cf_util.cfm 4KB
cf_connector.cfm 3KB
cf_basexml.cfm 3KB
cf_upload.cfm 2KB
connector.cfm 1005B
upload.cfm 993B
connector.cgi 4KB
upload.cgi 3KB
UserAction.class 6KB
BaseDaoImpl.class 4KB
AnchorTag.class 4KB
TreeViewPractice.class 4KB
Installer.class 4KB
RoleAction.class 4KB
User.class 4KB
ForumAction.class 4KB
DepartmentAction.class 3KB
TopicAction.class 3KB
TopicServiceImpl.class 3KB
ReplyServiceImpl.class 3KB
BaseAction.class 3KB
Privilege.class 3KB
ForumManageAction.class 3KB
ForumServiceImpl.class 2KB
Forum.class 2KB
DepartmentUtils.class 2KB
ReplyAction.class 2KB
CheckPrivilegeInterceptor.class 2KB
Department.class 2KB
Topic.class 2KB
PageBean.class 2KB
Role.class 2KB
Article.class 2KB
InitServletContextListener.class 2KB
DepartmentServiceImpl.class 1KB
UserServiceImpl.class 1KB
SpringTest.class 1KB
PrivilegeServiceImpl.class 1KB
DepartmentForm.class 1KB
TestService.class 1KB
TestAction.class 973B
IndexAction.class 952B
Log4jTest.class 929B
BaseDao.class 661B
TopicService.class 580B
ReplyService.class 580B
RoleServiceImpl.class 574B
Reply.class 571B
DepartmentService.class 516B
Configuration.class 468B
PrivilegeService.class 452B
BaseDaoTest.class 417B
UserService.class 357B
ForumService.class 314B
RoleService.class 253B
.classpath 3KB
pageCommon.css 17KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_dialog.css 6KB
fck_dialog.css 6KB
fck_dialog.css 6KB
fck_internal.css 4KB
forum.css 4KB
top.css 4KB
file.css 4KB
fck_editorarea.css 3KB
jquery.treeview.css 3KB
style.css 2KB
selectPerson.css 2KB
menu.css 2KB
login.css 2KB
fck_dialog_common.css 2KB
fck_showtableborders_gecko.css 2KB
browser.css 2KB
statusbar.css 1KB
spellerStyle.css 890B
logout.css 820B
共 1314 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
资源评论
JaniceLu
- 粉丝: 78
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功