/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jsnjfz.manage.modular.system.controller;
import com.jsnjfz.manage.modular.system.factory.UserFactory;
import com.jsnjfz.manage.modular.system.model.User;
import com.jsnjfz.manage.modular.system.service.IUserService;
import com.jsnjfz.manage.modular.system.warpper.UserWarpper;
import com.jsnjfz.manage.config.properties.GunsProperties;
import com.jsnjfz.manage.core.common.annotion.BussinessLog;
import com.jsnjfz.manage.core.common.annotion.Permission;
import com.jsnjfz.manage.core.common.constant.Const;
import com.jsnjfz.manage.core.common.constant.dictmap.UserDict;
import com.jsnjfz.manage.core.common.constant.factory.ConstantFactory;
import com.jsnjfz.manage.core.common.constant.state.ManagerStatus;
import com.jsnjfz.manage.core.common.exception.BizExceptionEnum;
import com.jsnjfz.manage.core.log.LogObjectHolder;
import com.jsnjfz.manage.core.shiro.ShiroKit;
import com.jsnjfz.manage.core.shiro.ShiroUser;
import com.jsnjfz.manage.modular.system.factory.UserFactory;
import com.jsnjfz.manage.modular.system.model.User;
import com.jsnjfz.manage.modular.system.service.IUserService;
import com.jsnjfz.manage.modular.system.transfer.UserDto;
import com.jsnjfz.manage.modular.system.warpper.UserWarpper;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.datascope.DataScope;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.exception.ServiceException;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.naming.NoPermissionException;
import javax.validation.Valid;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* 系统管理员控制器
*
*/
@Controller
@RequestMapping("/mgr")
public class UserMgrController extends BaseController {
private static String PREFIX = "/system/user/";
@Autowired
private GunsProperties gunsProperties;
@Autowired
private IUserService userService;
/**
* 跳转到查看管理员列表的页面
*/
@RequestMapping("")
public String index() {
return PREFIX + "user.html";
}
/**
* 跳转到查看管理员列表的页面
*/
@RequestMapping("/user_add")
public String addView() {
return PREFIX + "user_add.html";
}
/**
* 跳转到角色分配页面
*/
//@RequiresPermissions("/mgr/role_assign") //利用shiro自带的权限检查
@Permission
@RequestMapping("/role_assign/{userId}")
public String roleAssign(@PathVariable Integer userId, Model model) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
User user = this.userService.selectOne(new EntityWrapper<User>().eq("id", userId));
model.addAttribute("userId", userId);
model.addAttribute("userAccount", user.getAccount());
return PREFIX + "user_roleassign.html";
}
/**
* 跳转到编辑管理员页面
*/
@Permission
@RequestMapping("/user_edit/{userId}")
public String userEdit(@PathVariable Integer userId, Model model) {
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
assertAuth(userId);
User user = this.userService.selectById(userId);
model.addAttribute(user);
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
LogObjectHolder.me().set(user);
return PREFIX + "user_edit.html";
}
/**
* 跳转到查看用户详情页面
*/
@RequestMapping("/user_info")
public String userInfo(Model model) {
Integer userId = ShiroKit.getUser().getId();
if (ToolUtil.isEmpty(userId)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
User user = this.userService.selectById(userId);
model.addAttribute(user);
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
LogObjectHolder.me().set(user);
return PREFIX + "user_view.html";
}
/**
* 跳转到修改密码界面
*/
@RequestMapping("/user_chpwd")
public String chPwd() {
return PREFIX + "user_chpwd.html";
}
/**
* 修改当前用户的密码
*/
@RequestMapping("/changePwd")
@ResponseBody
public Object changePwd(@RequestParam String oldPwd, @RequestParam String newPwd, @RequestParam String rePwd) {
if (!newPwd.equals(rePwd)) {
throw new ServiceException(BizExceptionEnum.TWO_PWD_NOT_MATCH);
}
Integer userId = ShiroKit.getUser().getId();
User user = userService.selectById(userId);
String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt());
if (user.getPassword().equals(oldMd5)) {
String newMd5 = ShiroKit.md5(newPwd, user.getSalt());
user.setPassword(newMd5);
user.updateById();
return SUCCESS_TIP;
} else {
throw new ServiceException(BizExceptionEnum.OLD_PWD_NOT_RIGHT);
}
}
/**
* 查询管理员列表
*/
@RequestMapping("/list")
@Permission
@ResponseBody
public Object list(@RequestParam(required = false) String name, @RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) Integer deptid) {
if (ShiroKit.isAdmin()) {
List<Map<String, Object>> users = userService.selectUsers(null, name, beginTime, endTime, deptid);
return new UserWarpper(users).wrap();
} else {
DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope());
List<Map<String, Object>> users = userService.selectUsers(dataScope, name, beginTime, endTime, deptid);
return new UserWarpper(users).wrap();
}
}
/**
* 添加管理员
*/
@RequestMapping("/add")
@BussinessLog(value = "添加管理员", key = "account", dict = UserDict.class)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public ResponseData add(@Valid UserDto user, BindingResult result) {
if (result.hasErrors()) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
// 判断账号是否重复
User theUser = userService.getByAccount(user.getAccount());
if (theUser != null) {
throw new ServiceException(BizExceptionEnum.USER_ALREADY_REG);
}
// 完善账号信息
user.setSalt(ShiroKit.getRandomSalt(5));
user.setPassword(ShiroKit.md5(user.getPassword(), user.getSalt()));
user.setStatus(ManagerStatus.OK.getCode());
user.setCreatet
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源导航系统给予一些不知道如何挑选优质资源的普通用户来说,可以选择的平台之一,本系统中不但为用户提供了方便快捷的获取优质数据,也为用户提供了其他搜索引擎直接输入即可跳转并搜索响应的内容。本系统以IDEA+MySQL+VSCODE等主要制作工具,主要有网站模块、后台模块(管理员登录后台更新数据,网站也会更新);其中网站模块包括其他搜索引擎的使用、其他网站实时公开的热点信息、优秀的网站分类、详细内容页、分类汇总页、留言页等等,后台模块,管理员用户及其他(包含不用权限设置,但不可以超过管理员权限)、网站添加、网站分类管理、公告栏、留言管理等等。从而实现了用户最佳选择优秀资源,很大程度上提高用户浏览体验。并且,我们有理由相信导航网站定会以它巨大的优势在将来从优秀内容获取形式中占据主导地位。资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统资源导航系统
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM的资源导航系统(可用) (1011个子文件)
.classpath 1KB
app.css 799KB
xenon.css 683KB
xenon-skins.css 250KB
H-ui.3.css 203KB
xenon-core.css 173KB
H-ui.css 154KB
bootstrap.min.css 152KB
H-ui.min.3.css 149KB
xenon-components.css 148KB
style.css 133KB
bootstrap.min.css 118KB
bootstrap.css 113KB
H-ui.min.css 111KB
style.css 71KB
linecons-embedded.css 65KB
xenon-forms.css 57KB
font-awesome.css 32KB
bootstrap-rtl.css 31KB
font-awesome.css 26KB
font-awesome.min.css 26KB
iconfont.css 25KB
font-awesome.min.css 21KB
layer.css 14KB
fancybox.min.css 12KB
chosen.css 12KB
dropzone.css 11KB
he-simple.css 9KB
laydate.css 8KB
font.css 8KB
zTreeStyle.css 6KB
fontawesome-iconpicker.min.css 6KB
bootstrap-table.min.css 6KB
linecons-ie7.css 5KB
layer.css 5KB
linecons-ie7-codes.css 5KB
linecons.css 4KB
jquery-ui.structure.css 4KB
jquery-ui.css 4KB
basic.css 4KB
jquery-ui.min.css 3KB
jquery-ui.structure.min.css 3KB
linecons-codes.css 3KB
demo.css 2KB
login.css 2KB
animation.css 2KB
custom.css 1KB
_fstyle.css 975B
bootstrap-treetable.css 923B
bootstrapValidator.min.css 694B
webuploader.css 554B
webuploader.css 515B
custom.css 60B
fontawesome-webfont.eot 67KB
fontawesome-webfont.eot 55KB
linecons.eot 29KB
glyphicons-halflings-regular.eot 20KB
iconfont.eot 2KB
boy.gif 13KB
girl.gif 9KB
loading-0.gif 6KB
zTreeStandard.gif 5KB
loading-2.gif 2KB
loading-upload.gif 2KB
loading-1.gif 701B
loading.gif 381B
line_conn.gif 45B
.gitattributes 115B
.gitignore 359B
sites.html 29KB
_hot.html 16KB
_Search_modal.html 16KB
liuyan.html 15KB
_Search.html 14KB
_lunbotu.html 9KB
_content.html 6KB
code.html 6KB
about.html 5KB
_header.html 5KB
favorites.html 4KB
dict_edit.html 4KB
_container.html 4KB
_MyNav.html 4KB
index.html 4KB
_sidebar.html 4KB
user_view.html 4KB
_tab.html 4KB
user.html 3KB
_footer.html 3KB
login.html 3KB
dict_add.html 3KB
new_index.html 3KB
_theme.html 3KB
_right.html 3KB
user.html 2KB
code.html 2KB
user_roleassign.html 2KB
_sites.html 2KB
role_assign.html 2KB
log.html 2KB
共 1011 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
蓝兔兔
- 粉丝: 27
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功