-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhuoda
committed
Jan 8, 2025
1 parent
56517b6
commit 96d498f
Showing
77 changed files
with
2,713 additions
and
910 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...-api-java17-springboot3/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.lab1024.sa.base.config; | ||
|
||
import cn.dev33.satoken.config.SaTokenConfig; | ||
import jakarta.annotation.Resource; | ||
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* | ||
* 三级等保配置初始化后最低活跃频率全局配置 | ||
* | ||
* @Author 1024创新实验室-创始人兼主任:卓大 | ||
* @Date 2024/11/24 | ||
* @Wechat zhuoda1024 | ||
* @Email [email protected] | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012 | ||
*/ | ||
|
||
@Configuration | ||
public class TokenConfig { | ||
|
||
@Resource | ||
private Level3ProtectConfigService level3ProtectConfigService; | ||
|
||
// 此配置会覆盖 sa-base.yaml 中的配置 | ||
@Resource | ||
public void configSaToken(SaTokenConfig config) { | ||
|
||
config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds()); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* @Date 2022/9/29 17:20:41 | ||
* @Wechat zhuoda1024 | ||
* @Email [email protected] | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
*/ | ||
|
||
public class EntityVariableService extends CodeGenerateBaseVariableService { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
* @Date 2022/5/26 19:40:55 | ||
* @Wechat zhuoda1024 | ||
* @Email [email protected] | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> | ||
*/ | ||
@Service | ||
public class DictService { | ||
|
@@ -39,10 +39,6 @@ public class DictService { | |
private DictValueDao dictValueDao; | ||
@Resource | ||
private DictCacheService dictCacheService; | ||
/** | ||
* CODE锁 | ||
*/ | ||
private static final Interner<String> CODE_POOL = Interners.newWeakInterner(); | ||
|
||
|
||
/** | ||
|
@@ -51,15 +47,15 @@ public class DictService { | |
* @param keyAddForm | ||
* @return | ||
*/ | ||
public ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) { | ||
synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) { | ||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false); | ||
if (dictKeyEntity != null) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class); | ||
dictKeyDao.insert(dictKeyEntity); | ||
public synchronized ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) { | ||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false); | ||
if (dictKeyEntity != null) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class); | ||
dictKeyDao.insert(dictKeyEntity); | ||
//刷新缓存 | ||
dictCacheService.cacheRefresh(); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
@@ -69,15 +65,15 @@ public ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) { | |
* @param valueAddForm | ||
* @return | ||
*/ | ||
public ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) { | ||
synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) { | ||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false); | ||
if (dictValueEntity != null) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class); | ||
dictValueDao.insert(dictValueEntity); | ||
public synchronized ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) { | ||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false); | ||
if (dictValueEntity != null) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class); | ||
dictValueDao.insert(dictValueEntity); | ||
//刷新缓存 | ||
dictCacheService.cacheRefresh(); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
@@ -87,15 +83,15 @@ public ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) { | |
* @param keyUpdateForm | ||
* @return | ||
*/ | ||
public ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) { | ||
synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) { | ||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false); | ||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class); | ||
dictKeyDao.updateById(dictKeyUpdateEntity); | ||
public synchronized ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) { | ||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false); | ||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class); | ||
dictKeyDao.updateById(dictKeyUpdateEntity); | ||
//刷新缓存 | ||
dictCacheService.cacheRefresh(); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
@@ -105,19 +101,19 @@ public ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) { | |
* @param valueUpdateForm | ||
* @return | ||
*/ | ||
public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) { | ||
public synchronized ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) { | ||
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId()); | ||
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) { | ||
return ResponseDTO.userErrorParam("key不能存在"); | ||
} | ||
synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) { | ||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false); | ||
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class); | ||
dictValueDao.updateById(dictValueUpdateEntity); | ||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false); | ||
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) { | ||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST); | ||
} | ||
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class); | ||
dictValueDao.updateById(dictValueUpdateEntity); | ||
//刷新缓存 | ||
dictCacheService.cacheRefresh(); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
@@ -127,11 +123,13 @@ public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) { | |
* @param keyIdList | ||
* @return | ||
*/ | ||
public ResponseDTO<String> keyDelete(List<Long> keyIdList) { | ||
public synchronized ResponseDTO<String> keyDelete(List<Long> keyIdList) { | ||
if (CollectionUtils.isEmpty(keyIdList)) { | ||
return ResponseDTO.ok(); | ||
} | ||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true); | ||
//刷新缓存 | ||
dictCacheService.cacheRefresh(); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
@@ -141,11 +139,13 @@ public ResponseDTO<String> keyDelete(List<Long> keyIdList) { | |
* @param valueIdList | ||
* @return | ||
*/ | ||
public ResponseDTO<String> valueDelete(List<Long> valueIdList) { | ||
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) { | ||
if (CollectionUtils.isEmpty(valueIdList)) { | ||
return ResponseDTO.ok(); | ||
} | ||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true); | ||
//刷新缓存 | ||
dictCacheService.cacheRefresh(); | ||
return ResponseDTO.ok(); | ||
} | ||
|
||
|
Oops, something went wrong.