/**
* 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 cn.stylefeng.guns.modular.system.controller;
import cn.stylefeng.guns.config.properties.GunsProperties;
import cn.stylefeng.guns.core.common.annotion.BussinessLog;
import cn.stylefeng.guns.core.common.annotion.Permission;
import cn.stylefeng.guns.core.common.constant.Const;
import cn.stylefeng.guns.core.common.constant.dictmap.UserDict;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.common.constant.state.ManagerStatus;
import cn.stylefeng.guns.core.common.exception.BizExceptionEnum;
import cn.stylefeng.guns.core.log.LogObjectHolder;
import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.modular.system.factory.UserFactory;
import cn.stylefeng.guns.modular.system.model.User;
import cn.stylefeng.guns.modular.system.service.IUserService;
import cn.stylefeng.guns.modular.system.transfer.UserDto;
import cn.stylefeng.guns.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;
/**
* 系统管理员控制器
*
* @author fengshuonan
* @Date 2017年1月11日 下午1:08:17
*/
@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.setCreatetime(new Date());
this.userService.insert(UserFactory.createUser(user));
return SUCCESS_TIP;
}
/**
* 修改管理员
*
* @throws NoPe
没有合适的资源?快使用搜索试试~ 我知道了~
基于SpringBoot的guns社区养老医疗服务综合平台管理系统+源代码+文档说明+数据库sql
共428个文件
java:178个
js:84个
html:58个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 147 浏览量
2023-11-28
16:14:59
上传
评论
收藏 2.11MB ZIP 举报
温馨提示
- ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
资源推荐
资源详情
资源评论
收起资源包目录
基于SpringBoot的guns社区养老医疗服务综合平台管理系统+源代码+文档说明+数据库sql (428个子文件)
style.css 133KB
bootstrap.min.css 118KB
font-awesome.css 32KB
bootstrap-rtl.css 31KB
font-awesome.min.css 26KB
layer.css 14KB
chosen.css 12KB
laydate.css 8KB
zTreeStyle.css 6KB
bootstrap-table.min.css 6KB
layer.css 5KB
demo.css 2KB
login.css 2KB
custom.css 1KB
_fstyle.css 975B
bootstrap-treetable.css 923B
bootstrapValidator.min.css 694B
webuploader.css 554B
webuploader.css 515B
fontawesome-webfont.eot 67KB
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
code.html 6KB
dict_edit.html 4KB
user_view.html 4KB
_container.html 4KB
_tab.html 4KB
user.html 3KB
dict_add.html 3KB
login.html 3KB
_right.html 3KB
_theme.html 3KB
code.html 2KB
user_roleassign.html 2KB
role_assign.html 2KB
log.html 2KB
menu_edit.html 2KB
user_edit.html 2KB
role.html 2KB
user_add.html 2KB
role_edit.html 2KB
dept_edit.html 2KB
patientHistory.html 2KB
menu.html 2KB
patientHealth.html 2KB
patientHealth.html 2KB
medicineInfo.html 2KB
doctorPoint.html 2KB
patientInfo.html 2KB
patientHistory_edit.html 2KB
order.html 2KB
role_add.html 2KB
notice.html 2KB
dept_add.html 2KB
info.html 2KB
dept.html 2KB
dict.html 2KB
index.html 2KB
patientHealth_edit.html 2KB
notice_edit.html 2KB
login_log.html 2KB
patientHealth_edit.html 2KB
user_chpwd.html 2KB
patientHistory_add.html 2KB
notice_add.html 2KB
patientHealth_add.html 1KB
doctorPoint_edit.html 1KB
menu_add.html 1KB
patientHealth_add.html 1KB
doctorPoint_add.html 1KB
order_edit.html 1KB
medicineInfo_edit.html 1KB
404.html 1KB
order_add.html 1KB
info_edit.html 1KB
medicineInfo_add.html 1KB
patientInfo_edit.html 1KB
info_add.html 1KB
patientInfo_add.html 1KB
blackboard.html 389B
favicon.ico 4KB
UserMgrController.java 14KB
ConstantFactory.java 10KB
Contrast.java 9KB
DictSelectorTag.java 9KB
MenuController.java 8KB
ShiroConfig.java 8KB
ShiroKit.java 8KB
RoleController.java 8KB
WebConfig.java 7KB
共 428 条
- 1
- 2
- 3
- 4
- 5
资源评论
奋斗奋斗再奋斗的ajie
- 粉丝: 230
- 资源: 2166
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功