├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.en.md
├── README.md
├── pom.xml
└── src
└── main
├── java
└── com
│ └── cry
│ └── flutter
│ └── admin
│ ├── Application.java
│ ├── common
│ ├── DictExportExcelListener.java
│ ├── EnvUtil.java
│ ├── FileProperties.java
│ ├── MyMetaObjectHandler.java
│ ├── Operation.java
│ ├── RedisUtil.java
│ ├── RequestBodyApi.java
│ ├── RequestInterceptor.java
│ ├── ResponseBodyApi.java
│ ├── SysAspect.java
│ └── Utils.java
│ ├── config
│ ├── MybatisPlusConfig.java
│ ├── RedisConfig.java
│ └── SysConfig.java
│ ├── constants
│ ├── Constant.java
│ ├── ConstantDict.java
│ └── ResponseCodeConstant.java
│ ├── controller
│ ├── ArticleController.java
│ ├── DeptController.java
│ ├── DictController.java
│ ├── DictItemController.java
│ ├── FileController.java
│ ├── ImageController.java
│ ├── MenuController.java
│ ├── MenuDemoController.java
│ ├── MessageController.java
│ ├── PersonController.java
│ ├── RoleController.java
│ ├── RoleMenuController.java
│ ├── RoleUserController.java
│ ├── SAreaAgeGenderController.java
│ ├── SettingDefaultTabController.java
│ ├── SubsystemController.java
│ ├── UserController.java
│ ├── UserInfoController.java
│ └── VideoController.java
│ ├── entity
│ ├── Article.java
│ ├── BaseEntity.java
│ ├── BizBaseEntity.java
│ ├── Dept.java
│ ├── Dict.java
│ ├── DictItem.java
│ ├── File.java
│ ├── Image.java
│ ├── Menu.java
│ ├── MenuDemo.java
│ ├── Message.java
│ ├── MessageReplay.java
│ ├── Person.java
│ ├── Role.java
│ ├── RoleMenu.java
│ ├── RoleUser.java
│ ├── SAreaAgeGender.java
│ ├── SettingDefaultTab.java
│ ├── Subsystem.java
│ ├── SysLog.java
│ ├── User.java
│ ├── UserInfo.java
│ └── Video.java
│ ├── mapper
│ ├── ArticleMapper.java
│ ├── DeptMapper.java
│ ├── DictItemMapper.java
│ ├── DictMapper.java
│ ├── FileMapper.java
│ ├── ImageMapper.java
│ ├── MenuDemoMapper.java
│ ├── MenuMapper.java
│ ├── MessageMapper.java
│ ├── MessageReplayMapper.java
│ ├── PersonMapper.java
│ ├── RoleMapper.java
│ ├── RoleMenuMapper.java
│ ├── RoleUserMapper.java
│ ├── SAreaAgeGenderMapper.java
│ ├── SettingDefaultTabMapper.java
│ ├── SubsystemMapper.java
│ ├── SysLogMapper.java
│ ├── UserInfoMapper.java
│ ├── UserMapper.java
│ └── VideoMapper.java
│ ├── service
│ ├── IArticleService.java
│ ├── IDeptService.java
│ ├── IDictItemService.java
│ ├── IDictService.java
│ ├── IFileService.java
│ ├── IImageService.java
│ ├── IMenuDemoService.java
│ ├── IMenuService.java
│ ├── IMessageReplayService.java
│ ├── IMessageService.java
│ ├── IPersonService.java
│ ├── IRoleMenuService.java
│ ├── IRoleService.java
│ ├── IRoleUserService.java
│ ├── ISAreaAgeGenderService.java
│ ├── ISettingDefaultTabService.java
│ ├── ISubsystemService.java
│ ├── ISysLogService.java
│ ├── IUserInfoService.java
│ ├── IUserService.java
│ ├── IVideoService.java
│ └── impl
│ │ ├── ArticleServiceImpl.java
│ │ ├── DeptServiceImpl.java
│ │ ├── DictItemServiceImpl.java
│ │ ├── DictServiceImpl.java
│ │ ├── FileServiceImpl.java
│ │ ├── ImageServiceImpl.java
│ │ ├── MenuDemoServiceImpl.java
│ │ ├── MenuServiceImpl.java
│ │ ├── MessageReplayServiceImpl.java
│ │ ├── MessageServiceImpl.java
│ │ ├── PersonServiceImpl.java
│ │ ├── RoleMenuServiceImpl.java
│ │ ├── RoleServiceImpl.java
│ │ ├── RoleUserServiceImpl.java
│ │ ├── SAreaAgeGenderServiceImpl.java
│ │ ├── SettingDefaultTabServiceImpl.java
│ │ ├── SubsystemServiceImpl.java
│ │ ├── SysLogServiceImpl.java
│ │ ├── UserInfoServiceImpl.java
│ │ ├── UserServiceImpl.java
│ │ └── VideoServiceImpl.java
│ ├── utils
│ ├── CryStringUtil.java
│ ├── FileUtil.java
│ ├── JwtUtil.java
│ ├── MpGenerator.java
│ └── RequestUtil.java
│ ├── vo
│ ├── ArticleVO.java
│ ├── MenuVO.java
│ ├── MessageReplayVO.java
│ ├── RoleMenuVO.java
│ └── SubsystemVO.java
│ └── wrapper
│ ├── DictWrapper.java
│ └── UserInofWrapper.java
└── resources
├── application-dev.yml
├── application-test.yml
├── application.yml
├── logback-spring.xml
└── mapper
├── ArticleMapper.xml
├── DeptMapper.xml
├── MenuMapper.xml
├── MessageReplayMapper.xml
├── RoleMapper.xml
├── SAreaAgeGenderMapper.xml
├── SettingDefaultTabMapper.xml
└── UserInfoMapper.xml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: http://cairuoyu.com/screenshots/pay.png
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Maven #
2 | target/
3 |
4 | # IDEA #
5 | .idea/
6 | *.iml
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 cairuoyu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.en.md:
--------------------------------------------------------------------------------
1 | # flutter_admin_backend
2 |
3 |
4 | 
5 | 
6 | 
7 | 
8 |
9 | > [简体中文](./README.md) | English
10 |
11 | > Using Java, Flutter implementation of a backend management system. This project is the back end, and the corresponding front end is https://github.com/cairuoyu/flutter_admin。
12 |
13 | ---
14 | ## Functional
15 | * User Registration
16 | * Login And Logout
17 | * Function Menu
18 | * Dashboard
19 | * Role Management
20 | * User Management
21 | * Menu Management
22 | * Article Management
23 | * upload Picture
24 | * Video Upload
25 | * Personnel Management
26 | * Data Dictionary Management
27 | * Message
28 | * My Information
29 | * Chart
30 | * Globalization
31 | * Language Switch
32 | * Theme Switch
33 | * Font Switch
34 | * Standalone configuration file
35 | * Component packaging
36 | * Import or Export Excle
37 |
38 | ## Technology
39 | | Name | Technology |
40 | | --------------- | ------------------- |
41 | | Language | Java |
42 | | General Library | Spring、Spring Boot |
43 | | Data | Mybatis-plus |
44 | | Environment | Maven |
45 | | Permissions | JWT |
46 |
47 | ## The code structure
48 | ```
49 | ├─src
50 | │ └─main
51 | │ │ └─com
52 | │ │ └─cry
53 | │ │ └─flutter
54 | │ │ └─admin
55 | │ │ ├─common
56 | │ │ ├─config
57 | │ │ ├─constants
58 | │ │ ├─controller
59 | │ │ ├─entity
60 | │ │ ├─mapper
61 | │ │ ├─service
62 | │ │ │ └─impl
63 | │ │ ├─utils
64 | │ │ ├─vo
65 | │ │ └─wrapper
66 | │ └─resources
67 | │ └─mapper
68 | ```
69 |
70 | ## Configuration application.yml
71 | ```bash
72 | server:
73 | port: 8081
74 |
75 | spring:
76 | datasource:
77 | driver-class-name: com.mysql.jdbc.Driver
78 | # 配置数据库连接
79 | url: jdbc:mysql://ip:3306/sid?serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true
80 | username: us
81 | password: ps
82 | hikari:
83 | max-lifetime: 60000
84 | jackson:
85 | date-format: yyyy-MM-dd HH:mm:ss
86 | servlet:
87 | multipart:
88 | max-file-size: 10000000
89 | max-request-size: 10000000
90 |
91 | debug: true
92 | mybatis-plus:
93 | configuration:
94 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
95 | mapper-locations: classpath:/mapper/**.xml
96 |
97 | file:
98 | # 文件上传地址
99 | upload-path: G:\apache-tomcat-9.0.34-8093\webapps\download\
100 | # 文件下载地址
101 | downloadPath: http://localhost:8093/download/
102 |
103 |
104 | ```
105 |
106 | ## packaging
107 | ```bash
108 | mvn package
109 | ```
110 |
111 | ## run
112 |
113 | ```bash
114 | java -jar .\target\flutter-admin-backend.jar
115 | ```
116 |
117 | ## live demo
118 | http://www.cairuoyu.com/flutter_admin
119 |
120 | Visit the website for more pictures:https://github.com/cairuoyu/flutter_admin
121 |
122 | 
123 |
124 | ## Join Discussion Group
125 | ### Add me to WeChat to pull you into the group
126 | 
127 |
128 | ### QQ
129 | 851796663
130 |
131 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # flutter_admin_backend
2 |
3 |
4 | 
5 | 
6 | 
7 | 
8 |
9 | > 简体中文 | [English](./README.en.md)
10 |
11 | > 使用Java、Flutter实现的一个后台管理系统。本项目为后端,对应的前端为 https://github.com/cairuoyu/flutter_admin。
12 |
13 | ---
14 | ## 功能
15 | * 用户注册
16 | * 登录登出
17 | * 功能菜单
18 | * Dashboard
19 | * 角色管理
20 | * 用户管理
21 | * 部门管理
22 | * 菜单管理
23 | * 文章管理
24 | * 图片上传
25 | * 视频上传
26 | * 人员管理
27 | * 数据字典管理
28 | * 留言
29 | * 我的信息
30 | * 图表
31 | * 国际化
32 | * 语言切换
33 | * 主题切换
34 | * 字体切换
35 | * 独立配置文件
36 | * 组件封装
37 | * 导入导出Excel
38 |
39 | ## 技术
40 | | 名称 | 技术 |
41 | | ------ | ------------------- |
42 | | 语言 | Java |
43 | | 通用包 | Spring、Spring Boot |
44 | | 数据 | Mybatis-plus |
45 | | 环境 | Maven |
46 | | 权限 | JWT |
47 |
48 | ## 代码结构
49 | ```
50 | ├─src
51 | │ └─main
52 | │ │ └─com
53 | │ │ └─cry
54 | │ │ └─flutter
55 | │ │ └─admin
56 | │ │ ├─common 公共类
57 | │ │ ├─config 配置
58 | │ │ ├─constants 常量类
59 | │ │ ├─controller 控制类
60 | │ │ ├─entity 实体类
61 | │ │ ├─mapper 映射
62 | │ │ ├─service 服务
63 | │ │ │ └─impl
64 | │ │ ├─utils 工具
65 | │ │ ├─vo
66 | │ │ └─wrapper 对象封装
67 | │ └─resources
68 | │ └─mapper 映射配置文件
69 | ```
70 |
71 | ## 配置application.yml
72 | ```bash
73 | server:
74 | port: 8081
75 |
76 | spring:
77 | datasource:
78 | driver-class-name: com.mysql.jdbc.Driver
79 | # 配置数据库连接
80 | url: jdbc:mysql://ip:3306/sid?serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true
81 | username: us
82 | password: ps
83 | hikari:
84 | max-lifetime: 60000
85 | jackson:
86 | date-format: yyyy-MM-dd HH:mm:ss
87 | servlet:
88 | multipart:
89 | max-file-size: 10000000
90 | max-request-size: 10000000
91 |
92 | debug: true
93 | mybatis-plus:
94 | configuration:
95 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
96 | mapper-locations: classpath:/mapper/**.xml
97 |
98 | file:
99 | # 文件上传地址
100 | upload-path: G:\apache-tomcat-9.0.34-8093\webapps\download\
101 | # 文件下载地址
102 | downloadPath: http://localhost:8093/download/
103 |
104 |
105 | ```
106 |
107 | ## 打包
108 | ```bash
109 | mvn package
110 | ```
111 |
112 | ## 运行
113 |
114 | ```bash
115 | java -jar .\target\flutter-admin-backend.jar
116 | ```
117 |
118 | ## live demo
119 |
120 | http://www.cairuoyu.com/flutter_admin
121 |
122 | 更多图片请访问:https://github.com/cairuoyu/flutter_admin
123 |
124 | 
125 |
126 |
127 | ## 加入讨论组
128 | ### 加我微信拉你入群
129 | 
130 |
131 | ### QQ
132 | 851796663
133 |
134 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.cry
8 | flutter-admin-backend
9 | 1.0.0
10 |
11 |
12 | org.springframework.boot
13 | spring-boot-starter-parent
14 | 2.2.2.RELEASE
15 |
16 |
17 |
18 |
19 |
20 | com.spring4all
21 | swagger-spring-boot-starter
22 | 1.9.1.RELEASE
23 |
24 |
25 |
26 | com.alibaba
27 | easyexcel
28 | 2.2.7
29 |
30 |
31 |
32 | cn.hutool
33 | hutool-all
34 | 5.1.0
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-aop
40 |
41 |
42 |
43 |
44 | javax.xml.bind
45 | jaxb-api
46 | 2.3.0
47 |
48 |
49 | com.auth0
50 | java-jwt
51 | 3.2.0
52 |
53 |
54 | io.jsonwebtoken
55 | jjwt
56 | 0.7.0
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-starter
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-starter-test
65 | test
66 |
67 |
68 | org.springframework.boot
69 | spring-boot-starter-data-redis
70 |
71 |
72 | org.projectlombok
73 | lombok
74 | true
75 |
76 |
77 | com.baomidou
78 | mybatis-plus-boot-starter
79 | 3.3.0
80 |
81 |
82 |
83 | org.springframework.boot
84 | spring-boot-starter-web
85 |
86 |
87 | mysql
88 | mysql-connector-java
89 |
90 |
91 |
92 | org.springframework.boot
93 | spring-boot-starter-freemarker
94 |
95 |
96 | com.baomidou
97 | mybatis-plus-generator
98 | 3.3.1
99 |
100 |
101 |
102 | org.apache.logging.log4j
103 | log4j-api
104 | 2.15.0
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 | flutter-admin-backend
120 |
121 |
122 |
123 | org.springframework.boot
124 | spring-boot-maven-plugin
125 |
126 | true
127 | com.cry.flutter.admin.Application
128 |
129 |
130 |
131 | org.springframework
132 | springloaded
133 | 1.2.5.RELEASE
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/Application.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin;
2 |
3 | import com.cry.flutter.admin.common.FileProperties;
4 | import com.spring4all.swagger.EnableSwagger2Doc;
5 | import org.mybatis.spring.annotation.MapperScan;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
9 |
10 | @EnableSwagger2Doc
11 | @SpringBootApplication
12 | @MapperScan("com.cry.flutter.admin.mapper")
13 | @EnableConfigurationProperties({
14 | FileProperties.class
15 | })
16 | public class Application {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(Application.class, args);
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/DictExportExcelListener.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 |
4 | import com.alibaba.excel.context.AnalysisContext;
5 | import com.alibaba.excel.event.AnalysisEventListener;
6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7 | import com.cry.flutter.admin.constants.ConstantDict;
8 | import com.cry.flutter.admin.entity.Dict;
9 | import com.cry.flutter.admin.service.IDictService;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 |
17 | public class DictExportExcelListener extends AnalysisEventListener {
18 | private static final Logger LOGGER = LoggerFactory.getLogger(DictExportExcelListener.class);
19 | private static final int BATCH_COUNT = 5;
20 | List list = new ArrayList();
21 | IDictService dictService;
22 |
23 | public DictExportExcelListener(IDictService dictService) {
24 | this.dictService = dictService;
25 | }
26 |
27 | @Override
28 | public void invoke(Dict dict, AnalysisContext context) {
29 | LOGGER.info("解析到一条数据:{}", dict.getName());
30 | int count = dictService.count(new QueryWrapper().lambda().eq(Dict::getCode, dict.getCode()));
31 | if (count > 0) {
32 | LOGGER.info("代码"+dict.getCode()+"已存在");
33 | return ;
34 | }
35 | dict.setState(ConstantDict.CODE_YESNO_NO);
36 | list.add(dict);
37 | if (list.size() >= BATCH_COUNT) {
38 | saveData();
39 | list.clear();
40 | }
41 | }
42 |
43 | @Override
44 | public void doAfterAllAnalysed(AnalysisContext context) {
45 | saveData();
46 | LOGGER.info("所有数据解析完成!");
47 | }
48 |
49 | private void saveData() {
50 | LOGGER.info("{}条数据,开始存储数据库!", list.size());
51 | dictService.saveBatch(list);
52 | LOGGER.info("存储数据库成功!");
53 | }
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/EnvUtil.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import lombok.Getter;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @Getter
9 | public class EnvUtil {
10 | @Value("${token.timeout}")
11 | private Long tokenTimeout;
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/FileProperties.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import org.springframework.boot.context.properties.ConfigurationProperties;
4 |
5 | @ConfigurationProperties(prefix = "file")
6 | public class FileProperties {
7 | private String uploadPath;
8 | private String downloadPath;
9 |
10 | public String getUploadPath() {
11 | return uploadPath;
12 | }
13 |
14 | public void setUploadPath(String uploadPath) {
15 | this.uploadPath = uploadPath;
16 | }
17 |
18 | public String getDownloadPath() {
19 | return downloadPath;
20 | }
21 |
22 | public void setDownloadPath(String downloadPath) {
23 | this.downloadPath = downloadPath;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/MyMetaObjectHandler.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
4 | import com.cry.flutter.admin.utils.RequestUtil;
5 | import org.apache.ibatis.reflection.MetaObject;
6 | import org.springframework.stereotype.Component;
7 |
8 | import java.util.Date;
9 |
10 | @Component
11 | public class MyMetaObjectHandler implements MetaObjectHandler {
12 |
13 | @Override
14 | public void insertFill(MetaObject metaObject) {
15 | Date now = new Date();
16 |
17 | this.setFieldValByName("createTime", now, metaObject);
18 | this.setFieldValByName("updateTime", now, metaObject);
19 | this.setFieldValByName("createrId", RequestUtil.getCurrentUserId(), metaObject);
20 | }
21 |
22 | @Override
23 | public void updateFill(MetaObject metaObject) {
24 | this.setFieldValByName("updateTime", new Date(), metaObject);
25 | this.setFieldValByName("updateId", RequestUtil.getCurrentUserId(), metaObject);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/Operation.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 |
4 | import java.lang.annotation.*;
5 |
6 | import static java.lang.annotation.ElementType.METHOD;
7 | import static java.lang.annotation.ElementType.TYPE;
8 |
9 | @Target({METHOD, TYPE})
10 | @Retention(RetentionPolicy.RUNTIME)
11 | @Inherited
12 | @Documented
13 | public @interface Operation {
14 | String value() default "";
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/RequestBodyApi.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4 | import lombok.Data;
5 |
6 | import java.io.Serializable;
7 |
8 | @Data
9 | public class RequestBodyApi implements Serializable {
10 | Page page;
11 | T params;
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/RequestInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import com.cry.flutter.admin.constants.Constant;
4 | import com.cry.flutter.admin.constants.ResponseCodeConstant;
5 | import com.cry.flutter.admin.utils.JwtUtil;
6 | import com.fasterxml.jackson.databind.ObjectMapper;
7 | import io.jsonwebtoken.Claims;
8 | import lombok.extern.log4j.Log4j2;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.http.HttpHeaders;
11 | import org.springframework.util.StringUtils;
12 | import org.springframework.web.bind.annotation.RequestMethod;
13 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
14 |
15 | import javax.servlet.http.HttpServletRequest;
16 | import javax.servlet.http.HttpServletResponse;
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | /**
21 | *
22 | *
23 | *
24 | * @author cairuoyu
25 | * @homepage: http://cairuoyu.com
26 | * @github: https://github.com/cairuoyu/flutter_admin_backend
27 | * @since 2020-10-12
28 | */
29 | @Log4j2
30 | public class RequestInterceptor extends HandlerInterceptorAdapter {
31 |
32 | @Autowired
33 | private RedisUtil redisUtil;
34 | private List whiteList = new ArrayList(){{
35 | add("/loginByCode");
36 | add("/user/login");
37 | add("/user/loginByFace");
38 | add("/user/register");
39 | add("/userInfo/page");
40 | add("/dict/map");
41 | }};
42 |
43 | @Override
44 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
45 | String servletPath = request.getServletPath();
46 | if(whiteList.contains(servletPath)){
47 | return true;
48 | }
49 | String method = request.getMethod();
50 | if (method.equals(RequestMethod.OPTIONS)) {
51 | return true;
52 | }
53 |
54 | response.setContentType("application/json;charset=utf-8");
55 | String authorization = request.getHeader(HttpHeaders.AUTHORIZATION);
56 | if (StringUtils.isEmpty(authorization)) {
57 | return false;
58 | }
59 | String token = authorization;
60 |
61 | Claims claims = null;
62 | try {
63 | claims = JwtUtil.parseJWT(token);
64 | } catch (Exception e) {
65 | log.info(e.getMessage());
66 | return false;
67 | }
68 | String userId = claims.getSubject();
69 | request.setAttribute("userId", userId);
70 | Long expire = redisUtil.getExpire(Constant.REDIS_TOKEN_PRE + userId);
71 | if (expire < 0) {
72 | String res = new ObjectMapper().writeValueAsString(new ResponseBodyApi<>(ResponseCodeConstant.SESSION_EXPIRE_CODE, false, ResponseCodeConstant.SESSION_EXPIRE_MESSAGE));
73 | response.getWriter().println(res);
74 | return false;
75 | }
76 | return true;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/ResponseBodyApi.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | *
9 | *
10 | *
11 | * @author cairuoyu
12 | * @homepage: http://cairuoyu.com
13 | * @github: https://github.com/cairuoyu/flutter_admin_backend
14 | * @since 2020-10-12
15 | */
16 | @Data
17 | public class ResponseBodyApi implements Serializable {
18 | private String code = "0";
19 | private boolean success = true;
20 | private String message;
21 | private T data;
22 | public ResponseBodyApi(){}
23 |
24 | public ResponseBodyApi(String code, boolean success, String message) {
25 | this.code = code;
26 | this.success = success;
27 | this.message = message;
28 | }
29 |
30 | public ResponseBodyApi(boolean success, String message) {
31 | this.success = success;
32 | this.message = message;
33 | }
34 |
35 | public ResponseBodyApi(T data) {
36 | this.data = data;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/SysAspect.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 |
4 | import cn.hutool.extra.servlet.ServletUtil;
5 | import com.cry.flutter.admin.entity.SysLog;
6 | import com.cry.flutter.admin.service.ISysLogService;
7 | import com.cry.flutter.admin.utils.RequestUtil;
8 | import org.aspectj.lang.JoinPoint;
9 | import org.aspectj.lang.annotation.AfterReturning;
10 | import org.aspectj.lang.annotation.Aspect;
11 | import org.aspectj.lang.annotation.Pointcut;
12 | import org.aspectj.lang.reflect.MethodSignature;
13 | import org.springframework.stereotype.Component;
14 | import org.springframework.web.context.request.RequestContextHolder;
15 | import org.springframework.web.context.request.ServletRequestAttributes;
16 |
17 | import javax.annotation.Resource;
18 | import javax.servlet.http.HttpServletRequest;
19 | import java.lang.reflect.Method;
20 |
21 |
22 | @Aspect
23 | @Component
24 | public class SysAspect {
25 |
26 | @Resource
27 | private ISysLogService sysLogService;
28 |
29 | @Pointcut("@annotation(com.cry.flutter.admin.common.Operation)")
30 | public void logPointCut() {
31 | }
32 |
33 | @AfterReturning("logPointCut()")
34 | // @Before("logPointCut()")
35 | public void saveSysLog(JoinPoint joinPoint) {
36 | SysLog sysLog = new SysLog();
37 | MethodSignature signature = (MethodSignature) joinPoint.getSignature();
38 | Method method = signature.getMethod();
39 | Operation operation = method.getAnnotation(Operation.class);
40 | if (operation != null) {
41 | String value = operation.value();
42 | sysLog.setRequestDesc(value);
43 | }
44 |
45 | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
46 | String clientIP = ServletUtil.getClientIP(request,new String[]{"cryip"});
47 | String className = joinPoint.getTarget().getClass().getSimpleName();
48 | String methodName = method.getName();
49 |
50 |
51 | sysLog.setUserId(RequestUtil.getCurrentUserId());
52 | sysLog.setUserIp(clientIP);
53 | sysLog.setRequestClass(className);
54 | sysLog.setRequestMethod(methodName);
55 |
56 | sysLogService.save(sysLog);
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/common/Utils.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.common;
2 |
3 | import static java.lang.Math.pow;
4 | import static java.lang.Math.sqrt;
5 |
6 | /**
7 | *
8 | *
9 | *
10 | * @author cairuoyu
11 | * @homepage: http://cairuoyu.com
12 | * @github: https://github.com/cairuoyu/flutter_admin_backend
13 | * @since 2022-03-24
14 | */
15 | public class Utils {
16 |
17 | public static double euclideanDistance(String[] face1, String[] face2) {
18 | double sum = 0.0;
19 | for (int i = 0; i < face1.length; i++) {
20 | sum += pow((Double.parseDouble(face1[i]) - Double.parseDouble(face2[i])), 2);
21 | }
22 | return sqrt(sum);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/config/MybatisPlusConfig.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.config;
2 |
3 | import com.baomidou.mybatisplus.core.config.GlobalConfig;
4 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
5 | import com.cry.flutter.admin.common.MyMetaObjectHandler;
6 | import com.cry.flutter.admin.common.RequestInterceptor;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
11 |
12 | @Configuration
13 | public class MybatisPlusConfig implements WebMvcConfigurer {
14 | @Bean
15 | public PaginationInterceptor paginationInterceptor() {
16 | PaginationInterceptor page = new PaginationInterceptor();
17 | page.setDialectType("mysql");
18 | return page;
19 | }
20 | @Bean
21 | public GlobalConfig globalConfig() {
22 | GlobalConfig globalConfig = new GlobalConfig();
23 | globalConfig.setMetaObjectHandler(new MyMetaObjectHandler());
24 | return globalConfig;
25 | }
26 | @Override
27 | public void addInterceptors(InterceptorRegistry registry) {
28 | registry.addInterceptor(RequestInterceptor()).addPathPatterns("/**");
29 | }
30 |
31 | @Bean
32 | public RequestInterceptor RequestInterceptor() {
33 | return new RequestInterceptor();
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/config/RedisConfig.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.config;
2 |
3 | import org.springframework.cache.annotation.EnableCaching;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.data.redis.connection.RedisConnectionFactory;
7 | import org.springframework.data.redis.core.StringRedisTemplate;
8 |
9 | /**
10 | *
11 | *
12 | *
13 | * @author cairuoyu
14 | * @homepage: http://cairuoyu.com
15 | * @github: https://github.com/cairuoyu/flutter_admin_backend
16 | * @since 2020-10-12
17 | */
18 | @Configuration
19 | @EnableCaching
20 | public class RedisConfig {
21 |
22 | @Bean
23 | public StringRedisTemplate redisTemplate(RedisConnectionFactory factory) {
24 | StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
25 | stringRedisTemplate.setConnectionFactory(factory);
26 | return stringRedisTemplate;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/config/SysConfig.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.config;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 | import org.springframework.web.cors.CorsConfiguration;
8 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
9 | import org.springframework.web.filter.CorsFilter;
10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
11 |
12 | /**
13 | *
14 | *
15 | *
16 | * @author cairuoyu
17 | * @homepage: http://cairuoyu.com
18 | * @github: https://github.com/cairuoyu/flutter_admin_backend
19 | * @since 2020-10-12
20 | */
21 | @Configuration
22 | @EnableAutoConfiguration
23 | @Slf4j
24 | public class SysConfig implements WebMvcConfigurer {
25 | private CorsConfiguration corsConfig() {
26 | CorsConfiguration corsConfiguration = new CorsConfiguration();
27 | corsConfiguration.addAllowedOrigin("*");
28 | corsConfiguration.addAllowedHeader("*");
29 | corsConfiguration.addAllowedMethod("*");
30 | corsConfiguration.setAllowCredentials(true);
31 | corsConfiguration.setMaxAge(3600L);
32 | return corsConfiguration;
33 | }
34 |
35 | @Bean
36 | public CorsFilter corsFilter() {
37 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
38 | source.registerCorsConfiguration("/**", corsConfig());
39 | return new CorsFilter(source);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/constants/Constant.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.constants;
2 |
3 | /**
4 | *
5 | *
6 | *
7 | * @author cairuoyu
8 | * @homepage: http://cairuoyu.com
9 | * @github: https://github.com/cairuoyu/flutter_admin_backend
10 | * @since 2020-10-12
11 | */
12 | public class Constant {
13 | public static final String REDIS_TOKEN_PRE = "token";
14 | public static final String ID_ADMIN = "db288d951c390afb08c8341088bd90fa";
15 | public static final String ID_ADMIN1 = "73dc6c8a3cfe1504d04cd34ec0750a82";
16 | public static final String ID_ADMIN2 = "379755345bbede04a256fdc0b4a2c829";
17 | public static final String SUBSYSTEM_ID_FLUTTER_ADMIN = "1";
18 | public static final String MESSAGE_NO_PERMISSIONS = "没有权限";
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/constants/ConstantDict.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.constants;
2 |
3 | /**
4 | *
5 | *
6 | *
7 | * @author cairuoyu
8 | * @homepage: http://cairuoyu.com
9 | * @github: https://github.com/cairuoyu/flutter_admin_backend
10 | * @since 2020-10-12
11 | */
12 | public class ConstantDict {
13 | public static final String CODE_YESNO_YES = "1";
14 | public static final String CODE_YESNO_NO = "0";
15 | public static final String ARTICLE_STATUS_DRAFT = "draft";
16 | public static final String ARTICLE_STATUS_AUDIT= "audit";
17 | public static final String ARTICLE_STATUS_PUBLIC= "public";
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/constants/ResponseCodeConstant.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.constants;
2 |
3 | /**
4 | *
5 | *
6 | *
7 | * @author cairuoyu
8 | * @homepage: http://cairuoyu.com
9 | * @github: https://github.com/cairuoyu/flutter_admin_backend
10 | * @since 2020-10-12
11 | */
12 | public class ResponseCodeConstant {
13 | public static String SESSION_EXPIRE_CODE = "100001";
14 | public static String SESSION_EXPIRE_MESSAGE = "登录已失效";
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/controller/ArticleController.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.controller;
2 |
3 |
4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 | import com.cry.flutter.admin.common.RequestBodyApi;
7 | import com.cry.flutter.admin.common.ResponseBodyApi;
8 | import com.cry.flutter.admin.constants.ConstantDict;
9 | import com.cry.flutter.admin.entity.Article;
10 | import com.cry.flutter.admin.service.IArticleService;
11 | import com.cry.flutter.admin.service.IFileService;
12 | import com.cry.flutter.admin.vo.ArticleVO;
13 | import org.springframework.util.StringUtils;
14 | import org.springframework.web.bind.annotation.*;
15 |
16 | import javax.annotation.Resource;
17 | import java.util.List;
18 |
19 | /**
20 | *
21 | * 前端控制器
22 | *
23 | *
24 | * @author cairuoyu
25 | * @homepage: http://cairuoyu.com
26 | * @github: https://github.com/cairuoyu/flutter_admin_backend
27 | * @since 2021-03-11
28 | */
29 |
30 | @CrossOrigin(origins = {"*"})
31 | @RestController
32 | @RequestMapping("/article")
33 | public class ArticleController {
34 |
35 |
36 | @Resource(name = "articleServiceImpl")
37 | IArticleService articleService;
38 |
39 | @Resource(name = "fileServiceImpl")
40 | IFileService fileService;
41 |
42 |
43 | @PostMapping("save")
44 | public ResponseBodyApi save(@RequestBody Article article) {
45 | article.setStatus(ConstantDict.ARTICLE_STATUS_DRAFT);
46 | articleService.saveOrUpdate(article);
47 | return new ResponseBodyApi();
48 | }
49 |
50 | @PostMapping("audit")
51 | public ResponseBodyApi audit(@RequestBody Article article) {
52 | article.setStatus(ConstantDict.ARTICLE_STATUS_AUDIT);
53 | articleService.saveOrUpdate(article);
54 | return new ResponseBodyApi();
55 | }
56 |
57 | @PostMapping("public")
58 | public ResponseBodyApi publicAritcle(@RequestBody Article article) {
59 | article.setStatus(ConstantDict.ARTICLE_STATUS_PUBLIC);
60 | articleService.saveOrUpdate(article);
61 | return new ResponseBodyApi();
62 | }
63 |
64 |
65 | @PostMapping("pagePortal")
66 | public ResponseBodyApi> pagePortal(@RequestBody RequestBodyApi requestBodyApi) {
67 | requestBodyApi.getParams().setStatus(ConstantDict.ARTICLE_STATUS_PUBLIC);
68 | return this.page(requestBodyApi);
69 | }
70 |
71 | @PostMapping("page")
72 | public ResponseBodyApi> page(@RequestBody RequestBodyApi requestBodyApi) {
73 | ArticleVO articleVO = requestBodyApi.getParams();
74 | Page page = articleService.page(requestBodyApi.getPage(), new QueryWrapper().lambda()
75 | .eq(!StringUtils.isEmpty(articleVO.getStatus()), Article::getStatus, articleVO.getStatus())
76 | .like(!StringUtils.isEmpty(articleVO.getTitle()), Article::getTitle, articleVO.getTitle())
77 | .like(!StringUtils.isEmpty(articleVO.getTitleSub()), Article::getTitleSub, articleVO.getTitleSub())
78 | .like(!StringUtils.isEmpty(articleVO.getAuthor()), Article::getAuthor, articleVO.getAuthor())
79 | .ge(!StringUtils.isEmpty(articleVO.getPublishTimeStart()), Article::getPublishTime, articleVO.getPublishTimeStart())
80 | .le(!StringUtils.isEmpty(articleVO.getPublishTimeEnd()), Article::getPublishTime, articleVO.getPublishTimeEnd())
81 | .orderByDesc(Article::getCreateTime));
82 | return new ResponseBodyApi<>(page);
83 | }
84 |
85 | @PostMapping("saveOrUpdate")
86 | public ResponseBodyApi saveOrUpdate(@RequestBody Article article) {
87 | articleService.saveOrUpdate(article);
88 | return new ResponseBodyApi();
89 | }
90 |
91 | @PostMapping("removeByIds")
92 | public ResponseBodyApi removeByIds(@RequestBody List idList) {
93 | articleService.removeByIds(idList);
94 | return new ResponseBodyApi();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/controller/DeptController.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.controller;
2 |
3 |
4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 | import com.cry.flutter.admin.common.RequestBodyApi;
6 | import com.cry.flutter.admin.common.ResponseBodyApi;
7 | import com.cry.flutter.admin.entity.Dept;
8 | import com.cry.flutter.admin.entity.UserInfo;
9 | import com.cry.flutter.admin.service.IDeptService;
10 | import com.cry.flutter.admin.service.IUserInfoService;
11 | import org.springframework.util.StringUtils;
12 | import org.springframework.web.bind.annotation.*;
13 |
14 | import javax.annotation.Resource;
15 | import java.util.List;
16 |
17 | /**
18 | *
19 | * 前端控制器
20 | *
21 | *
22 | * @author cairuoyu
23 | * @homepage: http://cairuoyu.com
24 | * @github: https://github.com/cairuoyu/flutter_admin_backend
25 | * @since 2021-03-11
26 | */
27 |
28 | @CrossOrigin(origins = {"*"})
29 | @RestController
30 | @RequestMapping("/dept")
31 | public class DeptController {
32 |
33 | @Resource(name = "deptServiceImpl")
34 | IDeptService deptService;
35 |
36 | @Resource(name = "userInfoService")
37 | IUserInfoService userInfoService;
38 |
39 | @PostMapping("list")
40 | public ResponseBodyApi> list(@RequestBody RequestBodyApi requestBody) {
41 | Dept dept = requestBody.getParams();
42 | if (dept != null && !StringUtils.isEmpty(dept.getName())) {
43 | return new ResponseBodyApi<>(deptService.query(dept));
44 | }
45 | return new ResponseBodyApi<>(deptService.list(new QueryWrapper().lambda()
46 | .orderByAsc(Dept::getOrderBy)));
47 | }
48 |
49 | @PostMapping("saveOrUpdate")
50 | public ResponseBodyApi saveOrUpdate(@RequestBody Dept dept) {
51 | deptService.saveOrUpdate(dept);
52 | return new ResponseBodyApi();
53 | }
54 |
55 | @PostMapping("removeByIds")
56 | public ResponseBodyApi removeByIds(@RequestBody List idList) {
57 | int count = userInfoService.count(new QueryWrapper().lambda().in(UserInfo::getDeptId, idList));
58 | if (count > 0) {
59 | return new ResponseBodyApi(false, "此部门已被使用,不能删除");
60 | }
61 | deptService.removeByIds(idList);
62 | return new ResponseBodyApi();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/cry/flutter/admin/controller/DictController.java:
--------------------------------------------------------------------------------
1 | package com.cry.flutter.admin.controller;
2 |
3 |
4 | import com.alibaba.excel.EasyExcel;
5 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8 | import com.cry.flutter.admin.common.DictExportExcelListener;
9 | import com.cry.flutter.admin.common.FileProperties;
10 | import com.cry.flutter.admin.common.RequestBodyApi;
11 | import com.cry.flutter.admin.common.ResponseBodyApi;
12 | import com.cry.flutter.admin.constants.ConstantDict;
13 | import com.cry.flutter.admin.entity.Dict;
14 | import com.cry.flutter.admin.entity.DictItem;
15 | import com.cry.flutter.admin.service.IDictItemService;
16 | import com.cry.flutter.admin.service.IDictService;
17 | import com.cry.flutter.admin.wrapper.DictWrapper;
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.annotation.Resource;
24 | import java.io.IOException;
25 | import java.util.*;
26 |
27 | /**
28 | *
29 | * 前端控制器
30 | *
31 | *
32 | * @author cairuoyu
33 | * @homepage: http://cairuoyu.com
34 | * @github: https://github.com/cairuoyu/flutter_admin_backend
35 | * @since 2020-09-26
36 | */
37 | @CrossOrigin(origins = {"*"})
38 | @RestController
39 | @RequestMapping("/dict")
40 | public class DictController {
41 |
42 | @Autowired
43 | private FileProperties fileProperties;
44 | @Resource(name = "dictItemServiceImpl")
45 | IDictItemService dictItemService;
46 | @Resource(name = "dictServiceImpl")
47 | IDictService dictService;
48 |
49 |
50 | @GetMapping("map")
51 | public ResponseBodyApi