项目介绍
- 企业的销售要进行培训,由技术人员进行辅导并考评检测培训效果,所以有了这个小系统。
- 实现了系统的登录验证、请求拦截验证、基础模块(用户管理、角色管理、销售管理)、业务模块(评分管理、评分结果)。
- 除了基本的CRUD之外,其中评分结果模块实现了数据可视化及图表的联动。
主要角色有管理员、销售、评委
环境要求
1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat7.x,8.X,9.x版本均可
4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;
5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目
6.数据库:MySql5.7/8.0等版本均可;
技术栈
- 技术框架:jQuery + MySQL5.7 + mybatis + shiro + Layui + HTML + CSS + JS + jpa
- 运行环境:jdk8 + IntelliJ IDEA + maven3 + mariaDB
使用说明
1.使用Navicati或者其它工具,在mysql中创建对应sq文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;
运行指导
idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:
http://mtw.so/5MHvZq
源码地址:http://codegym.top。
运行截图
界面
代码
UserController
package cn.temptation.web;import cn.temptation.dao.RoleDao;
import cn.temptation.dao.UserDao;
import cn.temptation.domain.Role;
import cn.temptation.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Controller
public class UserController {@Autowiredprivate UserDao userDao;@Autowiredprivate RoleDao roleDao;@RequestMapping("/user")public String index() {return "user";}@RequestMapping("/user_list")@ResponseBodypublic Map<String, Object> userList(@RequestParam Map<String, Object> queryParams) {Map<String, Object> result = new HashMap<>();try {Integer page = Integer.parseInt(queryParams.get("page").toString());Integer limit = Integer.parseInt(queryParams.get("limit").toString());String condition = (String) queryParams.get("condition");String keyword = (String) queryParams.get("keyword");// 创建查询规格对象Specification<User> specification = (Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {Predicate predicate = null;Path path = null;if (condition != null && !"".equals(condition) && keyword != null && !"".equals(keyword)) {switch (condition) {case "username": // 用户名称path = root.get("username");predicate = cb.like(path, "%" + keyword + "%");break;case "rolename": // 角色名称path = root.join("role", JoinType.INNER);predicate = cb.like(path.get("rolename"), "%" + keyword + "%");break;}}return predicate;};Pageable pageable = PageRequest.of(page - 1, limit, Sort.Direction.ASC, "userid");Page<User> users = userDao.findAll(specification, pageable);result.put("code", 0);result.put("msg", "查询OK");result.put("count", users.getTotalElements());result.put("data", users.getContent());} catch (Exception e) {e.printStackTrace();result.put("code", 500);result.put("msg", "服务器内部错误");result.put("count", 0);result.put("data", new ArrayList());}return result;}@RequestMapping("/user_delete")@ResponseBodypublic Integer userDelete(@RequestParam String userid) {try {userDao.deleteById(Integer.parseInt(userid));return 0;} catch (Exception e) {e.printStackTrace();}return -1;}@RequestMapping("/user_view")public String view(Integer userid, Model model) {User user = new User();if (userid != null) {user = userDao.getOne(userid);}model.addAttribute("user", user);return "user_view";}@RequestMapping("/role_load")@ResponseBodypublic List<Role> roleList() {return roleDao.findAll();}@RequestMapping("/user_update")@ResponseBodypublic Integer userUpdate(User user) {try {userDao.save(user);return 0;} catch (Exception e) {e.printStackTrace();}return -1;}
}
ScoreController
package cn.temptation.web;import cn.temptation.dao.SalesDao;
import cn.temptation.dao.ScoreDao;
import cn.temptation.domain.Sales;
import cn.temptation.domain.Score;
import cn.temptation.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import javax.persistence.criteria.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Controller
public class ScoreController {@Autowiredprivate ScoreDao scoreDao;@Autowiredprivate SalesDao salesDao;@RequestMapping("/score")public String index() {return "score";}@RequestMapping("/score_list")@ResponseBodypublic Map<String, Object> scoreList(@RequestParam Map<String, Object> queryParams, HttpServletRequest request) {Map<String, Object> result = new HashMap<>();try {HttpSession session = request.getSession();User user = (User) session.getAttribute("user");Integer page = Integer.parseInt(queryParams.get("page").toString());Integer limit = Integer.parseInt(queryParams.get("limit").toString());String condition = (String) queryParams.get("condition");String keyword = (String) queryParams.get("keyword");// 创建查询规格对象Specification<Score> specification = (Root<Score> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {Predicate predicate = null;Path path = null;// 从session中取出当前用户信息,获取该用户创建的数据if (null != user) {path = root.join("user", JoinType.INNER);predicate = cb.equal(path.get("userid"), user.getUserid());}if (condition != null && !"".equals(condition) && keyword != null && !"".equals(keyword)) {switch (condition) {case "salesname": // 销售名称path = root.join("sales", JoinType.INNER);predicate = cb.like(path.get("salesname"), "%" + keyword + "%");break;}}return predicate;};Pageable pageable = PageRequest.of(page - 1, limit, Sort.Direction.ASC, "scoreid");Page<Score> scores = scoreDao.findAll(specification, pageable);result.put("code", 0);result.put("msg", "查询OK");result.put("count", scores.getTotalElements());result.put("data", scores.getContent());} catch (Exception e) {e.printStackTrace();result.put("code", 500);result.put("msg", "服务器内部错误");result.put("count", 0);result.put("data", new ArrayList());}return result;}@RequestMapping("/score_delete")@ResponseBodypublic Integer scoreDelete(@RequestParam String scoreid) {try {scoreDao.deleteById(Integer.parseInt(scoreid));return 0;} catch (Exception e) {e.printStackTrace();}return -1;}@RequestMapping("/score_view")public String view(Integer scoreid, Model model) {Score score = new Score();if (scoreid != null) {score = scoreDao.findByScoreid(scoreid);}model.addAttribute("score", score);return "score_view";}@RequestMapping("/sales_load")@ResponseBodypublic List<Sales> salesList() {return salesDao.findAll();}@RequestMapping("/score_update")@ResponseBodypublic Integer scoreUpdate(Score score, HttpServletRequest request) {try {HttpSession session = request.getSession();User user = (User) session.getAttribute("user");if (null != user) {score.setUser(user);}scoreDao.save(score);return 0;} catch (Exception e) {e.printStackTrace();}return -1;}
}