基于javaweb和mysql的ssh微信小程序果蔬商城管理系统(java+ssh+jsp+javascript+mysql)

私信源码获取及调试交流

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SSH微信小程序果蔬商城管理系统(java+ssh+jsp+javascript+mysql)

管理员(web)端:

http://localhost:8080

admin 123456

用户(小程序)端

1.使用微信开发者工具导入项目

2.导入成功后编译运行

3.运行成功后登录账号:

user1 123456

user2 123456

程序功能:

1.小程序前台:用户注册登录、首页、轮播图、新品推荐、分类、购物车、我的订单。

2.网站后台:管理员登录、用户管理、商品类别管理、商品管理、订单管理、公告管理。

  1. 后端:spring+struts+hibernate

  2. 前端:JSP+css+javascript+jquery

				  alias.put("userName",name);
				  alias.put("passWord", pass);
				List<User> manageList=userService.getByHQL(hql, alias);
				if(manageList.size()>0){
					//将用户信息放入session
					HttpSession session = ServletActionContext.getRequest()
							.getSession();
					session.setAttribute("userName", manageList.get(0).getRealName());
					session.setAttribute("userId",manageList.get(0).getId() );
					session.setAttribute("manage", manageList.get(0));
					session.setAttribute("roleId", role);
					jsonMap.put("result", 1);
					jsonMap.put("userId", manageList.get(0).getId() );
					return "json";
				}else{
					jsonMap.put("result", 2);
					return "json";
				}
				
			}
	       //登录
			public String toLogin(){
						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",  manageList.get(0).getType());
							session.setAttribute("userName", manageList.get(0).getRealName());
							session.setAttribute("userId",manageList.get(0).getId() );
							session.setAttribute("manage", manageList.get(0));
							session.setAttribute("roleId", role);
							return "index";
						}else{
							return "login";
						}
			}
			
			   //退出
				public String tuichu() {
					ActionContext ac = ActionContext.getContext();
					Map session = ac.getSession();
					session.remove("userName");
					session.remove("userId");
					return "login";
				}
				
		
}
		//返回json
		public static final String JSON_TYPE = "json";
		
		//挑转
		public static final String RETIRCT_URL = "redirect";
		
		//chain
		public static final String CHAIN = "chain";

		public Map<String, Object> jsonMap = new HashMap<String, Object>();
		//===================================================================
		public Map<String, Object> getJsonMap() {
			return jsonMap;
		}
	
		public void setJsonMap(Map<String, Object> jsonMap) {
			this.jsonMap = jsonMap;
		}
	//===================================================================
		
			/**
			 * 獲取request
			 * @return
			 */
			public HttpServletRequest getRequest() {
		
				return ServletActionContext.getRequest();
		
			}
		
			/**
			 * 获取response
			 * @return
			 */
			public HttpServletResponse getResponse() {
		
				return ServletActionContext.getResponse();
		
			}
		
			public HttpSession getSession() {
		
				return getRequest().getSession();
		
			}
		
			public ServletContext getServletContext() {
		
				return ServletActionContext.getServletContext();
		
			}
			
			/**
			 * 存值
		if(fileFileName != null){
			   String root  = "D:/my/upload";
		        InputStream is = new FileInputStream(file);
		        fileFileName = UUIDUtils.create()+fileFileName;
		        OutputStream os = new FileOutputStream(new File(root, fileFileName));
		        System.out.println("fileFileName: " + fileFileName);
		        System.out.println("file: " + file.getName());
		        System.out.println("file: " + file.getPath());
		        byte[] buffer = new byte[500];
		        int length = 0;
		        
		        while(-1 != (length = is.read(buffer, 0, buffer.length)))
		        {
		            os.write(buffer);
		        }
		        os.close();
		        is.close();
		        n.setCpUrl("\\upload\\"+fileFileName);
		}
		n.setName(pp.getName());
		ppService.update(n);
		ActionContext.getContext().put("url", "/pp_pp.do?lbId="+lbId);
		return "redirect";
	}
	
	
	/**
	 * 删除
	 * @return
	 */
	public String delete(){
		ppService.delete(pp.getId());
		ActionContext.getContext().put("url", "/pp_pp.do?lbId="+lbId);
		return "redirect";
	}
	
	//=============公=======共=======方=======法==========区=========end============//
	
	 //-------------------------华丽分割线---------------------------------------------//
	
	 //=============自=======定=======义=========方=======法==========区=========start============//
	
	
	
	
	//=============自=======定=======义=========方=======法==========区=========end============//
	 */
	public String userLb(){
		HttpServletRequest request = getRequest();
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
		List<LbDto> lbs = new ArrayList<LbDto>();
		List<Lb> pagers = lbService.listByAlias("from Lb where 1=1 and isDelete = 0",null);
		if(!isEmpty(pagers)){
			for(Lb lb : pagers){
				LbDto ld = new LbDto();
				ld.setLb(lb);
				//查询品牌
				List<Pp> listByAlias = ppService.listByAlias("from Pp where 1=1 and  lb.id="+lb.getId(), null);
				if(!isEmpty(listByAlias)){
					for(Pp p : listByAlias){
						String string = basePath+p.getCpUrl();
						String replaceAll;
						try {
							replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
							p.setCpUrl(replaceAll);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
				}
				ld.setPps(listByAlias);
				lbs.add(ld);
			}
			
		}
		
		jsonMap.put("lbs", lbs);
		return "json";
	}
	
	public String userpp(){
		HttpServletRequest request = getRequest();
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
		List<Pp> listByAlias = ppService.listByAlias("from Pp where 1=1 and  lb.id="+lbId, null);
		if(!isEmpty(listByAlias)){
			for(Pp p : listByAlias){
				String string = basePath+p.getCpUrl();
				String replaceAll;
				try {
					replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends BaseAction {
	//============依赖注入start================
			@Autowired
			private ManageService manageService;//管理
			@Autowired
			private UserService userService;//用户
			@Autowired
		    private NewsService newsService;
			@Autowired
			private GoodsService goodsService;
			//===========依赖注入end==================
			
			//-------------------------华丽分割线---------------------------------------------
			
			//============自定义参数start=============
			private Integer role;
			public Integer getRole() {
				return role;
			}
			public void setRole(Integer role) {
				this.role = role;
			}

			public String getName() {
				return name;
			}
			public void setName(String name) {
				this.name = name;
			}
			public String getPass() {
				return pass;
			}
			public void setPass(String pass) {
				this.pass = pass;
			}
			public String getPhone() {
				return phone;
			}
			public void setPhone(String phone) {
				this.phone = phone;
			}

					List<Car> listByAlias = carService.listByAlias("from Car where goods.id="+Integer.parseInt(split[i]),null );
					if(!isEmpty(listByAlias)){
						carService.delete(listByAlias.get(0).getId());
					}
					ddService.save( d);
				}
			}
			
		}
		
		return "json";
	}
	
	public String userList(){
		HttpServletRequest request = getRequest();
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
		List<DdDto> dds = new ArrayList<DdDto>();
		Map<String,Object> alias = new HashMap<String,Object>();
		StringBuffer sb = new StringBuffer();
		sb = sb.append("from Dd where 1=1 and user.id= "+userId);
		if(dd!=null && dd.getCode() !=null && !"".equals(dd.getCode())){
			sb.append("  and code like :realName ");
			alias.put("realName", "%" +dd.getCode()+ "%" );
		}
		sb = sb.append("order by id desc");
		List<Dd> pagers = ddService.listByAlias(sb.toString(),alias);
		if(!isEmpty(pagers)){
			for(Dd d :pagers){
				DdDto do2 = new DdDto();
				String string = basePath+d.getGoods().getUrl1();
				String replaceAll;
				try {
					replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
					do2.setPpUrl(replaceAll);
					do2.setCode(d.getCode());
					do2.setDdId(d.getId());
					do2.setPrice(String.valueOf(d.getGoods().getPrice()));
					do2.setTitle(d.getGoods().getTitle());
					dds.add(do2);
				} catch (Exception e) {
					// TODO Auto-generated catch block

@Controller("manageAction")
@Scope("prototype")
public class ManageAction extends BaseAction implements ModelDriven<Manage>{
   private Manage manage;
   @Autowired
	private UserService userService;
    @Autowired
   private ManageService manageService;
    private int userId;
    private String userName;
    private int sayId;
    private String new1;
    public String getNew1() {
		return new1;
	}
		return "redirect";
	}
	
	
	/**
	 * 删除
	 * @return
	 */
	public String delete(){
		ppService.delete(pp.getId());
		ActionContext.getContext().put("url", "/pp_pp.do?lbId="+lbId);
		return "redirect";
	}
	
	//=============公=======共=======方=======法==========区=========end============//
	
	 //-------------------------华丽分割线---------------------------------------------//
	
	 //=============自=======定=======义=========方=======法==========区=========start============//
	
	
	
	
	//=============自=======定=======义=========方=======法==========区=========end============//
		
	
	
}

		HttpServletRequest request = getRequest();
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
		if(!isEmpty(gg)){
			for(CarGoods g2 : gg){
				
				String string = basePath+g2.getGoods().getUrl1();
				String replaceAll = null;
				try {
					replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
					g2.getGoods().setUrl1(replaceAll);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		}
		jsonMap.put("listgoods",gg);
		return "json";
	}
	/**
	 * 跳转到添加页面
	 * @return
	 */
	public String add(){
		return SUCCESS;
	}
	
	/**
	 * 执行添加
	 * @return
	 */
	public String exAdd(){
		  
		List<Goods> listByAlias = goodsService.listByAlias("from Car where user.id="+userId+"and goods.id="+goodsId, null);
		if(isEmpty(listByAlias)){
			User user = new User();
			user.setId(userId);
			Goods byId = goodsService.getById(goodsId);
			car.setGoods(byId);
			car.setUser(user);
			carService.save(car);
			
		}
		jsonMap.put("result", 1);
		return "json";
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	@Autowired
	private GoodsService goodsService;
	private Integer goodsId;
	
	//依赖注入 end  dao/service/===
	
	//-------------------------华丽分割线---------------------------------------------
	
	//============自定义参数start=============
	
	//============自定义参数end=============

	
	//-------------------------华丽分割线---------------------------------------------
	
	//============文件上传start=======================================================
	
	
	public Integer getGoodsId() {
		return goodsId;
	}
	public void setGoodsId(Integer goodsId) {
		this.goodsId = goodsId;
	}
	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) {
	
	
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	public String getIds() {
		return ids;
	}
	public void setIds(String ids) {
		this.ids = ids;
	}
	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 jsonAction() {
		  // dataMap中的数据将会被Struts2转换成JSON字符串,所以这里要先清空其中的数据
		  jsonMap.clear();
		  jsonMap.put("success", true);
}

/**
 * @ClassName:  
 * @Description: 
 */

@Controller("ppAction")
@Scope("prototype")

	
	//==========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() {
			public String ulogin() {
				return "success";
			}
			/**
			 * 用户首页
			 * @return
			 */
			public String uIndex() {
				List<Goods> list = goodsService.list();
				HttpServletRequest request = getRequest();
				String path = request.getContextPath();
				String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
				if(!isEmpty(list)){
					for(Goods g : list){
						String string = basePath+g.getUrl1();
						String replaceAll = null;
						try {
							replaceAll = string.replaceAll("\\\\", "/").replaceAll("shop", "");
							g.setUrl1(replaceAll);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						
					}
					
				}
				jsonMap.put("newgoods",list);
				return JSON_TYPE;
			}
			public String home() {
				return "success";
			}
			
			//注册
			public String res() throws UnsupportedEncodingException{
				
				
				User user = new User();
				if(!isEmpty(realName)){
					String str =  URLDecoder.decode((new String(realName.getBytes("ISO8859-1"), "UTF-8")), "UTF-8");
					user.setRealName(str);
			List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
			Map<String, Object> map1 = new HashMap<String, Object>();
			map1.put("NAME", getsy());
			if(users != null && users.size()>0){
				map1.put("TOTAL", users.size());
			}else{
				map1.put("TOTAL", 0);
			}
			
			Map<String, Object> map2 = new HashMap<String, Object>();
			map2.put("NAME", getBy());
			if(users2 != null && users2.size()>0){
				map2.put("TOTAL", users2.size());
			}else{
				map2.put("TOTAL", 0);
			}
			list.add(map1);
			list.add(map2);
			
			 //创建Option
		    GsonOption option = new GsonOption();
		    option.title("发表图片数").tooltip(Trigger.axis).legend("数量(人)");
		    //横轴为值轴
		    option.xAxis(new ValueAxis().boundaryGap(0d, 0.01));
		    //创建类目轴
		    CategoryAxis category = new CategoryAxis();
		    //柱状数据
		    Bar bar = new Bar("月份");
		    //饼图数据
		    Pie pie = new Pie("月份");
		    //循环数据
		    for (Map<String, Object> objectMap : list) {
		        //设置类目
		        category.data(objectMap.get("NAME"));
		        //类目对应的柱状图
		        bar.data(objectMap.get("TOTAL"));
		        //饼图数据
		        pie.data(new PieData(objectMap.get("NAME").toString(), objectMap.get("TOTAL")));
		    }
		    //设置类目轴
		    option.yAxis(category);
		    //饼图的圆心和半径
		    pie.center(900,380).radius(100);
		    //设置数据
		    option.series(bar, pie);
		    //由于药品名字过长,图表距离左侧距离设置180,关于grid可以看ECharts的官方文档
		    option.grid().x(180);
		    //返回Option
		    out = resp.getWriter();
			 out.write(option.toString());
	  */}
	  
	  
	  public String welcome(){

/**
 * @ClassName:  
 * @Description: 
 */

@Controller("userAction")
@Scope("prototype")
public class UserAction extends BaseAction 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/===
	
	//-------------------------华丽分割线---------------------------------------------
	 * 执行修改
	 * @return
	 */
	public String exUpdate(){
		User n = userService.getById(user.getId());
		userService.update(n);
		ActionContext.getContext().put("url", "/user_user.do");
		return "redirect";
	}
	
	
	/**
	 * 删除
	 * @return
	 */
	public String delete(){
		User n = userService.getById(user.getId());
		n.setIsDelete(1);
		userService.update(n);
		ActionContext.getContext().put("url", "/user_user.do");
		return "redirect";
	}
	
	//=============公=======共=======方=======法==========区=========end============//
	
	 //-------------------------华丽分割线---------------------------------------------//
	
	 //=============自=======定=======义=========方=======法==========区=========start============//
	
	
	
	
	//=============自=======定=======义=========方=======法==========区=========end============//
		
	
	
}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐