Skip to content

Commit 86f59c0

Browse files
committed
refactor: 完成 lin_group 表 level 字段类型的修改
1 parent 315d6ab commit 86f59c0

8 files changed

Lines changed: 27 additions & 29 deletions

File tree

src/main/java/io/github/talelin/latticy/common/enumeration/GroupLevelEnum.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ public enum GroupLevelEnum {
2121
;
2222

2323
@EnumValue
24-
private Integer code;
24+
private Integer value;
2525

26-
private String value;
26+
private String description;
2727

28-
GroupLevelEnum(Integer code , String value) {
29-
this.code = code;
28+
GroupLevelEnum(Integer value , String description) {
3029
this.value = value;
30+
this.description = description;
3131
}
3232

33-
public Integer getCode() {
34-
return code;
33+
public Integer getValue() {
34+
return value;
3535
}
3636

37-
public void setCode(Integer code) {
38-
this.code = code;
37+
public String getDescription() {
38+
return description;
3939
}
4040
}

src/main/java/io/github/talelin/latticy/model/GroupDO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@Builder
1919
@NoArgsConstructor
2020
@AllArgsConstructor
21-
@TableName(value = "lin_group",autoResultMap = true)
21+
@TableName(value = "lin_group", autoResultMap = true)
2222
@EqualsAndHashCode(callSuper = true)
2323
public class GroupDO extends BaseModel implements Serializable {
2424

src/main/java/io/github/talelin/latticy/service/impl/GroupServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ public List<Integer> getGroupUserIds(Integer id) {
117117

118118
@Override
119119
public GroupDO getParticularGroupByLevel(GroupLevelEnum level) {
120-
if (GroupLevelEnum.USER.getCode().equals(level.getCode())) {
120+
if (GroupLevelEnum.USER == level) {
121121
return null;
122122
} else {
123123
QueryWrapper<GroupDO> wrapper = new QueryWrapper<>();
124-
wrapper.lambda().eq(GroupDO::getLevel, level);
124+
wrapper.lambda().eq(GroupDO::getLevel, level.getValue());
125125
GroupDO groupDO = this.baseMapper.selectOne(wrapper);
126126
return groupDO;
127127
}

src/main/resources/application-test.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ logging:
1212
spring:
1313
# h2 内存数据库配置,供测试使用,其它环境勿用
1414
datasource:
15-
driver-class-name: com.mysql.cj.jdbc.Driver
16-
password: '17605259250'
17-
url: jdbc:mysql://jokky.fun:3306/lin-cms?useSSL=false&serverTimezone=UTC&characterEncoding=UTF8
18-
username: root
19-
20-
# 开启权限拦截
21-
auth:
22-
enabled: true
23-
24-
25-
# 开启http请求日志记录
26-
request-log:
27-
enabled: true
15+
continue-on-error: false
16+
driver-class-name: org.h2.Driver
17+
password: ''
18+
platform: h2
19+
schema: classpath:/h2-test.sql
20+
url: jdbc:h2:mem:testdbsa;MODE=MYSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false
21+
username: sa
22+
h2:
23+
console:
24+
enabled: true
25+
path: /h2

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
spring:
44
# 激活环境配置
55
profiles:
6-
active: test
6+
active: dev
77
# 文件编码 UTF8
88
mandatory-file-encoding: UTF-8
99
mvc:

src/main/resources/mapper/GroupMapper.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<id column="id" property="id"/>
88
<result column="name" property="name"/>
99
<result column="info" property="info"/>
10-
<result column="level" property="level"/>
10+
<result column="level" property="level" typeHandler="com.baomidou.mybatisplus.extension.handlers.MybatisEnumTypeHandler"/>
1111
<result column="create_time" property="createTime"/>
1212
<result column="update_time" property="updateTime"/>
1313
<result column="delete_time" property="deleteTime"/>

src/main/resources/schema.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ VALUES (1, 1, 'USERNAME_PASSWORD', 'root',
172172
'pbkdf2sha256:64000:18:24:n:yUnDokcNRbwILZllmUOItIyo9MnI00QW:6ZcPf+sfzyoygOU8h/GSoirF');
173173

174174
INSERT INTO lin_group(id, name, info, level)
175-
VALUES (1, 'root', '超级用户组', 'root');
175+
VALUES (1, 'root', '超级用户组', 1);
176176

177177
INSERT INTO lin_group(id, name, info, level)
178-
VALUES (2, 'guest', '游客组', 'guest');
178+
VALUES (2, 'guest', '游客组', 2);
179179

180180
INSERT INTO lin_user_group(id, user_id, group_id)
181181
VALUES (1, 1, 1);

src/test/resources/h2-test.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ CREATE TABLE lin_group
7575
id int(10) unsigned NOT NULL AUTO_INCREMENT,
7676
name varchar(60) NOT NULL COMMENT '分组名称,例如:搬砖者',
7777
info varchar(255) DEFAULT NULL COMMENT '分组信息:例如:搬砖的人',
78-
level ENUM('root', 'guest', 'user') DEFAULT 'user' COMMENT '分组级别(root、guest分组只能存在一个',
78+
level smallint(1) NOT NULL DEFAULT 3 COMMENT '分组级别 1:root 2:guest 3:user root(root、guest分组只能存在一个)',
7979
create_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
8080
update_time datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
8181
delete_time datetime(3) DEFAULT NULL,

0 commit comments

Comments
 (0)