package com.dzl.smbms.controller;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.dzl.smbms.pojo.User;
import com.dzl.smbms.service.RoleService;
import com.dzl.smbms.service.UserService;
import com.dzl.smbms.tools.Constants;
import com.dzl.smbms.tools.PageSupport;
import com.mysql.jdbc.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.dzl.smbms.pojo.Role;
@Controller
@RequestMapping("/user")
public class UserController {
private Logger logger = Logger.getLogger(UserController.class);
@Resource
private UserService userService;
@Resource
private RoleService roleService;
// 登录成功 -----首页
@RequestMapping(value = "/main.html")
public String main(HttpSession session) {
if (session.getAttribute(Constants.USER_SESSION) == null) {
return "redirect:/login.html";// 跳转到登录页面
}
return "jsp/frame"; // 登录成功:跳转到首页
}
// 退出登录
@RequestMapping(value = "/logout.html")
public String logout(HttpSession session) {
// 清除session
session.removeAttribute(Constants.USER_SESSION);
return "login";
}
// 用户条件查询 --------分页
@RequestMapping(value = "/userlist.html")
public String getUserlist(Model model,
@RequestParam(value = "queryUserName", required = false) String queryUserName,
@RequestParam(value = "queryUserRole", required = false) String queryUserRole,
@RequestParam(value = "pageIndex", required = false) String pageIndex) {
int _queryUserRole = 0;
List<User> userList = null;
// 设置页面容量
int pageSize = Constants.pageSize;
// 当前页码
int currentPageNo = 1;
if (queryUserName == null) {
queryUserName = "";
}
if (queryUserRole != null && !queryUserRole.equals("")) {
_queryUserRole = Integer.parseInt(queryUserRole);
}
if (pageIndex != null) {
try {
currentPageNo = Integer.valueOf(pageIndex);
} catch (NumberFormatException e) {
return "redirect:/user/syserror.html";
}
}
// 总数量(表)
int totalCount = userService.getUserCount(queryUserName, _queryUserRole);
// 总页数
PageSupport pages = new PageSupport();
pages.setCurrentPageNo(currentPageNo);
pages.setPageSize(pageSize);
pages.setTotalCount(totalCount);
int totalPageCount = pages.getTotalPageCount();
// 控制首页和尾页
if (currentPageNo < 1) {
currentPageNo = 1;
} else if (currentPageNo > totalPageCount) {
currentPageNo = totalPageCount;
}
userList = userService.getUserList(queryUserName, _queryUserRole, currentPageNo, pageSize);
model.addAttribute("userList", userList);
List<Role> roleList = null;
roleList = roleService.selectRoleList();
model.addAttribute("roleList", roleList);
model.addAttribute("queryUserName", queryUserName);
model.addAttribute("queryUserRole", queryUserRole);
model.addAttribute("totalPageCount", totalPageCount);
model.addAttribute("totalCount", totalCount);
model.addAttribute("currentPageNo", currentPageNo);
return "jsp/userlist";
}
@RequestMapping(value = "/syserror.html")
public String sysError() {
return "syserror";
}
// 跳到修改密码页面
@RequestMapping(value = "/pwdmodify.html")
public String pwdmodify() {
return "jsp/pwdmodify";
}
// 查询原始密码是否正确
@ResponseBody
@RequestMapping(value = "/pwd.html", method = RequestMethod.GET)
public String pwd(@RequestParam String oldpassword, HttpSession session) {
Map<String, String> map = new HashMap<String, String>();
User user = (User) session.getAttribute(Constants.USER_SESSION);
if (user.getUserPassword().equals(oldpassword)) {
map.put("result", "true");
} else if (!oldpassword.equals(user.getUserPassword())) {
map.put("result", "false");
} else if (user.getUserPassword().equals("") && user.getUserPassword() == null) {
map.put("result", "sessionerror");
} else {
map.put("result", "error");
}
return JSONArray.toJSONString(map);
}
// 修改密码
@RequestMapping(value = "/updatepwd.html", method = RequestMethod.POST)
public String updatepwd(@RequestParam String method, @RequestParam String newpassword) {
userService.updatePwd(Integer.valueOf(method), newpassword);
return "redirect:/user/login.html";
}
// 根据用户id删除用户信息
@ResponseBody
@RequestMapping(value = "/deluser.html", method = RequestMethod.GET)
public String deluser(@RequestParam String uid) {
Map<String, String> resultMap = new HashMap<String, String>();
if (StringUtils.isNullOrEmpty(uid)) {
resultMap.put("delResult", "notexist");
} else {
if (userService.deleteByPrimaryKey(Integer.parseInt(uid)) > 0) {
resultMap.put("delResult", "true");
}else {
resultMap.put("delResult", "false");
}
}
return JSONArray.toJSONString(resultMap);
}
// 根据用户id查询指定用户信息
@RequestMapping(value = "/view", method = RequestMethod.GET)
public String view(@RequestParam String uid, Model model) {
User user = userService.selectByPrimaryKey(Integer.valueOf(uid));
model.addAttribute("user", user);
return "jsp/userview";
}
// 根据用户id查询指定用户信息 (显示usermodify.jsp)
@RequestMapping(value = "/usermodify", method = RequestMethod.GET)
public String usermodify(@RequestParam String uid, Model model) {
User user = userService.selectByPrimaryKey(Integer.valueOf(uid));
model.addAttribute("user", user);
return "jsp/usermodify";
}
// 显示全部用户角色(返回JSON)
@ResponseBody
@RequestMapping(value = "/getrolelist.html", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
public String getrolelist() {
List<Role> roleList = roleService.selectRoleList();
return JSONArray.toJSONString(roleList);
}
// 修改用户信息
@RequestMapping(value = "/usermodifysave.html", method = RequestMethod.POST)
public String modifyUserSave(User user, HttpSession session) {
logger.debug("modifyUserSave userid===================== " + user.getId());
user.setModifyBy(((User) session.getAttribute(Constants.USER_SESSION)).getId());
user.setModifyDate(new Date());
if (userService.updateByPrimaryKeySelective(user) > 0) {
return "redirect:/user/userlist.html";
}
return "jsp/usermodify";
}
// 跳转到添加用户页面
@RequestMapping("/useradd.html")
public String useradd() {
return "jsp/useradd";
}
// 查询userCode是否存在
@ResponseBody
@RequestMapping(value = "/ucexist.html")
public String ucexist(@RequestParam String userCode) {
Map<String, Object> map = new HashMap<String, Object>();
User user = userService.selectUserCodeExist(userCode);
if (user != null) {
map.put("userCode", "exist");
}
return JSONArray.toJSONString(map);
}
// 添加用户操作
@RequestMapping(value="/addUser.html",method=RequestMethod.POST)
public String addUser(User user, HttpSession session, HttpServletRequest request,
@RequestParam(value = "attachs", required = false) MultipartFile[] attachs) {
String idPicPath = null;
String workPicPath = null;
String errorInfo = null;
boolean flag = true;
String path = "F:/Work/SSM/SSM-MyS
没有合适的资源?快使用搜索试试~ 我知道了~
SSM框架开发超市订单管理系统包含MySQL数据库
共223个文件
jar:29个
js:26个
class:25个
3星 · 超过75%的资源 需积分: 16 92 下载量 108 浏览量
2018-10-14
19:40:28
上传
评论 5
收藏 10.71MB ZIP 举报
温馨提示
备注:这个系统模块,订单和供应商管理,功能与用户管理,这个项目是利用mybatis的反向工程生成的dao、entity、mapper,运行环境:jdk8+tomcat7以上+mysql,里面包含MySQL数据库
资源推荐
资源详情
资源评论
收起资源包目录
SSM框架开发超市订单管理系统包含MySQL数据库 (223个子文件)
UserController.class 11KB
BillController.class 7KB
ProviderController.class 7KB
RoleContrller.class 5KB
UserServiceImpl.class 5KB
User.class 4KB
ProviderServiceImpl.class 4KB
BillServiceImpl.class 4KB
Bill.class 4KB
Provider.class 3KB
IndexController.class 3KB
RoleServiceImpl.class 2KB
Address.class 2KB
LoginInterceptor.class 2KB
Role.class 2KB
PageSupport.class 1KB
UserMapper.class 1KB
ProviderMapper.class 1KB
UserService.class 974B
BillMapper.class 929B
ProviderService.class 877B
BillService.class 791B
RoleMapper.class 564B
RoleService.class 512B
Constants.class 456B
.classpath 847B
org.eclipse.wst.common.component 565B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 9KB
public.css 6KB
datepicker.css 4KB
datepicker.css 4KB
WdatePicker.css 158B
entries 846B
entries 692B
entries 659B
entries 567B
entries 539B
img.gif 2KB
img.gif 2KB
datePicker.gif 1KB
My97DatePicker.htm 1KB
aspectjweaver-1.6.9.jar 1.59MB
spring-core-3.2.13.RELEASE.jar 865KB
spring-context-3.2.13.RELEASE.jar 848KB
mybatis-3.2.2.jar 683KB
spring-webmvc-3.2.13.RELEASE.jar 626KB
spring-web-3.2.13.RELEASE.jar 617KB
spring-beans-3.2.13.RELEASE.jar 600KB
mysql-connector-java-5.1.0-bin.jar 553KB
fastjson-1.2.49.jar 548KB
log4j-1.2.17.jar 478KB
hibernate-validator-4.3.2.Final.jar 474KB
spring-jdbc-3.2.13.RELEASE.jar 396KB
standard.jar 384KB
fastjson-1.2.13.jar 384KB
spring-aop-3.2.13.RELEASE.jar 331KB
commons-lang-2.6.jar 278KB
spring-tx-3.2.13.RELEASE.jar 237KB
spring-expression-3.2.13.RELEASE.jar 192KB
commons-io-2.4.jar 181KB
commons-dbcp-1.4.jar 157KB
commons-pool-1.6.jar 109KB
commons-logging-1.2.jar 60KB
commons-logging-1.1.1.jar 59KB
jboss-logging-3.1.0.CR2.jar 59KB
commons-fileupload-1.2.2.jar 58KB
mybatis-spring-1.2.0.jar 48KB
validation-api-1.0.0.GA.jar 46KB
jstl.jar 20KB
aopalliance-1.0.jar 4KB
UserController.java 10KB
BillController.java 7KB
ProviderController.java 6KB
RoleContrller.java 4KB
User.java 4KB
UserServiceImpl.java 4KB
ProviderServiceImpl.java 4KB
Bill.java 3KB
BillServiceImpl.java 3KB
IndexController.java 3KB
UserMapper.java 2KB
Provider.java 2KB
UserService.java 2KB
RoleServiceImpl.java 2KB
ProviderMapper.java 2KB
Address.java 2KB
ProviderService.java 2KB
BillService.java 2KB
Role.java 1KB
LoginInterceptor.java 1KB
PageSupport.java 1KB
RoleMapper.java 1KB
RoleService.java 1KB
BillMapper.java 1KB
Constants.java 214B
1538209900746_Personal.jpg 245KB
1538209618900_Personal.jpg 100KB
1538979979076_Personal.jpg 79KB
1538213001444_Personal.jpg 79KB
共 223 条
- 1
- 2
- 3
资源评论
- 「已注销」2019-01-03还是挺不错的
- 什么都不会的小廖2019-02-28数据库连接不上啊
Mr微笑
- 粉丝: 208
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功