Skip to content

Commit b02b0d1

Browse files
committed
refactor/重构
1 parent b947b91 commit b02b0d1

File tree

73 files changed

+482
-445
lines changed

Some content is hidden

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

73 files changed

+482
-445
lines changed

pmhub-auth/src/main/java/com/laigeoffer/pmhub/auth/service/SysPasswordService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.laigeoffer.pmhub.base.core.core.domain.entity.SysUser;
66
import com.laigeoffer.pmhub.base.core.exception.user.UserPasswordNotMatchException;
77
import com.laigeoffer.pmhub.base.core.exception.user.UserPasswordRetryLimitExceedException;
8-
import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
8+
import com.laigeoffer.pmhub.base.security.utils.SecurityUtils;
99
import com.laigeoffer.pmhub.base.security.context.AuthenticationContextHolder;
1010
import org.springframework.beans.factory.annotation.Value;
1111
import org.springframework.security.core.Authentication;

pmhub-auth/src/main/java/com/laigeoffer/pmhub/auth/service/SysRegisterService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//import com.laigeoffer.pmhub.base.core.exception.user.CaptchaException;
99
//import com.laigeoffer.pmhub.base.core.exception.user.CaptchaExpireException;
1010
//import com.laigeoffer.pmhub.base.core.utils.MessageUtils;
11-
//import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
11+
//import com.laigeoffer.pmhub.base.security.utils.SecurityUtils;
1212
//import com.laigeoffer.pmhub.base.core.utils.StringUtils;
1313
//import com.laigeoffer.pmhub.base.framework.manager.AsyncManager;
1414
//import com.laigeoffer.pmhub.base.framework.manager.factory.AsyncFactory;

pmhub-base/pmhub-base-core/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
</dependency>
7474

7575
<!-- spring security 安全认证 -->
76-
<dependency>
77-
<groupId>org.springframework.boot</groupId>
78-
<artifactId>spring-boot-starter-security</artifactId>
79-
</dependency>
76+
<!-- <dependency>-->
77+
<!-- <groupId>org.springframework.boot</groupId>-->
78+
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
79+
<!-- </dependency>-->
8080

8181
<!-- collections工具类 -->
8282
<dependency>

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/config/MetaObjectHandlerConfig.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.laigeoffer.pmhub.base.core.config;
22

33
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
4-
import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
54
import org.apache.ibatis.reflection.MetaObject;
65
import org.springframework.stereotype.Component;
76

@@ -35,10 +34,12 @@ public void insertFill(MetaObject metaObject) {
3534
this.strictInsertFill(metaObject, "deleted", Integer.class, 0);
3635
}
3736
if (createdBy == null) {
38-
this.strictInsertFill(metaObject, "createBy", String.class, SecurityUtils.getUsername());
37+
// TODO: 2024.05.11 拿到用户信息
38+
this.strictInsertFill(metaObject, "createBy", String.class, null);
3939
}
4040
if (updatedBy == null) {
41-
this.strictInsertFill(metaObject, "updateBy", String.class, SecurityUtils.getUsername());
41+
// TODO: 2024.05.11 拿到用户信息
42+
this.strictInsertFill(metaObject, "updateBy", String.class,null);
4243
}
4344

4445

@@ -53,7 +54,8 @@ public void updateFill(MetaObject metaObject) {
5354
this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
5455
}
5556
if (updatedBy == null) {
56-
this.strictInsertFill(metaObject, "updateBy", String.class, SecurityUtils.getUsername());
57+
// TODO: 2024.05.11 拿到用户信息
58+
this.strictInsertFill(metaObject, "updateBy", String.class, null);
5759
}
5860
}
5961
}

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/core/controller/BaseController.java

-29
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
import com.laigeoffer.pmhub.base.core.constant.HttpStatus;
66
import com.laigeoffer.pmhub.base.core.core.domain.AjaxResult;
77
import com.laigeoffer.pmhub.base.core.core.domain.R;
8-
import com.laigeoffer.pmhub.base.core.core.domain.model.LoginUser;
98
import com.laigeoffer.pmhub.base.core.core.page.PageDomain;
109
import com.laigeoffer.pmhub.base.core.core.page.TableDataInfo;
1110
import com.laigeoffer.pmhub.base.core.core.page.TableDataInfoForUs;
1211
import com.laigeoffer.pmhub.base.core.core.page.TableSupport;
1312
import com.laigeoffer.pmhub.base.core.utils.DateUtils;
1413
import com.laigeoffer.pmhub.base.core.utils.PageUtils;
15-
import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
1614
import com.laigeoffer.pmhub.base.core.utils.StringUtils;
1715
import com.laigeoffer.pmhub.base.core.utils.sql.SqlUtil;
1816
import org.slf4j.Logger;
@@ -186,31 +184,4 @@ public String redirect(String url) {
186184
return StringUtils.format("redirect:{}", url);
187185
}
188186

189-
/**
190-
* 获取用户缓存信息
191-
*/
192-
public LoginUser getLoginUser() {
193-
return SecurityUtils.getLoginUser();
194-
}
195-
196-
/**
197-
* 获取登录用户id
198-
*/
199-
public Long getUserId() {
200-
return getLoginUser().getUserId();
201-
}
202-
203-
/**
204-
* 获取登录部门id
205-
*/
206-
public Long getDeptId() {
207-
return getLoginUser().getDeptId();
208-
}
209-
210-
/**
211-
* 获取登录用户名
212-
*/
213-
public String getUsername() {
214-
return getLoginUser().getUsername();
215-
}
216187
}

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/core/domain/model/LoginUser.java

+28-30
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
import com.alibaba.fastjson2.annotation.JSONField;
44
import com.laigeoffer.pmhub.base.core.core.domain.entity.SysUser;
5-
import org.springframework.security.core.GrantedAuthority;
6-
import org.springframework.security.core.userdetails.UserDetails;
75

8-
import java.util.Collection;
6+
import java.io.Serializable;
97
import java.util.Set;
108

119
/**
1210
* 登录用户身份权限
1311
*
1412
* @author canghe
1513
*/
16-
public class LoginUser implements UserDetails {
14+
public class LoginUser implements Serializable {
1715
private static final long serialVersionUID = 1L;
1816

1917
/**
@@ -118,57 +116,57 @@ public void setToken(String token) {
118116
}
119117

120118
@JSONField(serialize = false)
121-
@Override
119+
// @Override
122120
public String getPassword() {
123121
return user.getPassword();
124122
}
125123

126-
@Override
124+
// @Override
127125
public String getUsername() {
128126
return user.getUserName();
129127
}
130128

131129
/**
132130
* 账户是否未过期,过期无法验证
133131
*/
134-
@JSONField(serialize = false)
135-
@Override
136-
public boolean isAccountNonExpired() {
137-
return true;
138-
}
132+
// @JSONField(serialize = false)
133+
// @Override
134+
// public boolean isAccountNonExpired() {
135+
// return true;
136+
// }
139137

140138
/**
141139
* 指定用户是否解锁,锁定的用户无法进行身份验证
142140
*
143141
* @return
144142
*/
145-
@JSONField(serialize = false)
146-
@Override
147-
public boolean isAccountNonLocked() {
148-
return true;
149-
}
143+
// @JSONField(serialize = false)
144+
// @Override
145+
// public boolean isAccountNonLocked() {
146+
// return true;
147+
// }
150148

151149
/**
152150
* 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
153151
*
154152
* @return
155153
*/
156-
@JSONField(serialize = false)
157-
@Override
158-
public boolean isCredentialsNonExpired() {
159-
return true;
160-
}
154+
// @JSONField(serialize = false)
155+
// @Override
156+
// public boolean isCredentialsNonExpired() {
157+
// return true;
158+
// }
161159

162160
/**
163161
* 是否可用 ,禁用的用户不能身份验证
164162
*
165163
* @return
166164
*/
167-
@JSONField(serialize = false)
168-
@Override
169-
public boolean isEnabled() {
170-
return true;
171-
}
165+
// @JSONField(serialize = false)
166+
// @Override
167+
// public boolean isEnabled() {
168+
// return true;
169+
// }
172170

173171
public Long getLoginTime() {
174172
return loginTime;
@@ -242,8 +240,8 @@ public void setRoles(Set<String> roles) {
242240
this.roles = roles;
243241
}
244242

245-
@Override
246-
public Collection<? extends GrantedAuthority> getAuthorities() {
247-
return null;
248-
}
243+
// @Override
244+
// public Collection<? extends GrantedAuthority> getAuthorities() {
245+
// return null;
246+
// }
249247
}

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/utils/ExcelUtils.java

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package com.laigeoffer.pmhub.base.core.utils;
22

33
import cn.hutool.core.util.IdUtil;
4-
import cn.hutool.log.LogFactory;
54
import cn.hutool.poi.excel.ExcelUtil;
65
import cn.hutool.poi.excel.ExcelWriter;
7-
import com.laigeoffer.pmhub.base.core.utils.file.FileUtils;
86
import org.apache.poi.ss.usermodel.*;
97

108
import javax.servlet.http.HttpServletResponse;
119
import java.io.File;
12-
import java.io.IOException;
1310
import java.util.List;
1411
import java.util.Map;
1512

@@ -34,15 +31,15 @@ public static void exportExcelRows(List<Map<String, Object>> rows, HttpServletRe
3431
}
3532

3633
// 文件输出
37-
try {
38-
FileUtils.setAttachmentResponseHeader(response, fileName);
39-
FileUtils.writeBytes(tmpExcelPath, response);
40-
}catch (IOException ex){
41-
LogFactory.get().error(ex);
42-
throw new RuntimeException("文件导出失败!");
43-
}
44-
45-
FileUtils.deleteFile(tmpExcelPath);
34+
// try {
35+
// FileUtils.setAttachmentResponseHeader(response, fileName);
36+
// FileUtils.writeBytes(tmpExcelPath, response);
37+
// }catch (IOException ex){
38+
// LogFactory.get().error(ex);
39+
// throw new RuntimeException("文件导出失败!");
40+
// }
41+
//
42+
// FileUtils.deleteFile(tmpExcelPath);
4643
}
4744

4845
public static String createExcel(List<Map<String, Object>> rows,String path,String fileName){
@@ -121,13 +118,13 @@ public static void exportMaterialsChangeRows(List<Map<String, Object>> rows, Htt
121118
// 关闭writer,释放内存
122119
writer.close();
123120
// 文件输出
124-
try {
125-
FileUtils.setAttachmentResponseHeader(response, fileName);
126-
FileUtils.writeBytes(tmpExcelPath, response);
127-
}catch (IOException ex){
128-
LogFactory.get().error(ex);
129-
throw new RuntimeException("文件导出失败!");
130-
}
131-
FileUtils.deleteFile(tmpExcelPath);
121+
// try {
122+
// FileUtils.setAttachmentResponseHeader(response, fileName);
123+
// FileUtils.writeBytes(tmpExcelPath, response);
124+
// }catch (IOException ex){
125+
// LogFactory.get().error(ex);
126+
// throw new RuntimeException("文件导出失败!");
127+
// }
128+
// FileUtils.deleteFile(tmpExcelPath);
132129
}
133130
}

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/utils/UserMessageUtils.java

-29
This file was deleted.

pmhub-base/pmhub-base-core/src/main/java/com/laigeoffer/pmhub/base/core/utils/poi/ExcelUtil.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.laigeoffer.pmhub.base.core.utils.DateUtils;
1414
import com.laigeoffer.pmhub.base.core.utils.StringUtils;
1515
import com.laigeoffer.pmhub.base.core.utils.file.FileTypeUtils;
16-
import com.laigeoffer.pmhub.base.core.utils.file.FileUtils;
1716
import com.laigeoffer.pmhub.base.core.utils.file.ImageUtils;
1817
import com.laigeoffer.pmhub.base.core.utils.reflect.ReflectUtils;
1918
import org.apache.commons.lang3.ArrayUtils;
@@ -466,7 +465,7 @@ public List<T> importExcel(String sheetName, InputStream is, int titleNum) throw
466465
val = "";
467466
} else {
468467
byte[] data = image.getData();
469-
val = FileUtils.writeImportBytes(data);
468+
// val = FileUtils.writeImportBytes(data);
470469
}
471470
}
472471
ReflectUtils.invokeSetter(entity, propertyName, val);
@@ -1412,7 +1411,7 @@ public static <T> void exportExcel2(List<T> list, String sheetName, Class<T> cla
14121411
*/
14131412
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
14141413
String filename = encodingFilename(sheetName);
1415-
FileUtils.setAttachmentResponseHeader(response, filename);
1414+
// FileUtils.setAttachmentResponseHeader(response, filename);
14161415
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
14171416
}
14181417
}

pmhub-base/pmhub-base-log/src/main/java/com/laigeoffer/pmhub/base/log/aspect/LogAspect.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//import com.laigeoffer.pmhub.base.core.enums.BusinessStatus;
77
//import com.laigeoffer.pmhub.base.core.filter.PropertyPreExcludeFilter;
88
//import com.laigeoffer.pmhub.base.core.manage.AsyncManager;
9-
//import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
9+
//import com.laigeoffer.pmhub.base.security.utils.SecurityUtils;
1010
//import com.laigeoffer.pmhub.base.core.utils.ServletUtils;
1111
//import com.laigeoffer.pmhub.base.core.utils.StringUtils;
1212
//import com.laigeoffer.pmhub.base.core.utils.ip.IpUtils;

pmhub-base/pmhub-base-security/src/main/java/com/laigeoffer/pmhub/base/security/aspect/DataScopeAspect.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.laigeoffer.pmhub.base.core.core.domain.entity.SysUser;
88
import com.laigeoffer.pmhub.base.core.core.domain.model.LoginUser;
99
import com.laigeoffer.pmhub.base.core.core.text.Convert;
10-
import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
10+
import com.laigeoffer.pmhub.base.security.utils.SecurityUtils;
1111
import com.laigeoffer.pmhub.base.core.utils.StringUtils;
1212
import com.laigeoffer.pmhub.base.security.context.PermissionContextHolder;
1313
import org.aspectj.lang.JoinPoint;

pmhub-base/pmhub-base-security/src/main/java/com/laigeoffer/pmhub/base/security/auth/AuthLogic.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.laigeoffer.pmhub.base.core.exception.auth.NotLoginException;
66
import com.laigeoffer.pmhub.base.core.exception.auth.NotPermissionException;
77
import com.laigeoffer.pmhub.base.core.exception.auth.NotRoleException;
8-
import com.laigeoffer.pmhub.base.core.utils.SecurityUtils;
8+
import com.laigeoffer.pmhub.base.security.utils.SecurityUtils;
99
import com.laigeoffer.pmhub.base.core.utils.spring.SpringUtils;
1010
import com.laigeoffer.pmhub.base.security.annotation.Logical;
1111
import com.laigeoffer.pmhub.base.security.annotation.RequiresLogin;

0 commit comments

Comments
 (0)