作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目分为前后台,前台为普通用户登录,后台为管理员登录;
管理员角色:
管理员登录,新增管理员信息,查看管理员信息,查询管理员信息,查看用户信息列表,查询用户信息,新增新闻公告,查看新闻公告,查询新闻公告,新增配件类型,查看配件类型,查询配件类型,新增城市信息,查看城市信息,查询城市信息,新增维修站信息,查看维修站信息,查询维修站信息,新增配件商品,查看配件商品,查询配件商品,查看订单信息,查询订单信息,查看评价信息,查询评价信息等功能。
用户角色包含以下功能:
用户登录,查看首页,查看商品详情,提交预约,下订单,查看我的订单,查看公告,查看维修站,修改个人信息等功能。
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项目:否;
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
用户账号/密码: user/123456
管理员账号/密码:admin/admin
- /定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/topic" , produces = "text/plain;charset=utf-8")
- public class TopicAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private TopicService topicService;
- @Autowired
- @Resource
- private UsersService usersService;
- @Autowired
- @Resource
- private JiancaiService jiancaiService;
-
- // 准备添加数据
- @RequestMapping("createTopic.action")
- public String createTopic() {
- List
usersList = this.usersService.getAllUsers(); - this.getRequest().setAttribute("usersList", usersList);
- List
jiancaiList = this.jiancaiService.getAllJiancai(); - this.getRequest().setAttribute("jiancaiList", jiancaiList);
- return "admin/addtopic";
- }
- // 添加数据
- @RequestMapping("addTopic.action")
- public String addTopic(Topic topic) {
- this.topicService.insertTopic(topic);
- return "redirect:/topic/createTopic.action";
- }
-
- // 通过主键删除数据
- @RequestMapping("deleteTopic.action")
- public String deleteTopic(String id) {
- this.topicService.deleteTopic(id);
- return "redirect:/topic/getAllTopic.action";
- }
-
- // 批量删除数据
- @RequestMapping("deleteTopicByIds.action")
- public String deleteTopicByIds() {
- String[] ids = this.getRequest().getParameterValues("topicid");
- for (String topicid : ids) {
- this.topicService.deleteTopic(topicid);
- }
- return "redirect:/topic/getAllTopic.action";
- }
-
- // 更新数据
- @RequestMapping("updateTopic.action")
- public String updateTopic(Topic topic) {
- this.topicService.updateTopic(topic);
- return "redirect:/topic/getAllTopic.action";
- }
- // 显示全部数据
- @RequestMapping("getAllTopic.action")
- public String getAllTopic(String number) {
- List
topicList = this.topicService.getAllTopic(); - PageHelper.getPage(topicList, "topic", null, null, 10, number, this.getRequest(), null);
- return "admin/listtopic";
- }
-
- // 按条件查询数据 (模糊查询)
- @RequestMapping("queryTopicByCond.action")
- public String queryTopicByCond(String cond, String name, String number) {
- Topic topic = new Topic();
- if(cond != null){
- if ("username".equals(cond)) {
- topic.setUsername(name);
- }
- if ("jiancainame".equals(cond)) {
- topic.setJiancainame(name);
- }
- if ("num".equals(cond)) {
- topic.setNum(name);
- }
- if ("contents".equals(cond)) {
- topic.setContents(name);
- }
- if ("addtime".equals(cond)) {
- topic.setAddtime(name);
- }
- }
-
- List
nameList = new ArrayList(); - List
valueList = new ArrayList(); - nameList.add(cond);
- valueList.add(name);
- PageHelper.getPage(this.topicService.getTopicByLike(topic), "topic", nameList, valueList, 10, number, this.getRequest(), "query");
- name = null;
- cond = null;
- return "admin/querytopic";
- }
-
- // 按主键查询数据
- @RequestMapping("getTopicById.action")
- public String getTopicById(String id ) {
- Topic topic = this.topicService.getTopicById(id);
- this.getRequest().setAttribute("topic", topic);
- List
usersList = this.usersService.getAllUsers(); - this.getRequest().setAttribute("usersList", usersList);
- List
jiancaiList = this.jiancaiService.getAllJiancai(); - this.getRequest().setAttribute("jiancaiList", jiancaiList);
- return "admin/edittopic";
- }
-
- public TopicService getTopicService() { return topicService; }
-
- public void setTopicService(TopicService topicService) { this.topicService = topicService; }
-
- }
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/city", produces = "text/plain;charset=utf-8")
- public class CityAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private CityService cityService;
-
- // 准备添加数据
- @RequestMapping("createCity.action")
- public String createCity() {
- return "admin/addcity";
- }
-
- // 添加数据
- @RequestMapping("addCity.action")
- public String addCity(City city) {
- this.cityService.insertCity(city);
- return "redirect:/city/createCity.action";
- }
-
- // 通过主键删除数据
- @RequestMapping("deleteCity.action")
- public String deleteCity(String id) {
- this.cityService.deleteCity(id);
- return "redirect:/city/getAllCity.action";
- }
-
- // 批量删除数据
- @RequestMapping("deleteCityByIds.action")
- public String deleteCityByIds() {
- String[] ids = this.getRequest().getParameterValues("cityid");
- for (String cityid : ids) {
- this.cityService.deleteCity(cityid);
- }
- return "redirect:/city/getAllCity.action";
- }
-
- // 更新数据
- @RequestMapping("updateCity.action")
- public String updateCity(City city) {
- this.cityService.updateCity(city);
- return "redirect:/city/getAllCity.action";
- }
-
- // 显示全部数据
- @RequestMapping("getAllCity.action")
- public String getAllCity(String number) {
- List
cityList = this.cityService.getAllCity(); - PageHelper.getPage(cityList, "city", null, null, 10, number, this.getRequest(), null);
- return "admin/listcity";
- }
-
- // 按条件查询数据 (模糊查询)
- @RequestMapping("queryCityByCond.action")
- public String queryCityByCond(String cond, String name, String number) {
- City city = new City();
- if (cond != null) {
- if ("cityname".equals(cond)) {
- city.setCityname(name);
- }
- }
-
- List
nameList = new ArrayList(); - List
valueList = new ArrayList(); - nameList.add(cond);
- valueList.add(name);
- PageHelper.getPage(this.cityService.getCityByLike(city), "city", nameList, valueList, 10, number, this.getRequest(), "query");
- name = null;
- cond = null;
- return "admin/querycity";
- }
-
- // 按主键查询数据
- @RequestMapping("getCityById.action")
- public String getCityById(String id) {
- City city = this.cityService.getCityById(id);
- this.getRequest().setAttribute("city", city);
- return "admin/editcity";
- }
-
- public CityService getCityService() {
- return cityService;
- }
-
- public void setCityService(CityService cityService) {
- this.cityService = cityService;
- }
-
- }
如果也想学习本系统,下面领取。关注并回复:074ssm