基于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
@RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
@ResponseBody
public Result updatePassword(@RequestBody UpdatePasswordVo vo) {
return userService.updatePassword(vo);
}
}
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()));
}
@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
public Result checkMenuCode(@RequestBody Menu menu) {
return menuService.checkMenuCode(menu);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody Menu menu) {
return menuService.insert(menu);
}
@RequestMapping(value = "/remove", method = RequestMethod.POST)
@ResponseBody
public Result remove(@RequestBody Menu menu) {
return menuService.delete(menu.getMenuId());
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Controller
@RequestMapping("/opportunity")
public class OpportunityController extends AuthorizedController {
@Autowired
private OpportunityService opportunityService;
@Autowired
private OrgUnitService orgUnitService;
@RequestMapping(value = "", method = RequestMethod.GET)
public String customer() {
return "crm/opportunity";
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody Opportunity opportunity) {
opportunity.setCreateBy(getUser().getUserId());
return opportunityService.insert(opportunity);
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
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);
Field field = fields.get(j);
Class<?> fieldType = field.getType();
if (fieldType == String.class) {
cell.setCellValue(field.get(item).toString());
} else if (fieldType == int.class) {
cell.setCellValue(field.getInt(item));
@Controller
@RequestMapping("/opportunity")
public class OpportunityController extends AuthorizedController {
@Autowired
private OpportunityService opportunityService;
@Autowired
private OrgUnitService orgUnitService;
@RequestMapping(value = "", method = RequestMethod.GET)
public String customer() {
return "crm/opportunity";
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result add(@RequestBody Opportunity opportunity) {
opportunity.setCreateBy(getUser().getUserId());
return opportunityService.insert(opportunity);
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
@ResponseBody
public PageInfo<Opportunity> find(@RequestBody QueryOpportunityVo vo) {
List<Integer> subordinate = orgUnitService.findSubordinate(getUser().getUserId());
vo.setUserIdList(subordinate);
return opportunityService.find(vo);
}
@RequestMapping(value = "/detail/{opportunityId}", method = RequestMethod.GET)
public ModelAndView detail(@PathVariable int opportunityId) {
ModelAndView vm = new ModelAndView("crm/opportunityDetail");
vm.addObject("opportunityId", opportunityId);
return vm;
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public Opportunity findById(@RequestBody Opportunity opportunity) {
return opportunityService.findById(opportunity.getOpportunityId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@Controller
@RequestMapping("/district")
public class DistrictController {
@Autowired
private DistrictService districtService;
@RequestMapping(value = "/findAllProvince", method = RequestMethod.POST)
@ResponseBody
public List<District> findAllProvince() {
return districtService.findAllProvince();
}
@RequestMapping(value = "/findCity", method = RequestMethod.POST)
@ResponseBody
public List<District> findCity(@RequestBody int provinceId) {
return districtService.findCity(provinceId);
}
@RequestMapping(value = "/findCounty", method = RequestMethod.POST)
@ResponseBody
public List<District> findCounty(@RequestBody int cityId) {
return districtService.findCounty(cityId);
}
}
return result;
}
@RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
@ResponseBody
public Result updateStatus(@RequestBody User user) {
return userService.updateStatus(user);
}
@RequestMapping(value = "/checkUserName", method = RequestMethod.POST)
@ResponseBody
public Result checkUserName(@RequestBody User user) {
return userService.checkUserName(user);
}
@RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
@ResponseBody
public Result resetPassword(@RequestBody User user) {
return userService.resetPassword(user);
}
@RequestMapping(value = "/profile", method = RequestMethod.GET)
public String profile() {
return "sys/profile";
}
@RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
@ResponseBody
public Result updatePassword(@RequestBody UpdatePasswordVo vo) {
return userService.updatePassword(vo);
}
}
@RequestMapping(value = "/findCity", method = RequestMethod.POST)
@ResponseBody
public List<District> findCity(@RequestBody int provinceId) {
return districtService.findCity(provinceId);
}
@RequestMapping(value = "/findCounty", method = RequestMethod.POST)
@ResponseBody
public List<District> findCounty(@RequestBody int cityId) {
return districtService.findCounty(cityId);
}
}
@Controller
@RequestMapping("/fun")
public class FunController {
@Autowired
private FunService funService;
@RequestMapping(value = "/findAll", method = RequestMethod.POST)
@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"));
}
}
List<Integer> subordinate = orgUnitService.findSubordinate(getUser().getUserId());
vo.setUserIdList(subordinate);
return opportunityService.find(vo);
}
@RequestMapping(value = "/detail/{opportunityId}", method = RequestMethod.GET)
public ModelAndView detail(@PathVariable int opportunityId) {
ModelAndView vm = new ModelAndView("crm/opportunityDetail");
vm.addObject("opportunityId", opportunityId);
return vm;
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public Opportunity findById(@RequestBody Opportunity opportunity) {
return opportunityService.findById(opportunity.getOpportunityId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody Opportunity opportunity) {
return opportunityService.update(opportunity);
}
@RequestMapping(value = "/addContactsRole", method = RequestMethod.POST)
@ResponseBody
public Result addContactsRole(@RequestBody ContactsRole contactsRole) {
return opportunityService.insertContactsRole(contactsRole);
}
@RequestMapping(value = "/updateContactsRole", method = RequestMethod.POST)
@ResponseBody
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);
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);
Field field = fields.get(j);
Class<?> fieldType = field.getType();
if (fieldType == String.class) {
cell.setCellValue(field.get(item).toString());
} else if (fieldType == int.class) {
cell.setCellValue(field.getInt(item));
} else if (fieldType == double.class) {
cell.setCellValue(field.getDouble(item));
} else if (fieldType == float.class) {
cell.setCellValue(field.getFloat(item));
} else if (fieldType == boolean.class) {
cell.setCellValue(field.getBoolean(item));
} else if (fieldType == byte.class) {
cell.setCellValue(field.getByte(item));
} else if (fieldType == long.class) {
cell.setCellValue(field.getLong(item));
} else if (fieldType == short.class) {
cell.setCellValue(field.getShort(item));
} else if (fieldType == char.class) {
cell.setCellValue(field.getChar(item));
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
@ResponseBody
public PageInfo<Opportunity> find(@RequestBody QueryOpportunityVo vo) {
List<Integer> subordinate = orgUnitService.findSubordinate(getUser().getUserId());
vo.setUserIdList(subordinate);
return opportunityService.find(vo);
}
@RequestMapping(value = "/detail/{opportunityId}", method = RequestMethod.GET)
public ModelAndView detail(@PathVariable int opportunityId) {
ModelAndView vm = new ModelAndView("crm/opportunityDetail");
vm.addObject("opportunityId", opportunityId);
return vm;
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public Opportunity findById(@RequestBody Opportunity opportunity) {
return opportunityService.findById(opportunity.getOpportunityId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody Opportunity opportunity) {
return opportunityService.update(opportunity);
}
@RequestMapping(value = "/addContactsRole", method = RequestMethod.POST)
@ResponseBody
public Result addContactsRole(@RequestBody ContactsRole contactsRole) {
return opportunityService.insertContactsRole(contactsRole);
}
@RequestMapping(value = "/updateContactsRole", method = RequestMethod.POST)
@ResponseBody
public Result updateContactsRole(@RequestBody ContactsRole contactsRole) {
return opportunityService.updateContactsRole(contactsRole);
}
}
@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 Result delete(@RequestBody List<Integer> ids) {
return userService.deleteByIds(ids);
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public User findById(@RequestBody User user) {
return userService.findById(user.getUserId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody User user) {
Result result = userService.update(user);
if (result.isSuccess() && user.getUserId() == getUser().getUserId()) {
session.setAttribute("User", userService.findById(getUser().getUserId()));
}
return result;
}
@RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
@ResponseBody
public Result updateStatus(@RequestBody User user) {
return userService.updateStatus(user);
}
@RequestMapping(value = "/checkUserName", method = RequestMethod.POST)
@ResponseBody
public Result checkUserName(@RequestBody User user) {
return userService.checkUserName(user);
}
@RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
@ResponseBody
public Result resetPassword(@RequestBody User user) {
return userService.resetPassword(user);
}
vm.addObject("opportunityId", opportunityId);
return vm;
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public Opportunity findById(@RequestBody Opportunity opportunity) {
return opportunityService.findById(opportunity.getOpportunityId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody Opportunity opportunity) {
return opportunityService.update(opportunity);
}
@RequestMapping(value = "/addContactsRole", method = RequestMethod.POST)
@ResponseBody
public Result addContactsRole(@RequestBody ContactsRole contactsRole) {
return opportunityService.insertContactsRole(contactsRole);
}
@RequestMapping(value = "/updateContactsRole", method = RequestMethod.POST)
@ResponseBody
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)
@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 = "/findById", method = RequestMethod.POST)
@ResponseBody
public Customer findById(@RequestBody Customer customer) {
return customerService.findById(customer.getCustomerId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody Customer customer) {
return customerService.update(customer);
}
@RequestMapping(value = "/dashboard/{customerId}", method = RequestMethod.GET)
public ModelAndView dashboard(@PathVariable int customerId) {
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);
}
}
return opportunityService.insertContactsRole(contactsRole);
}
@RequestMapping(value = "/updateContactsRole", method = RequestMethod.POST)
@ResponseBody
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<>();
@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());
return contactsService.insert(contacts);
}
@RequestMapping(value = "/find", method = RequestMethod.POST)
@ResponseBody
public PageInfo<Contacts> find(@RequestBody QueryContactsVo vo) {
return contactsService.find(vo);
}
@RequestMapping(value = "/findById", method = RequestMethod.POST)
@ResponseBody
public Contacts findById(@RequestBody Contacts contacts) {
return contactsService.findById(contacts.getContactsId());
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody Contacts contacts) {
return contactsService.update(contacts);
}
}
@RequestMapping(value = "/findCity", method = RequestMethod.POST)
@ResponseBody
public List<District> findCity(@RequestBody int provinceId) {
return districtService.findCity(provinceId);
}
@RequestMapping(value = "/findCounty", method = RequestMethod.POST)
@ResponseBody
public List<District> findCounty(@RequestBody int cityId) {
return districtService.findCounty(cityId);
}
}
@Controller
@RequestMapping("/fun")
public class FunController {
@Autowired
private FunService funService;
@RequestMapping(value = "/findAll", method = RequestMethod.POST)
@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)