基于SpringBoot的企业客户管理系统

2023-09-20 19:46:31

目录

前言

 一、技术栈

二、系统功能介绍

管理员功能模块

员工功能模块

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

本论文主要论述了如何使用JAVA语言开发一个企业客户管理系统,本系统将严格按照软件开发流程进行各个阶段的工作,采用B/S架构,面向对象编程思想进行项目开发。在引言中,作者将论述企业客户管理系统的当前背景以及系统开发的目的,后续章节将严格按照软件开发流程,对系统进行各个阶段分析设计。

企业客户管理系统的主要使用者分为管理员和员工,实现功能包括管理员:首页、个人中心、员工管理、客户信息管理、行业类型管理、项目信息管理、项目类型管理、项目收益管理,员工:首页、个人中心、客户信息管理、项目信息管理、项目收益管理等功能。由于本网站的功能模块设计比较全面,所以使得整个企业客户管理系统信息管理的过程得以实现。

本系统的使用可以实现本企业客户管理的信息化,可以方便管理员进行更加方便快捷的管理,可以提高管理人员的工作效率。

 一、技术栈

末尾获取源码
SpringBoot+Vue+JS+ jQuery+Ajax...

二、系统功能介绍

管理员功能模块

管理员登录,通过填写用户名、密码、角色进行登录

管理员登录进入企业客户管理系统可以查看首页、个人中心、员工管理、客户信息管理、行业类型管理、项目信息管理、项目类型管理、项目收益管理等信息。

个人信息,在个人信息页面中可以通过填写用户名等内容进行修改、添加操作

在员工管理页面中可以填写工号、姓名、性别、照片、身份证、手机、邮箱等信息,还可以根据需要对员工管理进行详情、修改或删除等操作。

客户信息管理,在客户信息管理页面中可以填写客户名称、行业类型、性别、年龄、照片、手机、身份证、备注、工号、姓名等信息,并可根据需要对已有客户信息管理进行详情、修改或删除等操作 

 

行业类型管理,在行业类型管理页面中可以填写行业类型等内容,并可根据需要对已有行业类型管理进行修改或删除等操作

 

项目信息管理,在项目信息管理页面中可以填写项目名称、项目类型、客户名称、签单金额、签单数量、项目进度、签订日期、工号、签单人等内容,并且根据需要对已有项目信息管理进行详情、收益分配、修改或删除等操作

 

项目类型管理,在项目类型管理页面中可以填写项目类型等内容,并且根据需要对已有项目类型管理进行详情、修改或删除等操作

 

项目收益管理,在项目收益管理页面中可以填写项目名称、项目类型、签单金额、分配类型、分配金额、日期等内容,并且根据需要对已有项目收益管理进行详情、修改或删除等操作

 

员工功能模块

员工登录进入企业客户管理系统可以查看首页、个人中心、客户信息管理、项目信息管理、项目收益管理等内容。

员工注册,员工注册通过填写输入工号、姓名、性别、照片、身份证、手机、邮箱等信息即可进行员工注册

 

个人信息,在个人信息页面中可以查看工号、姓名、性别、照片、身份证、手机、邮箱等信息内容,并且根据需要对已有个人信息进行修改等其他详细操作

 

客户信息管理,在客户信息管理页面中通过填写客户名称、行业类型、性别、年龄、照片、手机、身份证、备注、工号、姓名等信息内容,并且根据需要对已有客户信息管理进行详情、修改、删除等其他详细操作。

项目信息管理,在项目信息管理页面中可以填写项目名称、项目类型、客户名称、签单金额、签单数量、项目进度、签订日期、工号、签单人等信息内容,并且根据需要对已有项目信息管理进行详情、修改、删除等详细操作

 

三、核心代码

1、登录模块

 
package com.controller;
 
 
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
 
/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;
 
	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }
 
	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }
 
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
 
    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }
 
    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

 2、文件上传模块

package com.controller;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
 
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
 
/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

3、代码封装

package com.utils;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}
 
	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}
 
	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

更多推荐

Java高级-反射

目录认识反射、获取类反射(Reflection)反射可进行的操作加载类,获取类的字节码:Class对象获取对象的三种方法获取构造器对象并使用获取构造器的方法获取构造器的作用获取成员变量和方法对象并使用获取类的成员变量的方法获取类的成员变量的作用获取成员方法的方法获取成员方法的作用认识反射、获取类反射(Reflectio

JVM--Java类加载器笔记

Java类加载器代码经过编译变成了字节码打包成Jar文件。让JVM去加载需要的字节码,变成持久代/元数据区上的Class对象,接着执行程序逻辑。类声明周期和加载过程步骤:加载->链接(校验->准备->解析)->初始化->使用->卸载加载:根据明确知道的class完全限定名,来获取二进制classfile格式的字节流(找

算法讨论题 —— Java实现两数之和

给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。即:每个index上的数字只能用一次。示例给定nums=[2,7,11,15],target=9因为nums[0]+nums[1]=2+7=9所以返回[0,1]解答这个题目的原题是在:力扣(Leet

Zookeeper分布式锁的概念及原理

文章目录1.Zookeeper分布式锁的概念2.分布式锁的实现方式3.Zookeeper分布式锁的原理1.Zookeeper分布式锁的概念分布式锁的概念图如下:一种演变过程。在我们进行单机应用程序开发时,往往会涉及到并发同步的问题,一般都会采用synchronized或者Lock锁的方式来解决多线程间的代码同步问题,这

EM3DANI包详解:使用Julia语言进行3D频域电磁数据建模的终极指南

第一部分:EM3DANI包的简介与安装1.EM3DANI包简介EM3DANI是一个强大的工具包,专门为那些希望使用Julia语言进行频域电磁(CSEM和MT)数据的3D建模的研究者和开发者设计。它支持各向同性和各向异性建模,使得用户可以更加灵活地进行电磁数据的模拟和分析。频域电磁(CSEM和MT)技术在地球物理勘探、矿

Leetcode.2826 将三个组排序

题目链接Leetcode.2826将三个组排序rating:1721题目描述给你一个下标从000开始长度为nnn的整数数组numsnumsnums。从000到n−1n-1n−1的数字被分为编号从111到333的三个组,数字iii属于组nums[i]nums[i]nums[i]。注意,有的组可能是空的。你可以执行以下操作

[C语言]栈与队列——喵喵队,冲冲冲

宝子,你不点个赞吗?不评个论吗?不收个藏吗?最后的最后,关注我,关注我,关注我,你会看到更多有趣的博客哦!!!喵喵喵,你对我真的很重要。目录前言栈栈的实现队列队列的实现总结前言实践,实践,实践,多练几遍力扣,牛客的题。落实到脚下。栈栈:一种特殊的线性表,其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作

Ubuntu安装RabbitMQ server - 在外远程访问

文章目录前言1.安装erlang语言2.安装rabbitMQ3.内网穿透3.1安装cpolar内网穿透(支持一键自动安装脚本)3.2创建HTTP隧道4.公网远程连接5.固定公网TCP地址5.1保留一个固定的公网TCP端口地址5.2配置固定公网TCP端口地址前言RabbitMQ是一个在AMQP(高级消息队列协议)基础上完

单例模式的安全写法

要想知道怎么写单例模式,那么必须得知道什么是单例模式。单例模式是一种设计模式,它确保某个类只有一个实例,并且提供一个全局访问该实例的方法。单例模式不会创建实例副本,而是返回对已创建实例的引用。单例模式的创建可以分为两类。第一类是饿汉式单例模式,它在类加载时就创建了唯一的实例对象,并在全局范围内提供访问点。第二类是懒汉式

如何制作一个成功的超市购物小程序

随着互联网的普及和移动支付的便捷性,越来越多的消费者选择在网上购物,这也促使越来越多的商家开始搭建自己的小程序商城。对于超市便利店来说,拥有一个便捷、易用的小程序商城能够吸引更多的消费者,提高销售效率。那么如何快速搭建一个超市便利店小程序呢?下面我们将通过乔拓云平台来介绍这个过程。步骤1:登录乔拓云网后台,进入商城管理

rabbitmq 面试题

1.交换机类型RabbitMQ是一个开源的消息队列系统,它支持多种交换机类型,用于在消息的生产者和消费者之间路由和分发消息DirectExchange(直接交换机):Direct交换机是最简单的交换机类型之一。它将消息按照消息的RoutingKey(路由键)与绑定的队列的RoutingKey进行精确匹配,并将消息发送到

热文推荐