基于javaweb+mysql的springboot在线心理测评系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot在线心理测评系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
一、项目简述
本系统主要实现的功能有: 在线测评,在线留言,在线文章浏览。,在线公告,后台 评论管理,用户管理,测评管理,分值管理,测评结果查 询等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持) 项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等
/**
* 修改密码
*/
@Controller
public class UpdatePasswordController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private UserService userService;
@RequestMapping("/updatePwdViwe")
public String updatePwd() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/system/pwdUpdate";
}
@ResponseBody
@RequestMapping("/admin/sysPwd/update")
public Map<String, Object> updatePwd(@RequestBody JSONObject json) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = false;
JSONObject data = JSON.parseObject(json.toJSONString());
String oldPassword = data.getString("oldPassword");
String password = data.getString("password");
String repassword = data.getString("repassword");
logger.info("====>" + oldPassword + "--" + password + "--" + repassword);
//这里默认只能修改管理员密码
/**
* 登入控制器
*/
@Controller
public class LoginController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
//注入
@Autowired
private Producer producer;
@Autowired
private UserService userService;
@RequestMapping("/login")
public String loginView() {
return "admin/login";
}
@RequestMapping("/register")
public String register() {
return "admin/register";
}
@ResponseBody
@RequestMapping("/login_do")
public String loginDo(@RequestBody User user, HttpServletRequest request) {
String vrifyCode = (String) request.getSession().getAttribute("vrifyCode");
if (user != null) {
User users = userService.loginByUser(user.getUsername(), user.getPassword());
if (users == null) {
return "passwordError";
} else if (!vrifyCode.equals(user.getVercode())) {
return "vrifyCodeErroe";
}
LoginSession.setUserInSession(users);
request.getSession().setAttribute("loginName", users.getUsername());
return "success";
/**
* 心理测试控制器
*/
@Controller
public class TopicController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private TopicService topicService;
@RequestMapping("/topicView")
public String topicView() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/topic/topicList";
}
/**
* 题目列表显示和高级查询
*
* @param page
* @param limit
* @param keyword1
* @return
*/
@ResponseBody
@RequestMapping("/admin/topic/list")
public ServerLayResult list(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit, String keyword1) {
logger.info("高级查询数据======"+keyword1);
package com.pengzhen.yixinli.controller.admin;
/**
* 修改密码
*/
@Controller
public class UpdatePasswordController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private UserService userService;
@RequestMapping("/updatePwdViwe")
public String updatePwd() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/system/pwdUpdate";
}
@ResponseBody
@RequestMapping("/admin/sysPwd/update")
public Map<String, Object> updatePwd(@RequestBody JSONObject json) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = false;
JSONObject data = JSON.parseObject(json.toJSONString());
* @return
*/
@ResponseBody
@RequestMapping(value = "/admin/topic/update", method = RequestMethod.POST)
public Map<String, Object> update(@RequestBody Topic topic) {
Map<String, Object> dataMap = new HashMap<>();
boolean update = topicService.updateByPrimaryKey(topic);
dataMap.put("status", update);
return dataMap;
}
@ResponseBody
@RequestMapping(value = "/admin/topic/add", method = RequestMethod.POST)
public Map<String, Object> insert(@RequestBody Topic topic) {
Map<String, Object> dataMap = new HashMap<>();
boolean insert = topicService.insert(topic);
dataMap.put("status",insert);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
//开始重置密码,重置密码使用的Spring提供的工具类进行对密码123456进行加密
user.setPassword("123456");
//调用更新方法
int restPwd = userService.updateByPrimaryKey(user);
if (restPwd > 0) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 公告管理
*/
@Controller
public class NoticeController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private NoticeService noticeService;
@RequestMapping("/noticeUi")
public String articleListUi() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/notice/noticeList";
}
@RequestMapping("/noticeUiAdd")
*
* @ClassName CheckLoginInterceptor
* @Description: TODO
* @Viersion V1.0.1
*/
public class CheckLoginInterceptor extends HandlerInterceptorAdapter {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//判断用户是否登入
if (LoginSession.getCurrentUser() == null) {
response.sendRedirect("/login");
System.out.println("CheckLoginInterceptor.preHandle" + "----------------未登入------拦截请求--------------->");
return false;
}
return true;
}
}
package com.pengzhen.yixinli.controller.admin;
@Controller
public class ConsoleController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@RequestMapping("/admin")
public String index() {
logger.info(LoginSession.getCurrentUser().getUsername());
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/index";
}
@RequestMapping("/home/console")
public String console() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
dataMap.put("success", isSuccess);
return dataMap;
}
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 心理测试控制器
*/
@Controller
public class TopicController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private TopicService topicService;
@RequestMapping("/topicView")
public String topicView() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/topic/topicList";
}
pgTest.setPgtestTime(new Date());
//从session中获取
pgTest.setUserOp(LoginSession.getCurrentUser().getUsername());
pgTest.setPgtestScore(count);
logger.info("------------------------------------");
//插入数据库
boolean insert = pgTestService.insert(pgTest);
mapData.put("status", insert);
return mapData;
} else if (count > 70 && count < 90) {
pgTest.setPgtestResult("稍外向性格");
pgTest.setPgtestTime(new Date());
//从session中获取
pgTest.setUserOp(LoginSession.getCurrentUser().getUsername());
pgTest.setPgtestScore(count);
logger.info("==========================================");
//插入数据库
boolean insert = pgTestService.insert(pgTest);
mapData.put("status", insert);
return mapData;
} else if (count > 50 && count < 70) {
pgTest.setPgtestResult("外内混合型性格");
pgTest.setPgtestTime(new Date());
//从session中获取
pgTest.setUserOp("test");
pgTest.setPgtestScore(count);
logger.info("=================");
//插入数据库
boolean insert = pgTestService.insert(pgTest);
mapData.put("status", insert);
return mapData;
} else if (count > 30 && count < 50) {
pgTest.setPgtestResult("典型的内向性格");
pgTest.setPgtestTime(new Date());
//从session中获取
pgTest.setUserOp(LoginSession.getCurrentUser().getUsername());
pgTest.setPgtestScore(count);
logger.info("+++++++++++++++++++++");
//插入数据库
boolean insert = pgTestService.insert(pgTest);
mapData.put("status", insert);
return mapData;
}
mapData.put("status", false);
return mapData;
}
dataMap.put("status", delete);
return dataMap;
}
/**
* 更新
*
* @param topic
* @return
*/
@ResponseBody
@RequestMapping(value = "/admin/topic/update", method = RequestMethod.POST)
public Map<String, Object> update(@RequestBody Topic topic) {
Map<String, Object> dataMap = new HashMap<>();
boolean update = topicService.updateByPrimaryKey(topic);
dataMap.put("status", update);
return dataMap;
}
@ResponseBody
@RequestMapping(value = "/admin/topic/add", method = RequestMethod.POST)
public Map<String, Object> insert(@RequestBody Topic topic) {
Map<String, Object> dataMap = new HashMap<>();
boolean insert = topicService.insert(topic);
dataMap.put("status",insert);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 处理测试记录
System.out.println("***************");
System.out.println("***************");
System.out.println("***************");
System.out.println("***************");
System.out.println("***************");
System.out.println("***************");
System.out.println("***************");
System.out.println("***************" + user);
List<User> users = userService.selectByUsername(user.getUsername(), 1, 1);
if (!users.isEmpty()) {
return "exist";
} else {
user.setUserType("普通用户");
user.setTocheck(0);
userService.insert(user);
return "success";
}
}
/**
* 生成验证码
*
* @param httpServletRequest
* @param httpServletResponse
* @throws Exception
*/
@GetMapping("/defaultKaptcha")
public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
//生产验证码字符串并保存到session中
String createText = producer.createText();
httpServletRequest.getSession().setAttribute("vrifyCode", createText);
//使用生产的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
BufferedImage challenge = producer.createImage(createText);
ImageIO.write(challenge, "jpg", jpegOutputStream);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
@ResponseBody
@RequestMapping("/admin/notice/del")
public Map<String, Object> delNotice(@RequestParam("id") int id) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = noticeService.deleteByPrimaryKey(id);
dataMap.put("success", isSuccess);
return dataMap;
}
/**
* 更新公告
*
* @param notice
* @return
*/
@ResponseBody
@RequestMapping("/admin/notice/save")
public Map<String, Object> saveNotice(@RequestBody Notice notice) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = noticeService.insert(notice);
dataMap.put("success", isSuccess);
return dataMap;
}
@ResponseBody
@RequestMapping("/admin/notice/update")
public Map<String, Object> updateNotice(@RequestBody Notice notice) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = noticeService.updateByPrimaryKey(notice);
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.client;
*
* @param id
* @param model
* @return
*/
@RequestMapping("/noticeClientUi/get")
public String clientNoticeByGet(@RequestParam("id") int id, Model model) {
Notice notice = noticeService.selectByPrimaryKey(id);
model.addAttribute("notice", notice);
int index = 1;
model.addAttribute("index", ++index);
return "client/html/noticeDetails";
}
}
package com.pengzhen.yixinli.common;
/**
* 存放用户登入的Session
*/
public class LoginSession {
public static final String USER_IN_SESSION = "user_in_session";
//获取session对象
private static HttpSession getSession() {
return ((ServletRequestAttributes) (RequestContextHolder.getRequestAttributes())).getRequest().getSession();
}
//设置用户登入的Session
public static void setUserInSession(User contextUser) {
if (contextUser != null) {
//保存session
getSession().setAttribute(USER_IN_SESSION, contextUser);
} else {
//注销session
//回复状态
String status = data.getString("status");
int temp = 0;
if (status != null) {
if (status.equals("on")) {
temp = 1;
}
}
//默认从session获得replyUser
Reply reply = new Reply(id, replyContent, new Date(), "admin");
//更新回复表
boolean updateReply = replyService.updateByPrimaryKey(reply);
Leacot leacot = new Leacot(id, content, new Date(), leacotsUser, reply, temp);
//更新留言表
boolean updateLeacot = leacotService.updateByPrimaryKey(leacot);
if (updateLeacot && updateReply) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
@Controller
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/userUi")
/**
* 用户留言
*/
@Controller
public class ClientLeacotsController {
@Autowired
private LeacotService leacotService;
@Autowired
private ReplyService replyService;
/**
* 留言列表
*
* @param page
* @param limit
* @param model
* @return
*/
@RequestMapping("/leacotsUi")
public String clientArticleUi(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Model model) {
PageHelper.startPage(page, limit);
List<Leacot> leacots = leacotService.selectByList();
PageInfo info = new PageInfo(leacots);
model.addAttribute("leacotsInfo", info);
model.addAttribute("leacots", info.getList());
//共享数据
return "client/html/leacots";
}
/**
* 用户留言
*
* @param data
* @return
*/
@ResponseBody
@RequestMapping(value = "/leacots/save", method = RequestMethod.POST)
public Map<String, Object> saveLeacot(@RequestBody JSONObject data) {
pgTest.setPgtestResult("典型的内向性格");
pgTest.setPgtestTime(new Date());
//从session中获取
pgTest.setUserOp(LoginSession.getCurrentUser().getUsername());
pgTest.setPgtestScore(count);
logger.info("+++++++++++++++++++++");
//插入数据库
boolean insert = pgTestService.insert(pgTest);
mapData.put("status", insert);
return mapData;
}
mapData.put("status", false);
return mapData;
}
}
package com.pengzhen.yixinli.controller.client;
/**
* 用户留言
*/
@Controller
public class ClientLeacotsController {
@Autowired
private LeacotService leacotService;
@Autowired
private ReplyService replyService;
/**
* 留言列表
*
* @param page
* @param limit
//开始重置密码,重置密码使用的Spring提供的工具类进行对密码123456进行加密
user.setPassword("123456");
//调用更新方法
int restPwd = userService.updateByPrimaryKey(user);
if (restPwd > 0) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 公告管理
*/
@Controller
public class NoticeController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
* @param model
* @return
*/
@RequestMapping("/leacotsUi")
public String clientArticleUi(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Model model) {
PageHelper.startPage(page, limit);
List<Leacot> leacots = leacotService.selectByList();
PageInfo info = new PageInfo(leacots);
model.addAttribute("leacotsInfo", info);
model.addAttribute("leacots", info.getList());
//共享数据
return "client/html/leacots";
}
/**
* 用户留言
*
* @param data
* @return
*/
@ResponseBody
@RequestMapping(value = "/leacots/save", method = RequestMethod.POST)
public Map<String, Object> saveLeacot(@RequestBody JSONObject data) {
Map<String, Object> mapData = new HashMap<>();
boolean isSuccess = false;
JSONObject json = JSON.parseObject(data.toJSONString());
//获取用户的留言内容
String desc = json.getString("desc");
//关联id
int indexId = 4;
//生成一条默认的用户评论
Reply reply = new Reply();
reply.setReplyContent("亲,管理员在快马加鞭的回复您!");
reply.setReplyTime(new Date());
reply.setReplyUser("管理员");
reply.setId(indexId);
boolean insertReply = replyService.insert(reply);
if (insertReply) {
Leacot leacot = new Leacot();
//用户留言的内容
leacot.setContent(desc);
//用户留言时间
leacot.setLeacotsTime(new Date());
//默认后台没有回复
leacot.setStatus(0);
//在Session中获取
*/
@ResponseBody
@RequestMapping(value = "/admin/topic/update", method = RequestMethod.POST)
public Map<String, Object> update(@RequestBody Topic topic) {
Map<String, Object> dataMap = new HashMap<>();
boolean update = topicService.updateByPrimaryKey(topic);
dataMap.put("status", update);
return dataMap;
}
@ResponseBody
@RequestMapping(value = "/admin/topic/add", method = RequestMethod.POST)
public Map<String, Object> insert(@RequestBody Topic topic) {
Map<String, Object> dataMap = new HashMap<>();
boolean insert = topicService.insert(topic);
dataMap.put("status",insert);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 处理测试记录
*/
@Controller
public class PgTestController {
@Autowired
private PgTestService pgTestService;
@RequestMapping("/pgtestView")
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 处理测试记录
*/
@Controller
public class PgTestController {
@Autowired
private PgTestService pgTestService;
@RequestMapping("/pgtestView")
public String pgtestView() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/topic/pgtestList";
}
List<User> users = userService.selectByUsername(user.getUsername(), 1, 1);
if (!users.isEmpty()) {
return "exist";
} else {
user.setUserType("普通用户");
user.setTocheck(0);
userService.insert(user);
return "success";
}
}
/**
* 生成验证码
*
* @param httpServletRequest
* @param httpServletResponse
* @throws Exception
*/
@GetMapping("/defaultKaptcha")
public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
//生产验证码字符串并保存到session中
String createText = producer.createText();
httpServletRequest.getSession().setAttribute("vrifyCode", createText);
//使用生产的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
BufferedImage challenge = producer.createImage(createText);
ImageIO.write(challenge, "jpg", jpegOutputStream);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
//定义response输出类型为image/jpeg类型,使用response输出流输出图片的byte数组
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
httpServletResponse.setHeader("Cache-Control", "no-store");
httpServletResponse.setHeader("Pragma", "no-cache");
httpServletResponse.setDateHeader("Expires", 0);
httpServletResponse.setContentType("image/jpeg");
ServletOutputStream responseOutputStream =
httpServletResponse.getOutputStream();
*
* @param notice
* @return
*/
@ResponseBody
@RequestMapping("/admin/notice/save")
public Map<String, Object> saveNotice(@RequestBody Notice notice) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = noticeService.insert(notice);
dataMap.put("success", isSuccess);
return dataMap;
}
@ResponseBody
@RequestMapping("/admin/notice/update")
public Map<String, Object> updateNotice(@RequestBody Notice notice) {
Map<String, Object> dataMap = new HashMap<>();
boolean isSuccess = noticeService.updateByPrimaryKey(notice);
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.client;
String status = json.getString("status");
int temp = 0;
if (status != null) {
if (status.equals("on")) {
temp = 1;
}
}
Label label1 = new Label();
label1.setId(label);
Article articles = new Article();
articles.setAuthor(author);
articles.setContent(content);
articles.setTitle(title);
articles.setStatus(temp);
articles.setCreateTime(new Date());
articles.setLabel(label1);
logger.info(article + "");
boolean isSuccess = articleService.insert(articles);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("success", isSuccess);
return dataMap;
}
/**
* 根据前台响应的json对象封装后通过业务方法保存到数据库
*
* @param article
* @return
*/
@ResponseBody
@RequestMapping("/admin/article/update")
public Map<String, Object> updateArticle(@RequestBody JSONObject article) {
JSONObject json = JSON.parseObject(article.toJSONString());
String author = json.getString("author");
Integer label = json.getInteger("label");
Integer id = json.getInteger("id");
String title = json.getString("title");
String content = json.getString("content");
String status = json.getString("status");
int temp = 0;
if (status != null) {
if (status.equals("on")) {
temp = 1;
}
}
//更新回复表
boolean updateReply = replyService.updateByPrimaryKey(reply);
Leacot leacot = new Leacot(id, content, new Date(), leacotsUser, reply, temp);
//更新留言表
boolean updateLeacot = leacotService.updateByPrimaryKey(leacot);
if (updateLeacot && updateReply) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
@Controller
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/userUi")
public String userUI() {
if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
return "client/html/index";
}
return "admin/user/userList";
}
user.setPassword("123456");
//调用更新方法
int restPwd = userService.updateByPrimaryKey(user);
if (restPwd > 0) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 公告管理
*/
@Controller
public class NoticeController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private NoticeService noticeService;
@RequestMapping("/noticeUi")
logger.info("---->" + byUsername);
if (byUsername != null) {
//校验旧密码是否正确
if (!byUsername.getPassword().equals(oldPassword)) {
dataMap.put("scueess", isSuccess);
return dataMap;
}
//校验两次输入的密码是否匹配
if (!password.equals(repassword)) {
dataMap.put("scueess", isSuccess);
return dataMap;
}
//更新数据库密码
//创建用户对象
User user = new User();
user.setId(byUsername.getId());
user.setUsername(byUsername.getUsername());
user.setPassword(password);
user.setAddress(byUsername.getAddress());
user.setEmail(byUsername.getEmail());
user.setPhone(byUsername.getPhone());
user.setTocheck(byUsername.getTocheck());
user.setUserType(byUsername.getUserType());
user.setName(byUsername.getName());
if (userService.updateByPrimaryKey(user) > 0) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/admin/user/resetPwd")
public Map<String, Object> restPwd(@RequestParam("id") Integer id) {
Map<String, Object> dataMap = new HashMap<>();
Boolean isSuccess = false;
if (id != null && id > 0) {
//根据id查询出用户
User user = userService.selectByPrimaryKey(id);
//开始重置密码,重置密码使用的Spring提供的工具类进行对密码123456进行加密
user.setPassword("123456");
//调用更新方法
int restPwd = userService.updateByPrimaryKey(user);
if (restPwd > 0) {
isSuccess = true;
dataMap.put("success", isSuccess);
return dataMap;
}
}
dataMap.put("success", isSuccess);
return dataMap;
}
}
package com.pengzhen.yixinli.controller.admin;
/**
* 公告管理
*/
@Controller