Compare commits
2 Commits
a50ab7a503
...
6160c48c7b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6160c48c7b | ||
|
|
474c9499f6 |
4
pom.xml
4
pom.xml
@ -107,6 +107,10 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package asia.yulinling.workflow.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig {
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(authorize -> authorize
|
||||
.requestMatchers("/users", "/users/**").permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.formLogin(formLogin -> formLogin
|
||||
.loginPage("/login")
|
||||
.permitAll())
|
||||
.rememberMe(Customizer.withDefaults());
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@ -72,4 +72,9 @@ public class TestController {
|
||||
public ApiResponse<PageResult<UserVO>> usersPage(PageParam pageParam) {
|
||||
return userService.getUserListByPage(pageParam);
|
||||
}
|
||||
|
||||
@GetMapping("/login")
|
||||
public ApiResponse<String> login() {
|
||||
return ApiResponse.ofSuccess("登录成功");
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ public class UserVO {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String name;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
|
||||
@ -42,7 +42,7 @@ public class UserServiceImpl implements UserService {
|
||||
if (ArrayUtil.isNotEmpty(users)) {
|
||||
for (User user : users) {
|
||||
UserVO userVO = new UserVO();
|
||||
userVO.setName(user.getUsername());
|
||||
userVO.setUsername(user.getUsername());
|
||||
userVO.setEmail(user.getEmail());
|
||||
userVO.setPhone(user.getPhone());
|
||||
userVO.setStatus(user.getStatus());
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# ????
|
||||
# 服务端配置
|
||||
server.port=8080
|
||||
server.servlet.context-path=/demo
|
||||
# mysql??
|
||||
# mysql配置
|
||||
spring.datasource.url=jdbc:mysql://122.152.201.90:9912/workflow?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=0andrx
|
||||
@ -10,7 +10,7 @@ spring.sql.init.mode=always
|
||||
spring.sql.init.continue-on-error=true
|
||||
spring.sql.init.schema-locations=classpath:db/schema.sql
|
||||
spring.sql.init.data-locations=classpath:db/data.sql
|
||||
# ???????
|
||||
# 连接池配置
|
||||
spring.datasource.hikari.minimum-idle=5
|
||||
spring.datasource.hikari.connection-test-query=SELECT 1
|
||||
spring.datasource.hikari.maximum-pool-size=20
|
||||
@ -19,10 +19,10 @@ spring.datasource.hikari.idle-timeout=30000
|
||||
spring.datasource.hikari.pool-name=MyAppHikariCP
|
||||
spring.datasource.hikari.max-lifetime=300000
|
||||
spring.datasource.hikari.connection-timeout=30000
|
||||
# log??
|
||||
# log配置
|
||||
logging.level.asia.yulinling=debug
|
||||
logging.level.asia.yulinling.workflow.mapper=trace
|
||||
# mail??
|
||||
# mail配置
|
||||
spring.mail.host=smtp.qq.com
|
||||
spring.mail.port=587
|
||||
spring.mail.username=2712495353@qq.com
|
||||
@ -35,5 +35,5 @@ spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
spring.mail.properties.mail.smtp.starttls.required=true
|
||||
spring.mail.properties.mail.smtp.ssl.enable=false
|
||||
spring.mail.properties.mail.display.sendmail=spring-boot-demo
|
||||
# Jasypt??
|
||||
# Jasypt配置
|
||||
jasypt.encryptor.password=abc
|
||||
@ -19,9 +19,9 @@ COMMIT;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `wk_role`
|
||||
VALUES (1072806379208708096, '管理员', '超级管理员', 1544611947239, 1544611947239);
|
||||
VALUES (1072806379208708096, '管理员', '超级管理员', '2018-12-12 14:52:27', '2018-12-12 14:52:27');
|
||||
INSERT INTO `wk_role`
|
||||
VALUES (1072806379238068224, '普通用户', '普通用户', 1544611947246, 1544611947246);
|
||||
VALUES (1072806379238068224, '普通用户', '普通用户', '2018-12-12 14:52:27', '2018-12-12 14:52:27');
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
@ -44,14 +44,45 @@ VALUES (1072806379238068224, 1072806379313565696);
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `wk_user`
|
||||
VALUES (1072806377661009920, 'admin', '管理员', 'ff342e862e7c3285cdc07e56d6b8973b',
|
||||
'412365a109674b2dbb1981ed561a4c70', 'admin@xkcoding.com', 785433600000, 1, '17300000000', 1, 1544611947032,
|
||||
1544611947032, 1544611947032);
|
||||
INSERT INTO `wk_user`
|
||||
VALUES (1072806378780889088, 'user', '普通用户', '6c6bf02c8d5d3d128f34b1700cb1e32c',
|
||||
'fcbdd0e8a9404a5585ea4e01d0e4d7a0', 'user@xkcoding.com', 785433600000, 1, '17300001111', 1, 1544611947234,
|
||||
1544611947234, 1544611947234);
|
||||
|
||||
INSERT INTO `wk_user` (
|
||||
id, username, nickname, password, salt, email, birthday, sex, phone, status,
|
||||
create_time, update_time, last_login_time
|
||||
) VALUES (
|
||||
1072806377661009920,
|
||||
'admin',
|
||||
'管理员',
|
||||
'ff342e862e7c3285cdc07e56d6b8973b',
|
||||
'412365a109674b2dbb1981ed561a4c70',
|
||||
'admin@xkcoding.com',
|
||||
'1994-11-28 00:00:00', -- birthday: 785433600000 → 1994-11-28
|
||||
1,
|
||||
'17300000000',
|
||||
1,
|
||||
'2018-12-12 14:52:27', -- create_time
|
||||
'2018-12-12 14:52:27', -- update_time
|
||||
'2018-12-12 14:52:27' -- last_login_time
|
||||
);
|
||||
|
||||
INSERT INTO `wk_user` (
|
||||
id, username, nickname, password, salt, email, birthday, sex, phone, status,
|
||||
create_time, update_time, last_login_time
|
||||
) VALUES (
|
||||
1072806378780889088,
|
||||
'user',
|
||||
'普通用户',
|
||||
'6c6bf02c8d5d3d128f34b1700cb1e32c',
|
||||
'fcbdd0e8a9404a5585ea4e01d0e4d7a0',
|
||||
'user@xkcoding.com',
|
||||
'1994-11-28 00:00:00', -- birthday: 785433600000 → 1994-11-28
|
||||
1,
|
||||
'17300001111',
|
||||
1,
|
||||
'2018-12-12 14:52:27', -- create_time
|
||||
'2018-12-12 14:52:27', -- update_time
|
||||
'2018-12-12 14:52:27' -- last_login_time
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
|
||||
@ -7,7 +7,7 @@ CREATE TABLE `wk_user`
|
||||
`password` VARCHAR(32) NOT NULL COMMENT '加密后的密码',
|
||||
`salt` VARCHAR(32) NOT NULL COMMENT '加密使用的盐',
|
||||
`email` VARCHAR(32) NOT NULL UNIQUE COMMENT '邮箱',
|
||||
`birthday` BIGINT(13) DEFAULT NULL COMMENT '生日',
|
||||
`birthday` DATETIME DEFAULT NULL COMMENT '生日',
|
||||
`sex` INT(2) DEFAULT NULL COMMENT '性别,男-1,女-2',
|
||||
`phone` VARCHAR(15) DEFAULT NULL UNIQUE COMMENT '手机号',
|
||||
`status` INT(2) NOT NULL DEFAULT 1 COMMENT '状态 -1:删除 0:警用 1:启用',
|
||||
@ -20,7 +20,7 @@ CREATE TABLE `wk_user`
|
||||
DROP TABLE IF EXISTS `wk_role`;
|
||||
CREATE TABLE `wk_role`
|
||||
(
|
||||
`id` bigint(64) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
|
||||
`id` BIGINT(64) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
|
||||
`name` VARCHAR(32) NOT NULL UNIQUE COMMENT '角色名',
|
||||
`description` VARCHAR(100) DEFAULT NULL COMMENT '描述',
|
||||
`create_time` DATETIME NOT NULL DEFAULT NOW() COMMENT '创建时间',
|
||||
@ -31,7 +31,7 @@ CREATE TABLE `wk_role`
|
||||
DROP TABLE IF EXISTS `wk_permission`;
|
||||
CREATE TABLE `wk_permission`
|
||||
(
|
||||
`id` bigint(64) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
|
||||
`id` BIGINT(64) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
|
||||
`name` VARCHAR(32) NOT NULL UNIQUE COMMENT '权限名',
|
||||
`url` VARCHAR(1000) DEFAULT NULL COMMENT '类型为页面时,代表前端路由地址,类型为按钮时,代表后端接口地址',
|
||||
`type` INT(2) NOT NULL COMMENT '权限类型,页面-1,按钮-2',
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="asia.yulinling.workflow.mapper.UserMapper">
|
||||
<insert id="saveUser">
|
||||
INSERT INTO `orm_user` (`name`,
|
||||
INSERT INTO `wk_user` (`username`,
|
||||
`nickname`,
|
||||
`password`,
|
||||
`salt`,
|
||||
`email`,
|
||||
@ -10,8 +11,9 @@
|
||||
`status`,
|
||||
`create_time`,
|
||||
`last_login_time`,
|
||||
`last_update_time`)
|
||||
`update_time`)
|
||||
VALUES (#{user.name},
|
||||
#{user.nickname},
|
||||
#{user.password},
|
||||
#{user.salt},
|
||||
#{user.email},
|
||||
@ -19,10 +21,12 @@
|
||||
#{user.status},
|
||||
#{user.createTime},
|
||||
#{user.lastLoginTime},
|
||||
#{user.lastUpdateTime})
|
||||
#{user.updateTime})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM `orm_user` WHERE id = #{id}
|
||||
DELETE
|
||||
FROM `wk_user`
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -57,7 +57,7 @@ public class UserMapperTest {
|
||||
public void saveUser() {
|
||||
String salt = IdUtil.simpleUUID();
|
||||
User user = User.builder()
|
||||
.name("yulinling_test")
|
||||
.username("yulinling_test")
|
||||
.password(SecureUtil.md5("123456" + salt))
|
||||
.salt(salt)
|
||||
.email("2712495353@qq.com")
|
||||
@ -65,7 +65,7 @@ public class UserMapperTest {
|
||||
.status(1)
|
||||
.lastLoginTime(new DateTime())
|
||||
.createTime(new DateTime())
|
||||
.lastUpdateTime(new DateTime())
|
||||
.updateTime(new DateTime())
|
||||
.build();
|
||||
|
||||
// int i = userMapper.saveUser(user);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user