基于javaweb+mysql的ssm+mavencrm客户管理系统(java+ssm+jsp+mysql+maven+redis)

基于javaweb+mysql的ssm+mavencrm客户管理系统(java+ssm+jsp+mysql+maven+redis)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SSM+Mavencrm客户管理系统(java+ssm+jsp+mysql+maven+redis)

一、项目简述

功能包括: 用户管理,系统管理,客户管理,客户服务,客户关怀, 销售机会,统计管理等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven+redis等等。

                updateUser.setLastLoginTime(now);
                userService.edit(updateUser);
                
                request.getSession().setAttribute("user", loginUser);
                logger.info("登陆的用户信息:" + loginUser.toString());

                request.getSession().setAttribute("user", loginUser);
                maps.put("code", 0); 
              //账号被锁定
            } catch(LockedAccountException e){
                maps.put("code",200);
                maps.put("msg","账号已被锁定,请联系管理员进行处理!");
              //不存在的账号
            } catch(UnknownAccountException e) {
                maps.put("code",200);
                maps.put("msg","账号或密码错误!");
              //密码错误
            } catch(IncorrectCredentialsException e) {
                maps.put("code",200);
                maps.put("msg","账号或密码错误!");
            }catch (Exception e) {
                e.printStackTrace();
                maps.put("code", 200);
                maps.put("msg", "系统出了小差,请稍等...");
            }
        }else {
        	maps.put("code", 0);
        }
        return maps;
    }
    
    /**
     * 
     * 描述:
     * @version 1.0
     * @param request request请求
     * @return ModelAndView
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="注销")
    @RequestMapping("/logout")
    public ModelAndView logout(HttpServletRequest request) {
        ModelAndView view = new ModelAndView();
        //获取shiro中的用户
        Subject subject = SecurityUtils.getSubject();
        //获取用户账号信息
        String account = (String) subject.getPrincipal();
        if(account != null) {
            //登出
            subject.logout();
    @ResponseBody
    public Map<String, Object> addDictionaryType(DictionaryType dictionaryType){
        
        Map<String, Object> map = new HashMap<String,Object>(16);
        if(dictionaryTypeService.insertDictionaryTypeSelective(dictionaryType)) {
            map.put("success", true);
            map.put("msg", "添加成功");
        }else {
            map.put("success", false);
            map.put("msg", "添加失败");
        }
        
        return map;
    }
    
    /**
     */
    @RequiresPermissions("20003")
    @Operation(name="更新数据字典")
    @RequestMapping("admin/update")
    @ResponseBody
    public Map<String, Object> updateDictionaryType(DictionaryType dictionaryType){

        
        Map<String, Object> map = new HashMap<String,Object>(16);
        if(dictionaryTypeService.updateDictionaryTypeByPrimaryKeySelective(dictionaryType)) {
            map.put("success", true);
            map.put("msg", "更新成功");
        }else {
            map.put("success", false);
            map.put("msg", "更新失败");
        }
        
        return map;
    }
    
    /**
     */
    @RequiresPermissions("20004")
    @Operation(name="删除数据字典")
    @RequestMapping("admin/delete")
    @ResponseBody
            for (CustomerCare customerCare : customerCares) {
                //更新客户关怀的所属客户经理
                customerCare.setManagerId(transfer.getNewManagerId());
                customerCareService.updateCustomerCareByPrimaryKeySelective(customerCare);
            }

        } catch (Exception e) {
            
            e.printStackTrace();
            map.put("code", -1000);
            map.put("status", false);
            map.put("msg", "操作失败");
            return map;
        }
        
        map.put("code", 0);
        map.put("status", true);
        map.put("msg", "操作成功");
        return map;
    }
    
}

     * 
     * 描述:编辑用户
     * @version 1.0
     * @param user 要编辑的用户信息
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="修改用户")
    @RequiresPermissions(value={"1002","13002"}, logical=Logical.OR)
    @RequestMapping("/editUser")
    @ResponseBody
    public Map<String, Object> editUser(User user){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        String msg = "";
        //修改成功
        if(userService.edit(user) == true) {
            success = true;
            msg = "修改成功!";
        }else {
            msg = "修改失败!";
        }
        map.put("success", success);
        map.put("msg", msg);
        map.put("code", 0);
        return map;
    }
    
    /**
     * 
     * 描述:添加用户
     * @version 1.0
     * @param user 要添加的用户信息
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="添加用户")
    @RequiresPermissions("1003")
    @RequestMapping("/addUser")
    @ResponseBody
    public Map<String, Object> addUser(User user){
        Map<String, Object> map = new HashMap<String, Object>(16);
    @ResponseBody
    public Map<String, Object> editUserPasswd(User user,String oldPassword){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        String msg = "";
        if(userService.editPasswd(user,oldPassword)) {
            success = true;
            msg = "修改成功!";
        }else {
            success = false;
            msg = "修改失败!";
        }
        map.put("success", success);
        map.put("msg", msg);
        map.put("code", 0);
        return map;
    }
    
    /**
     * 
     * 描述:获取忘记密码时的验证码
     * @version 1.0
     * @param email
     * @return 
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="获取找回密码所需的验证码")
    @RequestMapping("/getForgotPasswdCode")
    @ResponseBody
    public Map<String, Object> getForgotPasswdCode(String email){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        String msg = "";
        if(userService.findByEmail(email) == null){
            //找不到该邮箱的账号
            msg = "不存在的账号!";
        }else{
            try {
                //生成长度为4的随机数字
                String code = RandomStringUtil.getRandomCode(4, 0);
                //存到redis缓存中,有效时间为5分钟
                //先删除原来已存在的验证码
                redisUtil.remove(email);
                redisUtil.set(email, code, 300L);
                //发送邮件
                mailUtil.send(email, "找回密码", "验证码:" + code + "(验证码有效期为5分钟)");
                success = true;
                msg = "发送验证码成功!";
                Integer id = Integer.parseInt(idString);
                SaleOpportunity saleOpportunity = new SaleOpportunity();
                saleOpportunity.setId(id);
                saleOpportunity.setDeleteStatus(1);
                //如果删除失败,则直接抛出异常
                if(saleOpportunityMapper.updateByPrimaryKeySelective(saleOpportunity) < 1){
                	return false;
                	}
            	}
        return true;
	}

}

/**
 * 权限管理
 *
 */
@Operation(name="权限管理")
@Controller
@RequestMapping("/permiss")
public class PermissionController {

	@Autowired
	private IPermissionService permissionService;
        //确保子项状态非锁定
        item.setStatus(1);
        
        if(dictionaryItemService.updateDictionaryItemByPrimaryKeySelective(item)) {
            map.put("success", true);
            map.put("msg", "更新成功");
        }else {
            map.put("success", false);
            map.put("msg", "更新失败");
        }
        return map;
    }
    
    
    /**
     * 描述:删除非锁定子项
     */
    @RequiresPermissions("20009")
    @Operation(name="数据字典子项删除")
    @RequestMapping("delete")
    @ResponseBody
    public Map<String, Object> deleteDictionaryItem(int[] ids){
        
        Map<String, Object> map = new HashMap<String,Object>(16);
        List<Integer> success = new ArrayList<Integer>();
        List<Integer> fail = new ArrayList<Integer>();
        DictionaryItem dictionaryItem = null;
        
        if(ids == null) {
            map.put("msg", "参数为空,删除失败");
            map.put("status", false);
            return map;
        }
        for(int id : ids) {
            dictionaryItem = dictionaryItemService.selectDictionaryItemByPrimaryKey(id);
            if(dictionaryItem == null || dictionaryItem.getStatus() == 0) {
                fail.add(id);
                continue;
            }
            if(dictionaryItemService.deleteByPrimaryKey(id)) {
                success.add(id);
    @RequiresPermissions("1003")
    @RequestMapping("/addUser")
    @ResponseBody
    public Map<String, Object> addUser(User user){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        
        //设置user的初始密码为123456
        user.setPassword("123456");
        
        //添加
        if(userService.save(user) == true) {
            success = true;
        }
        map.put("success", success);
        map.put("code", 0);
        return map;
    }
    
    /**
     * 
     * 描述:查找所有的角色
     * @version 1.0
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="后台查找角色列表")
    @RequiresAuthentication
    @RequestMapping("/findRoles")
    @ResponseBody
    public Map<String, Object> findRoles(){
        Map<String, Object> map = new HashMap<String, Object>(16);
        List<Role> roles = roleService.selectByRoleExample(new RoleExample());
        map.put("success", true);
        map.put("list", roles);
        logger.info(roles.toString());
        return map;
    }
    

/**
 *
 */
@Operation(name="销售机会管理")
@RequestMapping("/opportunity")
@Controller
public class SaleOpportunityController {

	private Logger logger = LoggerFactory.getLogger(SaleOpportunityController.class);
	
	@Autowired
	private ISaleOpportunityService saleOpportunityService;
	@Autowired
	private ICustomerService customerService;
	@Autowired
	private ILinkmanService linkmanService;
	
	/**
	 * 查看销售机会
	 * @param page
	 * @param limit
	 * @param saleOpportunity
        }
        if(limit == null || limit <= 0) {
            limit = 5;
        }
        
        //如果不是查询全部数据,就设置分页属性
        String all = "all";
        if(!all.equals(type)) {
            example.setLimit(limit);
            Long offset = new Long((page-1)*limit);
            example.setOffset(offset);
        }
        //设置时间倒叙排序
        example.setOrderByClause(" time desc");
        
        //设置客户id
        if(followUp.getCustomerId() != null) {
            criteria.andCustomerIdEqualTo(followUp.getCustomerId());
        }else {
            //如果客户ID不存在,表示查询该用户所有的客户跟踪记录
            HttpSession session = request.getSession();
            User user = (User)session.getAttribute("user");
            
            CustomerExample customerExample = new CustomerExample();
            customerExample.createCriteria().andManagerIdEqualTo(user.getId());
            
            List<Customer> customers = customerService.selectByCustomerExample(customerExample);
            List<Integer> ids = new ArrayList<Integer>();
            for(Customer customer : customers) {
                ids.add(customer.getId());
            }
            criteria.andCustomerIdIn(ids);
        }
        
        Long count = followupService.countByFollowUpExample(example);
        List<FollowUp> list = followupService.selectByFollowUpExample(example);
        
        map.put("data", list);
        map.put("count", count);
        map.put("code", 0);
        
        int pages = (int)Math.ceil((count*1.0)/limit);
        map.put("pages", pages);
        
        
        return map;
    }
    
    /**
     * 
            List<DictionaryItem> items = dictionaryItemService.selectByDictionaryItemExample(example);
            type.setDictionaryItems(items);
        }
        
        if(type != null) {
            map.put("success", true);
            map.put("msg", "查找成功");
            map.put("data", type);
        }else {
            map.put("success", false);
            map.put("msg", "查找失败,字典不存在");
        }
        return map;
    }
    
}

/**
 * 
 * 
 */
@Controller
@RequestMapping("/user")
            if(customer.getMaturity() != null && !"".equals(customer.getMaturity())) {
                criteria.andMaturityEqualTo(customer.getMaturity());
            }
        }
        
        Long count = customerService.countByCustomerExample(example);
        List<Customer> customers = customerService.selectByCustomerExample(example);
        
        map.put("data", customers);
        map.put("count", count);
        map.put("code", 0);
        
        return map;
    }
    
    
    /**
     * 
     * 描述:添加一个客户
     * @version 1.0
     * @param customer 客户信息
     * @param linkman 联系人信息
     * @param customerName 客户名称
     * @param linkmanName 联系人名称
     * @param customerLevel 客户等级
     * @param request
     * @return Map<String,Object>
     * @since 1.8
     *
     */
    @RequiresPermissions("5002")
    @Operation(name="添加客户")
    @RequestMapping("add")
    @ResponseBody
    public Map<String, Object> addCustomer(Customer customer,Linkman linkman,String customerName,String linkmanName,String customerLevel,HttpServletRequest request){
        Map<String, Object> map = new HashMap<String,Object>(16);
        
        this.getUser(request);
        
        //检测是否存在customer对象
            List<DictionaryItem> items = dictionaryItemService.selectByDictionaryItemExample(example);
            type.setDictionaryItems(items);
        }
        
        if(type != null) {
            map.put("success", true);
            map.put("msg", "查找成功");
            map.put("data", type);
        }else {
            map.put("success", false);
            map.put("msg", "查找失败,字典不存在");
        }
        return map;
    }
    
}

    @ResponseBody
    public Map<String, Object> addDictionaryItemAdmin(DictionaryItem item){
        
        Map<String, Object> map = new HashMap<String,Object>(16);
        if(dictionaryItemService.insertDictionaryItemSelective(item)) {
            map.put("success", true);
            map.put("msg", "添加成功");
        }else {
            map.put("success", false);
            map.put("msg", "添加失败");
        }
        return map;
    }
    
    /**
     */
    @RequiresPermissions("20011")
    @Operation(name="数据字典子项更新")
    @RequestMapping("admin/update")
    @ResponseBody
    public Map<String, Object> updateDictionaryItemAdmin(DictionaryItem item){
        
        Map<String, Object> map = new HashMap<String,Object>(16);
        if(dictionaryItemService.updateDictionaryItemByPrimaryKeySelective(item)) {
            map.put("success", true);
            map.put("msg", "更新成功");
        }else {
            map.put("success", false);
            map.put("msg", "更新失败");
        }
        return map;
    }
    
    
    /**
     */
    @RequiresPermissions("20012")
    @Operation(name="数据字典子项删除")
    @RequestMapping("admin/delete")

	/**
	 * 
	 * 描述:根据职位编号删除职位
	 * 
	 * @version 1.0
	 * @param id
	 * @return Map<String,Object>
	 * @exception Nothing
	 * @since 1.8
	 *
	 */
	@Operation(name = "删除职位")
	@RequiresPermissions("4004")
	@RequestMapping("/deleteRole")
	@ResponseBody
	public Map<String, Object> deleteRole(Integer id) {
		Map<String, Object> map = new HashMap<String, Object>(16);
		// 用于判断返回给前台的结果
		boolean success = false;
		// 删除结果判断
		if (roleService.deleteRoleByPrimaryKey(id)) {
			success = true;
		}
		map.put("success", success);
		map.put("code", 0);
		return map;
	}

	/**
	 * 
	 * 描述:编辑职位
	 * 
	 * @version 1.0
	 * @param role
	 * @return Map<String,Object>
	 * @exception Nothing
	 * @since 1.8
	 *
	 */
	@Operation(name = "编辑职位")
	@RequiresPermissions("4002")
	@RequestMapping("/editRole")
	@ResponseBody
	public Map<String, Object> editRole(Role role) {
		Map<String, Object> map = new HashMap<String, Object>(16);
		// 用于判断返回给前台的结果
		boolean success = false;
		if (roleService.updateRoleByPrimaryKey(role)) {
			success = true;
		}

/**
 */
@Operation(name="跟踪记录管理")
@Controller
@RequestMapping("followup")
public class FollowUpController {
    
    @Autowired
    private IFollowUpService followupService;

    @Autowired 
    private ICustomerService customerService;
    
    /**
     *  分页查询跟踪记录
     * @param page 必填参数,需要的查询的页数,默认值 1
     * @param limit 可选参数,分页大小,默认值 5
     * @param followUp 内部customerId为必填参数
     * @param type 可选参数,值为 all 时 page与limit参数无效
     */
    @RequiresPermissions("6001")
    @Operation(name="分页查询跟踪记录")
    @RequestMapping("list")
    @ResponseBody
    public Map<String, Object> listLinkman(Integer page,Integer limit,FollowUp followUp,String type,HttpServletRequest request){
        Map<String, Object> map = new HashMap<String,Object>(16);
        
        FollowUpExample example = new FollowUpExample();
        Criteria criteria = example.createCriteria();

        if(followUp == null) {
            map.put("code", -1);
            map.put("msg", "非法查询");
            return map;
        }
        
        //设置分页参数
        if(page == null || page <= 0) {
            page = 1;
        }
        if(limit == null || limit <= 0) {
            limit = 5;
        }
     *
     */
    @Operation(name="修改用户")
    @RequiresPermissions(value={"1002","13002"}, logical=Logical.OR)
    @RequestMapping("/editUser")
    @ResponseBody
    public Map<String, Object> editUser(User user){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        String msg = "";
        //修改成功
        if(userService.edit(user) == true) {
            success = true;
            msg = "修改成功!";
        }else {
            msg = "修改失败!";
        }
        map.put("success", success);
        map.put("msg", msg);
        map.put("code", 0);
        return map;
    }
    
    /**
     * 
     * 描述:添加用户
     * @version 1.0
     * @param user 要添加的用户信息
     * @return Map<String,Object>
     * @exception Nothing
     * @since 1.8
     *
     */
    @Operation(name="添加用户")
    @RequiresPermissions("1003")
    @RequestMapping("/addUser")
    @ResponseBody
    public Map<String, Object> addUser(User user){
        Map<String, Object> map = new HashMap<String, Object>(16);
        boolean success = false;
        
        //设置user的初始密码为123456
        
        //判断用户是否已经登陆
        if(!subject.isAuthenticated()) {
            UsernamePasswordToken token = new UsernamePasswordToken(user.getAccount(),user.getPassword());
            try {
                subject.login(token);
                //验证成功
                //登陆成功后的用户账号信息
                String account =  (String)subject.getPrincipal();
                
                //根据用户账号,查询用户,并保存到session域中
                User loginUser = userService.findByAccount(account);
  
                LocalDateTime now = LocalDateTime.now();
                
                //如果上次登陆的时间为空,则说明这次是首次登陆,前台应该跳转到修改密码界面
                if(loginUser.getLastLoginTime() == null) {
                    maps.put("firstLogin", true);
                }
                //修改最后一次登录的时间,并保存到数据库
                loginUser.setLastLoginTime(now);
                loginUser.setPassword(null);
                
                //新创建对象用来更新user的最后一次登录时间
                User updateUser = new User();
                updateUser.setId(loginUser.getId());
                updateUser.setLastLoginTime(now);
                userService.edit(updateUser);
                
                request.getSession().setAttribute("user", loginUser);
                logger.info("登陆的用户信息:" + loginUser.toString());

                request.getSession().setAttribute("user", loginUser);
                maps.put("code", 0); 
              //账号被锁定
            } catch(LockedAccountException e){
                maps.put("code",200);
                maps.put("msg","账号已被锁定,请联系管理员进行处理!");
              //不存在的账号
            } catch(UnknownAccountException e) {
                maps.put("code",200);
                maps.put("msg","账号或密码错误!");
              //密码错误
            } catch(IncorrectCredentialsException e) {
                maps.put("code",200);
                maps.put("msg","账号或密码错误!");
            }catch (Exception e) {
                e.printStackTrace();
                maps.put("code", 200);
                maps.put("msg", "系统出了小差,请稍等...");
            }
        }else {
        	maps.put("code", 0);
        }

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值