作者主页:编程千纸鹤
作者简介:Java、前端、Pythone开发多年,做过高程,项目经理,架构师
主要内容:Java项目开发、毕业设计开发、面试技术整理、最新技术分享
收藏点赞不迷路 关注作者有好处
文末获得源码
项目编号:BS-GX-044
基于前后端分离开发的模式实现一个培训机构的小型CRM管理系统,主要实现根据不同的身份角色来进行不同的管理操作,主要完成的功能有,用户管理、咨询师管理、签到管理、学生跟踪信息管理、学生信息管理等相关功能模块。
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7+Redis
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台开发技术:springboot+mybatis
前台开发技术:html+jquery 直接部署在nginx下运行
管理员登陆
角色管理
权限设置
用户管理
角色设置
咨询经理登陆
学生信息管理
查询签到信息
咨询师管理
签到管理
网络咨询师管理
咨询师登陆系统
管理自己咨询的学生
完善学生信息
学生咨询回访问记录
vpackage com.ysd.crm_managerssystem.controller;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysd.crm_managerssystem.entity.Askers;
import com.ysd.crm_managerssystem.entity.Students;
import com.ysd.crm_managerssystem.entity.Userchecks;
import com.ysd.crm_managerssystem.service.IAskersService;
import com.ysd.crm_managerssystem.service.IStudentsService;
import com.ysd.crm_managerssystem.util.ExcelUtil;
import com.ysd.crm_managerssystem.util.Result;
import com.ysd.crm_managerssystem.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
/**
*
* 前端控制器
*
*
* @author
* @since 2020-05-12
*/
@RestController
@RequestMapping("/crm_managerssystem/askers")
public class AskersController {
@Autowired
private IAskersService service;
@Autowired
private IStudentsService studentsService;
/**
* 查询咨询师
*
* @param askerName
* @param page
* @param limit
* @return
*/
@GetMapping("/query")
public Object queryUserChecks(@RequestParam(required = false) String askerName, Integer page, Integer limit) {
Map result = new HashMap();
QueryWrapper queryWrapper = new QueryWrapper()
.like(!StringUtils.isEmpty(askerName), "asker_name", askerName).and(i -> i.eq("change_state", 1));
IPage find = service.page(new Page(page, limit), queryWrapper);
if (find != null) {
result.put("msg", "ok");
result.put("data", find.getRecords());
result.put("count", find.getTotal());
result.put("code", 0);
return result;
} else {
result.put("msg", "no");
result.put("code", 1);
return result;
}
}
/**
* 查询网络咨询师
*
* @param askerName
* @param page
* @param limit
* @return
*/
@GetMapping("/wangLuo")
public Result queryUserChecksWangLuo(@RequestParam(required = false) String askerName, Integer page, Integer limit) {
try {
QueryWrapper queryWrapper = new QueryWrapper()
.like(!StringUtils.isEmpty(askerName), "asker_name", askerName).and(i -> i.eq("change_state", 2));
IPage find = service.page(new Page(page, limit), queryWrapper);
return Result.successToPage("ok", find.getRecords(), find.getTotal());
} catch (Exception e) {
return Result.success("查询网络咨询师失败");
}
}
/**
* 添加咨询师、网络咨询师
*
* @param askers
* @return
*/
@PostMapping
public Result addAsker(@RequestBody Askers askers) {
try {
service.save(askers);
return Result.success("ok");
} catch (Exception e) {
e.printStackTrace();
return Result.success("添加失败");
}
}
/**
* 编辑咨询师、网络咨询师信息
*
* @param askers
* @return
*/
@PutMapping
public Object updateAsker(@RequestBody Askers askers) {
try {
service.updateById(askers);
return Result.success("ok");
} catch (Exception e) {
e.printStackTrace();
return Result.success("更新失败");
}
}
/**
* 根据id回显咨询师、网络咨询师信息
*
* @param id
* @return
*/
@GetMapping("/{id}")
public Result findOne(@PathVariable Integer id) {
return Result.success("ok", service.getById(id));
}
/**
* 根据id删除单个咨询师、网络咨询师信息
*
* @param id
* @return
*/
@DeleteMapping("/{id}")
public Result delete(@PathVariable Integer id) {
try {
service.removeById(id);
return Result.success("ok");
} catch (Exception e) {
e.printStackTrace();
return Result.success("删除失败");
}
}
/**
* 根据id批量删除咨询师、网络咨询师信息
*
* @param ids
* @return
*/
@DeleteMapping
public Result delete(@RequestParam("ids[]") Integer[] ids) {
try {
service.removeByIds(Arrays.asList(ids));
return Result.success("ok");
} catch (Exception e) {
e.printStackTrace();
return Result.success("删除失败");
}
}
@RequestMapping("/export")
public void export(HttpServletResponse response) {
String filename = "asker.xlsx";
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
try {
OutputStream out = response.getOutputStream();
List> rows = new ArrayList<>();
List
package com.ysd.crm_managerssystem.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysd.crm_managerssystem.entity.Students;
import com.ysd.crm_managerssystem.entity.Users;
import com.ysd.crm_managerssystem.service.IStudentsService;
import com.ysd.crm_managerssystem.util.LayuiUtils;
import com.ysd.crm_managerssystem.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@RestController
@RequestMapping("crm_managerssystem/askstudents")
public class AskStudentsController {
@Autowired
private IStudentsService studentsService;
/**
* 分页查询
* 每个咨询师只查出分配给自己的学生
* @param limit
* @param page
* @return
*/
@GetMapping("/page")
public Object pageStudents(HttpServletRequest httpServletRequest, @RequestParam(required = false) String stuName, @RequestParam(required = false) String stuStatus, Integer limit, Integer page) {
/**
* 从session中取出登录用户
* 根据登录用户角色只查出分配给自己的学生
*/
HttpSession session = httpServletRequest.getSession();
Users user = (Users)session.getAttribute("user");
if(user==null){
return LayuiUtils.error1("登录身份过期,请返回登录页重新登录");
}
QueryWrapper queryWrapper = new QueryWrapper()
//students_zi_xun_name用来表示咨询师的userID
.eq("zixun_name",user.getUserId())
.eq(!StringUtils.isEmpty(stuStatus),"stu_status",stuStatus)
//条件查询
.like(!StringUtils.isEmpty(stuName), "students_name", stuName);
IPage find = studentsService.page(new Page(page, limit), queryWrapper);
return Result.successToPage("ok", find.getRecords(), find.getTotal());
}
@GetMapping("/{id}")
public Result findOne(@PathVariable Integer id) {
return Result.success("ok", studentsService.getById(id));
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/{id}")
public Result delete(@PathVariable Integer id){
try {
studentsService.removeById(id);
return Result.success("ok");
} catch (Exception e) {
e.printStackTrace();
return Result.success("删除失败");
}
}
/**
* 修改
* @param students
* @return
*/
@PutMapping
public Result update(@RequestBody Students students){
try {
studentsService.updateById(students);
return Result.success("ok");
} catch (Exception e) {
e.printStackTrace();
return Result.success("更新失败");
}
}
}