作者主页:源码空间站2022
简介: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. 后端:mysql+Spring+hibernate+spring mcv
2. 前端:JSP+css+javascript+bootstrap+jQuery+easyui+echarts
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
管理员账号密码:admin/123456
销售人员账号密码:user/123456
运行截图
管理员角色
销售角色
相关代码
登录Action
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends ActionSupport {
//============依赖注入start================
@Autowired
private ManageService manageService;//管理
@Autowired
private UserService userService;//用户
//===========依赖注入end==================
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
private Integer role;
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
private String userName;//用户名
private String passWord;//密码
private String code;//统一社会信用代码:
private Integer type;//1新型材料、2生物医药、3富硒食品、4安康丝绸、5清洁能源、6装备制造
private String zczb;//注册资本
private String name;//企业名称
private String djjg;//登记机关
private String address;//地址
private String fr;//法定代表人
private String info;//企业简介包含 经营内容和数据分析
private Integer isSh;//是否审核 0否 1是
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getZczb() {
return zczb;
}
public void setZczb(String zczb) {
this.zczb = zczb;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDjjg() {
return djjg;
}
public void setDjjg(String djjg) {
this.djjg = djjg;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getFr() {
return fr;
}
public void setFr(String fr) {
this.fr = fr;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public Integer getIsSh() {
return isSh;
}
public void setIsSh(Integer isSh) {
this.isSh = isSh;
}
//============文件上传start=============
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=============
//-------------------------华丽分割线---------------------------------------------
public String login() {
return "login";
}
public String home() {
return "success";
}
//登录
public String toLogin(){
if(role==2){//销售
String hql = "from User where userName = :userName and passWord = :passWord and isDelete = 0 ";
Map<String,Object> alias = new HashMap<String,Object>();
alias.put("userName",userName);
alias.put("passWord", passWord);
List<User> userList= userService.getByHQL(hql, alias);
if(userList.size()>0){
//将用户信息放入session
HttpSession session = ServletActionContext.getRequest()
.getSession();
session.setAttribute("userId",userList.get(0).getId() );
session.setAttribute("user", userList.get(0));
session.setAttribute("role", 1);
return "index";
}else{
return "login";
}
}else{
String hql = "from Manage where name = :userName and passWord = :passWord";
Map<String,Object> alias = new HashMap<String,Object>();
alias.put("userName",userName);
alias.put("passWord", passWord);
List<Manage> manageList=manageService.getByHQL(hql, alias);
if(manageList.size()>0){
//将用户信息放入session
HttpSession session = ServletActionContext.getRequest()
.getSession();
session.setAttribute("role", 2);
session.setAttribute("userName", manageList.get(0).getRealName());
session.setAttribute("userId2",manageList.get(0).getId() );
session.setAttribute("manage", manageList.get(0));
session.setAttribute("roleId", role);
return "index";
}else{
return "login";
}
}
}
管理Action
@Controller("manageAction")
@Scope("prototype")
public class ManageAction extends ActionSupport implements ModelDriven<Manage>{
private static final long serialVersionUID = 1L;
//==========model==============
private Manage manage;
@Override
public Manage getModel() {
if(manage==null) manage = new Manage();
return manage;
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private ManageService manageService;
//依赖注入 end dao/service/===
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
* private String name;
private String passWord;
private String realName;//真实名
private int type;//管理员类型 1 是超级管理员 2 是普通管理员
*/
public String manage(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from Manage where 1=1 and type = 2");
if(manage!=null && manage.getName() !=null && !"".equals(manage.getName())){
sb.append(" and name like :name");
alias.put("name", "%" +manage.getName()+ "%");
}
sb = sb.append(" order by id desc");
Pager<Manage> pagers = manageService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("Manage", manage);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
/**
* 执行添加
* @return
*/
public String exAdd(){
manage.setType(2);
manageService.save(manage);
ActionContext.getContext().put("url", "/manage_manage.do");
return "redirect";
}
用户Action
@Controller("userAction")
@Scope("prototype")
public class UserAction extends ActionSupport implements ModelDriven<User>{
private static final long serialVersionUID = 1L;
//==========model==============
private User user;
@Override
public User getModel() {
if(user==null) user = new User();
return user;
}
//==========model==============
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private UserService userService;
//依赖注入 end dao/service/===
//-------------------------华丽分割线---------------------------------------------
//============自定义参数start=============
//============自定义参数end=============
//-------------------------华丽分割线---------------------------------------------
//============文件上传start=======================================================
private File file;
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//============文件上传end=========================================================
//-------------------------华丽分割线---------------------------------------------//
//=============公=======共=======方=======法==========区=========start============//
/**
* 列表分页查询
*/
public String user(){
Map<String,Object> alias = new HashMap<String,Object>();
StringBuffer sb = new StringBuffer();
sb = sb.append("from User where 1=1 and isDelete = 0 ");
if(user!=null && user.getRealName() !=null && !"".equals(user.getRealName())){
sb.append(" and realName like :realName ");
alias.put("realName", "%" +user.getRealName()+ "%" );
}
sb = sb.append("order by id desc");
Pager<User> pagers = userService.findByAlias(sb.toString(),alias);
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("User", user);
return SUCCESS;
}
/**
* 跳转到添加页面
* @return
*/
public String add(){
return SUCCESS;
}
如果也想学习本系统,下面领取。回复:074ssh