Get the source code: Download it from "Resources" on the homepage of the blog!
Project Introduction
This project is divided into two roles: administrator and visitor. The
super administrator role includes the following functions:
administrator login, loan and return management, asset addition, asset overview, loan and return report, user management, role management, rights management, resource type, Network management and other functions.
The visitor role includes the following functions:
visitor homepage-advertising page and other functions.
PS: Click on the WEB console in the upper left corner to enter the management page. It should be noted that the administrator can add countless roles and permissions in the background, so this is not a single-role system.
environmental needs
1. Operating environment: preferably java jdk 1.8, we are running on this platform. Other versions are also theoretically possible.
2. IDE environment: IDEA, Eclipse, Myeclipse can be used. IDEA is recommended;
3.tomcat environment: Tomcat 7.x,8.x,9.x versions are available
4.Hardware environment: windows 7/8/10 with 1G memory or more; or Mac OS;
5. Database: MySql version 5.7;
6. Whether Maven project: yes;
technology stack
1. Backend: springboot, mybatis, shiro
2. Front-end: HTML+CSS+JavaScript+VUE
Instructions for use
1. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of the project;
2. Use IDEA/Eclipse/MyEclipse to import the project. When importing from Eclipse/MyEclipse, if it is a maven project, please select maven;
if It is a maven project. After the import is successful, please execute the maven clean;maven install command, and then run it;
3. Change the database configuration in the config/application.properties configuration file in the project to your own configuration;
4. Run the project and enter http:/ /localhost:8080/ Login
Administrator account/password: admin/123456
Organization Controller:
/**
* 组织机构控制器
*/
@Controller
@RequestMapping("/organization")
public class OrgController {
@Autowired
private OrganizationService organizationService;
/**
* 根据条件动态查询组织,数据加载到表格
*/
@PostMapping("/list")
public String listOrganizationByLevel(Organization example, ModelMap map){
List<Organization> list = organizationService.listOrganizationByExample(example);
int sublevel = example.getOrgLevel();
map.put("dtoList",list);
String pageName = null;
switch (sublevel) { //根据参数确定返回页面目标
case 1: pageName= "friDepartments" ;break;
case 2: pageName= "secDepartments" ;break;
case 3: pageName= "macAddress" ;break;
}
return pageName+"::table-refresh";
}
/**
* 根据条件动态查询子级组织
*/
@PostMapping("/sub/list")
@ResponseBody
public List listOrganization(Organization example){
List<Organization> list = organizationService.listOrganizationByExample(example);
return list;
}
/**
* 根据一级部门和二级部门id查询物理位置
*/
@PostMapping("/macAddress/list")
public String listMacaddress(String fristId,String secondId,ModelMap map){
List<Organization> list = organizationService.listMacaddressByRootID(fristId,secondId);
map.put("dtoList",list);
return "macAddress::table-refresh";
}
/**
* 添加组织
* @param organization
* @return
*/
@PostMapping
@ResponseBody
public int addOrganization(Organization organization){
return organizationService.insertOrganization(organization);
}
/**
* 删除组织
* @param orgId
* @return
*/
@DeleteMapping("/{orgId}")
@ResponseBody
public int delteOrganizationByid(@PathVariable("orgId") String orgId){
return organizationService.deleteOrganizationById(orgId);
}
/**
* 修改组织名称
* @param organization
* @return
*/
@PutMapping
@ResponseBody
public int updateDeviceType(Organization organization){
return organizationService.updateOrganizationName(organization);
}
/**
* 获取组织树
* @return
*/
@GetMapping("/tree")
@ResponseBody
public OrganizationDTO getOrganizationTree(){
return organizationService.getOrgTree();
}
}
Account management control layer:
@Controller
@RequestMapping("/account")
public class AccountController {
//自动注入服务类
@Autowired
private AccountService accountService;
/**
* 管理员账户信息
* @return
*/
@GetMapping("/admins")
public String listAdmins(ModelMap map){
List<AccountDTO> adminList = accountService.listAccountByLevel(2);
List<AccountDTO> superAdminList = accountService.listAccountByLevel(1);
adminList.addAll(superAdminList);
map.put("adminsList", adminList);
return "system::table-refresh";
}
/**
* 获取所有账户信息
* @param map
* @return
*/
@GetMapping("/list")
public String listAccounts(ModelMap map){
List<AccountDTO> accountList = accountService.listAccount();
map.put("accountDTOList", accountList);
return "account::table-refresh";
}
/**
* 通过用户名称搜索用户
* @param map
* @param userName
* @return
*/
@GetMapping("/list/{userName}")
public String listAccountsByUserName(ModelMap map,@PathVariable("userName")String userName){
List<AccountDTO> accountList = accountService.listAccountByName(userName);
map.put("accountDTOList", accountList);
return "account::table-refresh";
}
/**
* 添加管理员页面
* @param map
* @return
*/
@GetMapping("/users")
public String listUsers(ModelMap map){
List<AccountDTO> accountList = accountService.listAccountByLevel(3);
map.put("usersDTOList", accountList);
return "system::list-refresh";
}
/**
* 获取设备使用人信息
* @param map
* @param devId
* @return
*/
@GetMapping("/ownerList")
public String getOwnerList(ModelMap map, String devId){
Map resMap = accountService.listOwenrByDevId(devId);
map.put("ownerMap", resMap);
return "allotDevice::list-refresh";
}
/**
* 添加账户
* @param account
* @return
*/
@PostMapping
@ResponseBody
public int addAccount(Account account){
return accountService.addAccount(account);
}
/**
* 根据uuid删除账户
* @param uuid
* @return
*/
@DeleteMapping("/{uuid}")
@ResponseBody
public int deleteAccount(@PathVariable("uuid")String uuid){
return accountService.deleteAccountById(uuid);
}
/**
* 修改账户密码
* @param uuid
* @param password
* @return
*/
@PutMapping("/password")
@ResponseBody
public int updatePassword(String uuid, String password){
return accountService.updatePasswordByid(uuid,password);
}
/**
* 修改账户状态
* @param uuid
* @param status
* @return
*/
@PutMapping("/status")
@ResponseBody
public int updateStatus(String uuid,int status){
return accountService.updateStatusByid(uuid,status);
}
/**
* 更改管理员
* @return
*/
@PutMapping("/admins")
@ResponseBody
public int updateDevOwner(HttpServletRequest request){
String[] groups = request.getParameter("groups").split(",");
int level = Integer.parseInt(request.getParameter("level"));
return accountService.updateAccountLevel(level,groups);
};
}
Login control layer:
@Controller
public class LoginController {
@RequestMapping("/login")
public String login(HttpServletRequest request, Model mv) {
String e = (String) request.getAttribute("shiroLoginFailure");
if (e != null) {
if (e.contains("org.apache.shiro.authc.UnknownAccountException")) {
mv.addAttribute("msg", "账号不存在");
} else if (e.contains("org.apache.shiro.authc.IncorrectCredentialsException")) {
mv.addAttribute("msg", "密码错误");
} else if (e.contains("org.apache.shiro.authc.LockedAccountException")) {
mv.addAttribute("msg", "账户已停用");
}
}
return "login";
}
}
Get the source code: Download it from "Resources" on the homepage of the blog!