Skip to content

Commit 3f71a91

Browse files
juzi214032colorful3
authored andcommitted
refactor(DataType): 重构所有 id 数据类型
将所有 Long 类型 id,修改为 Integer 类型
1 parent b3f88c6 commit 3f71a91

56 files changed

Lines changed: 416 additions & 309 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/io/github/talelin/latticy/bo/FileBO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
/**
66
* @author pedro@TaleLin
7+
* @author Juzi@TaleLin
78
*/
89
@Data
910
public class FileBO {
1011

1112
/**
1213
* 文件 id
1314
*/
14-
private Long id;
15+
private Integer id;
1516

1617
/**
1718
* 文件 key,上传时指定的

src/main/java/io/github/talelin/latticy/bo/GroupPermissionBO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import cn.hutool.core.bean.BeanUtil;
44
import io.github.talelin.latticy.model.GroupDO;
55
import io.github.talelin.latticy.model.PermissionDO;
6-
import lombok.*;
6+
import lombok.AllArgsConstructor;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
79

810
import java.util.List;
911

@@ -15,7 +17,7 @@
1517
@NoArgsConstructor
1618
@AllArgsConstructor
1719
public class GroupPermissionBO {
18-
private Long id;
20+
private Integer id;
1921

2022
private String name;
2123

src/main/java/io/github/talelin/latticy/common/interceptor/AuthorizeVerifyResolverImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
import io.github.talelin.autoconfigure.exception.AuthorizationException;
1212
import io.github.talelin.autoconfigure.exception.NotFoundException;
1313
import io.github.talelin.autoconfigure.exception.TokenInvalidException;
14+
import io.github.talelin.autoconfigure.interfaces.AuthorizeVerifyResolver;
15+
import io.github.talelin.core.token.DoubleJWT;
1416
import io.github.talelin.latticy.common.LocalUser;
1517
import io.github.talelin.latticy.model.PermissionDO;
1618
import io.github.talelin.latticy.model.UserDO;
1719
import io.github.talelin.latticy.service.GroupService;
1820
import io.github.talelin.latticy.service.UserService;
19-
import io.github.talelin.autoconfigure.interfaces.AuthorizeVerifyResolver;
20-
import io.github.talelin.core.token.DoubleJWT;
2121
import org.apache.logging.log4j.util.Strings;
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.beans.factory.annotation.Value;
@@ -77,7 +77,7 @@ public boolean handleGroup(HttpServletRequest request, HttpServletResponse respo
7777
if (verifyAdmin(user)) {
7878
return true;
7979
}
80-
long userId = user.getId();
80+
Integer userId = user.getId();
8181
String permission = meta.getPermission();
8282
String module = meta.getModule();
8383
List<PermissionDO> permissions = userService.getUserPermissions(userId);

src/main/java/io/github/talelin/latticy/common/interceptor/LoggerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/**
2121
* @author pedro@TaleLin
22+
* @author Juzi@TaleLin
2223
*/
2324
@Slf4j
2425
@Component
@@ -34,15 +35,14 @@ public class LoggerImpl implements LoggerResolver {
3435

3536
@Override
3637
public void handle(PermissionMeta meta, Logger logger, HttpServletRequest request, HttpServletResponse response) {
37-
// parse template and extract properties from request,response and modelAndView
3838
String template = logger.template();
3939
UserDO user = LocalUser.getLocalUser();
4040
template = this.parseTemplate(template, user, request, response);
4141
String permission = "";
4242
if (meta != null) {
4343
permission = StringUtils.isEmpty(meta.permission()) ? meta.value() : meta.permission();
4444
}
45-
Long userId = user.getId();
45+
Integer userId = user.getId();
4646
String username = user.getUsername();
4747
String method = request.getMethod();
4848
String path = request.getServletPath();

src/main/java/io/github/talelin/latticy/common/mybatis/Page.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public Page() {
1717
super.setCurrent(0);
1818
}
1919

20-
public Page(long current, long size) {
20+
public Page(int current, int size) {
2121
this(current, size, 0);
2222
}
2323

24-
public Page(long current, long size, long total) {
24+
public Page(int current, int size, int total) {
2525
this(current, size, total, true);
2626
}
2727

28-
public Page(long current, long size, boolean isSearchCount) {
28+
public Page(int current, int size, boolean isSearchCount) {
2929
this(current, size, 0, isSearchCount);
3030
}
3131

@@ -37,7 +37,7 @@ public Page(long current, long size, boolean isSearchCount) {
3737
* @param total 总数
3838
* @param isSearchCount 是否进行 count 查询
3939
*/
40-
public Page(long current, long size, long total, boolean isSearchCount) {
40+
public Page(int current, int size, int total, boolean isSearchCount) {
4141
super(current, size, total, isSearchCount);
4242

4343
if (current < 0) {

src/main/java/io/github/talelin/latticy/common/util/ResponseUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.github.talelin.latticy.common.util;
22

3-
import io.github.talelin.latticy.vo.PageResponseVO;
4-
import io.github.talelin.latticy.vo.UnifyResponseVO;
53
import io.github.talelin.autoconfigure.bean.Code;
64
import io.github.talelin.autoconfigure.util.RequestUtil;
5+
import io.github.talelin.latticy.vo.PageResponseVO;
6+
import io.github.talelin.latticy.vo.UnifyResponseVO;
77
import lombok.extern.slf4j.Slf4j;
88
import org.springframework.web.context.request.RequestContextHolder;
99
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -87,7 +87,7 @@ public static <T> UnifyResponseVO<T> generateUnifyResponse(int code) {
8787
.build();
8888
}
8989

90-
public static PageResponseVO generatePageResult(long total, List items, long page, long count) {
90+
public static PageResponseVO generatePageResult(int total, List items, int page, int count) {
9191
return new PageResponseVO(total, items, page, count);
9292
}
9393
}

src/main/java/io/github/talelin/latticy/controller/cms/AdminController.java

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,34 @@
66
import io.github.talelin.core.annotation.PermissionModule;
77
import io.github.talelin.latticy.bo.GroupPermissionBO;
88
import io.github.talelin.latticy.common.util.PageUtil;
9-
import io.github.talelin.latticy.dto.admin.*;
9+
import io.github.talelin.latticy.dto.admin.DispatchPermissionDTO;
10+
import io.github.talelin.latticy.dto.admin.DispatchPermissionsDTO;
11+
import io.github.talelin.latticy.dto.admin.NewGroupDTO;
12+
import io.github.talelin.latticy.dto.admin.RemovePermissionsDTO;
13+
import io.github.talelin.latticy.dto.admin.ResetPasswordDTO;
14+
import io.github.talelin.latticy.dto.admin.UpdateGroupDTO;
15+
import io.github.talelin.latticy.dto.admin.UpdateUserInfoDTO;
1016
import io.github.talelin.latticy.model.GroupDO;
1117
import io.github.talelin.latticy.model.PermissionDO;
1218
import io.github.talelin.latticy.model.UserDO;
1319
import io.github.talelin.latticy.service.AdminService;
1420
import io.github.talelin.latticy.service.GroupService;
15-
import io.github.talelin.latticy.vo.*;
21+
import io.github.talelin.latticy.vo.CreatedVO;
22+
import io.github.talelin.latticy.vo.DeletedVO;
23+
import io.github.talelin.latticy.vo.PageResponseVO;
24+
import io.github.talelin.latticy.vo.UpdatedVO;
25+
import io.github.talelin.latticy.vo.UserInfoVO;
1626
import org.springframework.beans.factory.annotation.Autowired;
1727
import org.springframework.validation.annotation.Validated;
18-
import org.springframework.web.bind.annotation.*;
28+
import org.springframework.web.bind.annotation.DeleteMapping;
29+
import org.springframework.web.bind.annotation.GetMapping;
30+
import org.springframework.web.bind.annotation.PathVariable;
31+
import org.springframework.web.bind.annotation.PostMapping;
32+
import org.springframework.web.bind.annotation.PutMapping;
33+
import org.springframework.web.bind.annotation.RequestBody;
34+
import org.springframework.web.bind.annotation.RequestMapping;
35+
import org.springframework.web.bind.annotation.RequestParam;
36+
import org.springframework.web.bind.annotation.RestController;
1937

2038
import javax.validation.constraints.Max;
2139
import javax.validation.constraints.Min;
@@ -26,6 +44,7 @@
2644

2745
/**
2846
* @author pedro@TaleLin
47+
* @author Juzi@TaleLin
2948
*/
3049
@RestController
3150
@RequestMapping("/cms/admin")
@@ -52,12 +71,12 @@ public Map<String, List<PermissionDO>> getAllPermissions() {
5271
@PermissionMeta(value = "查询所有用户", mount = false)
5372
public PageResponseVO getUsers(
5473
@RequestParam(name = "group_id", required = false)
55-
@Min(value = 1, message = "{group.id.positive}") Long groupId,
74+
@Min(value = 1, message = "{group.id.positive}") Integer groupId,
5675
@RequestParam(name = "count", required = false, defaultValue = "10")
5776
@Min(value = 1, message = "{page.count.min}")
58-
@Max(value = 30, message = "{page.count.max}") Long count,
77+
@Max(value = 30, message = "{page.count.max}") Integer count,
5978
@RequestParam(name = "page", required = false, defaultValue = "0")
60-
@Min(value = 0, message = "{page.number.min}") Long page) {
79+
@Min(value = 0, message = "{page.number.min}") Integer page) {
6180
IPage<UserDO> iPage = adminService.getUserPageByGroupId(groupId, count, page);
6281
List<UserInfoVO> userInfos = iPage.getRecords().stream().map(user -> {
6382
List<GroupDO> groups = groupService.getUserGroupsByUserId(user.getId());
@@ -69,23 +88,23 @@ public PageResponseVO getUsers(
6988
@PutMapping("/user/{id}/password")
7089
@AdminRequired
7190
@PermissionMeta(value = "修改用户密码", mount = false)
72-
public UpdatedVO changeUserPassword(@PathVariable @Positive(message = "{id.positive}") Long id, @RequestBody @Validated ResetPasswordDTO validator) {
91+
public UpdatedVO changeUserPassword(@PathVariable @Positive(message = "{id.positive}") Integer id, @RequestBody @Validated ResetPasswordDTO validator) {
7392
adminService.changeUserPassword(id, validator);
7493
return new UpdatedVO(4);
7594
}
7695

7796
@DeleteMapping("/user/{id}")
7897
@AdminRequired
7998
@PermissionMeta(value = "删除用户", mount = false)
80-
public DeletedVO deleteUser(@PathVariable @Positive(message = "{id.positive}") Long id) {
99+
public DeletedVO deleteUser(@PathVariable @Positive(message = "{id.positive}") Integer id) {
81100
adminService.deleteUser(id);
82101
return new DeletedVO(5);
83102
}
84103

85104
@PutMapping("/user/{id}")
86105
@AdminRequired
87106
@PermissionMeta(value = "管理员更新用户信息", mount = false)
88-
public UpdatedVO updateUser(@PathVariable @Positive(message = "{id.positive}") Long id, @RequestBody @Validated UpdateUserInfoDTO validator) {
107+
public UpdatedVO updateUser(@PathVariable @Positive(message = "{id.positive}") Integer id, @RequestBody @Validated UpdateUserInfoDTO validator) {
89108
adminService.updateUserInfo(id, validator);
90109
return new UpdatedVO(6);
91110
}
@@ -96,9 +115,9 @@ public UpdatedVO updateUser(@PathVariable @Positive(message = "{id.positive}") L
96115
public PageResponseVO getGroups(
97116
@RequestParam(name = "count", required = false, defaultValue = "10")
98117
@Min(value = 1, message = "{page.count.min}")
99-
@Max(value = 30, message = "{page.count.max}") Long count,
118+
@Max(value = 30, message = "{page.count.max}") Integer count,
100119
@RequestParam(name = "page", required = false, defaultValue = "0")
101-
@Min(value = 0, message = "{page.number.min}") Long page) {
120+
@Min(value = 0, message = "{page.number.min}") Integer page) {
102121
IPage<GroupDO> iPage = adminService.getGroupPage(page, count);
103122
return PageUtil.build(iPage);
104123
}
@@ -114,7 +133,7 @@ public List<GroupDO> getAllGroup() {
114133
@GetMapping("/group/{id}")
115134
@AdminRequired
116135
@PermissionMeta(value = "查询一个权限组及其权限", mount = false)
117-
public GroupPermissionBO getGroup(@PathVariable @Positive(message = "{id.positive}") Long id) {
136+
public GroupPermissionBO getGroup(@PathVariable @Positive(message = "{id.positive}") Integer id) {
118137
GroupPermissionBO groupPermissions = adminService.getGroup(id);
119138
return groupPermissions;
120139
}
@@ -130,7 +149,7 @@ public CreatedVO createGroup(@RequestBody @Validated NewGroupDTO validator) {
130149
@PutMapping("/group/{id}")
131150
@AdminRequired
132151
@PermissionMeta(value = "更新一个权限组", mount = false)
133-
public UpdatedVO updateGroup(@PathVariable @Positive(message = "{id.positive}") Long id,
152+
public UpdatedVO updateGroup(@PathVariable @Positive(message = "{id.positive}") Integer id,
134153
@RequestBody @Validated UpdateGroupDTO validator) {
135154
adminService.updateGroup(id, validator);
136155
return new UpdatedVO(7);
@@ -139,7 +158,7 @@ public UpdatedVO updateGroup(@PathVariable @Positive(message = "{id.positive}")
139158
@DeleteMapping("/group/{id}")
140159
@AdminRequired
141160
@PermissionMeta(value = "删除一个权限组", mount = false)
142-
public DeletedVO deleteGroup(@PathVariable @Positive(message = "{id.positive}") Long id) {
161+
public DeletedVO deleteGroup(@PathVariable @Positive(message = "{id.positive}") Integer id) {
143162
adminService.deleteGroup(id);
144163
return new DeletedVO(8);
145164
}

src/main/java/io/github/talelin/latticy/controller/cms/LogController.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/**
2424
* @author pedro@TaleLin
25+
* @author Juzi@TaleLin
2526
*/
2627
@RestController
2728
@RequestMapping("/cms/log")
@@ -41,9 +42,9 @@ public PageResponseVO getLogs(
4142
@RequestParam(name = "name", required = false) String name,
4243
@RequestParam(name = "count", required = false, defaultValue = "15")
4344
@Min(value = 1, message = "{page.count.min}")
44-
@Max(value = 30, message = "{page.count.max}") Long count,
45+
@Max(value = 30, message = "{page.count.max}") Integer count,
4546
@RequestParam(name = "page", required = false, defaultValue = "0")
46-
@Min(value = 0, message = "{page.number.min}") Long page) {
47+
@Min(value = 0, message = "{page.number.min}") Integer page) {
4748
IPage<LogDO> iPage = logService.getLogPage(page, count, name, start, end);
4849
return PageUtil.build(iPage);
4950
}
@@ -58,9 +59,9 @@ public PageResponseVO searchLogs(
5859
@RequestParam(name = "keyword", required = false, defaultValue = "") String keyword,
5960
@RequestParam(name = "count", required = false, defaultValue = "15")
6061
@Min(value = 1, message = "{page.count.min}")
61-
@Max(value = 30, message = "{page.count.max}") Long count,
62+
@Max(value = 30, message = "{page.count.max}") Integer count,
6263
@RequestParam(name = "page", required = false, defaultValue = "0")
63-
@Min(value = 0, message = "{page.number.min}") Long page) {
64+
@Min(value = 0, message = "{page.number.min}") Integer page) {
6465
IPage<LogDO> iPage = logService.searchLogPage(page, count, name, keyword, start, end);
6566
return PageUtil.build(iPage);
6667
}
@@ -71,9 +72,9 @@ public PageResponseVO searchLogs(
7172
public PageResponseVO getUsers(
7273
@RequestParam(name = "count", required = false, defaultValue = "15")
7374
@Min(value = 1, message = "{page.count.min}")
74-
@Max(value = 30, message = "{page.count.max}") Long count,
75+
@Max(value = 30, message = "{page.count.max}") Integer count,
7576
@RequestParam(name = "page", required = false, defaultValue = "0")
76-
@Min(value = 0, message = "{page.number.min}") Long page) {
77+
@Min(value = 0, message = "{page.number.min}") Integer page) {
7778
IPage<String> iPage = logService.getUserNamePage(page, count);
7879
return PageUtil.build(iPage);
7980
}

src/main/java/io/github/talelin/latticy/controller/v1/BookController.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@
1111
import io.github.talelin.latticy.vo.UpdatedVO;
1212
import org.springframework.beans.factory.annotation.Autowired;
1313
import org.springframework.validation.annotation.Validated;
14-
import org.springframework.web.bind.annotation.*;
14+
import org.springframework.web.bind.annotation.DeleteMapping;
15+
import org.springframework.web.bind.annotation.GetMapping;
16+
import org.springframework.web.bind.annotation.PathVariable;
17+
import org.springframework.web.bind.annotation.PostMapping;
18+
import org.springframework.web.bind.annotation.PutMapping;
19+
import org.springframework.web.bind.annotation.RequestBody;
20+
import org.springframework.web.bind.annotation.RequestMapping;
21+
import org.springframework.web.bind.annotation.RequestParam;
22+
import org.springframework.web.bind.annotation.RestController;
1523

1624
import javax.validation.constraints.Positive;
1725
import java.util.List;
1826

1927
/**
2028
* @author pedro@TaleLin
29+
* @author Juzi@TaleLin
2130
*/
2231
@RestController
2332
@RequestMapping("/v1/book")
@@ -28,7 +37,7 @@ public class BookController {
2837
private BookService bookService;
2938

3039
@GetMapping("/{id}")
31-
public BookDO getBook(@PathVariable(value = "id") @Positive(message = "{id.positive}") Long id) {
40+
public BookDO getBook(@PathVariable(value = "id") @Positive(message = "{id.positive}") Integer id) {
3241
BookDO book = bookService.getById(id);
3342
if (book == null) {
3443
throw new NotFoundException("book not found", 10022);
@@ -58,7 +67,7 @@ public CreatedVO createBook(@RequestBody @Validated CreateOrUpdateBookDTO valida
5867

5968

6069
@PutMapping("/{id}")
61-
public UpdatedVO updateBook(@PathVariable("id") @Positive(message = "{id.positive}") Long id, @RequestBody @Validated CreateOrUpdateBookDTO validator) {
70+
public UpdatedVO updateBook(@PathVariable("id") @Positive(message = "{id.positive}") Integer id, @RequestBody @Validated CreateOrUpdateBookDTO validator) {
6271
BookDO book = bookService.getById(id);
6372
if (book == null) {
6473
throw new NotFoundException("book not found", 10022);
@@ -71,7 +80,7 @@ public UpdatedVO updateBook(@PathVariable("id") @Positive(message = "{id.positiv
7180
@DeleteMapping("/{id}")
7281
@GroupRequired
7382
@PermissionMeta(value = "删除图书", module = "图书")
74-
public DeletedVO deleteBook(@PathVariable("id") @Positive(message = "{id.positive}") Long id) {
83+
public DeletedVO deleteBook(@PathVariable("id") @Positive(message = "{id.positive}") Integer id) {
7584
BookDO book = bookService.getById(id);
7685
if (book == null) {
7786
throw new NotFoundException("book not found", 10022);

src/main/java/io/github/talelin/latticy/dto/admin/DispatchPermissionDTO.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
/**
99
* @author pedro@TaleLin
10+
* @author Juzi@TaleLin
1011
*/
1112
@Data
1213
public class DispatchPermissionDTO {
1314

1415
@Positive(message = "{group.id.positive}")
1516
@NotNull(message = "{group.id.not-null}")
16-
private Long groupId;
17+
private Integer groupId;
1718

1819
@Positive(message = "{permission.id.positive}")
1920
@NotNull(message = "{permission.id.not-null}")
20-
private Long permissionId;
21+
private Integer permissionId;
2122
}

0 commit comments

Comments
 (0)