本系统实现了进销存系统,管理端实现了管理员登录、首页、修改密码、 系统日志、 用户管理、角色管理、
进货入库、退货出库、进货单据查询、退货单据查询、当前库存查询、销售出库、客户退货、销售单据查询、客户退货查询、当前库存查询、商品报损、商品报溢、库存报警、报损报溢查询、当前库存查询、供应商统计、客户统计、商品采购统计、商品销售统计、按日统计分析、按月统计分析、供应商管理、客户管理、商品管理、期初库存
JDK版本:1.8
Mysql:5.7
登录用户名密码:admin 123
package com.mf.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import com.mf.entity.User;
/**
* 用户Repository接口
* @author Administrator
*
*/
public interface UserRepository extends JpaRepository<User, Integer>,JpaSpecificationExecutor<User>{
/**
* 根据用户名查找用户实体
* @param userName
* @return
*/
@Query(value="select * from t_user where user_name=?1",nativeQuery=true)
public User findByUserName(String userName);
}
package com.mf.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mf.entity.Log;
import com.mf.entity.Menu;
import com.mf.entity.Role;
import com.mf.entity.User;
import com.mf.service.LogService;
import com.mf.service.MenuService;
import com.mf.service.RoleService;
import com.mf.service.UserService;
import com.mf.util.StringUtil;
/**
* 用户Controller
* @author Administrator
*
*/
@Controller
@RequestMapping("/user")
public class UserController {
@Resource
private UserService userService;
@Resource
private RoleService roleService;
@Resource
private MenuService menuService;
@Resource
private LogService logService;
/**
* 用户登录判断
* @param imageCode
* @param user
* @param bindingResult
* @param session
* @return
*/
@ResponseBody
@RequestMapping("/login")
public Map<String,Object> login(String imageCode,@Valid User user,BindingResult bindingResult,HttpSession session){
Map<String,Object> map=new HashMap<String,Object>();
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<Role> 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;
}
}
/**
* 保存角色信息
* @param roleId
* @param session
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/saveRole")
public Map<String,Object> saveRole(Integer roleId,HttpSession session)throws Exception{
Map<String,Object> map=new HashMap<String,Object>();
Role currentRole=roleService.findById(roleId);
session.setAttribute("currentRole", currentRole);
map.put("success", true);
return map;
}
/**
* 加载当前用户信息
* @param session
* @return
* @throws Exception
*/
@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()+" ]";
}
/**
* 加载权限菜单
* @param session
* @param parentId
* @return
* @throws Exception
*/
@ResponseBody
@PostMapping("/loadMenuInfo")
public String loadMenuInfo(HttpSession session,Integer parentId)throws Exception{
Role currentRole=(Role) session.getAttribute("currentRole");
return getAllMenuByParentId(parentId,currentRole.getId()).toString();
}
/**
* 获取所有菜单信息
* @param parentId
* @param roleId
* @return
*/
public JsonArray getAllMenuByParentId(Integer parentId,Integer roleId){
JsonArray jsonArray=this.getMenuByParentId(parentId, roleId);
for(int i=0;i<jsonArray.size();i++){
JsonObject jsonObject=(JsonObject) jsonArray.get(i);
if("open".equals(jsonObject.get("state").getAsString())){
continue;
}else{
jsonObject.add("children", getAllMenuByParentId(jsonObject.get("id").getAsInt(), roleId));
}
}
return jsonArray;
}
/**
* 根据父节点和用户角色Id查询菜单
* @param parentId
* @param roleId
* @return
*/
public JsonArray getMenuByParentId(Integer parentId,Integer roleId){
List<Menu> 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;
}
}
package com.mf.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.validator.constraints.NotEmpty;
/**
* 用户实体
* @author Administrator
*
*/
@Entity
@Table(name="t_user")
public class User {
@Id
@GeneratedValue
private Integer id; // 编号
@NotEmpty(message="请输入用户名!")
@Column(length=50)
private String userName; // 用户名
@NotEmpty(message="请输入密码!")
@Column(length=50)
private String password; // 密码
@Column(length=50)
private String trueName; // 真实姓名
@Column(length=1000)
private String remarks; // 备注
@Transient
private String roles; // 所拥有的角色
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
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 getTrueName() {
return trueName;
}
public void setTrueName(String trueName) {
this.trueName = trueName;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getRoles() {
return roles;
}
public void setRoles(String roles) {
this.roles = roles;
}
@Override
public String toString() {
return "User [id=" + id + ", userName=" + userName + ", password=" + password + ", trueName=" + trueName
+ ", remarks=" + remarks + ", roles=" + roles + "]";
}
}
点击以下链接获取源码。
IDEA+springboot + ssm +shiro+ easyui +mysql实现的进销存系统
IDEA+springboot+mybatis+shiro+bootstrap+Mysql网上书店管理系统
IDEA+springboot+mybatis+shiro+bootstrap+Mysql WMS仓库管理系统
IDEA+spring+spring mvc+mybatis+bootstrap+jquery+Mysql运动会管理系统源码
IDEA+SpringBoot+mybatis+bootstrap+jquery+Mysql车险理赔管理系统源码
IDEA+Spring Boot + MyBatis + Layui+Mysql垃圾回收管理系统源码
IDEA+SpringBoot+mybatis+SSM+layui+Mysql学生就业信息管理系统源码
IDEA+springboot+jpa+Layui+Mysql销售考评系统源码
IDEA+Spring + Spring MVC + MyBatis+Bootstrap+Mysql酒店管理系统源码
IDEA+spring boot+mybatis+spring mvc+bootstrap+Mysql停车位管理系统源码
Java+Swing+Mysql实现学生宿舍管理系统
Java+Swing+Txt实现自助款机系统
Java+Swing+Mysql自助存取款机系统
Java+Swing+mysql5实现学生成绩管理系统(带分页)
Java+Swing+Mysql实现超市商品管理系统源码
Java+Swing+Mysql实现通讯录管理系统源码
Java+Swing+Mysql实现图书管理系统源码