Java项目:CRM客户关系管理系统(java+Springboot+maven+mysql)
Posted qq_1334611189
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java项目:CRM客户关系管理系统(java+Springboot+maven+mysql)相关的知识,希望对你有一定的参考价值。
Springboot项目CRM客户关系管理系统:
系统实现了CRM客户关系系统的基本功能,主要有看板(当月参与的业务机会、当月转化情况、将要结束的业务机会等)、业务机会(初步接触中、需求分析中、协商方案中、商业谈判中的业务机会)、客户管理、联系人管理、个人日报管理、查看团队日报、主数据管理(组织架构管理)、系统管理(用户管理、角色管理、菜单管理)。
角色控制层:
/**
* @author yy
*/
@Controller
@RequestMapping("/role")
public class RoleController extends BaseController
private String prefix = "system/role/";
@Autowired
IUserService iUserService;
@Autowired
IRoleService iRoleService;
@Autowired
IPermissionService iPermissionService;
/**
*
* @描述 页面跳转
*
* @date 2018/9/16 10:59
*/
@RequestMapping("/tolist")
@RequiresPermissions("role:list")
public String tolist()
return prefix + "role";
/**
*
* @描述 ajax请求所有
*
* @date 2018/9/16 10:48
*/
@RequestMapping("/ajaxlist")
@ResponseBody
public List<Role> list(Role role)
List<Role> roles = iRoleService.selectRoleList(role);
return roles;
/**
*
* @描述 列表
*
* @date 2018/9/16 10:52
*/
@RequestMapping("/tableList")
@ResponseBody
public TableDataInfo listPag(Role role)
//开启分页
startPage();
List<Role> roles = iRoleService.selectRoleList(role);
return getDataTable(roles);
/**
*
* @描述 新增页面
*
* @date 2018/9/16 11:37
*/
@RequestMapping("/toAdd")
@RequiresPermissions("role:add")
public String toAdd(Model model)
return prefix + "add";
/**
*
* @描述 批量删除
*
* @date 2018/9/16 11:53
*/
@RequestMapping("/del")
@RequiresPermissions("role:del")
@Operlog(modal = "角色管理",descr = "删除角色")
@ResponseBody
public AjaxResult del(Integer[] ids)
try
iRoleService.deleteByPrimaryKeys(ids);
catch (Exception e)
return error(e.getMessage());
return success();
/**
*
* @描述 添加保存
*
* @date 2018/9/16 11:54
*/
@RequestMapping("/addSave")
@RequiresPermissions("role:update")
@Operlog(modal = "角色管理",descr = "添加角色")
@ResponseBody
public AjaxResult addRole(Role role, Integer[] ids)
role.setCreateTime(new Date());
int insert = 0;
try
if (StringUtils.isEmpty(ids))
ids = new Integer[0];
insert = iRoleService.insert(role, ids);
catch (Exception e)
return error(e.getMessage());
//清空缓存
ShiroUtils.clearCachedAuthorizationInfo();
return result(insert);
/**
*
* @描述: 根据ID 获取u他的所有权限 做回显
*
* @params: roleId 角色Id
* @return:
* @date: 2018/9/27 14:04
*/
@RequestMapping("/selectById/roleId")
@ResponseBody
public Role selectById(@PathVariable("roleId") Integer roleId)
Role role = iRoleService.selectByPrimaryKey(roleId);
return role;
/**
*
* @描述 编辑修改页面
*
* @date 2018/9/16 14:06
*/
@RequestMapping("/edit/id")
@RequiresPermissions("role:update")
public String edit(@PathVariable("id") Integer id, Model model)
Role role = iRoleService.selectByPrimaryKey(id);
model.addAttribute("Role", role);
return prefix + "edit";
/**
*
* @描述 编辑修改权限页面
*
* @date 2018/9/16 14:06
*/
@RequestMapping("/editPower/id")
@RequiresPermissions("role:update")
public String editPower(@PathVariable("id") Integer id, Model model)
Role role = iRoleService.selectByPrimaryKey(id);
model.addAttribute("Role", role);
return prefix + "editPower";
/**
*
* @描述 修改角色信息保存
*
* @date 2018/9/16 16:12
*/
@RequestMapping("/editSave")
@RequiresPermissions("role:update")
@Operlog(modal = "角色管理",descr = "修改角色信息")
@ResponseBody
public AjaxResult save(Role role)
int i = 0;
try
i = iRoleService.updateByPrimaryKeySelective(role);
catch (Exception e)
return error(e.getMessage());
return result(i);
/**
*
* @描述 修改角色权限信息保存
*
* @date 2018/9/16 16:12
*/
@RequestMapping("/editPowerSave")
@RequiresPermissions("role:update")
@Operlog(modal = "角色管理",descr = "修改角色权限")
@ResponseBody
public AjaxResult editPowerSave(Role role, Integer[] ids)
int i = 0;
try
if (StringUtils.isEmpty(ids))
ids = new Integer[0];
i = iRoleService.updateByPrimaryKeyPowerSelective(role, ids);
catch (Exception e)
return error(e.getMessage());
//清空缓存
ShiroUtils.clearCachedAuthorizationInfo();
//如果用户正在修改的角色id 是当前用户的角色id 则刷新 subject的User信息
if (role.getRoleId().equals(getRoleId()))
ShiroUtils.reloadUser(iUserService.selectByPrimaryKey(getUserId()));
return result(i);
/**
* 校验名称唯一
*/
@PostMapping("/checkRoleNameUnique")
@ResponseBody
public String checkDeptNameUnique(Role role)
String uniqueFlag = "0";
if (role != null)
uniqueFlag = iRoleService.checkRoleNameUnique(role);
return uniqueFlag;
登录控制层:
@RequestMapping("/login")
public class LoginController extends BaseController
private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
private String prefix = "system/user/";
@Autowired
LoginService loginService;
@Autowired
IUserService userService;
/**
*
* @描述: 执行登录操作
*
* @params: user:用户登录信息;
* validateCode:验证码
* @return:
* @date: 2018/9/29 21:20
*/
@RequestMapping("/login")
@Operlog(descr = "用户登录", modal = "登录模块")
@ResponseBody
public AjaxResult Logining(User user, String validateCode, Boolean rememberMe, HttpServletRequest request)
HttpSession session = ServletUtils.getSession();
UsernamePasswordToken token = new UsernamePasswordToken(user.getName(), user.getPwd());
token.setRememberMe(rememberMe);
Subject subject = SecurityUtils.getSubject();
//验证用户名和密码 验证码的问题
try
loginService.checkLogin(user.getName(), user.getPwd(), validateCode);
catch (Exception e)
session.setAttribute(Constants.LOGIN_ERROR, e.getMessage());
return error(e.getMessage());
try
if (!subject.isAuthenticated())
subject.login(token);
catch (IncorrectCredentialsException e)
session.setAttribute(Constants.LOGIN_ERROR,"密码错误");
return error("密码错误!");
catch (UnknownAccountException e)
session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());
return error(e.getMessage());
catch (LockedAccountException e)
session.setAttribute("login",e.getMessage());
return error(e.getMessage());
catch (AuthenticationException e)
// String msg = "用户名或密码错误!";
// if (!StringUtils.isEmpty(e.getMessage()))
//
// msg = e.getMessage();
//
session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());
return error("系统异常!");
return success();
/**
s sl
*
* @描述: 登录页面
*
* @params:
* @return:
* @date: 2018/9/29 21:20
*/
@RequestMapping("/toLogin")
public String toLogin()
return "login";
部门控制层:
/**
* @author yy
*/
@Controller
@RequestMapping("/dept")
public class DeptController extends BaseController
private String prefix = "system/dept/";
@Autowired
IDeptService iDeptService;
@Autowired
IUserService iUserService;
/**
*
* @描述 页面跳转到部门
*
* @date 2018/9/16 10:59
*/
@RequestMapping("/tolist")
@RequiresPermissions("dept:list")
public String tolist()
return prefix + "dept";
/**
*
* @描述 ajax请求的所有部门
*
* @date 2018/9/16 10:48
*/
@RequestMapping("/ajaxlist")
@ResponseBody
public List<Dept> list(Dept dept)
List<Dept> depts = iDeptService.selectDeptList(dept);
return depts;
/**
*
* @描述 部门列表页
*
* @date 2018/9/16 10:52
*/
@RequestMapping("/tableList")
@ResponseBody
public TableDataInfo listPag(Dept dept)
//开启分页
startPage();
List<Dept> depts = iDeptService.selectDeptList(dept);
return getDataTable(depts);
/**
*
* @描述 新增页面
*
* @date 2018/9/16 11:37
*/
@RequiresPermissions("dept:add")
@RequestMapping("/toAdd")
public String toAdd(Model model)
List<User> users = iUserService.selectByUser(new User());
model.addAttribute("users", users);
return prefix + "add";
/**
*
* @描述: 查询所有部门下的所有用户 用户归类 树状数据
*
* @date: 2018/9/27 11:25
*/
@RequestMapping("/getDeptAndUserTreeData")
@ResponseBody
public List<Object> DeptAndUserTreeData()
List<Dept> depts = iDeptService.selectDeptAndUser();
List<User> users=new ArrayList<>();
LinkedList<Object> deptList = new LinkedList<>();
for (Dept dept : depts)
Map<String, Object> deptMap = new HashMap();
deptMap.put("name", dept.getDeptName());
deptMap.put("id", null);
users = dept.getUsers();
LinkedList<Object> userlist = new LinkedList<>();
for (User user : users)
Map<String, Object> userMap = new HashMap();
userMap.put("name",user.getName());
userMap.put("id",user.getUid());
userMap.put("icon","/img/timg.jpg");
userlist.add(userMap);
deptMap.put("children",userlist);
deptList.add(deptMap);
return deptList;
/**
*
* @描述 批量删除
*
* @date 2018/9/16 11:53
*/
@RequestMapping("/del")
@RequiresPermissions("dept:del")
@ResponseBody
@Operlog(modal = "部门管理",descr = "删除部门")
public AjaxResult del(String[] ids)
try
iDeptService.deleteByPrimaryKeys(ids);
catch (Exception e)
return error(e.getMessage());
return success();
/**
*
* @描述 执行保存操作
*
* @date 2018/9/16 11:54
*/
@RequestMapping("/addSave")
@Operlog(modal = "部门管理",descr = "添加部门")
@RequiresPermissions("dept:add")
@ResponseBody
public AjaxResult addDept(Dept dept)
dept.setCreateTime(new Date());
return result(iDeptService.insertSelective(dept));
/**
*
* @描述 编辑修改页面
*
* @date 2018/9/16 14:06
*/
@RequestMapping("/edit/id")
@RequiresPermissions("dept:update")
public String edit(@PathVariable("id") String id, Model model)
Dept dept = iDeptService.selectByPrimaryKey(id);
List<User> users = iUserService.selectByUser(new User());
model.addAttribute("users", users);
model.addAttribute("Dept", dept);
return prefix + "edit";
/**
*
* @描述 修改保存
*
* @date 2018/9/16 16:12
*/
@RequestMapping("/editSave")
@RequiresPermissions("dept:update")
@Operlog(modal = "部门管理",descr = "修改信息")
@ResponseBody
public AjaxResult save(Dept dept)
int i = 0;
try
i = iDeptService.updateByPrimaryKeySelective(dept);
catch (Exception e)
return error(e.getMessage());
return result(i);
/**
* 校验部门名称
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
public String checkDeptNameUnique(Dept dept)
String uniqueFlag = "0";
if (dept != null)
uniqueFlag = iDeptService.checkDeptNameUnique(dept);
return uniqueFlag;
以上是关于Java项目:CRM客户关系管理系统(java+Springboot+maven+mysql)的主要内容,如果未能解决你的问题,请参考以下文章