├── README.md ├── School-java ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ └── misc.xml ├── School-java.iml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── tothefor │ │ │ ├── SchoolJavaApplication.java │ │ │ ├── config │ │ │ ├── CorsConfig.java │ │ │ ├── InterceptorConfig.java │ │ │ ├── JWTInterceptor.java │ │ │ └── mybatis_plus │ │ │ │ ├── MyMetaObjectHandler.java │ │ │ │ └── MybatisPlusConfig.java │ │ │ ├── controller │ │ │ ├── RecordController.java │ │ │ ├── itemController.java │ │ │ ├── itemTypeController.java │ │ │ ├── menuController.java │ │ │ ├── userController.java │ │ │ └── userRoleController.java │ │ │ ├── mapper │ │ │ ├── ItemMapper.java │ │ │ ├── ItemTypeMapper.java │ │ │ ├── MenuMapper.java │ │ │ ├── RecordMapper.java │ │ │ ├── RoleMenuMapper.java │ │ │ ├── UserMapper.java │ │ │ └── UserRoleMapper.java │ │ │ ├── pojo │ │ │ ├── dto │ │ │ │ ├── CheckURL.java │ │ │ │ ├── LoginDTO.java │ │ │ │ ├── PieData.java │ │ │ │ ├── RequestReturnInfo.java │ │ │ │ └── UserPassword.java │ │ │ └── entity │ │ │ │ ├── Item.java │ │ │ │ ├── ItemType.java │ │ │ │ ├── Menu.java │ │ │ │ ├── Record.java │ │ │ │ ├── RoleMenu.java │ │ │ │ ├── User.java │ │ │ │ └── UserRole.java │ │ │ ├── resultR │ │ │ ├── R.java │ │ │ └── RCode.java │ │ │ ├── service │ │ │ ├── ItemService.java │ │ │ ├── ItemTypeService.java │ │ │ ├── MenuService.java │ │ │ ├── RecordService.java │ │ │ ├── RoleMenuService.java │ │ │ ├── UserRoleService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ ├── ItemServiceImpl.java │ │ │ │ ├── ItemTypeServiceImpl.java │ │ │ │ ├── MenuServiceImpl.java │ │ │ │ ├── RecordServiceImpl.java │ │ │ │ ├── RoleMenuServiceImpl.java │ │ │ │ ├── UserRoleServiceImpl.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── utils │ │ │ ├── JWTUtils.java │ │ │ ├── MD5Utils.java │ │ │ └── RequestInfoUtils.java │ └── resources │ │ ├── application-dev.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── tothefor │ └── SchoolJavaApplicationTests.java ├── schoolm ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ └── tothefor.png ├── src │ ├── App.vue │ ├── assets │ │ ├── global.css │ │ ├── logo.png │ │ └── tothefor.png │ ├── components │ │ └── HelloWorld.vue │ ├── main.js │ ├── request │ │ └── request.js │ ├── router │ │ └── index.js │ ├── store │ │ └── index.js │ └── views │ │ ├── basic │ │ ├── itemShow │ │ │ └── index.vue │ │ ├── itemType │ │ │ └── index.vue │ │ ├── lookData │ │ │ └── index.vue │ │ └── recordShow │ │ │ └── index.vue │ │ ├── homeData │ │ └── index.vue │ │ ├── index.vue │ │ ├── login │ │ └── index.vue │ │ ├── register │ │ └── index.vue │ │ └── sys │ │ ├── auth │ │ └── index.vue │ │ ├── mans │ │ └── index.vue │ │ ├── perPwd │ │ └── index.vue │ │ ├── role │ │ └── index.vue │ │ └── updatePwd │ │ └── index.vue └── vue.config.js └── sql └── sql.sql /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![](https://img-blog.csdnimg.cn/e96c7ae561684f83a611631d1b24ca8f.png) 3 | 4 | # FirstBlood 5 | 一个基于SpringBoot+Vue3实现的前后端分离后台管理系统。在学习的过程中让自己也成长了很多,踩了很多坑但也收获到了很多。 6 | 7 | ## 设计知识点 8 | 9 | 前端:Vue3、Element-Plus、Echarts、Axios、Vue-Router 10 | 11 | 后端:SpringBoot、MyBatis-Plus 12 | 13 | JDK:1.8 14 | 15 | MySQL:8.0 16 | 17 | 其他相关:Hutool工具、JWT等。 18 | 19 | 20 | ## 注意事项 21 | 22 | - 管理员创建用户时,用户的默认密码为123456。 23 | - 添加物品时(手动SQL添加),物品类型的编号必须是类型表中已有的类型的编号。通过界面添加则只需要选择即可。 24 | 25 | ## 功能截图 26 | 27 | ### 物品管理 28 | 29 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/c61429c688574ed8983b8066712441d2.png) 30 | 31 | 32 | 33 | 34 | ### 物品类型 35 | 36 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/c1d6cb8b177d4008a32dbe34ce3754f6.png) 37 | 38 | 39 | 40 | 41 | ### 借出管理 42 | 43 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/fdcc44cf98a044548403d7e5bcccec1b.png) 44 | 45 | 46 | 47 | 48 | ### 数据展示 49 | 50 | 将数据进行可视化展示。 51 | 52 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/5ccfa9abf6c142e286467ec8cc2d6b3a.png) 53 | 54 | 55 | 56 | 57 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/fcdc53b8b577481199c41f9f8c53f3fd.png) 58 | 59 | 60 | 61 | 62 | ### 角色管理 63 | 64 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/43cd719eab9a4414a8207614c70a4923.png) 65 | 66 | 67 | ### 人员管理 68 | 69 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/d1c874154a5445ccaad86aeae817e624.png) 70 | 71 | 72 | 73 | 74 | ### 密码修改 75 | 76 | 可以修改其他账号的密码。 77 | 78 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/305296b8638547b7b55276ae275da87b.png) 79 | 80 | 81 | 82 | 83 | ### 个人密码 84 | 85 | 修改当前账号的密码。 86 | 87 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/b4d822120b2943568d0ef930140fda15.png) 88 | 89 | 90 | 91 | 92 | ## 数据库表 93 | 94 | 用户表: 95 | 96 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/ffa0e1b19e51407cb47e5f5af3b2f581.png) 97 | 98 | 99 | 角色表: 100 | 101 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/5408000ed2194a60a354512c47b67dd0.png) 102 | 103 | 104 | 105 | 106 | 菜单表: 107 | 108 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/6186631213644d5594cc455276778513.png) 109 | 110 | 111 | 权限表: 112 | 113 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/c26a5a43d343482eb4328bf17506daa9.png) 114 | 115 | 116 | 物品信息表: 117 | 118 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/8311abd58cda4b079797be274432c273.png) 119 | 120 | 121 | 类型表: 122 | 123 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/983e5e498cf84f069eda82c61ef11699.png) 124 | 125 | 126 | 物品借出记录表: 127 | 128 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/02d8994b1d484f03a130a9cbed5517e4.png) 129 | 130 | 131 | 132 | 133 | 134 | 135 | ## 其他效果展示 136 | 137 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/d8a7051b01b64ec2acecb685d14c90ef.png) 138 | 139 | 140 | 141 | 142 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/71250d4f00044d3fa39337e73333929d.png) 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /School-java/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /School-java/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /School-java/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /School-java/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /School-java/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /School-java/School-java.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /School-java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.6.4 9 | 10 | 11 | com.tothefor 12 | School-java 13 | 0.0.1-SNAPSHOT 14 | School-java 15 | School-java 16 | 17 | 1.8 18 | 19 | 20 | 21 | 22 | eu.bitwalker 23 | UserAgentUtils 24 | 1.21 25 | 26 | 27 | 28 | 29 | cn.hutool 30 | hutool-all 31 | 5.7.20 32 | 33 | 34 | org.apache.poi 35 | poi-ooxml 36 | 4.1.2 37 | 38 | 39 | 40 | 41 | com.auth0 42 | java-jwt 43 | 3.18.3 44 | 45 | 46 | 47 | 48 | com.baomidou 49 | mybatis-plus-boot-starter 50 | 3.5.1 51 | 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-data-redis 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-web 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-devtools 70 | runtime 71 | true 72 | 73 | 74 | mysql 75 | mysql-connector-java 76 | runtime 77 | 78 | 79 | org.projectlombok 80 | lombok 81 | true 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-starter-test 86 | test 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | org.springframework.boot 99 | spring-boot-maven-plugin 100 | 101 | 102 | 103 | org.projectlombok 104 | lombok 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/SchoolJavaApplication.java: -------------------------------------------------------------------------------- 1 | package com.tothefor; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @MapperScan("com.tothefor.mapper") 12 | @SpringBootApplication 13 | public class SchoolJavaApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(SchoolJavaApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 7 | import org.springframework.web.filter.CorsFilter; 8 | 9 | /** 10 | * 解决跨域问题 11 | * @Author DragonOne 12 | * @Date 2022/3/4 13:28 13 | * @墨水记忆 www.tothefor.com 14 | */ 15 | 16 | @Configuration 17 | public class CorsConfig { 18 | 19 | // 当前跨域请求最大有效时长。这里默认1天 20 | private static final long MAX_AGE = 24 * 60 * 60; 21 | 22 | @Bean 23 | public CorsFilter corsFilter() { 24 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 25 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 26 | corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址 27 | // corsConfiguration.addAllowedOrigin("http://localhost:8080"); // 1 设置访问源地址 28 | corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头 29 | corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法 30 | corsConfiguration.setMaxAge(MAX_AGE); 31 | source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置 32 | return new CorsFilter(source); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/config/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | //package com.tothefor.config; 2 | // 3 | //import org.springframework.context.annotation.Bean; 4 | //import org.springframework.context.annotation.Configuration; 5 | //import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | //import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | // 8 | // 9 | ///** 10 | // * 拦截器配置 11 | // * @Author DragonOne 12 | // * @Date 2022/3/4 13:28 13 | // * @墨水记忆 www.tothefor.com 14 | // */ 15 | // 16 | // 17 | //@Configuration 18 | //public class InterceptorConfig implements WebMvcConfigurer { 19 | // @Override 20 | // public void addInterceptors(InterceptorRegistry registry) { 21 | // registry.addInterceptor(jwtInterceptor()) 22 | // .addPathPatterns("/**") //哪些url需要验证 23 | // .excludePathPatterns("/user/login"); //哪些不需要验证 24 | // } 25 | // @Bean 26 | // public JWTInterceptor jwtInterceptor(){ 27 | // return new JWTInterceptor(); 28 | // } 29 | //} 30 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/config/JWTInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.config; 2 | 3 | 4 | import com.auth0.jwt.exceptions.JWTDecodeException; 5 | import com.auth0.jwt.interfaces.DecodedJWT; 6 | import com.tothefor.utils.JWTUtils; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.web.method.HandlerMethod; 9 | import org.springframework.web.servlet.HandlerInterceptor; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | 14 | /** 15 | * jwt拦截器 16 | * @Author DragonOne 17 | * @Date 2022/3/4 13:28 18 | * @墨水记忆 www.tothefor.com 19 | */ 20 | 21 | 22 | @Configuration 23 | public class JWTInterceptor implements HandlerInterceptor { 24 | 25 | // @Autowired 26 | // private UserMapper userMapper; 27 | 28 | @Override 29 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 30 | String token = request.getHeader("token");// 从 http 请求头中取出 token 31 | // 如果不是映射到方法直接通过 32 | if(!(handler instanceof HandlerMethod)){ 33 | return true; 34 | } 35 | if (token == null || token=="") { 36 | return false; 37 | } 38 | // 获取 token 中的用户信息 39 | try { 40 | DecodedJWT djwt = JWTUtils.getTokenInfo(token); //验证成功并返回信息,失败直接中断 41 | String userid = djwt.getClaim("id").asString(); 42 | Integer id = Integer.valueOf(userid); 43 | // User queryUser = userMapper.queryinfoByID(id); 44 | // if(queryUser==null) return false; 45 | return true; 46 | } catch (JWTDecodeException j) { 47 | return false; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/config/mybatis_plus/MyMetaObjectHandler.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.config.mybatis_plus; 2 | 3 | import cn.hutool.core.util.RandomUtil; 4 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 5 | import com.tothefor.utils.MD5Utils; 6 | import org.apache.ibatis.reflection.MetaObject; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * 数据库填充策略 13 | * @Author DragonOne 14 | * @Date 2022/3/4 13:28 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | 18 | 19 | @Component 20 | public class MyMetaObjectHandler implements MetaObjectHandler { 21 | 22 | //插入时的策略 23 | @Override 24 | public void insertFill(MetaObject metaObject) { 25 | //setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject) 26 | this.setFieldValByName("itemAddTime",new Date(),metaObject); 27 | this.setFieldValByName("itemUpdateTime",new Date(),metaObject); 28 | 29 | this.setFieldValByName("recordAddTime",new Date(),metaObject); 30 | this.setFieldValByName("recordUpdateTime",new Date(),metaObject); 31 | this.setFieldValByName("password", MD5Utils.getMD5("123456"),metaObject); //设置默认密码 32 | 33 | this.setFieldValByName("getCode", RandomUtil.randomString(6),metaObject); 34 | 35 | 36 | } 37 | 38 | //更新时的策略 39 | @Override 40 | public void updateFill(MetaObject metaObject) { 41 | this.setFieldValByName("itemUpdateTime",new Date(),metaObject); 42 | this.setFieldValByName("recordUpdateTime",new Date(),metaObject); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/config/mybatis_plus/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.config.mybatis_plus; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.mybatis.spring.mapper.MapperScannerConfigurer; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | /** 13 | * mybatis-plus 分页 14 | * @Author DragonOne 15 | * @Date 2022/3/4 13:28 16 | * @墨水记忆 www.tothefor.com 17 | */ 18 | 19 | 20 | @EnableTransactionManagement 21 | @MapperScan("com.tothefor.mapper") 22 | @Configuration 23 | public class MybatisPlusConfig { 24 | 25 | @Bean 26 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 27 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 28 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2)); 29 | return interceptor; 30 | } 31 | 32 | @Bean 33 | public MapperScannerConfigurer mapperScannerConfigurer(){ 34 | MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer(); 35 | //可以通过环境变量获取你的mapper路径,这样mapper扫描可以通过配置文件配置了 36 | scannerConfigurer.setBasePackage("com.tothefor.mapper"); 37 | return scannerConfigurer; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/controller/RecordController.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.controller; 2 | 3 | import cn.hutool.core.collection.CollUtil; 4 | import cn.hutool.core.io.IoUtil; 5 | import cn.hutool.poi.excel.ExcelReader; 6 | import cn.hutool.poi.excel.ExcelUtil; 7 | import cn.hutool.poi.excel.ExcelWriter; 8 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 9 | import com.baomidou.mybatisplus.core.metadata.IPage; 10 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 11 | import com.tothefor.mapper.ItemMapper; 12 | import com.tothefor.mapper.ItemTypeMapper; 13 | import com.tothefor.mapper.RecordMapper; 14 | import com.tothefor.pojo.dto.PieData; 15 | import com.tothefor.pojo.entity.Item; 16 | import com.tothefor.pojo.entity.ItemType; 17 | import com.tothefor.pojo.entity.Record; 18 | import com.tothefor.resultR.R; 19 | import com.tothefor.service.impl.ItemServiceImpl; 20 | import com.tothefor.service.impl.ItemTypeServiceImpl; 21 | import com.tothefor.service.impl.RecordServiceImpl; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.util.StringUtils; 24 | import org.springframework.web.bind.annotation.*; 25 | import org.springframework.web.multipart.MultipartFile; 26 | 27 | import javax.servlet.ServletOutputStream; 28 | import javax.servlet.http.HttpServletRequest; 29 | import javax.servlet.http.HttpServletResponse; 30 | import java.io.InputStream; 31 | import java.net.URLEncoder; 32 | import java.text.SimpleDateFormat; 33 | import java.util.ArrayList; 34 | import java.util.LinkedHashMap; 35 | import java.util.List; 36 | import java.util.Map; 37 | 38 | /** 39 | * 物品controller 40 | * @Author DragonOne 41 | * @Date 2022/3/4 13:28 42 | * @墨水记忆 www.tothefor.com 43 | */ 44 | 45 | @RestController 46 | @RequestMapping("/record") 47 | public class RecordController { 48 | 49 | @Autowired 50 | private RecordMapper recordMapper; 51 | 52 | @Autowired 53 | private RecordServiceImpl recordService; 54 | 55 | 56 | /** 57 | * @Author DragonOne 58 | * @Date 2022/3/6 17:01 59 | * @墨水记忆 www.tothefor.com 60 | * @方法 itemAll 61 | * @作用 查找所有物品信息接口 62 | * @参数说明 63 | * @return 64 | */ 65 | @GetMapping("/recordAll") 66 | public R> itemAll(){ 67 | 68 | return R.SUCCESS(recordMapper.selectList(null)); 69 | } 70 | 71 | /** 72 | * @Author DragonOne 73 | * @Date 2022/3/6 17:02 74 | * @墨水记忆 www.tothefor.com 75 | * @方法 itemSave 76 | * @作用 插入和修改接口 77 | * @参数说明 78 | * @return 79 | */ 80 | @PostMapping("/save") 81 | public R itemSave(@RequestBody Record item){ 82 | 83 | if(recordService.saveOrUpdate(item)){ 84 | return R.SUCCESS(); 85 | }else { 86 | return R.FAIL(); 87 | } 88 | } 89 | 90 | 91 | /** 92 | * @Author DragonOne 93 | * @Date 2022/3/6 17:06 94 | * @墨水记忆 www.tothefor.com 95 | * @方法 itemDelete 96 | * @作用 根据id删除信息 97 | * @参数说明 98 | * @return 99 | */ 100 | @DeleteMapping("/del/{id}") 101 | public R itemDelete(@PathVariable Integer id){ 102 | if(recordMapper.deleteById(id)==1){ 103 | return R.SUCCESS(); 104 | }else{ 105 | return R.FAIL(); 106 | } 107 | } 108 | 109 | /** 110 | * @Author DragonOne 111 | * @Date 2022/3/6 17:11 112 | * @墨水记忆 www.tothefor.com 113 | * @方法 itemBatchDelete 114 | * @作用 批量删除 115 | * @参数说明 116 | * @return 117 | */ 118 | @PostMapping("/batch/del") 119 | public R itemBatchDelete(@RequestBody List ids){ 120 | int len = ids.size(); 121 | if(recordMapper.deleteBatchIds(ids)==len){ 122 | return R.SUCCESS(); 123 | }else { 124 | return R.FAIL(); 125 | } 126 | } 127 | 128 | 129 | /** 130 | * @Author DragonOne 131 | * @Date 2022/3/7 12:37 132 | * @墨水记忆 www.tothefor.com 133 | * @方法 PageitemAll 134 | * @作用 物品的分页查询 135 | * @参数说明 136 | * @return 137 | */ 138 | @GetMapping("/pageAll") 139 | public R> PageItemAll(@RequestParam("pageNum") Integer pageNum, 140 | @RequestParam("PageSize") Integer pageSize, 141 | @RequestParam(defaultValue = "") String itemname){ 142 | 143 | 144 | IPage page = new Page<>(pageNum,pageSize); 145 | QueryWrapper queryWrapper = new QueryWrapper<>(); 146 | if(StringUtils.hasText(itemname)){ 147 | queryWrapper.like("record_name",itemname); 148 | } 149 | queryWrapper.orderByDesc("id"); 150 | 151 | 152 | IPage page1 = recordService.page(page, queryWrapper); 153 | return R.SUCCESS(page1); 154 | } 155 | 156 | /** 157 | * @Author DragonOne 158 | * @Date 2022/3/9 16:28 159 | * @墨水记忆 www.tothefor.com 160 | * @方法 itemShow 161 | * @作用 修改物品状态 162 | * @参数说明 163 | * @return 164 | */ 165 | @PostMapping("/changeShow") 166 | public R itemShow(@RequestBody Record id){ 167 | if(recordMapper.updateById(id)==1){ 168 | return R.SUCCESS(); 169 | }else { 170 | return R.FAIL(); 171 | } 172 | } 173 | 174 | 175 | /** 176 | * @Author DragonOne 177 | * @Date 2022/3/9 17:13 178 | * @墨水记忆 www.tothefor.com 179 | * @方法 export 180 | * @作用 数据导出 181 | * @参数说明 182 | * @return 183 | */ 184 | @GetMapping("/export") 185 | public void export(HttpServletRequest request, HttpServletResponse response) throws Exception{ 186 | // String token = request.getHeader("token"); 187 | 188 | List> list = CollUtil.newArrayList(); 189 | List all = recordMapper.selectList(null); 190 | 191 | for(Record it : all){ 192 | Map row1 = new LinkedHashMap<>(); 193 | row1.put("借出唯一标识符",it.getId()); 194 | row1.put("借出单名称",it.getRecordName()); 195 | row1.put("领取者",it.getRecordMan()); 196 | row1.put("添加时间",it.getRecordAddTime()); 197 | row1.put("最后修改时间",it.getRecordUpdateTime()); 198 | row1.put("描述",it.getDescription()); 199 | 200 | list.add(row1); 201 | } 202 | 203 | // 2. 写excel 204 | ExcelWriter writer = ExcelUtil.getWriter(true); 205 | writer.write(list, true); 206 | 207 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); 208 | String fileName = URLEncoder.encode("下载信息", "UTF-8"); 209 | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); 210 | 211 | ServletOutputStream out = response.getOutputStream(); 212 | writer.flush(out, true); 213 | writer.close(); 214 | IoUtil.close(System.out); 215 | 216 | 217 | } 218 | 219 | 220 | } 221 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/controller/itemTypeController.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.controller; 2 | 3 | import cn.hutool.core.collection.CollUtil; 4 | import cn.hutool.core.io.IoUtil; 5 | import cn.hutool.poi.excel.ExcelReader; 6 | import cn.hutool.poi.excel.ExcelUtil; 7 | import cn.hutool.poi.excel.ExcelWriter; 8 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 9 | import com.baomidou.mybatisplus.core.metadata.IPage; 10 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 11 | import com.tothefor.mapper.ItemMapper; 12 | import com.tothefor.mapper.ItemTypeMapper; 13 | import com.tothefor.pojo.entity.Item; 14 | import com.tothefor.pojo.entity.ItemType; 15 | import com.tothefor.resultR.R; 16 | import com.tothefor.service.impl.ItemServiceImpl; 17 | import com.tothefor.service.impl.ItemTypeServiceImpl; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.util.StringUtils; 20 | import org.springframework.web.bind.annotation.*; 21 | import org.springframework.web.multipart.MultipartFile; 22 | 23 | import javax.servlet.ServletOutputStream; 24 | import javax.servlet.http.HttpServletRequest; 25 | import javax.servlet.http.HttpServletResponse; 26 | import java.io.InputStream; 27 | import java.net.URLEncoder; 28 | import java.text.SimpleDateFormat; 29 | import java.util.LinkedHashMap; 30 | import java.util.List; 31 | import java.util.Map; 32 | 33 | /** 34 | * @Author DragonOne 35 | * @Date 2022/3/9 15:34 36 | * @墨水记忆 www.tothefor.com 37 | */ 38 | 39 | @RestController 40 | @RequestMapping("/itemType") 41 | public class itemTypeController { 42 | 43 | @Autowired 44 | private ItemTypeMapper itemTypeMapper; 45 | 46 | @Autowired 47 | private ItemMapper itemMapper; 48 | 49 | @Autowired 50 | private ItemServiceImpl itemService; 51 | 52 | @Autowired 53 | private ItemTypeServiceImpl itemTypeService; 54 | 55 | 56 | /** 57 | * @Author DragonOne 58 | * @Date 2022/3/9 15:44 59 | * @墨水记忆 www.tothefor.com 60 | * @方法 itemTypeAll 61 | * @作用 查询全部类型 62 | * @参数说明 63 | * @return 64 | */ 65 | @GetMapping("/itemTypeAll") 66 | public R> itemTypeAll(){ 67 | return R.SUCCESS(itemTypeMapper.selectList(null)); 68 | } 69 | 70 | /** 71 | * @Author DragonOne 72 | * @Date 2022/3/6 17:02 73 | * @墨水记忆 www.tothefor.com 74 | * @方法 itemSave 75 | * @作用 插入和修改接口 76 | * @参数说明 77 | * @return 78 | */ 79 | @PostMapping("/save") 80 | public R itemTypeSave(@RequestBody ItemType item){ 81 | Long newTypeId = item.getTypeId(); 82 | Long oldTypeID = null; 83 | Long id = item.getId(); 84 | if(id!=null){ 85 | QueryWrapper qw = new QueryWrapper<>(); 86 | 87 | ItemType itemType = itemTypeMapper.selectById(id); 88 | oldTypeID = itemType.getTypeId(); 89 | 90 | qw.eq("typeID",oldTypeID); 91 | List items = itemMapper.selectList(qw); 92 | 93 | for(Item it : items){ 94 | it.setTypeid(newTypeId); 95 | itemService.updateById(it); 96 | } 97 | 98 | } 99 | 100 | 101 | 102 | if(itemTypeService.saveOrUpdate(item)){ 103 | 104 | return R.SUCCESS(); 105 | }else { 106 | return R.FAIL(); 107 | } 108 | } 109 | 110 | /** 111 | * @Author DragonOne 112 | * @Date 2022/3/6 17:06 113 | * @墨水记忆 www.tothefor.com 114 | * @方法 itemDelete 115 | * @作用 根据id删除信息 116 | * @参数说明 117 | * @return 118 | */ 119 | @DeleteMapping("/del/{id}") 120 | public R itemTypeDelete(@PathVariable Integer id){ 121 | if(itemTypeMapper.deleteById(id)==1){ 122 | return R.SUCCESS(); 123 | }else{ 124 | return R.FAIL(); 125 | } 126 | } 127 | 128 | /** 129 | * @Author DragonOne 130 | * @Date 2022/3/6 17:11 131 | * @墨水记忆 www.tothefor.com 132 | * @方法 itemBatchDelete 133 | * @作用 批量删除 134 | * @参数说明 135 | * @return 136 | */ 137 | @PostMapping("/batch/del") 138 | public R itemTypeBatchDelete(@RequestBody List ids){ 139 | int len = ids.size(); 140 | if(itemTypeMapper.deleteBatchIds(ids)==len){ 141 | return R.SUCCESS(); 142 | }else { 143 | return R.FAIL(); 144 | } 145 | } 146 | 147 | /** 148 | * @Author DragonOne 149 | * @Date 2022/3/7 12:37 150 | * @墨水记忆 www.tothefor.com 151 | * @方法 PageitemAll 152 | * @作用 物品的分页查询 153 | * @参数说明 154 | * @return 155 | */ 156 | @GetMapping("/pageAll") 157 | public R> PageItemTypeAll(@RequestParam("pageNum") Integer pageNum, 158 | @RequestParam("PageSize") Integer pageSize, 159 | @RequestParam(defaultValue = "") String itemname){ 160 | 161 | IPage page = new Page<>(pageNum,pageSize); 162 | QueryWrapper queryWrapper = new QueryWrapper<>(); 163 | if(StringUtils.hasText(itemname)){ 164 | queryWrapper.like("typename",itemname); 165 | } 166 | // queryWrapper.ne("id",1); 167 | queryWrapper.orderByDesc("id"); 168 | return R.SUCCESS(itemTypeService.page(page, queryWrapper)); 169 | } 170 | 171 | /** 172 | * @Author DragonOne 173 | * @Date 2022/3/9 17:13 174 | * @墨水记忆 www.tothefor.com 175 | * @方法 export 176 | * @作用 数据导出 177 | * @参数说明 178 | * @return 179 | */ 180 | @GetMapping("/export") 181 | public void exportType(HttpServletRequest request, HttpServletResponse response) throws Exception{ 182 | // String token = request.getHeader("token"); 183 | 184 | List> list = CollUtil.newArrayList(); 185 | List all = itemTypeMapper.selectList(null); 186 | 187 | for(ItemType it : all){ 188 | Map row1 = new LinkedHashMap<>(); 189 | row1.put("类型唯一标识符",it.getId()); 190 | row1.put("类型编号",it.getTypeId()); 191 | row1.put("类型名称",it.getTypename()); 192 | row1.put("类型描述",it.getDescription()); 193 | 194 | list.add(row1); 195 | } 196 | 197 | // 2. 写excel 198 | ExcelWriter writer = ExcelUtil.getWriter(true); 199 | writer.write(list, true); 200 | 201 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); 202 | String fileName = URLEncoder.encode("下载信息", "UTF-8"); 203 | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); 204 | 205 | ServletOutputStream out = response.getOutputStream(); 206 | writer.flush(out, true); 207 | writer.close(); 208 | IoUtil.close(System.out); 209 | 210 | 211 | } 212 | 213 | /** 214 | * @Author DragonOne 215 | * @Date 2022/3/9 17:13 216 | * @墨水记忆 www.tothefor.com 217 | * @方法 imp 218 | * @作用 数据导入 219 | * @参数说明 220 | * @return 221 | */ 222 | @PostMapping("/import") 223 | public R imp(MultipartFile file) { 224 | 225 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 226 | List items = CollUtil.newArrayList(); 227 | try { 228 | 229 | InputStream inputStream = file.getInputStream(); 230 | ExcelReader reader = ExcelUtil.getReader(inputStream); 231 | 232 | List> list = reader.read(1); 233 | 234 | System.out.println(list.size()); 235 | for (List row : list) { 236 | ItemType item = new ItemType(); 237 | item.setTypeId(Long.valueOf(row.get(0).toString())); 238 | item.setTypename(row.get(1).toString()); 239 | item.setDescription(row.get(2).toString()); 240 | 241 | items.add(item); 242 | } 243 | }catch (Exception e){ 244 | return R.FAIL(); 245 | } 246 | 247 | if(itemTypeService.saveBatch(items)){ 248 | return R.SUCCESS(); 249 | }else{ 250 | return R.FAIL(); 251 | } 252 | } 253 | 254 | 255 | /** 256 | * @Author DragonOne 257 | * @Date 2022/3/10 10:30 258 | * @墨水记忆 www.tothefor.com 259 | * @方法 exportMB 260 | * @作用 导入数据模板 261 | * @参数说明 262 | * @return 263 | */ 264 | @GetMapping("/exportMB") 265 | public void exportMB(HttpServletRequest request, HttpServletResponse response) throws Exception{ 266 | // String token = request.getHeader("token"); 267 | 268 | List> list = CollUtil.newArrayList(); 269 | ItemType it = new ItemType(); 270 | it.setTypeId(2L); 271 | it.setTypename("这里填写类型名称"); 272 | it.setDescription("类型描述"); 273 | 274 | 275 | Map row1 = new LinkedHashMap<>(); 276 | row1.put("物品编号",it.getTypeId()); 277 | row1.put("物品名称",it.getTypename()); 278 | row1.put("物品描述",it.getDescription()); 279 | 280 | list.add(row1); 281 | 282 | 283 | // 2. 写excel 284 | ExcelWriter writer = ExcelUtil.getWriter(true); 285 | writer.write(list, true); 286 | 287 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); 288 | String fileName = URLEncoder.encode("导入模板", "UTF-8"); 289 | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); 290 | 291 | ServletOutputStream out = response.getOutputStream(); 292 | writer.flush(out, true); 293 | writer.close(); 294 | IoUtil.close(System.out); 295 | 296 | 297 | } 298 | 299 | } 300 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/controller/menuController.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.controller; 2 | 3 | import cn.hutool.core.collection.CollUtil; 4 | import cn.hutool.core.io.IoUtil; 5 | import cn.hutool.poi.excel.ExcelReader; 6 | import cn.hutool.poi.excel.ExcelUtil; 7 | import cn.hutool.poi.excel.ExcelWriter; 8 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 9 | import com.baomidou.mybatisplus.core.metadata.IPage; 10 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 11 | import com.tothefor.mapper.MenuMapper; 12 | import com.tothefor.mapper.UserMapper; 13 | import com.tothefor.mapper.UserRoleMapper; 14 | import com.tothefor.pojo.entity.Menu; 15 | import com.tothefor.pojo.entity.User; 16 | import com.tothefor.pojo.entity.UserRole; 17 | import com.tothefor.resultR.R; 18 | import com.tothefor.service.impl.MenuServiceImpl; 19 | import com.tothefor.service.impl.UserRoleServiceImpl; 20 | import com.tothefor.service.impl.UserServiceImpl; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.util.StringUtils; 23 | import org.springframework.web.bind.annotation.*; 24 | import org.springframework.web.multipart.MultipartFile; 25 | 26 | import javax.servlet.ServletOutputStream; 27 | import javax.servlet.http.HttpServletRequest; 28 | import javax.servlet.http.HttpServletResponse; 29 | import java.io.InputStream; 30 | import java.net.URLEncoder; 31 | import java.text.SimpleDateFormat; 32 | import java.util.LinkedHashMap; 33 | import java.util.List; 34 | import java.util.Map; 35 | import java.util.stream.Collectors; 36 | 37 | /** 38 | * @Author DragonOne 39 | * @Date 2022/3/4 15:31 40 | * @墨水记忆 www.tothefor.com 41 | */ 42 | 43 | @RestController 44 | @RequestMapping("/menu") 45 | public class menuController { 46 | 47 | @Autowired 48 | private MenuMapper menuMapper; 49 | 50 | @Autowired 51 | private MenuServiceImpl menuService; 52 | 53 | 54 | /** 55 | * @Author DragonOne 56 | * @Date 2022/3/6 17:01 57 | * @墨水记忆 www.tothefor.com 58 | * @方法 itemAll 59 | * @作用 查找所有物品信息接口 60 | * @参数说明 61 | * @return 62 | */ 63 | @GetMapping("/menuAll") 64 | public R menuAll(){ 65 | List list = menuService.list(); 66 | List parNode = list.stream().filter(menu -> menu.getPid() == null).collect(Collectors.toList()); 67 | for( Menu it : parNode){ 68 | it.setChildren(list.stream().filter(m->it.getId().equals(m.getPid())).collect(Collectors.toList())); 69 | } 70 | 71 | return R.SUCCESS(parNode); 72 | } 73 | 74 | /** 75 | * @Author DragonOne 76 | * @Date 2022/3/6 17:02 77 | * @墨水记忆 www.tothefor.com 78 | * @方法 itemSave 79 | * @作用 插入和修改接口 80 | * @参数说明 81 | * @return 82 | */ 83 | @PostMapping("/save") 84 | public R menuSave(@RequestBody Menu item){ 85 | 86 | if(menuService.saveOrUpdate(item)){ 87 | return R.SUCCESS(); 88 | }else { 89 | return R.FAIL(); 90 | } 91 | } 92 | 93 | /** 94 | * @Author DragonOne 95 | * @Date 2022/3/6 17:06 96 | * @墨水记忆 www.tothefor.com 97 | * @方法 itemDelete 98 | * @作用 根据id删除信息 99 | * @参数说明 100 | * @return 101 | */ 102 | @DeleteMapping("/del/{id}") 103 | public R menuDelete(@PathVariable Integer id){ 104 | if(menuMapper.deleteById(id)==1){ 105 | return R.SUCCESS(); 106 | }else{ 107 | return R.FAIL(); 108 | } 109 | } 110 | 111 | /** 112 | * @Author DragonOne 113 | * @Date 2022/3/6 17:11 114 | * @墨水记忆 www.tothefor.com 115 | * @方法 itemBatchDelete 116 | * @作用 批量删除 117 | * @参数说明 118 | * @return 119 | */ 120 | @PostMapping("/batch/del") 121 | public R menuBatchDelete(@RequestBody List ids){ 122 | int len = ids.size(); 123 | if(menuMapper.deleteBatchIds(ids)==len){ 124 | return R.SUCCESS(); 125 | }else { 126 | return R.FAIL(); 127 | } 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/controller/userRoleController.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.controller; 2 | 3 | import cn.hutool.core.collection.CollUtil; 4 | import cn.hutool.core.io.IoUtil; 5 | import cn.hutool.poi.excel.ExcelReader; 6 | import cn.hutool.poi.excel.ExcelUtil; 7 | import cn.hutool.poi.excel.ExcelWriter; 8 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 9 | import com.baomidou.mybatisplus.core.metadata.IPage; 10 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 11 | import com.tothefor.mapper.UserRoleMapper; 12 | import com.tothefor.pojo.entity.ItemType; 13 | import com.tothefor.pojo.entity.UserRole; 14 | import com.tothefor.resultR.R; 15 | import com.tothefor.service.impl.UserRoleServiceImpl; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.util.StringUtils; 18 | import org.springframework.web.bind.annotation.*; 19 | import org.springframework.web.multipart.MultipartFile; 20 | 21 | import javax.servlet.ServletOutputStream; 22 | import javax.servlet.http.HttpServletRequest; 23 | import javax.servlet.http.HttpServletResponse; 24 | import java.io.InputStream; 25 | import java.net.URLEncoder; 26 | import java.text.SimpleDateFormat; 27 | import java.util.LinkedHashMap; 28 | import java.util.List; 29 | import java.util.Map; 30 | 31 | /** 32 | * @Author DragonOne 33 | * @Date 2022/3/10 16:34 34 | * @墨水记忆 www.tothefor.com 35 | */ 36 | @RestController 37 | @RequestMapping("/userRole") 38 | public class userRoleController { 39 | 40 | @Autowired 41 | private UserRoleMapper userRoleMapper; 42 | 43 | @Autowired 44 | private UserRoleServiceImpl userRoleService; 45 | 46 | /** 47 | * @Author DragonOne 48 | * @Date 2022/3/9 15:44 49 | * @墨水记忆 www.tothefor.com 50 | * @方法 itemTypeAll 51 | * @作用 查询全部类型 52 | * @参数说明 53 | * @return 54 | */ 55 | @GetMapping("/userRoleAll") 56 | public R> userRoleAll(){ 57 | return R.SUCCESS(userRoleMapper.selectList(null)); 58 | } 59 | 60 | /** 61 | * @Author DragonOne 62 | * @Date 2022/3/6 17:02 63 | * @墨水记忆 www.tothefor.com 64 | * @方法 itemSave 65 | * @作用 插入和修改接口 66 | * @参数说明 67 | * @return 68 | */ 69 | @PostMapping("/save") 70 | public R userRoleSave(@RequestBody UserRole item){ 71 | if(userRoleService.saveOrUpdate(item)){ 72 | return R.SUCCESS(); 73 | }else { 74 | return R.FAIL(); 75 | } 76 | } 77 | 78 | /** 79 | * @Author DragonOne 80 | * @Date 2022/3/6 17:06 81 | * @墨水记忆 www.tothefor.com 82 | * @方法 itemDelete 83 | * @作用 根据id删除信息 84 | * @参数说明 85 | * @return 86 | */ 87 | @DeleteMapping("/del/{id}") 88 | public R userRoleDelete(@PathVariable Integer id){ 89 | if(userRoleMapper.deleteById(id)==1){ 90 | return R.SUCCESS(); 91 | }else{ 92 | return R.FAIL(); 93 | } 94 | } 95 | 96 | /** 97 | * @Author DragonOne 98 | * @Date 2022/3/6 17:11 99 | * @墨水记忆 www.tothefor.com 100 | * @方法 itemBatchDelete 101 | * @作用 批量删除 102 | * @参数说明 103 | * @return 104 | */ 105 | @PostMapping("/batch/del") 106 | public R userRoleBatchDelete(@RequestBody List ids){ 107 | int len = ids.size(); 108 | if(userRoleMapper.deleteBatchIds(ids)==len){ 109 | return R.SUCCESS(); 110 | }else { 111 | return R.FAIL(); 112 | } 113 | } 114 | 115 | /** 116 | * @Author DragonOne 117 | * @Date 2022/3/7 12:37 118 | * @墨水记忆 www.tothefor.com 119 | * @方法 PageitemAll 120 | * @作用 物品的分页查询 121 | * @参数说明 122 | * @return 123 | */ 124 | @GetMapping("/pageAll") 125 | public R> PageUserRoleAll(@RequestParam("pageNum") Integer pageNum, 126 | @RequestParam("PageSize") Integer pageSize, 127 | @RequestParam(defaultValue = "") String itemname){ 128 | 129 | IPage page = new Page<>(pageNum,pageSize); 130 | QueryWrapper queryWrapper = new QueryWrapper<>(); 131 | if(StringUtils.hasText(itemname)){ 132 | queryWrapper.like("rolename",itemname); 133 | } 134 | queryWrapper.ne("id",1); 135 | queryWrapper.orderByDesc("id"); 136 | return R.SUCCESS(userRoleService.page(page, queryWrapper)); 137 | } 138 | 139 | /** 140 | * @Author DragonOne 141 | * @Date 2022/3/9 17:13 142 | * @墨水记忆 www.tothefor.com 143 | * @方法 export 144 | * @作用 数据导出 145 | * @参数说明 146 | * @return 147 | */ 148 | @GetMapping("/export") 149 | public void exportRole(HttpServletRequest request, HttpServletResponse response) throws Exception{ 150 | // String token = request.getHeader("token"); 151 | 152 | List> list = CollUtil.newArrayList(); 153 | List all = userRoleMapper.selectList(null); 154 | 155 | for(UserRole it : all){ 156 | Map row1 = new LinkedHashMap<>(); 157 | row1.put("唯一标识符",it.getId()); 158 | row1.put("角色编号",it.getRoleId()); 159 | row1.put("角色名称",it.getRolename()); 160 | row1.put("角色描述",it.getDescription()); 161 | 162 | list.add(row1); 163 | } 164 | 165 | // 2. 写excel 166 | ExcelWriter writer = ExcelUtil.getWriter(true); 167 | writer.write(list, true); 168 | 169 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); 170 | String fileName = URLEncoder.encode("下载信息", "UTF-8"); 171 | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); 172 | 173 | ServletOutputStream out = response.getOutputStream(); 174 | writer.flush(out, true); 175 | writer.close(); 176 | IoUtil.close(System.out); 177 | 178 | 179 | } 180 | 181 | /** 182 | * @Author DragonOne 183 | * @Date 2022/3/9 17:13 184 | * @墨水记忆 www.tothefor.com 185 | * @方法 imp 186 | * @作用 数据导入 187 | * @参数说明 188 | * @return 189 | */ 190 | @PostMapping("/import") 191 | public R impRole(MultipartFile file) { 192 | 193 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 194 | List items = CollUtil.newArrayList(); 195 | try { 196 | 197 | InputStream inputStream = file.getInputStream(); 198 | ExcelReader reader = ExcelUtil.getReader(inputStream); 199 | 200 | List> list = reader.read(1); 201 | 202 | System.out.println(list.size()); 203 | for (List row : list) { 204 | UserRole item = new UserRole(); 205 | item.setRoleId(Long.valueOf(row.get(0).toString())); 206 | item.setRolename(row.get(1).toString()); 207 | item.setDescription(row.get(2).toString()); 208 | 209 | items.add(item); 210 | } 211 | }catch (Exception e){ 212 | return R.FAIL(); 213 | } 214 | 215 | if(userRoleService.saveBatch(items)){ 216 | return R.SUCCESS(); 217 | }else{ 218 | return R.FAIL(); 219 | } 220 | } 221 | 222 | 223 | /** 224 | * @Author DragonOne 225 | * @Date 2022/3/10 10:30 226 | * @墨水记忆 www.tothefor.com 227 | * @方法 exportMB 228 | * @作用 导入数据模板 229 | * @参数说明 230 | * @return 231 | */ 232 | @GetMapping("/exportMB") 233 | public void exportMBRole(HttpServletRequest request, HttpServletResponse response) throws Exception{ 234 | // String token = request.getHeader("token"); 235 | 236 | List> list = CollUtil.newArrayList(); 237 | UserRole it = new UserRole(); 238 | it.setRoleId(2L); 239 | it.setRolename("这里填写角色名称"); 240 | it.setDescription("角色描述"); 241 | 242 | 243 | Map row1 = new LinkedHashMap<>(); 244 | row1.put("角色编号",it.getRoleId()); 245 | row1.put("角色名称",it.getRolename()); 246 | row1.put("角色描述",it.getDescription()); 247 | 248 | list.add(row1); 249 | 250 | 251 | // 2. 写excel 252 | ExcelWriter writer = ExcelUtil.getWriter(true); 253 | writer.write(list, true); 254 | 255 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); 256 | String fileName = URLEncoder.encode("导入模板", "UTF-8"); 257 | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); 258 | 259 | ServletOutputStream out = response.getOutputStream(); 260 | writer.flush(out, true); 261 | writer.close(); 262 | IoUtil.close(System.out); 263 | 264 | 265 | } 266 | 267 | /** 268 | * @Author DragonOne 269 | * @Date 2022/3/12 17:02 270 | * @墨水记忆 www.tothefor.com 271 | * @方法 roleMenu 272 | * @作用 通过角色id修改菜单权限 273 | * @参数说明 274 | * @return 275 | */ 276 | @PostMapping("/roleMenu/{roleId}") 277 | public R roleMenu(@PathVariable Integer roleId,@RequestBody List menuIds){ 278 | if(roleId==2) return R.FAIL(); 279 | userRoleService.setRoleMenu(roleId,menuIds); 280 | return R.SUCCESS(); 281 | } 282 | 283 | /** 284 | * @Author DragonOne 285 | * @Date 2022/3/12 17:02 286 | * @墨水记忆 www.tothefor.com 287 | * @方法 getroleMenu 288 | * @作用 通过角色id获取菜单权限 289 | * @参数说明 290 | * @return 291 | */ 292 | @GetMapping("/roleMenu/{roleId}") 293 | public R getRoleMenu(@PathVariable Integer roleId){ 294 | return R.SUCCESS(userRoleService.getRoleMenu(roleId)); 295 | } 296 | 297 | 298 | } 299 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/ItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.Item; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.stereotype.Repository; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | /** 11 | * @Author DragonOne 12 | * @Date 2022/3/4 13:28 13 | * @墨水记忆 www.tothefor.com 14 | */ 15 | @Component 16 | @Repository 17 | @Mapper 18 | public interface ItemMapper extends BaseMapper { 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/ItemTypeMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.ItemType; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.stereotype.Repository; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | /** 11 | * @Author DragonOne 12 | * @Date 2022/3/9 15:30 13 | * @墨水记忆 www.tothefor.com 14 | */ 15 | 16 | @Component 17 | @Repository 18 | @Mapper 19 | public interface ItemTypeMapper extends BaseMapper { 20 | } 21 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/MenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.Menu; 5 | import com.tothefor.pojo.entity.User; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.stereotype.Repository; 9 | 10 | /** 11 | * @Author DragonOne 12 | * @Date 2022/3/10 15:40 13 | * @墨水记忆 www.tothefor.com 14 | */ 15 | @Component 16 | @Repository 17 | @Mapper 18 | public interface MenuMapper extends BaseMapper { 19 | } 20 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/RecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.Record; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * @Author DragonOne 11 | * @Date 2022/3/4 13:28 12 | * @墨水记忆 www.tothefor.com 13 | */ 14 | @Component 15 | @Repository 16 | @Mapper 17 | public interface RecordMapper extends BaseMapper { 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/RoleMenuMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.Menu; 5 | import com.tothefor.pojo.entity.RoleMenu; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | import org.apache.ibatis.annotations.Select; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.stereotype.Repository; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @Author DragonOne 16 | * @Date 2022/3/10 15:40 17 | * @墨水记忆 www.tothefor.com 18 | */ 19 | @Component 20 | @Repository 21 | @Mapper 22 | public interface RoleMenuMapper extends BaseMapper { 23 | 24 | @Select("select menu_id from s_role_menu where role_id = #{roleId}") 25 | List selectByRoleId(@Param("roleId") Integer roleId); 26 | } 27 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.User; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * @Author DragonOne 11 | * @Date 2022/3/10 15:40 12 | * @墨水记忆 www.tothefor.com 13 | */ 14 | @Component 15 | @Repository 16 | @Mapper 17 | public interface UserMapper extends BaseMapper { 18 | } 19 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.tothefor.pojo.entity.UserRole; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * @Author DragonOne 11 | * @Date 2022/3/10 15:56 12 | * @墨水记忆 www.tothefor.com 13 | */ 14 | @Component 15 | @Repository 16 | @Mapper 17 | public interface UserRoleMapper extends BaseMapper { 18 | } 19 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/dto/CheckURL.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @Author DragonOne 10 | * @Date 2022/3/13 15:43 11 | * @墨水记忆 www.tothefor.com 12 | */ 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @ToString 18 | public class CheckURL { 19 | private String token ; 20 | private String urlpath; 21 | } 22 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/dto/LoginDTO.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.tothefor.pojo.entity.Menu; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | 10 | import java.io.Serializable; 11 | import java.util.List; 12 | 13 | /** 14 | * @Author DragonOne 15 | * @Date 2022/3/12 19:59 16 | * @墨水记忆 www.tothefor.com 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @ToString 22 | public class LoginDTO implements Serializable { 23 | private String username; 24 | // @JsonIgnore 25 | private String password; 26 | private String userToken; 27 | private List menus; 28 | private String roleName; 29 | private String RULpath; 30 | } 31 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/dto/PieData.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @Author DragonOne 10 | * @Date 2022/3/13 17:06 11 | * @墨水记忆 www.tothefor.com 12 | */ 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @ToString 18 | public class PieData { 19 | private Integer value; 20 | private String name; 21 | } 22 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/dto/RequestReturnInfo.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.dto; 2 | 3 | import com.tothefor.utils.RequestInfoUtils; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | /** 10 | * @Author DragonOne 11 | * @Date 2022/3/13 19:51 12 | * @墨水记忆 www.tothefor.com 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @ToString 18 | 19 | public class RequestReturnInfo { 20 | /** 21 | * ip 22 | */ 23 | private String ip; 24 | /** 25 | *浏览器名称 26 | */ 27 | private String browserName; 28 | /** 29 | * 浏览器版本 30 | */ 31 | private String browserVersion; 32 | /** 33 | * 操作系统 34 | */ 35 | private String osName ; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/dto/UserPassword.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @Author DragonOne 10 | * @Date 2022/3/13 20:17 11 | * @墨水记忆 www.tothefor.com 12 | */ 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @ToString 18 | public class UserPassword { 19 | 20 | private Long userid; 21 | private String oldP; 22 | private String newP; 23 | private String newPP; 24 | } 25 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/Item.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | import org.springframework.format.annotation.DateTimeFormat; 11 | 12 | import java.util.Date; 13 | import java.io.Serializable; 14 | 15 | /** 16 | * @Author DragonOne 17 | * @Date 2022/3/4 13:28 18 | * @墨水记忆 www.tothefor.com 19 | */ 20 | 21 | @Data 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | @ToString 25 | @Accessors(chain = true)// 使用链式方法 26 | @TableName("s_item") 27 | public class Item implements Serializable { 28 | private static final long serialVersionUID = 373498731959536545L; 29 | /** 30 | * 物品id 31 | */ 32 | @TableId(type = IdType.AUTO) 33 | @TableField("id") 34 | private Long id; 35 | /** 36 | * 物品编号 37 | */ 38 | @TableField("item_id") 39 | private String itemId; 40 | /** 41 | * 物品名 42 | */ 43 | @TableField("name") 44 | private String name; 45 | /** 46 | * 物品类型编号 47 | */ 48 | @TableField("typeID") 49 | private Long typeid; 50 | /** 51 | * 物品名称 52 | */ 53 | @TableField(exist = false) 54 | private String typeName; 55 | /** 56 | * 启用状态 57 | */ 58 | @TableField("is_show") 59 | private Boolean isShow; 60 | /** 61 | * 是否删除 62 | */ 63 | @TableLogic 64 | @TableField("is_delete") 65 | private Boolean isDelete; 66 | /** 67 | * 物品入库时间 68 | */ 69 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 70 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 71 | @TableField(value = "item_add_time",fill = FieldFill.INSERT) //在插入时填充 72 | private Date itemAddTime; 73 | /** 74 | * 最后修改时间 75 | */ 76 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 77 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 78 | @TableField(value = "item_update_time",fill = FieldFill.INSERT_UPDATE) //在插入和更新时填充 79 | private Date itemUpdateTime; 80 | /** 81 | * 物品规格 82 | */ 83 | @TableField("size") 84 | private String size; 85 | /** 86 | * 物品描述或备注 87 | */ 88 | @TableField("description") 89 | private String description; 90 | /** 91 | * 物品数量 92 | */ 93 | @TableField("item_count") 94 | private Long itemCount; 95 | 96 | 97 | } 98 | 99 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/ItemType.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | import org.springframework.format.annotation.DateTimeFormat; 11 | 12 | import java.util.Date; 13 | import java.io.Serializable; 14 | 15 | /** 16 | * @Author DragonOne 17 | * @Date 2022/3/4 13:28 18 | * @墨水记忆 www.tothefor.com 19 | */ 20 | 21 | @Data 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | @ToString 25 | @Accessors(chain = true)// 使用链式方法 26 | @TableName("s_item_type") 27 | public class ItemType implements Serializable { 28 | private static final long serialVersionUID = 373498731959536545L; 29 | /** 30 | * 类型唯一标识符 31 | */ 32 | @TableId(type = IdType.AUTO) 33 | @TableField("id") 34 | private Long id; 35 | /** 36 | * 类型编号 37 | */ 38 | @TableField("type_id") 39 | private Long typeId; 40 | /** 41 | * 类型名称 42 | */ 43 | @TableField("typename") 44 | private String typename; 45 | /** 46 | * 逻辑删除 47 | */ 48 | @TableLogic 49 | @TableField("is_delete") 50 | private Boolean isDelete; 51 | 52 | /** 53 | * 类型描述 54 | */ 55 | @TableField("description") 56 | private String description; 57 | 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/Menu.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import com.baomidou.mybatisplus.extension.activerecord.Model; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | import lombok.ToString; 12 | import lombok.experimental.Accessors; 13 | 14 | import java.io.Serializable; 15 | import java.util.List; 16 | 17 | /** 18 | * @Author DragonOne 19 | * @Date 2022/3/12 17:28 20 | * @墨水记忆 www.tothefor.com 21 | */ 22 | @Data 23 | @AllArgsConstructor 24 | @NoArgsConstructor 25 | @ToString 26 | @Accessors(chain = true)// 使用链式方法 27 | @TableName("s_menu") 28 | public class Menu implements Serializable { 29 | /** 30 | * 唯一标识符 31 | */ 32 | @TableId(type = IdType.AUTO) 33 | @TableField("id") 34 | private Long id; 35 | /** 36 | * 菜单编号 37 | */ 38 | @TableField("menu_id") 39 | private Long menuId; 40 | /** 41 | * 菜单名称 42 | */ 43 | @TableField("menu_name") 44 | private String menuName; 45 | //菜单路径 46 | @TableField("menu_path") 47 | private String menuPath; 48 | //菜单图标 49 | @TableField("menu_ico") 50 | private String menuIco; 51 | 52 | @TableField(exist = false) 53 | private List children; 54 | 55 | /** 56 | * 父级id 57 | */ 58 | @TableField("pid") 59 | private Long pid; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/Record.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | import org.springframework.format.annotation.DateTimeFormat; 11 | 12 | import java.io.Serializable; 13 | import java.util.Date; 14 | 15 | /** 16 | * @Author DragonOne 17 | * @Date 2022/3/4 13:28 18 | * @墨水记忆 www.tothefor.com 19 | */ 20 | 21 | @Data 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | @ToString 25 | @Accessors(chain = true)// 使用链式方法 26 | @TableName("s_record") 27 | public class Record implements Serializable { 28 | /** 29 | * id 30 | */ 31 | @TableId(type = IdType.AUTO) 32 | @TableField("id") 33 | private Long id; 34 | /** 35 | * 记录单名称 36 | */ 37 | @TableField("record_name") 38 | private String recordName; 39 | /** 40 | * 启用状态 41 | */ 42 | @TableField("is_show") 43 | private Boolean isShow; 44 | /** 45 | * 是否删除 46 | */ 47 | @TableLogic 48 | @TableField("is_delete") 49 | private Boolean isDelete; 50 | /** 51 | * 入库时间 52 | */ 53 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 54 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 55 | @TableField(value = "record_add_time",fill = FieldFill.INSERT) //在插入时填充 56 | private Date recordAddTime; 57 | /** 58 | * 最后修改时间 59 | */ 60 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 61 | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") 62 | @TableField(value = "record_update_time",fill = FieldFill.INSERT_UPDATE) //在插入和更新时填充 63 | private Date recordUpdateTime; 64 | /** 65 | * 物品描述或备注 66 | */ 67 | @TableField("description") 68 | private String description; 69 | /** 70 | * 签到人 71 | */ 72 | @TableField("record_man") 73 | private String recordMan; 74 | /** 75 | * 领取码 76 | */ 77 | @TableField(value = "getCode",fill = FieldFill.INSERT) 78 | private String getCode; 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/RoleMenu.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import com.baomidou.mybatisplus.extension.activerecord.Model; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | import lombok.ToString; 12 | import lombok.experimental.Accessors; 13 | 14 | import java.io.Serializable; 15 | 16 | /** 17 | * @Author DragonOne 18 | * @Date 2022/3/12 17:28 19 | * @墨水记忆 www.tothefor.com 20 | */ 21 | @Data 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | @ToString 25 | @Accessors(chain = true)// 使用链式方法 26 | @TableName("s_role_menu") 27 | public class RoleMenu implements Serializable { 28 | /** 29 | * 唯一标识符 30 | */ 31 | @TableId(type = IdType.AUTO) 32 | @TableField("id") 33 | private Long id; 34 | /** 35 | * 角色编号 36 | */ 37 | @TableField("role_id") 38 | private Long roleId; 39 | /** 40 | * 菜单编号 41 | */ 42 | @TableField("menu_id") 43 | private Long menuId; 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.Accessors; 10 | 11 | import java.io.Serializable; 12 | 13 | /** 14 | * @Author DragonOne 15 | * @Date 2022/3/4 13:28 16 | * @墨水记忆 www.tothefor.com 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @ToString 22 | @Accessors(chain = true)// 使用链式方法 23 | @TableName("s_user") 24 | public class User implements Serializable { 25 | private static final long serialVersionUID = -37411317986856736L; 26 | /** 27 | * 用户唯一标识符 28 | */ 29 | @TableId(type = IdType.AUTO) 30 | @TableField("id") 31 | private Long id; 32 | /** 33 | * 用户编号 34 | */ 35 | @TableField("user_ID") 36 | private String userid; 37 | /** 38 | * 用户名称 39 | */ 40 | @TableField("username") 41 | private String username; 42 | /** 43 | * 用户密码 44 | */ 45 | @TableField(value = "password",fill = FieldFill.INSERT) 46 | @JsonIgnore 47 | private String password; 48 | /** 49 | * 用户角色ID 50 | */ 51 | @TableField("role_ID") 52 | private Long roleId; 53 | /** 54 | * 角色名称 55 | */ 56 | @TableField(exist = false) 57 | private String roleName; 58 | /** 59 | * 用户描述 60 | */ 61 | @TableField("description") 62 | private String description; 63 | /** 64 | * 是否删除 65 | */ 66 | @TableLogic 67 | @TableField("is_delete") 68 | private Boolean isDelete; 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/pojo/entity/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.pojo.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | import lombok.ToString; 11 | import lombok.experimental.Accessors; 12 | 13 | import java.io.Serializable; 14 | 15 | /** 16 | * @Author DragonOne 17 | * @Date 2022/3/4 13:28 18 | * @墨水记忆 www.tothefor.com 19 | */ 20 | @Data 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | @ToString 24 | @Accessors(chain = true)// 使用链式方法 25 | @TableName("s_user_role") 26 | public class UserRole implements Serializable { 27 | private static final long serialVersionUID = 883443446115747143L; 28 | /** 29 | * 唯一标识符 30 | */ 31 | @TableId(type = IdType.AUTO) 32 | @TableField("id") 33 | private Long id; 34 | /** 35 | * 角色编号 36 | */ 37 | @TableField("role_id") 38 | private Long roleId; 39 | /** 40 | * 角色名称 41 | */ 42 | @TableField("rolename") 43 | private String rolename; 44 | /** 45 | * 逻辑删除 46 | */ 47 | @TableField("is_delete") 48 | private Integer isDelete; 49 | /** 50 | * 角色描述 51 | */ 52 | @TableField("description") 53 | private String description; 54 | 55 | 56 | } 57 | 58 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/resultR/R.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.resultR; 2 | 3 | import lombok.*; 4 | 5 | import java.io.Serializable; 6 | 7 | 8 | /** 9 | * 统一结果封装类 10 | * @Author DragonOne 11 | * @Date 2022/3/4 11:39 12 | * @墨水记忆 www.tothefor.com 13 | */ 14 | 15 | 16 | @Data 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @ToString 21 | public class R implements Serializable { 22 | 23 | /** 24 | * 对应 RCode 状态码中的属性 25 | */ 26 | private Boolean statusFlag; 27 | private Integer statusCode; 28 | private String statusMessage; 29 | 30 | /** 31 | * @Author DragonOne 32 | * @Date 2022/3/4 12:04 33 | * @墨水记忆 www.tothefor.com 34 | * @属性 timestamp 35 | * @作用 接口请求时间 36 | */ 37 | private long timestamp; 38 | 39 | /** 40 | * @Author DragonOne 41 | * @Date 2022/3/4 11:59 42 | * @墨水记忆 www.tothefor.com 43 | * @属性 data 44 | * @作用 携带后台传入的数据 45 | */ 46 | private T data; 47 | 48 | /** 49 | * @Author DragonOne 50 | * @Date 2022/3/4 13:04 51 | * @墨水记忆 www.tothefor.com 52 | * @方法 SUCCESS 53 | * @作用 成功,无数据 54 | * @参数说明 55 | * @return 56 | */ 57 | public static R SUCCESS(){ 58 | return SUCCESS(null); 59 | } 60 | 61 | /** 62 | * @Author DragonOne 63 | * @Date 2022/3/4 12:11 64 | * @墨水记忆 www.tothefor.com 65 | * @方法 SUCCESS 66 | * @作用 成功,有数据 67 | * @参数说明 68 | * @return 69 | */ 70 | public static R SUCCESS(T data){ 71 | return R.builder().data(data) 72 | .statusFlag(RCode.SUCCESS.getStatusFlag()) 73 | .statusCode(RCode.SUCCESS.getStatusCode()) 74 | .statusMessage(RCode.SUCCESS.getStatusMessage()) 75 | .timestamp(System.currentTimeMillis()) 76 | .build(); 77 | } 78 | 79 | /** 80 | * @Author DragonOne 81 | * @Date 2022/3/4 12:38 82 | * @墨水记忆 www.tothefor.com 83 | * @方法 FAIL 84 | * @作用 失败,无数据 85 | * @参数说明 86 | * @return 87 | */ 88 | public static R FAIL() { 89 | return FAIL(null); 90 | } 91 | 92 | /** 93 | * @Author DragonOne 94 | * @Date 2022/3/4 12:38 95 | * @墨水记忆 www.tothefor.com 96 | * @方法 FAIL 97 | * @作用 失败,有数据 98 | * @参数说明 99 | * @return 100 | */ 101 | public static R FAIL(T data){ 102 | return R.builder().data(data) 103 | .statusFlag(RCode.FAIL.getStatusFlag()) 104 | .statusCode(RCode.FAIL.getStatusCode()) 105 | .statusMessage(RCode.FAIL.getStatusMessage()) 106 | .timestamp(System.currentTimeMillis()) 107 | .build(); 108 | } 109 | 110 | /** 111 | * @Author DragonOne 112 | * @Date 2022/3/6 17:19 113 | * @墨水记忆 www.tothefor.com 114 | * @方法 FAIL 115 | * @作用 更具不同的场景,自定义不同的状态 116 | * @参数说明 自定义错误编码,自定义错误提示信息,无数据 117 | * @return 118 | */ 119 | public static R FAIL(Integer code,String msg){ 120 | return FAIL(code,msg,null); 121 | } 122 | 123 | /** 124 | * @Author DragonOne 125 | * @Date 2022/3/6 17:19 126 | * @墨水记忆 www.tothefor.com 127 | * @方法 FAIL 128 | * @作用 更具不同的场景,自定义不同的状态 129 | * @参数说明 自定义错误编码,自定义错误提示信息,有数据 130 | * @return 131 | */ 132 | public static R FAIL(Integer code,String msg,T data){ 133 | return R.builder().data(data) 134 | .statusFlag(RCode.FAIL.getStatusFlag()) 135 | .statusCode(code) 136 | .statusMessage(msg) 137 | .timestamp(System.currentTimeMillis()) 138 | .build(); 139 | } 140 | 141 | 142 | } 143 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/resultR/RCode.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.resultR; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | /** 9 | * 状态码 10 | * @Author DragonOne 11 | * @Date 2022/3/4 11:39 12 | * @墨水记忆 www.tothefor.com 13 | */ 14 | 15 | @Getter 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @ToString 19 | public enum RCode { 20 | 21 | /** 22 | * 成功 23 | */ 24 | SUCCESS(true,200, "成功"), 25 | 26 | /** 27 | * 失败 28 | */ 29 | FAIL(false,500, "失败"); 30 | 31 | /** 32 | * @Author DragonOne 33 | * @Date 2022/3/4 11:54 34 | * @墨水记忆 www.tothefor.com 35 | * @属性 statusFlag 36 | * @作用 判断是否成功 37 | */ 38 | private Boolean statusFlag; 39 | 40 | /** 41 | * @Author DragonOne 42 | * @Date 2022/3/4 11:56 43 | * @墨水记忆 www.tothefor.com 44 | * @属性 statusCode 45 | * @作用 返回结果状态码 46 | */ 47 | private Integer statusCode; 48 | 49 | /** 50 | * @Author DragonOne 51 | * @Date 2022/3/4 11:56 52 | * @墨水记忆 www.tothefor.com 53 | * @属性 statusMessage 54 | * @作用 提示信息 55 | */ 56 | private String statusMessage; 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/ItemService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.entity.Item; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * 物品service 9 | * @Author DragonOne 10 | * @Date 2022/3/4 13:28 11 | * @墨水记忆 www.tothefor.com 12 | */ 13 | @Service 14 | public interface ItemService extends IService { 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/ItemTypeService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.entity.ItemType; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.transaction.annotation.Transactional; 7 | 8 | /** 9 | * 物品类型service 10 | * @Author DragonOne 11 | * @Date 2022/3/4 13:28 12 | * @since 2022-03-09 15:31:07 13 | */ 14 | @Service 15 | public interface ItemTypeService extends IService { 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.entity.Menu; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * @Author DragonOne 9 | * @Date 2022/3/10 15:42 10 | * @墨水记忆 www.tothefor.com 11 | */ 12 | 13 | @Service 14 | public interface MenuService extends IService { 15 | } 16 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/RecordService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.entity.Record; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * 物品service 9 | * @Author DragonOne 10 | * @Date 2022/3/4 13:28 11 | * @墨水记忆 www.tothefor.com 12 | */ 13 | @Service 14 | public interface RecordService extends IService { 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/RoleMenuService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.entity.Menu; 5 | import com.tothefor.pojo.entity.RoleMenu; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @Author DragonOne 10 | * @Date 2022/3/10 15:42 11 | * @墨水记忆 www.tothefor.com 12 | */ 13 | 14 | @Service 15 | public interface RoleMenuService extends IService { 16 | } 17 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/UserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.entity.Item; 5 | import com.tothefor.pojo.entity.UserRole; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Author DragonOne 12 | * @Date 2022/3/10 16:01 13 | * @墨水记忆 www.tothefor.com 14 | */ 15 | @Service 16 | public interface UserRoleService extends IService { 17 | void setRoleMenu(Integer roleId, List menuIds); 18 | 19 | List getRoleMenu(Integer roleId); 20 | } 21 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.tothefor.pojo.dto.LoginDTO; 5 | import com.tothefor.pojo.entity.Item; 6 | import com.tothefor.pojo.entity.Menu; 7 | import com.tothefor.pojo.entity.User; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @Author DragonOne 14 | * @Date 2022/3/10 15:42 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | 18 | @Service 19 | public interface UserService extends IService { 20 | 21 | /** 22 | * 通过用户名查找菜单权限 23 | * @param username 24 | * @return 25 | */ 26 | List menuByName(String username); 27 | } 28 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/ItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.tothefor.mapper.ItemMapper; 6 | import com.tothefor.pojo.entity.Item; 7 | import com.tothefor.service.ItemService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | 11 | /** 12 | * 物品实现类 13 | * @Author DragonOne 14 | * @Date 2022/3/4 13:28 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | @Service("ItemServiceImpl") 18 | public class ItemServiceImpl extends ServiceImpl implements ItemService { 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/ItemTypeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.tothefor.mapper.ItemTypeMapper; 5 | import com.tothefor.pojo.entity.ItemType; 6 | import com.tothefor.service.ItemTypeService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | /** 11 | * 物品类型实现类 12 | * @Author DragonOne 13 | * @Date 2022/3/4 13:28 14 | * @since 2022-03-09 15:31:08 15 | */ 16 | @Service("ItemTypeServiceImpl") 17 | public class ItemTypeServiceImpl extends ServiceImpl implements ItemTypeService { 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/MenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.tothefor.mapper.MenuMapper; 5 | import com.tothefor.mapper.UserMapper; 6 | import com.tothefor.pojo.entity.Menu; 7 | import com.tothefor.pojo.entity.User; 8 | import com.tothefor.service.MenuService; 9 | import com.tothefor.service.UserService; 10 | import org.springframework.stereotype.Service; 11 | 12 | /** 13 | * @Author DragonOne 14 | * @Date 2022/3/10 15:43 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | @Service("MenuServiceImpl") 18 | public class MenuServiceImpl extends ServiceImpl implements MenuService { 19 | } 20 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/RecordServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.tothefor.mapper.ItemMapper; 6 | import com.tothefor.mapper.RecordMapper; 7 | import com.tothefor.pojo.entity.Item; 8 | import com.tothefor.pojo.entity.Record; 9 | import com.tothefor.service.ItemService; 10 | import com.tothefor.service.RecordService; 11 | import org.springframework.stereotype.Service; 12 | 13 | /** 14 | * 物品实现类 15 | * @Author DragonOne 16 | * @Date 2022/3/4 13:28 17 | * @墨水记忆 www.tothefor.com 18 | */ 19 | @Service("RecordServiceImpl") 20 | public class RecordServiceImpl extends ServiceImpl implements RecordService { 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/RoleMenuServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.tothefor.mapper.MenuMapper; 5 | import com.tothefor.mapper.RoleMenuMapper; 6 | import com.tothefor.pojo.entity.Menu; 7 | import com.tothefor.pojo.entity.RoleMenu; 8 | import com.tothefor.service.MenuService; 9 | import com.tothefor.service.RoleMenuService; 10 | import org.springframework.stereotype.Service; 11 | 12 | /** 13 | * @Author DragonOne 14 | * @Date 2022/3/10 15:43 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | @Service("RoleMenuServiceImpl") 18 | public class RoleMenuServiceImpl extends ServiceImpl implements RoleMenuService { 19 | } 20 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/UserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.tothefor.mapper.ItemMapper; 6 | import com.tothefor.mapper.RoleMenuMapper; 7 | import com.tothefor.mapper.UserRoleMapper; 8 | import com.tothefor.pojo.entity.Item; 9 | import com.tothefor.pojo.entity.RoleMenu; 10 | import com.tothefor.pojo.entity.UserRole; 11 | import com.tothefor.service.ItemService; 12 | import com.tothefor.service.UserRoleService; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Service; 15 | import org.springframework.transaction.annotation.Transactional; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @Author DragonOne 21 | * @Date 2022/3/10 16:02 22 | * @墨水记忆 www.tothefor.com 23 | */ 24 | @Service("UserRoleServiceImpl") 25 | public class UserRoleServiceImpl extends ServiceImpl implements UserRoleService { 26 | 27 | 28 | @Autowired 29 | private RoleMenuMapper roleMenuMapper; 30 | 31 | @Autowired 32 | private RoleMenuServiceImpl roleMenuService; 33 | 34 | @Transactional 35 | @Override 36 | public void setRoleMenu(Integer roleId, List menuIds) { 37 | 38 | QueryWrapper queryWrapper = new QueryWrapper<>(); 39 | queryWrapper.eq("role_id",roleId); 40 | roleMenuMapper.delete(queryWrapper); 41 | 42 | // String sd = roleId.toString(); 43 | for(Integer it: menuIds){ 44 | RoleMenu roleMenu = new RoleMenu(); 45 | roleMenu.setRoleId(Long.valueOf(roleId)); 46 | roleMenu.setMenuId(Long.valueOf(it)); 47 | roleMenuMapper.insert(roleMenu); 48 | 49 | } 50 | 51 | } 52 | 53 | @Override 54 | public List getRoleMenu(Integer roleId) { 55 | return roleMenuMapper.selectByRoleId(roleId); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.tothefor.mapper.MenuMapper; 6 | import com.tothefor.mapper.RoleMenuMapper; 7 | import com.tothefor.mapper.UserMapper; 8 | import com.tothefor.pojo.dto.LoginDTO; 9 | import com.tothefor.pojo.entity.Menu; 10 | import com.tothefor.pojo.entity.RoleMenu; 11 | import com.tothefor.pojo.entity.User; 12 | import com.tothefor.resultR.R; 13 | import com.tothefor.service.UserService; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashSet; 19 | import java.util.List; 20 | import java.util.Set; 21 | import java.util.stream.Collectors; 22 | 23 | /** 24 | * @Author DragonOne 25 | * @Date 2022/3/10 15:43 26 | * @墨水记忆 www.tothefor.com 27 | */ 28 | @Service("UserServiceImpl") 29 | public class UserServiceImpl extends ServiceImpl implements UserService { 30 | 31 | @Autowired 32 | private UserMapper userMapper; 33 | 34 | 35 | @Autowired 36 | private RoleMenuMapper roleMenuMapper; 37 | 38 | @Autowired 39 | private MenuMapper menuMapper; 40 | 41 | /** 42 | * 通过用户名查找菜单权限 43 | * @param username 44 | * @return 45 | */ 46 | @Override 47 | public List menuByName(String username) { 48 | QueryWrapper queryWrapper = new QueryWrapper<>(); 49 | queryWrapper.eq("username",username); 50 | User user = userMapper.selectOne(queryWrapper); 51 | //查找角色 52 | Long roleId = user.getRoleId(); 53 | QueryWrapper qw = new QueryWrapper<>(); 54 | qw.eq("role_id",roleId); 55 | List roleMenus = roleMenuMapper.selectList(qw); 56 | 57 | //查找角色对应的菜单 58 | List list = new ArrayList<>(); 59 | for(RoleMenu it : roleMenus){ 60 | Long menuId = it.getMenuId(); 61 | Menu menu = menuMapper.selectById(menuId); 62 | list.add(menu); 63 | } 64 | // 存储角色有的的菜单id 65 | Set set = new HashSet<>(); 66 | 67 | for(Menu it: list){ 68 | set.add(it.getId()); 69 | if(it.getPid()!=null)set.add(it.getPid()); 70 | } 71 | // 通过id找到菜单并加入 72 | List listall = new ArrayList<>(); 73 | for(Long it : set){ 74 | Menu menu = menuMapper.selectById(it); 75 | listall.add(menu); 76 | } 77 | 78 | List parNode = listall.stream().filter(menu -> menu.getPid() == null).collect(Collectors.toList()); 79 | for( Menu it : parNode){ 80 | it.setChildren(listall.stream().filter(m->it.getId().equals(m.getPid())).collect(Collectors.toList())); 81 | } 82 | return parNode; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/utils/JWTUtils.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.utils; 2 | 3 | import com.auth0.jwt.JWT; 4 | import com.auth0.jwt.JWTCreator; 5 | import com.auth0.jwt.algorithms.Algorithm; 6 | import com.auth0.jwt.interfaces.Claim; 7 | import com.auth0.jwt.interfaces.DecodedJWT; 8 | 9 | import java.util.*; 10 | 11 | /** 12 | * JWT工具类 13 | * @Author DragonOne 14 | * @Date 2022/3/4 13:28 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | 18 | 19 | public class JWTUtils { 20 | 21 | //自定义签名密钥 22 | private static final String SIG = "HIUDe9%^#&dsf4%#4tr115&*&*wer6grfvewfw"; 23 | 24 | /** 25 | * 生成token 26 | * @param map 自定义数据 27 | * @return String 28 | */ 29 | 30 | public static String getToken(Map map){ 31 | Algorithm alg = Algorithm.HMAC256(SIG); //自定义签名密钥 32 | Calendar ins = Calendar.getInstance(); 33 | ins.add(Calendar.DATE,1); //默认过期时间为1天 34 | // ins.add(Calendar.SECOND,30); 35 | //jwt builder 36 | JWTCreator.Builder builder = JWT.create(); 37 | builder.withIssuedAt(new Date()); 38 | //payload 39 | map.forEach((k,v)->{ 40 | builder.withClaim(k,v); 41 | }); 42 | //signature 43 | String token = builder.withExpiresAt(ins.getTime()).sign(alg); 44 | 45 | return token; 46 | } 47 | 48 | /** 49 | * 获取token信息 50 | * @param token 51 | * @return DecodedJWT 52 | */ 53 | public static DecodedJWT getTokenInfo(String token){ 54 | DecodedJWT verify = JWT.require(Algorithm.HMAC256(SIG)).build().verify(token); 55 | return verify; 56 | } 57 | 58 | /** 59 | * @Author DragonOne 60 | * @Date 2022/3/7 11:16 61 | * @墨水记忆 www.tothefor.com 62 | * @属性 检验token合法性 63 | * @作用 80 64 | */ 65 | public static boolean checkToken(String token){ 66 | boolean flag = false; 67 | try{ 68 | getTokenInfo(token); 69 | flag=true; 70 | }catch (Exception e){ 71 | flag=false; 72 | }finally { 73 | return flag; 74 | } 75 | } 76 | /** 77 | * @Author DragonOne 78 | * @Date 2022/3/13 12:16 79 | * @墨水记忆 www.tothefor.com 80 | * @属性 通过token获取用户名 81 | * @作用 80 82 | */ 83 | public static String getNameByToken(String token){ 84 | DecodedJWT tokenInfo = getTokenInfo(token); 85 | String username = tokenInfo.getClaim("username").asString(); 86 | return username; 87 | } 88 | 89 | /** 90 | * @Author DragonOne 91 | * @Date 2022/3/13 12:16 92 | * @墨水记忆 www.tothefor.com 93 | * @属性 通过token获取用户id 94 | * @作用 80 95 | */ 96 | public static String getIdByToken(String token){ 97 | DecodedJWT tokenInfo = getTokenInfo(token); 98 | String userid = tokenInfo.getClaim("userid").asString(); 99 | return userid; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/utils/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.utils; 2 | 3 | import cn.hutool.core.util.RandomUtil; 4 | import org.springframework.util.DigestUtils; 5 | 6 | /** 7 | * MD5加密工具类 8 | * @Author DragonOne 9 | * @Date 2022/3/4 13:28 10 | * @墨水记忆 www.tothefor.com 11 | */ 12 | 13 | 14 | public class MD5Utils { 15 | public static void main(String[] args) { 16 | // System.out.println(getMD5("123456"));8 17 | String s = "ba bai"; 18 | System.out.println(DigestUtils.md5DigestAsHex(s.getBytes())); 19 | } 20 | 21 | public static String getMD5(String password){ 22 | 23 | /** 24 | * 加密处理第一次 25 | */ 26 | String pwd = "abc123"; 27 | pwd+=password; 28 | pwd+="def123"; 29 | String s = DigestUtils.md5DigestAsHex(pwd.getBytes()); 30 | 31 | /** 32 | * 加密处理第二次 33 | */ 34 | String Dpwd = "ghi123"; 35 | Dpwd+=s; 36 | Dpwd+= "jkl123"; 37 | String ss = DigestUtils.md5DigestAsHex(Dpwd.getBytes()); 38 | return ss; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /School-java/src/main/java/com/tothefor/utils/RequestInfoUtils.java: -------------------------------------------------------------------------------- 1 | package com.tothefor.utils; 2 | 3 | import eu.bitwalker.useragentutils.Browser; 4 | import eu.bitwalker.useragentutils.OperatingSystem; 5 | import eu.bitwalker.useragentutils.UserAgent; 6 | import eu.bitwalker.useragentutils.Version; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import java.net.InetAddress; 10 | import java.net.UnknownHostException; 11 | 12 | /** 13 | * @Author DragonOne 14 | * @Date 2022/3/13 19:44 15 | * @墨水记忆 www.tothefor.com 16 | */ 17 | public class RequestInfoUtils { 18 | /** 19 | * 获取发起请求的IP地址 20 | */ 21 | public static String getIp(HttpServletRequest request) { 22 | String ip = null; 23 | ip = request.getHeader("x-forwarded-for"); 24 | if ((ip == null) || (ip.length() == 0) || ("unknown".equalsIgnoreCase(ip))) { 25 | ip = request.getHeader("Proxy-Client-IP"); 26 | } 27 | if ((ip == null) || (ip.length() == 0) || ("unknown".equalsIgnoreCase(ip))) { 28 | ip = request.getHeader("WL-Proxy-Client-IP"); 29 | } 30 | if ((ip == null) || (ip.length() == 0) || ("unknown".equalsIgnoreCase(ip))) { 31 | ip = request.getRemoteAddr(); 32 | if (ip.equals("127.0.0.1")) { 33 | InetAddress inet = null; 34 | try { 35 | inet = InetAddress.getLocalHost(); 36 | } catch (UnknownHostException e) { 37 | e.printStackTrace(); 38 | } 39 | ip = inet.getHostAddress(); 40 | } 41 | } 42 | if ((ip != null) && (ip.length() > 15)) { 43 | if (ip.indexOf(",") > 0) { 44 | ip = ip.substring(0, ip.indexOf(",")); 45 | } 46 | } 47 | return ip; 48 | } 49 | 50 | /** 51 | * 获取发起请求的浏览器名称 52 | */ 53 | public static String getBrowserName(HttpServletRequest request) { 54 | String header = request.getHeader("User-Agent"); 55 | UserAgent userAgent = UserAgent.parseUserAgentString(header); 56 | Browser browser = userAgent.getBrowser(); 57 | return browser.getName(); 58 | } 59 | 60 | /** 61 | * 获取发起请求的浏览器版本号 62 | */ 63 | public static String getBrowserVersion(HttpServletRequest request) { 64 | String header = request.getHeader("User-Agent"); 65 | UserAgent userAgent = UserAgent.parseUserAgentString(header); 66 | // 获取浏览器信息 67 | Browser browser = userAgent.getBrowser(); 68 | // 获取浏览器版本号 69 | Version version = browser.getVersion(header); 70 | return version.getVersion(); 71 | } 72 | 73 | /** 74 | * 获取发起请求的操作系统名称 75 | */ 76 | public static String getOsName(HttpServletRequest request) { 77 | String header = request.getHeader("User-Agent"); 78 | UserAgent userAgent = UserAgent.parseUserAgentString(header); 79 | OperatingSystem operatingSystem = userAgent.getOperatingSystem(); 80 | return operatingSystem.getName(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /School-java/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | username: root 4 | password: root 5 | url: jdbc:mysql://127.0.0.1:3306/tothefor?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8 6 | driver-class-name: com.mysql.cj.jdbc.Driver 7 | 8 | 9 | server: 10 | port: 8081 11 | 12 | mybatis-plus: 13 | global-config: 14 | db-config: 15 | logic-delete-field: isDelete # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2) 16 | logic-delete-value: true # 逻辑已删除值(默认为 1) 17 | logic-not-delete-value: false # 逻辑未删除值(默认为 0) 18 | 19 | type-aliases-package: com.tothefor.pojo.entity # 哪一个包里面的类可以在mapper文件中直接简写为类名 20 | mapper-locations: classpath:/mapper/*.xml # 找mapper文件的位置,第一个位置不需要斜杠,classpath表示从resources开始 21 | # configuration: 22 | # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 23 | -------------------------------------------------------------------------------- /School-java/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: dev 4 | -------------------------------------------------------------------------------- /School-java/src/test/java/com/tothefor/SchoolJavaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.tothefor; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SchoolJavaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /schoolm/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /schoolm/README.md: -------------------------------------------------------------------------------- 1 | # schoolm 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /schoolm/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /schoolm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "schoolm", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@element-plus/icons": "0.0.11", 12 | "@element-plus/icons-vue": "^1.0.0", 13 | "axios": "^0.26.0", 14 | "core-js": "^3.6.5", 15 | "echarts": "^5.3.0", 16 | "element-plus": "^2.0.4", 17 | "js-file-download": "^0.4.12", 18 | "vant": "^3.4.5", 19 | "vue": "^3.0.0", 20 | "vue-router": "^4.0.0-0", 21 | "vuex": "^4.0.0-0" 22 | }, 23 | "devDependencies": { 24 | "@vue/cli-plugin-babel": "~4.5.15", 25 | "@vue/cli-plugin-eslint": "~4.5.15", 26 | "@vue/cli-plugin-router": "~4.5.15", 27 | "@vue/cli-plugin-vuex": "~4.5.15", 28 | "@vue/cli-service": "~4.5.15", 29 | "@vue/compiler-sfc": "^3.0.0", 30 | "babel-eslint": "^10.1.0", 31 | "eslint": "^6.7.2", 32 | "eslint-plugin-vue": "^7.0.0" 33 | }, 34 | "eslintConfig": { 35 | "root": true, 36 | "env": { 37 | "node": true 38 | }, 39 | "extends": [ 40 | "plugin:vue/vue3-essential", 41 | "eslint:recommended" 42 | ], 43 | "parserOptions": { 44 | "parser": "babel-eslint" 45 | }, 46 | "rules": {} 47 | }, 48 | "browserslist": [ 49 | "> 1%", 50 | "last 2 versions", 51 | "not dead" 52 | ] 53 | } 54 | -------------------------------------------------------------------------------- /schoolm/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HEEKDragonOne/FirstBlood/75dd72a0ecf28a8aa589a84ca6362385a239ac43/schoolm/public/favicon.ico -------------------------------------------------------------------------------- /schoolm/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /schoolm/public/tothefor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HEEKDragonOne/FirstBlood/75dd72a0ecf28a8aa589a84ca6362385a239ac43/schoolm/public/tothefor.png -------------------------------------------------------------------------------- /schoolm/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 13 | -------------------------------------------------------------------------------- /schoolm/src/assets/global.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | -------------------------------------------------------------------------------- /schoolm/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HEEKDragonOne/FirstBlood/75dd72a0ecf28a8aa589a84ca6362385a239ac43/schoolm/src/assets/logo.png -------------------------------------------------------------------------------- /schoolm/src/assets/tothefor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HEEKDragonOne/FirstBlood/75dd72a0ecf28a8aa589a84ca6362385a239ac43/schoolm/src/assets/tothefor.png -------------------------------------------------------------------------------- /schoolm/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 43 | 44 | 45 | 61 | -------------------------------------------------------------------------------- /schoolm/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import store from './store' 5 | import ElementPlus from 'element-plus' 6 | import 'element-plus/dist/index.css' 7 | import './assets/global.css' 8 | import * as ElIcons from '@element-plus/icons-vue' 9 | import request from './request/request' 10 | 11 | const app = createApp(App) 12 | for (const icname in ElIcons){ 13 | app.component(icname,ElIcons[icname]) 14 | } 15 | app.config.globalProperties.$http = request 16 | app.use(store) 17 | app.use(router) 18 | app.use(ElementPlus,{size: 'default'}) 19 | app.mount('#app') 20 | -------------------------------------------------------------------------------- /schoolm/src/request/request.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const request = axios.create({ 4 | baseURL: 'http://127.0.0.1:8081', 5 | timeout: 10000 6 | }) 7 | 8 | // request 拦截器 9 | request.interceptors.request.use(config => { 10 | config.headers['Content-Type'] = 'application/json;charset=utf-8'; 11 | 12 | // let usertoken = localStorage.getItem("token")?JSON.parse(localStorage.getItem("token")):null 13 | 14 | let usertoken = localStorage.getItem("token") 15 | 16 | config.headers['token'] = usertoken; // 设置请求头 17 | return config 18 | }, error => { 19 | return Promise.reject(error) 20 | }); 21 | 22 | // response 拦截器 23 | request.interceptors.response.use( 24 | response => { 25 | let res = response.data; 26 | // 如果是返回的文件 27 | if (response.config.responseType === 'blob') { 28 | return res 29 | } 30 | // 兼容服务端返回的字符串数据 31 | if (typeof res === 'string') { 32 | res = res ? JSON.parse(res) : res 33 | } 34 | return res; 35 | }, 36 | error => { 37 | // console.log('err' + error) // for debug 38 | return Promise.reject(error) 39 | } 40 | ) 41 | 42 | 43 | export default request 44 | 45 | -------------------------------------------------------------------------------- /schoolm/src/router/index.js: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHistory } from 'vue-router' 2 | import request from '@/request/request' 3 | const routes = [ 4 | { 5 | path: '/login', 6 | name: '登陆', 7 | component: ()=>import('@/views/login/index'), 8 | }, 9 | { 10 | path: '/', 11 | name: '仪表盘', 12 | component: ()=>import('@/views/index'), 13 | redirect: '/home', 14 | children:[ 15 | { 16 | path: '/home', 17 | name: '首页', 18 | component: ()=>import('@/views/homeData/index'), 19 | } 20 | ] 21 | }, 22 | { 23 | path: '/basic', 24 | name: '物品管理', 25 | component: ()=>import('@/views/index'), 26 | children:[ 27 | { 28 | path: '/itemShow', 29 | name: '物品列表', 30 | component: ()=>import('@/views/basic/itemShow/index'), 31 | }, 32 | { 33 | path: '/itemType', 34 | name: '物品类型', 35 | component: ()=>import('@/views/basic/itemType/index'), 36 | }, 37 | { 38 | path: '/recordShow', 39 | name: '借出管理', 40 | component: ()=>import('@/views/basic/recordShow/index'), 41 | }, 42 | { 43 | path: '/lookData', 44 | name: '数据展示', 45 | component: ()=>import('@/views/basic/lookData/index'), 46 | } 47 | ], 48 | }, 49 | { 50 | path: '/sys', 51 | name: '权限设置', 52 | component: ()=>import('@/views/index'), 53 | children:[ 54 | { 55 | path: '/auth', 56 | name: '权限管理', 57 | component: ()=>import('@/views/sys/auth/index'), 58 | }, 59 | { 60 | path: '/role', 61 | name: '角色管理', 62 | component: ()=>import('@/views/sys/role/index'), 63 | }, 64 | { 65 | path: '/mans', 66 | name: '人员管理', 67 | component: ()=>import('@/views/sys/mans/index'), 68 | } 69 | ], 70 | }, 71 | { 72 | path: '/sett', 73 | name: '系统设置', 74 | component: ()=>import('@/views/index'), 75 | children:[ 76 | { 77 | path: '/pwd', 78 | name: '修改密码', 79 | component: ()=>import('@/views/sys/updatePwd/index'), 80 | }, 81 | { 82 | path: '/perPwd', 83 | name: '个人密码', 84 | component: ()=>import('@/views/sys/perPwd/index'), 85 | } 86 | ] 87 | } 88 | ] 89 | 90 | const router = createRouter({ 91 | history: createWebHistory(process.env.BASE_URL), 92 | routes 93 | }) 94 | 95 | router.beforeEach((to,from,next)=>{ 96 | if(to.path!='/login'){ //需要登录 97 | let token = localStorage.getItem('token') 98 | let logindto = {} 99 | logindto.token=token 100 | logindto.urlpath=to.path 101 | if(token!=null){ //登录过 102 | //验证token 103 | request.post("/user/checkToken",token).then(res=>{ 104 | //成功 105 | if(res.statusCode == '200'){ 106 | // next() 107 | if(to.path=='/' || to.path=='/home'){ 108 | next() 109 | }else { 110 | request.post("/user/checkURL",logindto).then(res=>{ 111 | if(res.statusCode == '200'){ 112 | next() 113 | }else{ 114 | next({path:'/login'}) 115 | } 116 | }) 117 | } 118 | 119 | }else{ 120 | next({path:'/login'}) 121 | } 122 | 123 | }).catch(()=>{ 124 | next({path:'/login'}) 125 | }) 126 | 127 | }else{ //没有登录 128 | next({path:'/login'}) 129 | } 130 | 131 | }else{ //不需要登录 132 | next() 133 | } 134 | }) 135 | 136 | export default router 137 | -------------------------------------------------------------------------------- /schoolm/src/store/index.js: -------------------------------------------------------------------------------- 1 | import { createStore } from 'vuex' 2 | 3 | export default createStore({ 4 | state: { 5 | }, 6 | mutations: { 7 | }, 8 | actions: { 9 | }, 10 | modules: { 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /schoolm/src/views/basic/itemShow/index.vue: -------------------------------------------------------------------------------- 1 | 164 | 165 | 408 | 409 | 415 | -------------------------------------------------------------------------------- /schoolm/src/views/basic/itemType/index.vue: -------------------------------------------------------------------------------- 1 | 92 | 93 | 284 | 285 | 291 | -------------------------------------------------------------------------------- /schoolm/src/views/basic/lookData/index.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 120 | 121 | 126 | -------------------------------------------------------------------------------- /schoolm/src/views/basic/recordShow/index.vue: -------------------------------------------------------------------------------- 1 | 104 | 105 | 307 | 308 | 314 | -------------------------------------------------------------------------------- /schoolm/src/views/homeData/index.vue: -------------------------------------------------------------------------------- 1 | 50 | 51 | 124 | 125 | 132 | -------------------------------------------------------------------------------- /schoolm/src/views/index.vue: -------------------------------------------------------------------------------- 1 | 124 | 125 | 194 | 195 | 238 | -------------------------------------------------------------------------------- /schoolm/src/views/login/index.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 96 | 97 | 122 | -------------------------------------------------------------------------------- /schoolm/src/views/register/index.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /schoolm/src/views/sys/auth/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /schoolm/src/views/sys/mans/index.vue: -------------------------------------------------------------------------------- 1 | 137 | 138 | 345 | 346 | 352 | -------------------------------------------------------------------------------- /schoolm/src/views/sys/perPwd/index.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 112 | 113 | 128 | -------------------------------------------------------------------------------- /schoolm/src/views/sys/role/index.vue: -------------------------------------------------------------------------------- 1 | 112 | 113 | 356 | 357 | 363 | -------------------------------------------------------------------------------- /schoolm/src/views/sys/updatePwd/index.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 96 | 97 | 112 | -------------------------------------------------------------------------------- /schoolm/vue.config.js: -------------------------------------------------------------------------------- 1 | // vue.config.js 2 | module.exports = { 3 | chainWebpack: config => { 4 | config 5 | .plugin('html') 6 | .tap(args => { 7 | args[0].title= 'TeamC便捷管理系统' 8 | return args 9 | }) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sql/sql.sql: -------------------------------------------------------------------------------- 1 | 2 | /*创建数据库*/ 3 | CREATE DATABASE `tothefor` ; 4 | 5 | use tothefor; 6 | /*创建表*/ 7 | # 如果有关数据库的报错问题,多半是数据库的编码问题。将其设置为utf8即可 8 | 9 | 10 | /*物品表*/ 11 | CREATE TABLE `s_item` ( 12 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '物品id', 13 | `item_id` varchar(100) NOT NULL COMMENT '物品编号', 14 | `name` varchar(200) NOT NULL COMMENT '物品名', 15 | `typeID` bigint NOT NULL COMMENT '物品类型编号', 16 | `is_show` tinyint(1) DEFAULT '1' COMMENT '启用状态', 17 | `is_delete` tinyint(1) DEFAULT '0' COMMENT '是否删除', 18 | `item_add_time` datetime DEFAULT NULL COMMENT '物品入库时间', 19 | `item_update_time` timestamp NULL DEFAULT NULL COMMENT '最后修改时间', 20 | `size` varchar(155) DEFAULT NULL COMMENT '物品规格', 21 | `description` varchar(200) DEFAULT NULL COMMENT '物品描述或备注', 22 | `item_count` bigint DEFAULT '0' COMMENT '物品数量', 23 | PRIMARY KEY (`id`) 24 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 25 | 26 | 27 | # 物品类型表 28 | CREATE TABLE `s_item_type` ( 29 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一标识符', 30 | `type_id` bigint NOT NULL COMMENT '物品编号', 31 | `typename` varchar(50) NOT NULL COMMENT '物品类型名称', 32 | `is_delete` tinyint(1) DEFAULT '0' COMMENT '逻辑删除', 33 | `description` varchar(250) DEFAULT NULL COMMENT '类型描述', 34 | PRIMARY KEY (`id`) 35 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 36 | 37 | # 菜单表 38 | CREATE TABLE `s_menu` ( 39 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一标识符', 40 | `menu_id` bigint DEFAULT NULL COMMENT '菜单编号', 41 | `menu_name` varchar(250) DEFAULT NULL COMMENT '菜单名称', 42 | `menu_path` varchar(250) DEFAULT NULL COMMENT '菜单路径', 43 | `menu_ico` varchar(200) DEFAULT NULL COMMENT '菜单图表', 44 | `pid` bigint DEFAULT NULL COMMENT '父级菜单id', 45 | PRIMARY KEY (`id`) 46 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 47 | 48 | # 借出管理表 49 | CREATE TABLE `s_record` ( 50 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录单唯一表示符', 51 | `record_name` varchar(200) DEFAULT NULL COMMENT '记录单名称', 52 | `is_show` tinyint(1) DEFAULT '1' COMMENT '归还状态', 53 | `is_delete` tinyint(1) DEFAULT '0' COMMENT '是否删除', 54 | `record_add_time` datetime DEFAULT NULL COMMENT '添加时间', 55 | `record_update_time` timestamp NULL DEFAULT NULL COMMENT '修改时间', 56 | `record_man` varchar(200) DEFAULT NULL COMMENT '借用者', 57 | `description` varchar(200) DEFAULT NULL COMMENT '描述或备注', 58 | `getCode` varchar(10) DEFAULT NULL COMMENT '领取码', 59 | PRIMARY KEY (`id`) 60 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 61 | 62 | # 角色表 63 | CREATE TABLE `s_role_menu` ( 64 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一标识符', 65 | `role_id` bigint DEFAULT NULL COMMENT '角色编号', 66 | `menu_id` bigint DEFAULT NULL COMMENT '菜单编号', 67 | PRIMARY KEY (`id`) 68 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 69 | 70 | # 用户表 71 | 72 | CREATE TABLE `s_user` ( 73 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户唯一标识符', 74 | `user_ID` bigint NOT NULL COMMENT '用户编号', 75 | `username` varchar(30) NOT NULL COMMENT '用户名称', 76 | `password` varchar(255) DEFAULT NULL COMMENT '用户密码', 77 | `role_ID` bigint NOT NULL COMMENT '用户角色ID', 78 | `description` varchar(250) DEFAULT NULL COMMENT '用户描述', 79 | `is_delete` tinyint(1) DEFAULT '0' COMMENT '逻辑删除', 80 | PRIMARY KEY (`id`) 81 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 82 | 83 | # 用户角色表 84 | CREATE TABLE `s_user_role` ( 85 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一标识符', 86 | `role_id` bigint NOT NULL COMMENT '角色编号', 87 | `rolename` varchar(50) NOT NULL COMMENT '角色名称', 88 | `is_delete` tinyint(1) DEFAULT '0' COMMENT '逻辑删除', 89 | `description` varchar(250) DEFAULT NULL COMMENT '角色描述', 90 | PRIMARY KEY (`id`) 91 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 92 | 93 | 94 | 95 | 96 | 97 | 98 | # 初始数据添加 99 | 100 | 101 | # 菜单表 102 | insert into s_menu(menu_name, menu_path, menu_ico, pid) VALUES 103 | ('物品管理',null,'IconMenu',null), 104 | ('权限设置',null,'Lock',null), 105 | ('系统设置',null,'Setting',null), 106 | ('物品列表','/itemShow','List',1), 107 | ('物品类型','/itemType','Tickets',1), 108 | ('角色管理','/role','User',2), 109 | ('人员管理','/mans','Avatar',2), 110 | ('修改密码','/pwd','Key',3), 111 | ('个人密码','/perPwd','User',3), 112 | ('借出管理','/recordShow','Document',1), 113 | ('数据展示','/lookData','Calendar',1); 114 | 115 | # 菜单权限表 116 | insert into s_role_menu(role_id, menu_id) VALUES 117 | (2,1), 118 | (2,2), 119 | (2,3), 120 | (2,4), 121 | (2,5), 122 | (2,6), 123 | (2,7), 124 | (2,8), 125 | (2,9), 126 | (2,10), 127 | (2,11); 128 | 129 | 130 | # 创建用户角色 131 | insert into s_user_role(role_id, rolename,description) VALUES 132 | (2,'超级管理员','拥有最高权限'); 133 | 134 | # 创建初始超级管理员admin,角色必须是角色表中已经存在的角色id,密码为123456 135 | insert into s_user(user_ID, username, password, role_ID, description) VALUES 136 | (1000,'admin','7ed917eb25c9fc56499a76bf5adbfa50',2,'超级管理员'); 137 | 138 | # 插入物品类型数据 139 | insert into s_item_type(type_id, typename, description) VALUES 140 | (2022001,'测试类','提供测试所用'); 141 | 142 | # 插入物品数据,物品的类型编号必须是类型表中已经存在的! 143 | insert into s_item(item_id, name, typeID,size, description, item_count) VALUES 144 | ('111111','测试物品名称',2022001,'这里填写规格','填写物品描述',7); 145 | 146 | 147 | # 注意:在建好数据库表后,自行查看s_user_role表的id和role_id是否相同,则将role_id修改为id,使两者相同。 148 | # 注意:再自行查看s_menu表,看数据的id是不是从1开始的,不是则将其改为从1开始。 149 | 150 | 151 | 152 | 153 | 154 | --------------------------------------------------------------------------------