package com.fh.controller.system.user;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.fh.controller.base.BaseController;
import com.fh.entity.Page;
import com.fh.entity.system.Role;
import com.fh.service.system.menu.MenuService;
import com.fh.service.system.role.RoleService;
import com.fh.service.system.user.UserService;
import com.fh.util.AppUtil;
import com.fh.util.Const;
import com.fh.util.FileDownload;
import com.fh.util.FileUpload;
import com.fh.util.GetPinyin;
import com.fh.util.ObjectExcelRead;
import com.fh.util.ObjectExcelView;
import com.fh.util.PageData;
import com.fh.util.PathUtil;
import com.fh.util.Tools;
/**
* 类名称:UserController
* @version
*/
@Controller
@RequestMapping(value = "/user")
public class UserController extends BaseController {
@Resource(name = "userService")
private UserService userService;
@Resource(name = "roleService")
private RoleService roleService;
@Resource(name = "menuService")
private MenuService menuService;
/**
* 保存用户
*/
@RequestMapping(value = "/saveU")
public ModelAndView saveU(PrintWriter out) throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
pd.put("USER_ID", this.get32UUID()); // ID
pd.put("RIGHTS", ""); // 权限
pd.put("LAST_LOGIN", ""); // 最后登录时间
pd.put("IP", ""); // IP
pd.put("STATUS", "0"); // 状态
pd.put("SKIN", "default"); // 默认皮肤
pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());
if (null == userService.findByUId(pd)) {
userService.saveU(pd);
mv.addObject("msg", "success");
} else {
mv.addObject("msg", "failed");
}
mv.setViewName("save_result");
return mv;
}
/**
* 判断用户名是否存在
*/
@RequestMapping(value = "/hasU")
public void hasU(PrintWriter out) {
PageData pd = new PageData();
try {
pd = this.getPageData();
if (userService.findByUId(pd) != null) {
out.write("error");
} else {
out.write("success");
}
out.close();
} catch (Exception e) {
logger.error(e.toString(), e);
}
}
/**
* 判断邮箱是否存在
*/
@RequestMapping(value = "/hasE")
public void hasE(PrintWriter out) {
PageData pd = new PageData();
try {
pd = this.getPageData();
if (userService.findByUE(pd) != null) {
out.write("error");
} else {
out.write("success");
}
out.close();
} catch (Exception e) {
logger.error(e.toString(), e);
}
}
/**
* 判断编码是否存在
*/
@RequestMapping(value = "/hasN")
public void hasN(PrintWriter out) {
PageData pd = new PageData();
try {
pd = this.getPageData();
if (userService.findByUN(pd) != null) {
out.write("error");
} else {
out.write("success");
}
out.close();
} catch (Exception e) {
logger.error(e.toString(), e);
}
}
/**
* 修改用户
*/
@RequestMapping(value = "/editU")
public ModelAndView editU(PrintWriter out) throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
if (pd.getString("PASSWORD") != null && !"".equals(pd.getString("PASSWORD"))) {
pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());
}
userService.editU(pd);
mv.addObject("msg", "success");
mv.setViewName("save_result");
return mv;
}
/**
* 去修改用户页面
*/
@RequestMapping(value = "/goEditU")
public ModelAndView goEditU() throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
// 顶部修改个人资料
String fx = pd.getString("fx");
// System.out.println(fx);
if ("head".equals(fx)) {
mv.addObject("fx", "head");
} else {
mv.addObject("fx", "user");
}
List<Role> roleList = roleService.listAllERRoles(); // 列出所有二级角色
pd = userService.findByUiId(pd); // 根据ID读取
mv.setViewName("system/user/user_edit");
mv.addObject("msg", "editU");
mv.addObject("pd", pd);
mv.addObject("roleList", roleList);
return mv;
}
/**
* 去新增用户页面
*/
@RequestMapping(value = "/goAddU")
public ModelAndView goAddU() throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
List<Role> roleList;
roleList = roleService.listAllERRoles(); // 列出所有二级角色
mv.setViewName("system/user/user_edit");
mv.addObject("msg", "saveU");
mv.addObject("pd", pd);
mv.addObject("roleList", roleList);
return mv;
}
/**
* 显示用户列表(用户组)
*/
@RequestMapping(value = "/listUsers")
public ModelAndView listUsers(Page page) throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
String USERNAME = pd.getString("USERNAME");
if (null != USERNAME && !"".equals(USERNAME)) {
USERNAME = USERNAME.trim();
pd.put("USERNAME", USERNAME);
}
String lastLoginStart = pd.getString("lastLoginStart");
String lastLoginEnd = pd.getString("lastLoginEnd");
if (lastLoginStart != null && !"".equals(lastLoginStart)) {
lastLoginStart = lastLoginStart + " 00:00:00";
pd.put("lastLoginStart", lastLoginStart);
}
if (lastLoginEnd != null && !"".equals(lastLoginEnd)) {
lastLoginEnd = lastLoginEnd + " 00:00:00";
pd.put("lastLoginEnd", lastLoginEnd);
}
page.setPd(pd);
List<PageData> userList = userService.listPdPageUser(page); // 列出用户列表
List<Role> roleList = roleService.listAllERRoles(); // 列出所有二级角色
mv.setViewName("system/user/user_list");
mv.addObject("userList", userList);
mv.addObject("roleList", roleList);
mv.addObject("pd", pd);
mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
return mv;
}
/**
* 显示用户列表(tab方式)
*/
@RequestMapping(value = "/listtabUsers")
public ModelAndView listtabUsers(Page page) throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
List<PageData> userList = userService.listAllUser(pd); // 列出用户列表
mv.setViewName("system/user/user_tb_list");
mv.addObject("userList", userList);
mv.addObject("pd", pd);
mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
return mv;
}
/**
* 删除用户
*/
@RequestMapping(value = "/deleteU")
public void deleteU(PrintWriter out) {
PageData pd = new PageData();
try {
pd = this.getPageData();
userService.deleteU(pd);
out.write("success");
out.close();
} catch (Exception e) {
logger.error(e.toString(), e);
}
}
/**
* 批量删除
*/
@RequestMapping(value = "/deleteA
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Java+Spring+SpringMvc+MyBaties+BootStrap框架详情 (991个子文件)
UserController.class 13KB
RoleController.class 13KB
LoginController.class 12KB
HeadController.class 11KB
PicturesController.class 11KB
AndorraController.class 10KB
AppuserController.class 10KB
Uploader.class 10KB
LinkController.class 10KB
PagePlugin.class 9KB
WeixinController.class 9KB
LineController.class 8KB
Page.class 8KB
NewsController.class 7KB
Tools.class 7KB
SmsUtil.class 6KB
DictionariesController.class 6KB
MenuController.class 6KB
ToolController.class 6KB
TwoDimensionCode.class 5KB
NoticeController.class 5KB
FeaturedController.class 5KB
FileUtil.class 5KB
LoginHandlerInterceptor.class 5KB
SimpleMailSender.class 5KB
RoleService.class 5KB
ObjectExcelView.class 4KB
AppUtil.class 4KB
AppUser.class 4KB
Watermark.class 4KB
CreateCodeController.class 4KB
SecCodeController.class 4KB
WeixinController$2.class 4KB
PageData.class 4KB
DateUtil.class 4KB
GetPinyin.class 4KB
JPushClientUtil.class 3KB
UserService.class 3KB
Freemarker.class 3KB
ObjectExcelRead.class 3KB
DaoSupport.class 3KB
MapDistance.class 3KB
MenuService.class 3KB
PathUtil.class 3KB
MailSenderInfo.class 3KB
AppuserService.class 3KB
Menu.class 3KB
User.class 3KB
SortUtil.class 3KB
IntAppuserController.class 3KB
PicturesService.class 2KB
Const.class 2KB
FileZip.class 2KB
ImageAnd64Binary.class 2KB
Logger.class 2KB
FileUpload.class 2KB
Tb.class 2KB
Role.class 2KB
WebSocket.class 2KB
LineService.class 2KB
DictionariesService.class 2KB
BaseController.class 2KB
NewsService.class 2KB
DelAllFile.class 2KB
ReflectHelper.class 2KB
AndorraService.class 2KB
LinkService.class 2KB
FileDownload.class 2KB
LatLonUtil.class 2KB
QueryController.class 2KB
FeaturedService.class 2KB
NoticeService.class 2KB
RequestUtil.class 2KB
MD5.class 2KB
MyExceptionResolver.class 2KB
RightsHelper.class 2KB
startFilter.class 2KB
PublicUtil.class 1KB
QueryVO.class 1KB
ShiroRealm.class 1KB
WeixinController$1.class 1KB
StringUtil.class 1KB
ServiceHelper.class 1KB
Constants.class 1KB
LoginFilter.class 1KB
WebAppContextListener.class 1KB
Tools4MD5.class 961B
MyX509TrustManager.class 915B
AddController.class 913B
QueryService.class 907B
UuidUtil.class 906B
TwoDimensionCodeImage.class 824B
MyAuthenticator.class 776B
startFilter$1.class 558B
DAO.class 466B
QueryVOMapper.class 274B
.classpath 867B
org.eclipse.wst.common.component 552B
org.eclipse.wst.jsdt.ui.superType.container 49B
ace.css 458KB
共 991 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
yongyuan1110
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页