Compare commits

..

2 Commits

Author SHA1 Message Date
雨霖铃
6160c48c7b Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main/java/asia/yulinling/workflow/service/impl/UserServiceImpl.java
#	src/main/resources/db/data.sql
#	src/main/resources/db/schema.sql
2025-06-11 00:27:31 +08:00
yulinling
474c9499f6 feat:
- 修改database sql
- 增加Security配置
2025-06-11 00:26:44 +08:00
10 changed files with 102 additions and 34 deletions

View File

@ -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>

View File

@ -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();
}
}

View File

@ -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("登录成功");
}
}

View File

@ -15,7 +15,7 @@ public class UserVO {
/**
* 用户名
*/
private String name;
private String username;
/**
* 邮箱

View File

@ -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());

View File

@ -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

View File

@ -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;

View File

@ -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',

View File

@ -2,16 +2,18 @@
<!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`,
`password`,
`salt`,
`email`,
`phone`,
`status`,
`create_time`,
`last_login_time`,
`last_update_time`)
INSERT INTO `wk_user` (`username`,
`nickname`,
`password`,
`salt`,
`email`,
`phone`,
`status`,
`create_time`,
`last_login_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>

View File

@ -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);