项目编号: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.*; /** * <p> * 前端控制器 * </p> * * @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<String, Object> result = new HashMap<String, Object>(); QueryWrapper<Askers> queryWrapper = new QueryWrapper<Askers>() .like(!StringUtils.isEmpty(askerName), "asker_name", askerName).and(i -> i.eq("change_state", 1)); IPage<Askers> find = service.page(new Page<Askers>(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<Askers> queryWrapper = new QueryWrapper<Askers>() .like(!StringUtils.isEmpty(askerName), "asker_name", askerName).and(i -> i.eq("change_state", 2)); IPage<Askers> find = service.page(new Page<Askers>(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<List<Object>> rows = new ArrayList<>(); List<Object> head = Arrays.asList("姓名", "状态", "入职时间", "角色", "公司名称"); rows.add(head); List<Askers> all = service.getAll(); for (Askers askers : all) { List<Object> columns = new ArrayList<>(); columns.add(askers.getAskerName()); columns.add(askers.getCheckState()); columns.add(askers.getCheckIntime()); columns.add(askers.getRoleName()); columns.add(askers.getBakcontent()); rows.add(columns); } ExcelUtil.export("asker", rows, out); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } @RequestMapping("/export1") public void export1(HttpServletResponse response) { String filename = "asker1.xlsx"; response.setHeader("Content-Disposition", "attachment;filename=" + filename); try { OutputStream out = response.getOutputStream(); List<List<Object>> rows = new ArrayList<>(); List<Object> head = Arrays.asList("姓名", "状态", "入职时间", "角色", "公司名称"); rows.add(head); List<Askers> all = service.getAll1(); for (Askers askers : all) { List<Object> columns = new ArrayList<>(); columns.add(askers.getAskerName()); columns.add(askers.getCheckState()); columns.add(askers.getCheckIntime()); columns.add(askers.getRoleName()); columns.add(askers.getBakcontent()); rows.add(columns); } ExcelUtil.export("asker1", rows, out); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } static List<Askers> askersList = new ArrayList<Askers>(); private static Random random = new Random(); Long select1 = null; /** * 根据权重随机生成wuyong * @return */ // @PutMapping // @ResponseBody public void quanZhong() { List<Askers> wight = service.getWight(); for (int i = 0; i < wight.size(); i++) { Long askerId = wight.get(i).getAskerId(); Integer weight = wight.get(i).getWeight(); Askers askers = new Askers(askerId, weight); askersList.add(askers); } Integer weightSum = 0; for (Askers wc : askersList) { weightSum += wc.getWeight(); } if (weightSum <= 0) { System.err.println("Error: weightSum=" + weightSum.toString()); return; } Integer n = random.nextInt(weightSum); // n in [0, weightSum) Integer m = 0; for (Askers wc : askersList) { if (m <= n && n < m + wc.getWeight()) { select1 = wc.getAskerId(); System.out.println("This Random Category is " + select1); break; } m += wc.getWeight(); } // try { // //根据id // boolean b = studentsService.updateById(a.setAskerId(select1)); // return Result.success("ok", b); // } catch (Exception e) { // return Result.success("分配失败"); // } } Boolean check=true; @RequestMapping("/boolean") public Result bool(Boolean c){ check=c; return Result.success("ok"); } /** * 根据权重随机生成咨询师 * @param students * @return */ @PutMapping("/wight") public Result OpenWight(@RequestBody Students students) { List<Askers> wight = service.getWight(); for (int i = 0; i < wight.size(); i++) { Long askerId = wight.get(i).getAskerId(); Integer weight = wight.get(i).getWeight(); Askers askers = new Askers(askerId, weight); askersList.add(askers); } Integer weightSum = 0; for (Askers wc : askersList) { weightSum += wc.getWeight(); } if (weightSum <= 0) { System.err.println("Error: weightSum=" + weightSum.toString()); return Result.success("权重<0"); } Integer n = random.nextInt(weightSum); // n in [0, weightSum) Integer m = 0; for (Askers wc : askersList) { if (m <= n && n < m + wc.getWeight()) { select1 = wc.getAskerId(); System.out.println("This Random Category is " + select1); break; } m += wc.getWeight(); } // AskersController controller = new AskersController(); // controller.quanZhong(); if (check == true) { students.setAskerId(select1); Askers byId = service.getById(select1); students.setZixunName(byId.getAskerName()); students.setShifoufengpei("已分配"); studentsService.updateById(students); return Result.success("ok"); } if (check == false){ Long aLong = new Long(2); studentsService.updateById(students.setAskerId(aLong)); return Result.success("ok"); } return Result.success("失败"); } //消息推送 @GetMapping("student") public Result student(Students students,Integer page,Integer limit){ try { // Long aLong = new Long(2); Long gg=UserUtil.getId(); QueryWrapper<Students> queryWrapper = new QueryWrapper<Students>().eq("askerId", gg); // .like(!StringUtils.isEmpty(askerName), "asker_name", askerName).and(i -> i.eq("change_state", 2)); IPage<Students> find = studentsService.page(new Page<Students>(page, limit), queryWrapper); return Result.successToPage("ok", find.getRecords(), find.getTotal()); }catch (Exception e){ e.printStackTrace(); return Result.success("查询失败"); } } //咨询师数据下拉框 @RequestMapping("asker") public Object asker(){ Map<String, Object> result = new HashMap<String, Object>(); try { List<Askers> all = service.getAll(); result.put("code",0); result.put("data",all); return result; }catch (Exception e){ e.printStackTrace(); return Result.success("no"); } } }
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<Students> queryWrapper = new QueryWrapper<Students>() //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<Students> find = studentsService.page(new Page<Students>(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("更新失败"); } } }