栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

基于SpringBoot框架的企业进销存商品管理系统

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于SpringBoot框架的企业进销存商品管理系统

项目描述

该项目的架构搭建使用的是maven,后台是使用的是spring boot框架,数据库的CRUD使用的是注解的方式,权限管理使用的是shiro框架,前端使用的框架是jquery,bootstrap,highcharts4插件,主要有以下功能:用户管理、角色管理、日志管理、供应商管理、客户管理、商品管理、库存管理、进货/退货管理、商品报损,报溢管理、商品采购,销售统计、商品销售按日分析统计。

在数字化时代中企业的信息越来越依赖于软件系统的处理,需要处理的数据量也越来越多。大量的数据和复杂的数据项使得旧的人工处理数据逐渐显得不足。甚至有些信息处理方法不能在人工模式下实现,只能利用计算机的高频进行迭代计算。

商品采集与管理系统为现代企业在贸易过程中的购销存提供了一个自由灵活的模板,用户可以根据需求扩展系统的一些功能,通过降低人力在操作方面的输出进而降低了采购等方面的支出,也可以减少不必要的支出比如因为错误导致的,仓库的库存也因此会变得更加合理,资金方面也会变得更加宽裕,增加各个部门之间信息的交流和沟通,有了充裕的时间后剩余的人力可以去搞市场搞销售推广,最后企业的综合竞争力因此得到大大地加强。

运行环境

jdk8+tomcat8+mysql+Idea+maven

项目技术

Spring boot+spring data jpa+apache shiro+bootstrap+jquery+highcharts4

演示视频

基于SpringBoot框架的进销存管理系统

用户登录逻辑代码

@Controller
@RequestMapping("/user")
public class UserController {

	@Resource
	private RoleService roleService;
	
	@Resource
	private UserService userService;
	
	@Resource
	private MenuService menuService;
	
	@Resource
	private LogService logService;
	
	
    @ResponseBody
    @PostMapping("/login")
    public Map login(String imageCode,@Valid User user,BindingResult bindingResult,HttpSession session){
    	Map map=new HashMap();
    	if(StringUtil.isEmpty(imageCode)){
    		map.put("success", false);
    		map.put("errorInfo", "请输入验证码!");
    		return map;
    	}
    	if(!session.getAttribute("checkcode").equals(imageCode)){
    		map.put("success", false);
    		map.put("errorInfo", "验证码输入错误!");
    		return map;
    	}
    	if(bindingResult.hasErrors()){
    		map.put("success", false);
    		map.put("errorInfo", bindingResult.getFieldError().getDefaultMessage());
    		return map;
    	}
		Subject subject=SecurityUtils.getSubject();
		UsernamePasswordToken token=new UsernamePasswordToken(user.getUserName(), user.getPassword());
		try{
			subject.login(token); // 登录认证
			String userName=(String) SecurityUtils.getSubject().getPrincipal();
			User currentUser=userService.findByUserName(userName);
			session.setAttribute("currentUser", currentUser);
			List roleList=roleService.findByUserId(currentUser.getId());
			map.put("roleList", roleList);
			map.put("roleSize", roleList.size());
			map.put("success", true);
			logService.save(new Log(Log.LOGIN_ACTION,"用户登录")); // 写入日志
			return map;
		}catch(Exception e){
			e.printStackTrace();
			map.put("success", false);
			map.put("errorInfo", "用户名或者密码错误!");
			return map;
		}
    }
    
    
    @ResponseBody
    @PostMapping("/saveRole")
    public Map saveRole(Integer roleId,HttpSession session)throws Exception{
    	Map map=new HashMap();
    	Role currentRole=roleService.findById(roleId);
    	session.setAttribute("currentRole", currentRole); // 保存当前角色信息
    	map.put("success", true);
    	return map;
    }
    
    
    @ResponseBody
    @GetMapping("/loadUserInfo")
    public String loadUserInfo(HttpSession session)throws Exception{
    	User currentUser=(User) session.getAttribute("currentUser");
    	Role currentRole=(Role) session.getAttribute("currentRole");
    	return "欢迎您:"+currentUser.getTrueName()+" [ "+currentRole.getName()+" ]";
    }
    
    
    @ResponseBody
    @PostMapping("/loadMenuInfo")
    public String loadMenuInfo(HttpSession session,Integer parentId)throws Exception{
    	Role currentRole=(Role) session.getAttribute("currentRole");
    	return getAllMenuByParentId(parentId,currentRole.getId()).toString();
    }
    
    
    private JsonArray getAllMenuByParentId(Integer parentId,Integer roleId){
    	JsonArray jsonArray=this.getMenuByParentId(parentId, roleId);
    	for(int i=0;i menuList=menuService.findByParentIdAndRoleId(parentId, roleId);
    	JsonArray jsonArray=new JsonArray();
    	for(Menu menu:menuList){
    		JsonObject jsonObject=new JsonObject();
    		jsonObject.addProperty("id", menu.getId()); // 节点id
    		jsonObject.addProperty("text", menu.getName()); // 节点名称
    		if(menu.getState()==1){
    			jsonObject.addProperty("state", "closed"); // 根节点
    		}else{
    			jsonObject.addProperty("state", "open"); // 叶子节点
    		}
    		jsonObject.addProperty("iconCls", menu.getIcon());
    		JsonObject attributeObject=new JsonObject(); // 扩展属性
    		attributeObject.addProperty("url", menu.getUrl()); // 菜单请求地址
			jsonObject.add("attributes", attributeObject);
			jsonArray.add(jsonObject);
    	}
    	return jsonArray;
    }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/601153.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号