[编程代码] Java项目:CRM客户关系管理系统(java+Springboot+maven+mysql)

6144 0
黑夜隐士 2021-12-13 08:10:19 | 显示全部楼层 |阅读模式

Springboot项目CRM客户关系管理系统:

系统实现了CRM客户关系系统的基本功能,主要有看板(当月参与的业务机会、当月转化情况、将要结束的业务机会等)、业务机会(初步接触中、需求分析中、协商方案中、商业谈判中的业务机会)、客户管理、联系人管理、个人日报管理、查看团队日报、主数据管理(组织架构管理)、系统管理(用户管理、角色管理、菜单管理)。

角色控制层:

  1. <code>/**
  2. * @author yy
  3. */
  4. @Controller
  5. @RequestMapping("/role")
  6. public class RoleController extends BaseController{
  7. private String prefix = "system/role/";
  8. @Autowired
  9. IUserService iUserService;
  10. @Autowired
  11. IRoleService iRoleService;
  12. @Autowired
  13. IPermissionService iPermissionService;
  14. /**
  15. *
  16. * @描述 页面跳转
  17. *
  18. * @date 2018/9/16 10:59
  19. */
  20. @RequestMapping("/tolist")
  21. @RequiresPermissions("role:list")
  22. public String tolist()
  23. {
  24. return prefix + "role";
  25. }
  26. /**
  27. *
  28. * @描述 ajax请求所有
  29. *
  30. * @date 2018/9/16 10:48
  31. */
  32. @RequestMapping("/ajaxlist")
  33. @ResponseBody
  34. public List<Role> list(Role role)
  35. {
  36. List<Role> roles = iRoleService.selectRoleList(role);
  37. return roles;
  38. }
  39. /**
  40. *
  41. * @描述 列表
  42. *
  43. * @date 2018/9/16 10:52
  44. */
  45. @RequestMapping("/tableList")
  46. @ResponseBody
  47. public TableDataInfo listPag(Role role)
  48. {
  49. //开启分页
  50. startPage();
  51. List<Role> roles = iRoleService.selectRoleList(role);
  52. return getDataTable(roles);
  53. }
  54. /**
  55. *
  56. * @描述 新增页面
  57. *
  58. * @date 2018/9/16 11:37
  59. */
  60. @RequestMapping("/toAdd")
  61. @RequiresPermissions("role:add")
  62. public String toAdd(Model model)
  63. {
  64. return prefix + "add";
  65. }
  66. /**
  67. *
  68. * @描述 批量删除
  69. *
  70. * @date 2018/9/16 11:53
  71. */
  72. @RequestMapping("/del")
  73. @RequiresPermissions("role:del")
  74. @Operlog(modal = "角色管理",descr = "删除角色")
  75. @ResponseBody
  76. public AjaxResult del(Integer[] ids)
  77. {
  78. try
  79. {
  80. iRoleService.deleteByPrimaryKeys(ids);
  81. }
  82. catch (Exception e)
  83. {
  84. return error(e.getMessage());
  85. }
  86. return success();
  87. }
  88. /**
  89. *
  90. * @描述 添加保存
  91. *
  92. * @date 2018/9/16 11:54
  93. */
  94. @RequestMapping("/addSave")
  95. @RequiresPermissions("role:update")
  96. @Operlog(modal = "角色管理",descr = "添加角色")
  97. @ResponseBody
  98. public AjaxResult addRole(Role role, Integer[] ids)
  99. {
  100. role.setCreateTime(new Date());
  101. int insert = 0;
  102. try
  103. {
  104. if (StringUtils.isEmpty(ids))
  105. {
  106. ids = new Integer[0];
  107. }
  108. insert = iRoleService.insert(role, ids);
  109. }
  110. catch (Exception e)
  111. {
  112. return error(e.getMessage());
  113. }
  114. //清空缓存
  115. ShiroUtils.clearCachedAuthorizationInfo();
  116. return result(insert);
  117. }
  118. /**
  119. *
  120. * @描述: 根据ID 获取u他的所有权限 做回显
  121. *
  122. * @params: roleId 角色Id
  123. * @return:
  124. * @date: 2018/9/27 14:04
  125. */
  126. @RequestMapping("/selectById/{roleId}")
  127. @ResponseBody
  128. public Role selectById(@PathVariable("roleId") Integer roleId)
  129. {
  130. Role role = iRoleService.selectByPrimaryKey(roleId);
  131. return role;
  132. }
  133. /**
  134. *
  135. * @描述 编辑修改页面
  136. *
  137. * @date 2018/9/16 14:06
  138. */
  139. @RequestMapping("/edit/{id}")
  140. @RequiresPermissions("role:update")
  141. public String edit(@PathVariable("id") Integer id, Model model)
  142. {
  143. Role role = iRoleService.selectByPrimaryKey(id);
  144. model.addAttribute("Role", role);
  145. return prefix + "edit";
  146. }
  147. /**
  148. *
  149. * @描述 编辑修改权限页面
  150. *
  151. * @date 2018/9/16 14:06
  152. */
  153. @RequestMapping("/editPower/{id}")
  154. @RequiresPermissions("role:update")
  155. public String editPower(@PathVariable("id") Integer id, Model model)
  156. {
  157. Role role = iRoleService.selectByPrimaryKey(id);
  158. model.addAttribute("Role", role);
  159. return prefix + "editPower";
  160. }
  161. /**
  162. *
  163. * @描述 修改角色信息保存
  164. *
  165. * @date 2018/9/16 16:12
  166. */
  167. @RequestMapping("/editSave")
  168. @RequiresPermissions("role:update")
  169. @Operlog(modal = "角色管理",descr = "修改角色信息")
  170. @ResponseBody
  171. public AjaxResult save(Role role)
  172. {
  173. int i = 0;
  174. try
  175. {
  176. i = iRoleService.updateByPrimaryKeySelective(role);
  177. }
  178. catch (Exception e)
  179. {
  180. return error(e.getMessage());
  181. }
  182. return result(i);
  183. }
  184. /**
  185. *
  186. * @描述 修改角色权限信息保存
  187. *
  188. * @date 2018/9/16 16:12
  189. */
  190. @RequestMapping("/editPowerSave")
  191. @RequiresPermissions("role:update")
  192. @Operlog(modal = "角色管理",descr = "修改角色权限")
  193. @ResponseBody
  194. public AjaxResult editPowerSave(Role role, Integer[] ids)
  195. {
  196. int i = 0;
  197. try
  198. {
  199. if (StringUtils.isEmpty(ids))
  200. {
  201. ids = new Integer[0];
  202. }
  203. i = iRoleService.updateByPrimaryKeyPowerSelective(role, ids);
  204. }
  205. catch (Exception e)
  206. {
  207. return error(e.getMessage());
  208. }
  209. //清空缓存
  210. ShiroUtils.clearCachedAuthorizationInfo();
  211. //如果用户正在修改的角色id 是当前用户的角色id 则刷新 subject的User信息
  212. if (role.getRoleId().equals(getRoleId()))
  213. {
  214. ShiroUtils.reloadUser(iUserService.selectByPrimaryKey(getUserId()));
  215. }
  216. return result(i);
  217. }
  218. /**
  219. * 校验名称唯一
  220. */
  221. @PostMapping("/checkRoleNameUnique")
  222. @ResponseBody
  223. public String checkDeptNameUnique(Role role)
  224. {
  225. String uniqueFlag = "0";
  226. if (role != null)
  227. {
  228. uniqueFlag = iRoleService.checkRoleNameUnique(role);
  229. }
  230. return uniqueFlag;
  231. }
  232. }
复制代码

登录控制层:

  1. <code>@RequestMapping("/login")
  2. public class LoginController extends BaseController{
  3. private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
  4. private String prefix = "system/user/";
  5. @Autowired
  6. LoginService loginService;
  7. @Autowired
  8. IUserService userService;
  9. /**
  10. *
  11. * @描述: 执行登录操作
  12. *
  13. * @params: user:用户登录信息;
  14. * validateCode:验证码
  15. * @return:
  16. * @date: 2018/9/29 21:20
  17. */
  18. @RequestMapping("/login")
  19. @Operlog(descr = "用户登录", modal = "登录模块")
  20. @ResponseBody
  21. public AjaxResult Logining(User user, String validateCode, Boolean rememberMe, HttpServletRequest request)
  22. {
  23. HttpSession session = ServletUtils.getSession();
  24. UsernamePasswordToken token = new UernamePasswordToken(user.getName(), user.getPwd());
  25. token.setRememberMe(rememberMe);
  26. Subject subject = SecurityUtils.getSubject();
  27. //验证用户名和密码 验证码的问题
  28. try
  29. {
  30. loginService.checkLogin(user.getName(), user.getPwd(), validateCode);
  31. }
  32. catch (Exception e)
  33. {
  34. session.setAttribute(Constants.LOGIN_ERROR, e.getMessage());
  35. return error(e.getMessage());
  36. }
  37. try
  38. {
  39. if (!subject.isAuthenticated())
  40. {
  41. subject.login(token);
  42. }
  43. }
  44. catch (IncorrectCredentialsException e)
  45. {
  46. session.setAttribute(Constants.LOGIN_ERROR,"密码错误");
  47. return error("密码错误!");
  48. }
  49. catch (UnknownAccountException e)
  50. {
  51. session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());
  52. return error(e.getMessage());
  53. }
  54. catch (LockedAccountException e)
  55. {
  56. session.setAttribute("login",e.getMessage());
  57. return error(e.getMessage());
  58. }
  59. catch (AuthenticationException e)
  60. {
  61. // String msg = "用户名或密码错误!";
  62. // if (!StringUtils.isEmpty(e.getMessage()))
  63. // {
  64. // msg = e.getMessage();
  65. // }
  66. session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());
  67. return error("系统异常!");
  68. }
  69. return success();
  70. }
  71. /**
  72. s sl
  73. *
  74. * @描述: 登录页面
  75. *
  76. * @params:
  77. * @return:
  78. * @date: 2018/9/29 21:20
  79. */
  80. @RequestMapping("/toLogin")
  81. public String toLogin()
  82. {
  83. return "login";
  84. }
  85. }
复制代码

部门控制层:

  1. <code>
  2. /**
  3. * @author yy
  4. */
  5. @Controller
  6. @RequestMapping("/dept")
  7. public class DeptController extends BaseController{
  8. private String prefix = "system/dept/";
  9. @Autowired
  10. IDeptService iDeptService;
  11. @Autowired
  12. IUserService iUserService;
  13. /**
  14. *
  15. * @描述 页面跳转到部门
  16. *
  17. * @date 2018/9/16 10:59
  18. */
  19. @RequestMapping("/tolist")
  20. @RequiresPermissions("dept:list")
  21. public String tolist()
  22. {
  23. return prefix + "dept";
  24. }
  25. /**
  26. *
  27. * @描述 ajax请求的所有部门
  28. *
  29. * @date 2018/9/16 10:48
  30. */
  31. @RequestMapping("/ajaxlist")
  32. @ResponseBody
  33. public List<Dept> list(Dept dept)
  34. {
  35. List<Dept> depts = iDeptService.selectDeptList(dept);
  36. return depts;
  37. }
  38. /**
  39. *
  40. * @描述 部门列表页
  41. *
  42. * @date 2018/9/16 10:52
  43. */
  44. @RequestMapping("/tableList")
  45. @ResponseBody
  46. public TableDataInfo listPag(Dept dept)
  47. {
  48. //开启分页
  49. startPage();
  50. List<Dept> depts = iDeptService.selectDeptList(dept);
  51. return getDataTable(depts);
  52. }
  53. /**
  54. *
  55. * @描述 新增页面
  56. *
  57. * @date 2018/9/16 11:37
  58. */
  59. @RequiresPermissions("dept:add")
  60. @RequestMapping("/toAdd")
  61. public String toAdd(Model model)
  62. {
  63. List<User> users = iUserService.selectByUser(new User());
  64. model.addAttribute("users", users);
  65. return prefix + "add";
  66. }
  67. /**
  68. *
  69. * @描述: 查询所有部门下的所有用户 用户归类 树状数据
  70. *
  71. * @date: 2018/9/27 11:25
  72. */
  73. @RequestMapping("/getDeptAndUserTreeData")
  74. @ResponseBody
  75. public List<Object> DeptAndUserTreeData()
  76. {
  77. List<Dept> depts = iDeptService.selectDeptAndUser();
  78. List<User> users=new ArrayList<>();
  79. LinkedList<Object> deptList = new LinkedList<>();
  80. for (Dept dept : depts)
  81. {
  82. Map<String, Object> deptMap = new HashMap();
  83. deptMap.put("name", dept.getDeptName());
  84. deptMap.put("id", null);
  85. users = dept.getUsers();
  86. LinkedList<Object> userlist = new LinkedList<>();
  87. for (User user : users)
  88. {
  89. Map<String, Object> userMap = new HashMap();
  90. userMap.put("name",user.getName());
  91. userMap.put("id",user.getUid());
  92. userMap.put("icon","/img/timg.jpg");
  93. userlist.add(userMap);
  94. }
  95. deptMap.put("children",userlist);
  96. deptList.add(deptMap);
  97. }
  98. return deptList;
  99. }
  100. /**
  101. *
  102. * @描述 批量删除
  103. *
  104. * @date 2018/9/16 11:53
  105. */
  106. @RequestMapping("/del")
  107. @RequiresPermissions("dept:del")
  108. @ResponseBody
  109. @Operlog(modal = "部门管理",descr = "删除部门")
  110. public AjaxResult del(String[] ids)
  111. {
  112. try
  113. {
  114. iDeptService.deleteByPrimaryKeys(ids);
  115. }
  116. catch (Exception e)
  117. {
  118. return error(e.getMessage());
  119. }
  120. return success();
  121. }
  122. /**
  123. *
  124. * @描述 执行保存操作
  125. *
  126. * @date 2018/9/16 11:54
  127. */
  128. @RequestMapping("/addSave")
  129. @Operlog(modal = "部门管理",descr = "添加部门")
  130. @RequiresPermissions("dept:add")
  131. @ResponseBody
  132. public AjaxResult addDept(Dept dept)
  133. {
  134. dept.setCreateTime(new Date());
  135. return result(iDeptService.insertSelective(dept));
  136. }
  137. /**
  138. *
  139. * @描述 编辑修改页面
  140. *
  141. * @date 2018/9/16 14:06
  142. */
  143. @RequestMapping("/edit/{id}")
  144. @RequiresPermissions("dept:update")
  145. public String edit(@PathVariable("id") String id, Model model)
  146. {
  147. Dept dept = iDeptService.selectByPrimaryKey(id);
  148. List<User> users = iUserService.selectByUser(new User());
  149. model.addAttribute("users", users);
  150. model.addAttribute("Dept", dept);
  151. return prefix + "edit";
  152. }
  153. /**
  154. *
  155. * @描述 修改保存
  156. *
  157. * @date 2018/9/16 16:12
  158. */
  159. @RequestMapping("/editSave")
  160. @RequiresPermissions("dept:update")
  161. @Operlog(modal = "部门管理",descr = "修改信息")
  162. @ResponseBody
  163. public AjaxResult save(Dept dept)
  164. {
  165. int i = 0;
  166. try
  167. {
  168. i = iDeptService.updateByPrimaryKeySelective(dept);
  169. }
  170. catch (Exception e)
  171. {
  172. return error(e.getMessage());
  173. }
  174. return result(i);
  175. }
  176. /**
  177. * 校验部门名称
  178. */
  179. @PostMapping("/checkDeptNameUnique")
  180. @ResponseBody
  181. public String checkDeptNameUnique(Dept dept)
  182. {
  183. String uniqueFlag = "0";
  184. if (dept != null)
  185. {
  186. uniqueFlag = iDeptService.checkDeptNameUnique(dept);
  187. }
  188. return uniqueFlag;
  189. }
  190. }
复制代码

来源:https://blog.csdn.net/m0_59687645/article/details/121874913
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行