基于javaweb+mysql的springboot销售团队后台管理系统(java+springboot+freemarker+bootstrap+echarts+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot销售团队后台管理系统(java+springboot+freemarker+bootstrap+echarts+mysql)
项目介绍
该项目为后管系统,主要功能包括:
看板、业务机会管理、客户管理、联系人管理、我的日报、团队日报、主数据管理:组织架构管理;系统管理:用户管理、角色管理、菜单管理等;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
-
后端:SpringBoot+mybatis
-
前端:FreeMarker+Angular+bootstrap+echarts+jQuery
使用说明
-
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
-
使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
- 将项目中application-powerteam.yml配置文件中的数据库配置改为自己的配置; 4. 前台访问路径:http://localhost:8080/ 登录账号:admin 登录密码:admin
public Result update(@RequestBody Contacts contacts) {
return contactsService.update(contacts);
}
}
@Controller
public class HomeController {
@Autowired
private HttpSession session;
@Autowired
private UserService userService;
@Autowired
private PowerTeamConfig powerTeamConfig;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String signIn() {
return "sys/home";
}
@RequestMapping(value = "/signIn", method = RequestMethod.POST)
@ResponseBody
public ResultData<User> signIn(@RequestBody User user) {
public class GlobalInterceptor extends HandlerInterceptorAdapter {
@Autowired
private PowerTeamConfig powerTeamConfig;
@Autowired
private HttpSession session;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
boolean result = true;
List<Annotation> marks = new ArrayList<>();
marks.addAll(Arrays.asList(handlerMethod.getBeanType().getAnnotations()));
marks.addAll(Arrays.asList(handlerMethod.getMethod().getAnnotations()));
boolean isAjax = marks.stream().anyMatch(e -> e instanceof ResponseBody);
if (marks.stream().anyMatch(e -> e instanceof RequireSession)) {
User user = (User) session.getAttribute("User");
if (user == null) {
result = false;
} else if (marks.stream().anyMatch(e -> e instanceof RequireMenu)) {
List<Menu> menuList = (List<Menu>) session.getAttribute("MenuList");
Optional<Annotation> annotation = marks.stream().filter(m -> m instanceof RequireMenu).findFirst();
RequireMenu menuMark = (RequireMenu) annotation.get();
if (menuList.stream().noneMatch(m -> m.getMenuCode().equals(menuMark.value()))) {
result = false;
}
}
}
if (!result) {
if (!isAjax) {
response.sendRedirect(StringUtils.isEmpty(powerTeamConfig.getWebRoot()) ? "/" : powerTeamConfig.getWebRoot());
} else {
response.setStatus(HttpStatus.FORBIDDEN.value());
public ModelAndView roleMenu(@PathVariable Integer roleId) {
ModelAndView mv = new ModelAndView("sys/roleMenu");
mv.addObject("roleId", roleId);
return mv;
}
@RequestMapping(value = "/menu/saveMenu", method = RequestMethod.POST)
@ResponseBody
public Result saveMenu(@RequestBody Map map) {
return roleService.saveRoleMenu((Integer) map.get("roleId"), (List<Integer>) map.get("menuIdList"));
}
@RequestMapping(value = "/fun/{roleId}", method = RequestMethod.GET)
public ModelAndView roleFun(@PathVariable int roleId) {
ModelAndView vm = new ModelAndView("sys/roleFun");
vm.addObject("roleId", roleId);
return vm;
}
}
@Controller
@RequestMapping("/orgUnit")
public class OrgUnitController extends AuthorizedController {
@Autowired
private OrgUnitService orgUnitService;
@RequestMapping(value = "", method = RequestMethod.GET)
public String index() {
@ResponseBody
public Result addRoleUser(@RequestBody RoleUser roleUser) {
return roleService.insertRoleUser(roleUser);
}
@RequestMapping(value = "/menu/{roleId}", method = RequestMethod.GET)
public ModelAndView roleMenu(@PathVariable Integer roleId) {
ModelAndView mv = new ModelAndView("sys/roleMenu");
mv.addObject("roleId", roleId);
return mv;
}
@RequestMapping(value = "/menu/saveMenu", method = RequestMethod.POST)
@ResponseBody
public Result saveMenu(@RequestBody Map map) {
return roleService.saveRoleMenu((Integer) map.get("roleId"), (List<Integer>) map.get("menuIdList"));
}
@RequestMapping(value = "/fun/{roleId}", method = RequestMethod.GET)
public ModelAndView roleFun(@PathVariable int roleId) {
ModelAndView vm = new ModelAndView("sys/roleFun");
vm.addObject("roleId", roleId);
return vm;
}
}
public Result updateContactsRole(@RequestBody ContactsRole contactsRole) {
return opportunityService.updateContactsRole(contactsRole);
}
@RequestMapping(value = "/removeContactsRole", method = RequestMethod.POST)
@ResponseBody
public Result removeContactsRole(@RequestBody ContactsRole contactsRole) {
return opportunityService.deleteContactsRole(contactsRole);
}
@RequestMapping(value = "/remove", method = RequestMethod.POST)
@ResponseBody
public Result remove(@RequestBody Opportunity opportunity) {
return opportunityService.delete(opportunity);
}
@RequestMapping(value = "/history", method = RequestMethod.GET)
public String history() {
return "crm/opportunityHistory";
}
@RequestMapping(value = "/history/view/{opportunityId}", method = RequestMethod.GET)
public ModelAndView view(@PathVariable int opportunityId) {
ModelAndView vm = new ModelAndView("crm/opportunityView");
vm.addObject("opportunityId", opportunityId);
return vm;
}
@RequestMapping(value = "/findMonthlyFunnel", method = RequestMethod.POST)
@ResponseBody
public List<Map> findMonthlyFunnel(@RequestBody QueryOpportunityVo vo) {
List<Integer> userIdList = new ArrayList<>();
userIdList.add(getUser().getUserId());
vo.setUserIdList(userIdList);
return opportunityService.findMonthlyFunnel(vo);
}
@RequestMapping(value = "/findMonthlyConversion", method = RequestMethod.POST)
@ResponseBody
public List<Map> findMonthlyConversion(@RequestBody QueryOpportunityVo vo) {
List<Integer> userIdList = new ArrayList<>();
userIdList.add(getUser().getUserId());
vo.setUserIdList(userIdList);
return opportunityService.findMonthlyConversion(vo);
}
@RequestMapping(value = "/findRecentlyClosing", method = RequestMethod.POST)
@ResponseBody
public List<Opportunity> findRecentlyClosing(@RequestBody QueryOpportunityVo vo) {
List<Integer> userIdList = new ArrayList<>();
public List<OrgUnit> findAllOrgUnit() {
return orgUnitService.findAllOrgUnit();
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody OrgUnit orgUnit) {
return orgUnitService.insert(orgUnit);
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody OrgUnit orgUnit) {
return orgUnitService.update(orgUnit);
}
@RequestMapping(value = "/remove", method = RequestMethod.POST)
@ResponseBody
public Result remove(@RequestBody OrgUnit orgUnit) {
return orgUnitService.delete(orgUnit.getOrgUnitId());
}
@RequestMapping(value = "/up", method = RequestMethod.POST)
@ResponseBody
public Result up(@RequestBody OrgUnit orgUnit) {
return orgUnitService.up(orgUnit.getOrgUnitId());
}
@RequestMapping(value = "/down", method = RequestMethod.POST)
@ResponseBody
public Result down(@RequestBody OrgUnit orgUnit) {
return orgUnitService.down(orgUnit.getOrgUnitId());
}
@RequestMapping(value = "/orgUser", method = RequestMethod.GET)
public String orgUser() {
return "masterData/orgUser";
}
@RequestMapping(value = "/orgUser/findUserNotInOrgUnit", method = RequestMethod.POST)
@Service
public class ExcelUtil {
@Autowired
private HttpServletResponse response;
public <T> void export(String fileName, List<T> data) {
try {
if (data == null || data.isEmpty()) {
return;
}
List<ExcelColumn> columnList = new ArrayList<>();
Class<?> type = data.get(0).getClass();
List<Field> fields = Arrays.asList(type.getDeclaredFields());
for (Field field : fields) {
field.setAccessible(true);
ExcelColumn excelColumn = field.getAnnotation(ExcelColumn.class);
columnList.add(excelColumn);
}
columnList.sort((e1, e2) -> e1.order() - e2.order());
fields.sort((f1, f2) -> f1.getAnnotation(ExcelColumn.class).order() - f2.getAnnotation(ExcelColumn.class).order());
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
HSSFRow headerRow = sheet.createRow(0);
for (ExcelColumn column : columnList) {
HSSFCell headerCell = headerRow.createCell(column.order());
headerCell.setCellValue(column.headerName());
}
for (int i = 0; i < data.size(); i++) {
T item = data.get(i);
HSSFRow row = sheet.createRow(i + 1);
for (int j = 0; j < fields.size(); j++) {
HSSFCell cell = row.createCell(j);
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public Menu findById(@RequestBody Menu menu) {
return menuService.findById(menu.getMenuId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody Menu menu) {
return menuService.update(menu);
}
@RequestMapping(value = "/up", method = RequestMethod.POST)
@ResponseBody
public Result up(@RequestBody Menu menu) {
return menuService.up(menu.getMenuId());
}
@RequestMapping(value = "/down", method = RequestMethod.POST)
@ResponseBody
public Result down(@RequestBody Menu menu) {
return menuService.down(menu.getMenuId());
}
}
@Controller
@RequestMapping("/user")
public class UserController extends AuthorizedController {
@Autowired
private UserService userService;
@Autowired
private HttpSession session;
@Controller
@RequestMapping("/user")
public class UserController extends AuthorizedController {
@Autowired
private UserService userService;
@Autowired
private HttpSession session;
@RequestMapping(value = "", method = RequestMethod.GET)
public String index() {
return "sys/user";
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
@ResponseBody
public PageInfo<User> find(@RequestBody QueryUserVo vo) {
return userService.find(vo);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody User user) {
return userService.insert(user);
}
@RequestMapping(value = "/remove", method = RequestMethod.POST)
@ResponseBody
public String customer() {
return "crm/customer";
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
@ResponseBody
public PageInfo<Customer> find(@RequestBody QueryCustomerVo vo) {
return customerService.find(vo);
}
@RequestMapping(value = "/findAllCustomerCategory", method = RequestMethod.POST)
@ResponseBody
public List<CustomerCategory> findAllCustomerCategory() {
return customerService.findAllCustomerCategory();
}
@RequestMapping(value = "/findAllIndustry", method = RequestMethod.POST)
@ResponseBody
public List<Industry> findAllIndustry() {
return customerService.findAllIndustry();
}
@RequestMapping(value = "/findAllSource", method = RequestMethod.POST)
@ResponseBody
public List<Source> findAllSource() {
return customerService.findAllSource();
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody Customer customer) {
customer.setCreateBy(getUser().getUserId());
return customerService.insert(customer);
}
@RequestMapping(value = "/checkCustomerName", method = RequestMethod.POST)
@ResponseBody
public Result checkCustomerName(@RequestBody Customer customer) {
return customerService.checkCustomerName(customer);
}
@RequestMapping(value = "/menu/{roleId}", method = RequestMethod.GET)
public ModelAndView roleMenu(@PathVariable Integer roleId) {
ModelAndView mv = new ModelAndView("sys/roleMenu");
mv.addObject("roleId", roleId);
return mv;
}
@RequestMapping(value = "/menu/saveMenu", method = RequestMethod.POST)
@ResponseBody
public Result saveMenu(@RequestBody Map map) {
return roleService.saveRoleMenu((Integer) map.get("roleId"), (List<Integer>) map.get("menuIdList"));
}
@RequestMapping(value = "/fun/{roleId}", method = RequestMethod.GET)
public ModelAndView roleFun(@PathVariable int roleId) {
ModelAndView vm = new ModelAndView("sys/roleFun");
vm.addObject("roleId", roleId);
return vm;
}
}
@Controller
@RequestMapping("/orgUnit")
public class OrgUnitController extends AuthorizedController {
@Autowired
private OrgUnitService orgUnitService;
ModelAndView vm = new ModelAndView("crm/customerDashboard");
vm.addObject("customerId", customerId);
return vm;
}
@RequestMapping(value = "/updateStar", method = RequestMethod.POST)
@ResponseBody
public Result updateStar(@RequestBody Customer customer) {
return customerService.updateStar(customer);
}
@RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
@ResponseBody
public Result updateLocation(@RequestBody Customer customer) {
return customerService.updateLocation(customer);
}
}
@Controller()
@RequestMapping("/menu")
public class MenuController extends AuthorizedController {
@Autowired
private MenuService menuService;
List<Integer> subordinate = orgUnitService.findSubordinate(getUser().getUserId());
vo.setCreateBy(subordinate);
return activityService.find(vo);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Activity activity) {
return activityService.delete(activity);
}
}
@Controller
@RequestMapping("/contacts")
public class ContactsController extends AuthorizedController {
@Autowired
private ContactsService contactsService;
@RequestMapping(value = "", method = RequestMethod.GET)
public String customer() {
return "crm/contacts";
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody Contacts contacts) {
contacts.setCreateBy(getUser().getUserId());
public class GlobalInterceptor extends HandlerInterceptorAdapter {
@Autowired
private PowerTeamConfig powerTeamConfig;
@Autowired
private HttpSession session;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
boolean result = true;
List<Annotation> marks = new ArrayList<>();
marks.addAll(Arrays.asList(handlerMethod.getBeanType().getAnnotations()));
marks.addAll(Arrays.asList(handlerMethod.getMethod().getAnnotations()));
boolean isAjax = marks.stream().anyMatch(e -> e instanceof ResponseBody);
if (marks.stream().anyMatch(e -> e instanceof RequireSession)) {
User user = (User) session.getAttribute("User");
if (user == null) {
result = false;
} else if (marks.stream().anyMatch(e -> e instanceof RequireMenu)) {
List<Menu> menuList = (List<Menu>) session.getAttribute("MenuList");
Optional<Annotation> annotation = marks.stream().filter(m -> m instanceof RequireMenu).findFirst();
RequireMenu menuMark = (RequireMenu) annotation.get();
if (menuList.stream().noneMatch(m -> m.getMenuCode().equals(menuMark.value()))) {
result = false;
}
}
}
if (!result) {
if (!isAjax) {
response.sendRedirect(StringUtils.isEmpty(powerTeamConfig.getWebRoot()) ? "/" : powerTeamConfig.getWebRoot());
} else {
@Controller()
@RequestMapping("/menu")
public class MenuController extends AuthorizedController {
@Autowired
private MenuService menuService;
@RequestMapping(value = "", method = RequestMethod.GET)
public String index() {
return "sys/menu";
}
@RequestMapping(value = "/findAllMenu", method = RequestMethod.POST)
@ResponseBody
public List<Menu> findAllMenu() {
return menuService.findAllMenu();
}
@RequestMapping(value = "/findAllMenuTree", method = RequestMethod.POST)
@ResponseBody
public List<TreeNode<Menu>> findAllMenuTree() {
return menuService.findAllMenuTree();
}
@RequestMapping(value = "/findUserMenuTree", method = RequestMethod.POST)
@ResponseBody
public List<TreeNode<Menu>> findUserMenuTree() {
return menuService.findUserMenuTree(getUser().getUserId());
}
@RequestMapping(value = "/findRoleMenu", method = RequestMethod.POST)
@ResponseBody
public List<Menu> findRoleMenu(@RequestBody Role role) {
return menuService.findRoleMenu(role.getRoleId());
}
@RequestMapping(value = "/checkMenuName", method = RequestMethod.POST)
@ResponseBody
public Result checkMenuName(@RequestBody Menu menu) {
return menuService.checkMenuName(menu);
}
@RequestMapping(value = "/checkMenuCode", method = RequestMethod.POST)
@ResponseBody
modelAndView.addObject("PowerTeam", powerTeamConfig);
}
}
}
@Controller
@RequestMapping("/activity")
public class ActivityController extends AuthorizedController {
@Autowired
private ActivityService activityService;
@Autowired
private OrgUnitService orgUnitService;
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody Activity activity) {
activity.setCreateBy(getUser().getUserId());
return activityService.insert(activity);
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
@ResponseBody
public PageInfo<Activity> find(@RequestBody QueryActivityVo vo) {
return activityService.find(vo);
}
@RequestMapping(value = "/findMyDailyReport", method = RequestMethod.POST)
@ResponseBody
public PageInfo<Activity> findMyDailyReport(@RequestBody QueryActivityVo vo) {
List<Integer> createBy = new ArrayList<>();
@ResponseBody
public List<Fun> findAll() {
return funService.findAll();
}
@RequestMapping(value = "/findFunInRole", method = RequestMethod.POST)
@ResponseBody
public List<Fun> findFunInRole(@RequestBody Integer roleId) {
return funService.findFunInRole(roleId);
}
@RequestMapping(value = "/saveRoleFun", method = RequestMethod.POST)
@ResponseBody
public Result saveMenu(@RequestBody Map map) {
return funService.saveRoleFun((Integer) map.get("roleId"), (List<Integer>) map.get("funIdList"));
}
}
@Controller
public class DailyReportController extends AuthorizedController {
@RequestMapping(value = "/dailyReport", method = RequestMethod.GET)
public String dailyReport() {
return "crm/dailyReport";
}
@RequestMapping(value = "/teamDailyReport", method = RequestMethod.GET)
public String teamDailyReport() {
return "crm/teamDailyReport";
}
}
@Controller
@RequestMapping("/dashboard")
public class DashboardController extends AuthorizedController {
@RequestMapping(value = "", method = RequestMethod.GET)
public String dashboard() {