当前位置:   article > 正文

springboot(ssm电力员工安全施工培训管理系统Java(code&LW)_电力安全管理源代码查询输入什么

电力安全管理源代码查询输入什么

springboot(ssm电力员工安全施工培训管理系统Java(code&LW)

开发语言:Java

框架:ssm/springboot + vue

JDK版本:JDK1.8(或11)

服务器:tomcat

数据库:mysql 5.7(或8.0)

数据库工具:Navicat

开发软件:eclipse//idea

依赖管理包:Maven

您是否想要一个与众不同的网站?我这提供精美的基于springboot(ssm)+vue框架的网站源码,涵盖多个领域,采用轻量级数据库mysql,适用于个人学习等。

另外,如需了解更多代码细节或修改代码功能界面,本人都能提供技术支持。(声音嘎嘎好听喔!)

祝你早日找到合适的代码哦~

  1. package com.controller;
  2. import java.util.Arrays;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5. import java.util.Map;
  6. import javax.servlet.http.HttpServletRequest;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PathVariable;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.annotation.IgnoreAuth;
  18. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  19. import com.entity.TokenEntity;
  20. import com.entity.UserEntity;
  21. import com.service.TokenService;
  22. import com.service.UserService;
  23. import com.utils.CommonUtil;
  24. import com.utils.MPUtil;
  25. import com.utils.PageUtils;
  26. import com.utils.R;
  27. import com.utils.ValidatorUtils;
  28. /**
  29. * 登录相关
  30. */
  31. @RequestMapping("users")
  32. @RestController
  33. public class UserController{
  34. @Autowired
  35. private UserService userService;
  36. @Autowired
  37. private TokenService tokenService;
  38. /**
  39. * 登录
  40. */
  41. @IgnoreAuth
  42. @PostMapping(value = "/login")
  43. public R login(String username, String password, String captcha, HttpServletRequest request) {
  44. UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
  45. if(user==null || !user.getPassword().equals(password)) {
  46. return R.error("账号或密码不正确");
  47. }
  48. String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
  49. return R.ok().put("token", token);
  50. }
  51. /**
  52. * 注册
  53. */
  54. @IgnoreAuth
  55. @PostMapping(value = "/register")
  56. public R register(@RequestBody UserEntity user){
  57. // ValidatorUtils.validateEntity(user);
  58. if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
  59. return R.error("用户已存在");
  60. }
  61. userService.insert(user);
  62. return R.ok();
  63. }
  64. /**
  65. * 退出
  66. */
  67. @GetMapping(value = "logout")
  68. public R logout(HttpServletRequest request) {
  69. request.getSession().invalidate();
  70. return R.ok("退出成功");
  71. }
  72. /**
  73. * 密码重置
  74. */
  75. @IgnoreAuth
  76. @RequestMapping(value = "/resetPass")
  77. public R resetPass(String username, HttpServletRequest request){
  78. UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
  79. if(user==null) {
  80. return R.error("账号不存在");
  81. }
  82. user.setPassword("123456");
  83. userService.update(user,null);
  84. return R.ok("密码已重置为:123456");
  85. }
  86. /**
  87. * 列表
  88. */
  89. @RequestMapping("/page")
  90. public R page(@RequestParam Map<String, Object> params,UserEntity user){
  91. EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
  92. PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
  93. return R.ok().put("data", page);
  94. }
  95. /**
  96. * 列表
  97. */
  98. @RequestMapping("/list")
  99. public R list( UserEntity user){
  100. EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
  101. ew.allEq(MPUtil.allEQMapPre( user, "user"));
  102. return R.ok().put("data", userService.selectListView(ew));
  103. }
  104. /**
  105. * 信息
  106. */
  107. @RequestMapping("/info/{id}")
  108. public R info(@PathVariable("id") String id){
  109. UserEntity user = userService.selectById(id);
  110. return R.ok().put("data", user);
  111. }
  112. /**
  113. * 获取用户的session用户信息
  114. */
  115. @RequestMapping("/session")
  116. public R getCurrUser(HttpServletRequest request){
  117. Long id = (Long)request.getSession().getAttribute("userId");
  118. UserEntity user = userService.selectById(id);
  119. return R.ok().put("data", user);
  120. }
  121. /**
  122. * 保存
  123. */
  124. @PostMapping("/save")
  125. public R save(@RequestBody UserEntity user){
  126. // ValidatorUtils.validateEntity(user);
  127. if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
  128. return R.error("用户已存在");
  129. }
  130. userService.insert(user);
  131. return R.ok();
  132. }
  133. /**
  134. * 修改
  135. */
  136. @RequestMapping("/update")
  137. public R update(@RequestBody UserEntity user){
  138. // ValidatorUtils.validateEntity(user);
  139. UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername()));
  140. if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
  141. return R.error("用户名已存在。");
  142. }
  143. userService.updateById(user);//全部更新
  144. return R.ok();
  145. }
  146. /**
  147. * 删除
  148. */
  149. @RequestMapping("/delete")
  150. public R delete(@RequestBody Long[] ids){
  151. userService.deleteBatchIds(Arrays.asList(ids));
  152. return R.ok();
  153. }
  154. }

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号