基于javaweb+mysql的ssm超市管理系统(java+ssm+jsp+javascript+jquery+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM超市管理系统(java+ssm+jsp+javascript+jquery+mysql)
管理员
admin 123456
库管员
kg 123456
项目介绍
本项目主要分为管理员和库管员两种角色; 管理员主要功能包括: 管理员:首页、用户信息管理、工作人员管理、分类信息管理、客户信息管理、供应商信息管理、商品信息管理、采购入库管理、销售出库管理、库存信息管理; 库管员:首页、用户信息管理、商品信息管理、采购入库管理、销售出库管理、库存信息管理;
环境需要
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.是否Maven项目: 否; 6.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:JSP+CSS+Javascript+JQUERY+H-ui
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置,然后运行; 4. 运行成功后,在浏览器中输入:http://localhost:8080/jxcs/ 管理员:admin 密码:111 库管员:kg 密码:111
public String addMethod(HttpServletRequest request, Kf kf) {
String method = request.getParameter("method");
if(method.equals("addkf")){
String mc=kf.getMc();
String str = kfService.getSame(mc);
if(str==null) {
int flag = kfService.insertSelective(kf);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
else {//修改
String str = kfService.upgetSame(kf);
if(str==null) {
int flag = kfService.updateByPrimaryKeySelective(kf);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = kfService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
return "admin/ck/add";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/ck/add";
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = ckService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/ck/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/ck/index";
}
}
@RequestMapping("batchDel") //批量删除
public String batchDel(HttpServletRequest request) {
String chk_list[] = request.getParameterValues("chk_list");
for(int i=0;i<chk_list.length;i++){
ckService.deleteByPrimaryKey(Integer.parseInt(chk_list[i]));
}
request.setAttribute("message", "操作成功!");
return "admin/ck/index";
}
}
/**
* 接收处理转发供应商页面数据
*/
@Controller
@RequestMapping("/gy")
public class GyController {
@Autowired
}
}
@RequestMapping("/addAdmin") //增加用户
public String addMethod(HttpServletRequest request, Admin admin) {
String method = request.getParameter("method");
if(method.equals("addm")){
String username=admin.getUsername();
String str = adminService.getSame(username);
if(str==null) {
admin.setAddtime(date);
int flag = adminService.insertSelective(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/system/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/system/index";
}
}
else {//修改用户
String str = adminService.upgetSame(admin);
if(str==null) {
admin.setAddtime(date);
int flag = adminService.updateByPrimaryKeySelective(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/system/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/system/index";
}
}
}
@RequestMapping("/updateAdmin") //修改用户
}
@RequestMapping("batchDel") //批量删除
public String batchDel(HttpServletRequest request) {
String chk_list[] = request.getParameterValues("chk_list");
for(int i=0;i<chk_list.length;i++){
kfService.deleteByPrimaryKey(Integer.parseInt(chk_list[i]));
}
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
}
/**
* 入库数据 接收处理转发
*/
@Controller
@RequestMapping("/rk")
public class RkController {
@Autowired
private RkService rkService;
@RequestMapping("/addMethod") //增加
public String addMethod(HttpServletRequest request, Rk rk) {
String method = request.getParameter("method");
if(method.equals("addrk")){
String rkbh=rk.getRkbh();
String str = rkService.getSame(rkbh);
if(str==null) {
int flag = rkService.insertSelective(rk);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/rk/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/rk/index";
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
else {//修改
String str = kfService.upgetSame(kf);
if(str==null) {
int flag = kfService.updateByPrimaryKeySelective(kf);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = kfService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
@RequestMapping("batchDel") //批量删除
@Controller
@RequestMapping("/admin")
public class AdminController {
String date=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
//String date2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
@Autowired
private AdminService adminService;
@RequestMapping("/toLogin")
public String toLogin(HttpServletRequest request,Model model) {
request.removeAttribute("message");
HttpSession session = request.getSession();
String user = (String)session.getAttribute("user");
if(user==null){
return "index";
}
else{
return "admin/index";
}
}
@RequestMapping("/addAdmin") //增加用户
public String addMethod(HttpServletRequest request, Admin admin) {
String method = request.getParameter("method");
if(method.equals("addm")){
String username=admin.getUsername();
String str = adminService.getSame(username);
if(str==null) {
admin.setAddtime(date);
int flag = adminService.insertSelective(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/system/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/system/index";
if(str==null) {
int flag = gyService.insertSelective(gy);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
// 1. 调用gyService的upgetSame方法,将返回结果存储到str字符串中。
// 2. 判断str是否为null,如果为null则表示不存在相同信息,执行下一步,否则直接返回信息重复提示。
// 3. 调用gyService的updateByPrimaryKeySelective方法进行更新操作,将返回结果存储到flag中。
// 4. 判断flag是否等于1,如果等于1则表示更新成功,设置成功提示信息,返回到管理员页面,否则设置失败提示信息,返回到管理员页面。
else {//修改
String str = gyService.upgetSame(gy);
if(str==null) {
int flag = gyService.updateByPrimaryKeySelective(gy);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = gyService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
// 4. 判断flag是否等于1,如果等于1则表示更新成功,设置成功提示信息,返回到管理员页面,否则设置失败提示信息,返回到管理员页面。
else {//修改
String str = gyService.upgetSame(gy);
if(str==null) {
int flag = gyService.updateByPrimaryKeySelective(gy);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = gyService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
@RequestMapping("batchDel") //批量删除
public String batchDel(HttpServletRequest request) {
String chk_list[] = request.getParameterValues("chk_list");
for(int i=0;i<chk_list.length;i++){
gyService.deleteByPrimaryKey(Integer.parseInt(chk_list[i]));
}
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
}
/**
* 产品数据 接收处理转发
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
// 1. 调用gyService的upgetSame方法,将返回结果存储到str字符串中。
// 2. 判断str是否为null,如果为null则表示不存在相同信息,执行下一步,否则直接返回信息重复提示。
// 3. 调用gyService的updateByPrimaryKeySelective方法进行更新操作,将返回结果存储到flag中。
// 4. 判断flag是否等于1,如果等于1则表示更新成功,设置成功提示信息,返回到管理员页面,否则设置失败提示信息,返回到管理员页面。
else {//修改
String str = gyService.upgetSame(gy);
if(str==null) {
int flag = gyService.updateByPrimaryKeySelective(gy);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = gyService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
@RequestMapping("batchDel") //批量删除
public String batchDel(HttpServletRequest request) {
String chk_list[] = request.getParameterValues("chk_list");
for(int i=0;i<chk_list.length;i++){
gyService.deleteByPrimaryKey(Integer.parseInt(chk_list[i]));
}
request.setAttribute("message", "操作成功!");
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = cpService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/cp/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/cp/index";
}
}
@RequestMapping("batchDel") //批量删除
public String batchDel(HttpServletRequest request) {
String chk_list[] = request.getParameterValues("chk_list");
for(int i=0;i<chk_list.length;i++){
cpService.deleteByPrimaryKey(Integer.parseInt(chk_list[i]));
}
request.setAttribute("message", "操作成功!");
return "admin/cp/index";
}
}
/**
* 接收分类信息页面数据 处理 转发
*/
@Controller
@RequestMapping("/fl")
public class FlController {
@Autowired
private FlService flService;
@RequestMapping("/addMethod") //增加
public String addMethod(HttpServletRequest request, Fl fl) {
String method = request.getParameter("method");
if(method.equals("addfl")){
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
// 1. 调用gyService的upgetSame方法,将返回结果存储到str字符串中。
// 2. 判断str是否为null,如果为null则表示不存在相同信息,执行下一步,否则直接返回信息重复提示。
// 3. 调用gyService的updateByPrimaryKeySelective方法进行更新操作,将返回结果存储到flag中。
// 4. 判断flag是否等于1,如果等于1则表示更新成功,设置成功提示信息,返回到管理员页面,否则设置失败提示信息,返回到管理员页面。
else {//修改
String str = gyService.upgetSame(gy);
if(str==null) {
int flag = gyService.updateByPrimaryKeySelective(gy);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/gy/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = gyService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/gy/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/gy/index";
}
}
@RequestMapping("batchDel") //批量删除
public String batchDel(HttpServletRequest request) {
String chk_list[] = request.getParameterValues("chk_list");
request.setAttribute("message", "操作成功!");
return "admin/system/index2";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/index2";
}
}
@RequestMapping("/adminupPwd") //用户修改密码
public String adminupPwd(HttpServletRequest request,Admin admin) {
HttpSession session = request.getSession();
String username = (String)session.getAttribute("user");
String oldpwd = request.getParameter("oldpwd");
String newpwd = request.getParameter("newpwd");
admin.setUsername(username);
admin.setPassword(oldpwd);
List<Admin> list = adminService.admincheckPwd(admin);
if(list.size()>0){
admin.setPassword(newpwd);
int flag = adminService.adminupPwd(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/system/pwd";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/pwd";
}
}
else{
request.setAttribute("message", "原始密码错误!");
return "admin/system/pwd";
}
}
@RequestMapping("/adminExit") //退出登录
public String adminExit(HttpServletRequest request){
HttpSession session = request.getSession();
session.removeAttribute("user");
session.removeAttribute("sf");
return "index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
else {//修改
String str = kfService.upgetSame(kf);
if(str==null) {
int flag = kfService.updateByPrimaryKeySelective(kf);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = kfService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
@RequestMapping("batchDel") //批量删除
@Controller
@RequestMapping("/admin")
public class AdminController {
String date=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
//String date2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
@Autowired
private AdminService adminService;
@RequestMapping("/toLogin")
public String toLogin(HttpServletRequest request,Model model) {
request.removeAttribute("message");
HttpSession session = request.getSession();
String user = (String)session.getAttribute("user");
if(user==null){
return "index";
}
else{
return "admin/index";
}
}
@RequestMapping("/addAdmin") //增加用户
public String addMethod(HttpServletRequest request, Admin admin) {
String method = request.getParameter("method");
if(method.equals("addm")){
String username=admin.getUsername();
String str = adminService.getSame(username);
if(str==null) {
admin.setAddtime(date);
int flag = adminService.insertSelective(admin);
admin.setPassword(oldpwd);
List<Admin> list = adminService.admincheckPwd(admin);
if(list.size()>0){
admin.setPassword(newpwd);
int flag = adminService.adminupPwd(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/system/pwd";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/pwd";
}
}
else{
request.setAttribute("message", "原始密码错误!");
return "admin/system/pwd";
}
}
@RequestMapping("/adminExit") //退出登录
public String adminExit(HttpServletRequest request){
HttpSession session = request.getSession();
session.removeAttribute("user");
session.removeAttribute("sf");
return "index";
}
}
/**
* 出库数据接收 处理转发
*/
private KfService kfService;
@RequestMapping("/addMethod") //增加
public String addMethod(HttpServletRequest request, Kf kf) {
String method = request.getParameter("method");
if(method.equals("addkf")){
String mc=kf.getMc();
String str = kfService.getSame(mc);
if(str==null) {
int flag = kfService.insertSelective(kf);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
else {//修改
String str = kfService.upgetSame(kf);
if(str==null) {
int flag = kfService.updateByPrimaryKeySelective(kf);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/kf/index";
}
}
}
@RequestMapping("/del/{id}") //删除
public String deleteMethod(HttpServletRequest request, @PathVariable("id") int id) {
int flag = kfService.deleteByPrimaryKey(id);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/kf/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/kf/index";
HttpSession session = request.getSession();
List<Admin> list = adminService.adminLogin(admin);
if(list.size()>0){
session.setAttribute("user",admin.getUsername());
session.setAttribute("sf",admin.getSf());
return "admin/index";
}
else{
request.setAttribute("message", "登录信息错误!");
return "index";
}
}
@RequestMapping("/adminupdateByUsername") //用户修改个人信息
public String adminupdateByUsername(HttpServletRequest request, Admin admin) {
HttpSession session = request.getSession();
String username = (String)session.getAttribute("user");
admin.setUsername(username);
int flag = adminService.adminupdateByUsername(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/system/index2";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/system/index2";
}
}
@RequestMapping("/adminupPwd") //用户修改密码
public String adminupPwd(HttpServletRequest request,Admin admin) {
HttpSession session = request.getSession();
String username = (String)session.getAttribute("user");
String oldpwd = request.getParameter("oldpwd");
String newpwd = request.getParameter("newpwd");
admin.setUsername(username);
admin.setPassword(oldpwd);
List<Admin> list = adminService.admincheckPwd(admin);
if(list.size()>0){
admin.setPassword(newpwd);
int flag = adminService.adminupPwd(admin);
if(flag==1){
request.setAttribute("message", "操作成功!");
private RkService rkService;
@RequestMapping("/addMethod") //增加
public String addMethod(HttpServletRequest request, Rk rk) {
String method = request.getParameter("method");
if(method.equals("addrk")){
String rkbh=rk.getRkbh();
String str = rkService.getSame(rkbh);
if(str==null) {
int flag = rkService.insertSelective(rk);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/rk/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/rk/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/rk/index";
}
}
else {//修改
String str = rkService.upgetSame(rk);
if(str==null) {
int flag = rkService.updateByPrimaryKeySelective(rk);
if(flag==1){
request.setAttribute("message", "操作成功!");
return "admin/rk/index";
}
else{
request.setAttribute("message", "操作失败!");
return "admin/rk/index";
}
}
else{
request.setAttribute("message", "信息重复!");
return "admin/rk/index";
}