环境:开发工具:idea,数据库:MySQL5.7 jdk1.8
架构:springMVC,前端jsp
主要功能
管理员:用户管理、角色管理、资源管理等;
前台接待:工单处理、历史查询、汽车档案、配件基础数据、客户资料等;
仓库管理员:配件采购、配件出库、库存管理;
部分代码:
package com.zou.controller;
import com.zou.bean.CarInfo;
import com.zou.service.CarInfoService;
import com.zou.service.ClientService;
import com.zou.utils.TableConvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.Map;
/** 汽车表控制层 */
@Controller
@RequestMapping("/car")
public class CarController {
// 创建汽车业务层对象
@Autowired private CarInfoService carService;
// 创建客户服务层对象
@Autowired private ClientService cliService;
/**
* 更新
*
* @param id
* @param
* @return
*/
@ResponseBody
@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String putResource(@PathVariable int id, @RequestBody CarInfo car) {
// 设置汽车Id
car.setCarId(id);
// 设置客户Id
car.setClientId(cliService.selectId(car.getClientName()));
// 调用更新方法
carService.updateByPrimaryKeySelective(car);
// 返回success
return "success";
}
/**
* 更新前跳转页面
*
* @param id
* @return
*/
@RequestMapping(value = "/jump/{id}", method = RequestMethod.POST)
public ModelAndView jump(
@PathVariable int id, String carBrand, String carNumber, String clientName) {
// 跳转至更新页面,并传递数据
return new ModelAndView("forward:/views-add/car-add.jsp")
.addObject("car", new CarInfo(id, carBrand, carNumber, clientName));
}
/** 新增 */
@ResponseBody
@RequestMapping(value = "/", method = RequestMethod.POST)
public String add(@RequestBody CarInfo car) {
// int i = 1 / 0;
// 设置客户Id
car.setClientId(cliService.selectId(car.getClientName()));
// 插入汽车信息
carService.insertSelective(car);
// 返回success
return "success";
}
/** 删除 */
@ResponseBody
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public String delete(@PathVariable int id) {
// 删除
carService.deleteByPrimaryKey(id);
// 返回success
return "success";
}
/**
* 查询所有汽车信息
*
* @return
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseBody
public List selectAll() {
return carService.selectAll();
}
/**
* 查询所有汽车信息(layui渲染)
*
* @return
*/
@RequestMapping(value = "/2", method = RequestMethod.GET)
@ResponseBody
public Map selectAll2() {
// 调用方法渲染
return TableConvent.toDo(carService.selectAll());
}
}
package com.zou.controller;
import com.zou.bean.RoleInfo;
import com.zou.service.ResourceService;
import com.zou.service.RoleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@Controller
@CrossOrigin
@RequestMapping(value = "/role")
public class RoleController {
// 资源表服务层实例
@Autowired RoleInfoService roleService;
// 角色资源表服务层实例
// @Autowired RoleResourceService roleResService;
// 资源表服务层实例
@Autowired ResourceService resService;
/**
* 更新
*
* @param id
* @param
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String putResource(@PathVariable int id, String roleName, String roleDesc) {
// 更新角色表
roleService.updateByPrimaryKeySelective(new RoleInfo(id, roleName, roleDesc));
// 跳转页面
return "role-list";
}
/**
* 更新前跳转页面
*
* @param id
* @return
*/
@RequestMapping(value = "/jump/{id}", method = RequestMethod.POST)
public ModelAndView postRole2(@PathVariable int id, String roleName, String roleDesc) {
return new ModelAndView("role-add").addObject("role", new RoleInfo(id, roleName, roleDesc));
}
/**
* 新增
*
* @param
* @return
*/
@RequestMapping(value = "/", method = RequestMethod.POST)
public String postResource(String roleName, String roleDesc) {
// 处理POST请求,用来新增
// 插入新的角色
roleService.insertSelective(new RoleInfo(roleName, roleDesc));
// 跳转页面
return "role-list";
}
/**
* 删除
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public String deleteResource(@PathVariable int id) {
// 处理DELETE请求,用来删除Resource
// 执行删除方法
roleService.deleteByPrimaryKey(id);
// 返回数据
return "success";
}
/**
* 查询所有角色信息(不包含资源)
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/", method = RequestMethod.GET)
public List getById() {
return roleService.selectAll();
}
}
获取方式一:点击获取
获取方式二:联系下方名片获取