#if>
<#else>
-
-
-
+
#if>
#if>
#list>
diff --git a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/mapper/AppMapper.java b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/mapper/AppMapper.java
index 66d6de523..7f30762b3 100644
--- a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/mapper/AppMapper.java
+++ b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/mapper/AppMapper.java
@@ -18,8 +18,8 @@
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
-import top.continew.starter.data.mp.base.BaseMapper;
import top.continew.admin.open.model.entity.AppDO;
+import top.continew.starter.data.mp.base.BaseMapper;
import top.continew.starter.security.crypto.annotation.FieldEncrypt;
/**
@@ -32,7 +32,7 @@ public interface AppMapper extends BaseMapper
{
/**
* 根据 Access Key 查询
- *
+ *
* @param accessKey Access Key
* @return 应用信息
*/
diff --git a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/entity/AppDO.java b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/entity/AppDO.java
index 0a58ff0b8..9b5ce3bdb 100644
--- a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/entity/AppDO.java
+++ b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/entity/AppDO.java
@@ -19,7 +19,7 @@
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import top.continew.admin.common.enums.DisEnableStatusEnum;
-import top.continew.starter.extension.crud.model.entity.BaseDO;
+import top.continew.admin.common.model.entity.BaseDO;
import top.continew.starter.security.crypto.annotation.FieldEncrypt;
import java.io.Serial;
diff --git a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppDetailResp.java b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppDetailResp.java
index 70627d652..99ae44e6e 100644
--- a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppDetailResp.java
+++ b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppDetailResp.java
@@ -20,8 +20,8 @@
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import top.continew.admin.common.model.resp.BaseDetailResp;
import top.continew.admin.common.enums.DisEnableStatusEnum;
-import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
import top.continew.starter.file.excel.converter.ExcelBaseEnumConverter;
import java.io.Serial;
diff --git a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppResp.java b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppResp.java
index 637d067d6..771c7796d 100644
--- a/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppResp.java
+++ b/continew-plugin/continew-plugin-open/src/main/java/top/continew/admin/open/model/resp/AppResp.java
@@ -18,8 +18,8 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import top.continew.admin.common.model.resp.BaseDetailResp;
import top.continew.admin.common.enums.DisEnableStatusEnum;
-import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
import java.io.Serial;
import java.time.LocalDateTime;
diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/JobInstanceLogPageResult.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/JobInstanceLogPageResult.java
index c0ee56dbf..341c79ef2 100644
--- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/JobInstanceLogPageResult.java
+++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/JobInstanceLogPageResult.java
@@ -18,10 +18,10 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import java.util.List;
import java.io.Serial;
import java.io.Serializable;
+import java.util.List;
/**
* 任务实例日志分页信息
diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java
index 9a1b63e22..c13bf89df 100644
--- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java
+++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java
@@ -18,10 +18,10 @@
import top.continew.admin.schedule.model.JobInstanceLogPageResult;
import top.continew.admin.schedule.model.query.JobInstanceLogQuery;
-import top.continew.admin.schedule.model.query.JobLogQuery;
import top.continew.admin.schedule.model.query.JobInstanceQuery;
-import top.continew.admin.schedule.model.resp.JobLogResp;
+import top.continew.admin.schedule.model.query.JobLogQuery;
import top.continew.admin.schedule.model.resp.JobInstanceResp;
+import top.continew.admin.schedule.model.resp.JobLogResp;
import top.continew.starter.extension.crud.model.resp.PageResp;
import java.util.List;
diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobService.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobService.java
index b485d331b..0f5266155 100644
--- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobService.java
+++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobService.java
@@ -85,7 +85,7 @@ public interface JobService {
/**
* 查询分组列表
- *
+ *
* @return 分组列表
*/
List listGroup();
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantDbConnectMapper.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantDbConnectMapper.java
index 640e3957a..1cba8d25a 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantDbConnectMapper.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantDbConnectMapper.java
@@ -16,8 +16,6 @@
package top.continew.admin.tenant.mapper;
-import com.baomidou.dynamic.datasource.annotation.DS;
-import top.continew.admin.common.constant.SysConstants;
import top.continew.starter.data.mp.base.BaseMapper;
import top.continew.admin.tenant.model.entity.TenantDbConnectDO;
@@ -27,5 +25,4 @@
* @author 小熊
* @since 2024/12/12 19:13
*/
-@DS(SysConstants.DEFAULT_DATASOURCE)
public interface TenantDbConnectMapper extends BaseMapper {}
\ No newline at end of file
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantMapper.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantMapper.java
index 306b6e9af..a18c2a090 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantMapper.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantMapper.java
@@ -16,13 +16,11 @@
package top.continew.admin.tenant.mapper;
-import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
-import top.continew.admin.common.constant.SysConstants;
import top.continew.admin.tenant.model.entity.TenantDO;
import top.continew.admin.tenant.model.resp.TenantResp;
import top.continew.starter.data.mp.base.BaseMapper;
@@ -33,7 +31,6 @@
* @author 小熊
* @since 2024/11/26 17:20
*/
-@DS(SysConstants.DEFAULT_DATASOURCE)
public interface TenantMapper extends BaseMapper {
@Select("SELECT sys_tenant.*,sys_tenant_package.`name` as package_name FROM sys_tenant\n" + "LEFT JOIN sys_tenant_package ON sys_tenant.package_id = sys_tenant_package.id\n" + "${ew.getCustomSqlSegment}")
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantPackageMapper.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantPackageMapper.java
index 20360eee4..0afdb7c14 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantPackageMapper.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/mapper/TenantPackageMapper.java
@@ -16,8 +16,6 @@
package top.continew.admin.tenant.mapper;
-import com.baomidou.dynamic.datasource.annotation.DS;
-import top.continew.admin.common.constant.SysConstants;
import top.continew.starter.data.mp.base.BaseMapper;
import top.continew.admin.tenant.model.entity.TenantPackageDO;
@@ -27,6 +25,5 @@
* @author 小熊
* @since 2024/11/26 11:25
*/
-@DS(SysConstants.DEFAULT_DATASOURCE)
public interface TenantPackageMapper extends BaseMapper {
}
\ No newline at end of file
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/req/TenantReq.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/req/TenantReq.java
index 52b5da67d..878de2566 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/req/TenantReq.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/req/TenantReq.java
@@ -103,7 +103,7 @@ public class TenantReq extends BaseReq {
* 隔离级别
*/
@Schema(description = "隔离级别")
- @NotNull(message = "隔离级别不能为空")
+ @NotNull(message = "隔离级别不能为空", groups = CrudValidationGroup.Add.class)
private Integer isolationLevel;
/**
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectDetailResp.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectDetailResp.java
index 7b4d9874d..413866ae5 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectDetailResp.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectDetailResp.java
@@ -20,7 +20,7 @@
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
+import top.continew.admin.common.model.resp.BaseDetailResp;
import java.io.Serial;
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectResp.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectResp.java
index cbf5d36bf..2a5b9b693 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectResp.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDbConnectResp.java
@@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import top.continew.starter.extension.crud.model.resp.BaseResp;
+import top.continew.admin.common.model.resp.BaseResp;
import java.io.Serial;
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDetailResp.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDetailResp.java
index 624a911ba..13b114777 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDetailResp.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantDetailResp.java
@@ -20,7 +20,7 @@
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
+import top.continew.admin.common.model.resp.BaseDetailResp;
import java.io.Serial;
import java.time.LocalDateTime;
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageDetailResp.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageDetailResp.java
index fbc20990c..d6188d770 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageDetailResp.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageDetailResp.java
@@ -27,7 +27,7 @@
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
-import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
+import top.continew.admin.common.model.resp.BaseDetailResp;
/**
* 租户套餐详情信息
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageResp.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageResp.java
index defca29fc..8b4077d35 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageResp.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantPackageResp.java
@@ -24,7 +24,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
-import top.continew.starter.extension.crud.model.resp.BaseResp;
+import top.continew.admin.common.model.resp.BaseResp;
/**
* 租户套餐信息
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantResp.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantResp.java
index 5b5e70350..325cc20da 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantResp.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/model/resp/TenantResp.java
@@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import top.continew.starter.extension.crud.model.resp.BaseResp;
+import top.continew.admin.common.model.resp.BaseResp;
import java.io.Serial;
import java.time.LocalDateTime;
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantDbConnectServiceImpl.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantDbConnectServiceImpl.java
index 8faa3025b..f895f5bcf 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantDbConnectServiceImpl.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantDbConnectServiceImpl.java
@@ -23,6 +23,8 @@
import org.springframework.stereotype.Service;
import top.continew.admin.common.constant.CacheConstants;
import top.continew.admin.tenant.mapper.TenantDbConnectMapper;
+import top.continew.admin.tenant.mapper.TenantMapper;
+import top.continew.admin.tenant.model.entity.TenantDO;
import top.continew.admin.tenant.model.entity.TenantDbConnectDO;
import top.continew.admin.tenant.model.enums.TenantConnectTypeEnum;
import top.continew.admin.tenant.model.query.TenantDbConnectQuery;
@@ -48,6 +50,8 @@
@RequiredArgsConstructor
public class TenantDbConnectServiceImpl extends BaseServiceImpl implements TenantDbConnectService {
+ private final TenantMapper tenantMapper;
+
@Override
@Cached(name = CacheConstants.DB_CONNECT_KEY_PREFIX, key = "#id")
public TenantDbConnectDetailResp get(Long id) {
@@ -85,6 +89,12 @@ protected void beforeUpdate(TenantDbConnectReq req, Long id) {
}
}
+ @Override
+ protected void beforeDelete(List ids) {
+ CheckUtils.throwIf(tenantMapper.selectCount(Wrappers.lambdaQuery(TenantDO.class)
+ .in(TenantDO::getDbConnectId, ids)) > 0, "存在关联租户无法删除");
+ }
+
@Override
protected void afterUpdate(TenantDbConnectReq req, TenantDbConnectDO entity) {
RedisUtils.delete(CacheConstants.DB_CONNECT_KEY_PREFIX + entity.getId());
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantPackageServiceImpl.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantPackageServiceImpl.java
index c6bc6cd49..036360377 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantPackageServiceImpl.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantPackageServiceImpl.java
@@ -21,7 +21,9 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
+import top.continew.admin.tenant.mapper.TenantMapper;
import top.continew.admin.tenant.mapper.TenantPackageMapper;
+import top.continew.admin.tenant.model.entity.TenantDO;
import top.continew.admin.tenant.model.entity.TenantPackageDO;
import top.continew.admin.tenant.model.query.TenantPackageQuery;
import top.continew.admin.tenant.model.req.TenantPackageReq;
@@ -42,6 +44,9 @@
@Service
@RequiredArgsConstructor
public class TenantPackageServiceImpl extends BaseServiceImpl implements TenantPackageService {
+
+ private final TenantMapper tenantMapper;
+
@Override
public TenantPackageDetailResp get(Long id) {
TenantPackageDO tenantPackageDO = getById(id);
@@ -60,7 +65,7 @@ protected void beforeAdd(TenantPackageReq req) {
@Override
protected void beforeDelete(List ids) {
- CheckUtils.throwIf(baseMapper.selectCount(Wrappers.lambdaQuery(TenantPackageDO.class)
- .in(TenantPackageDO::getId, ids)) > 0, "存在关联租户无法删除");
+ CheckUtils.throwIf(tenantMapper.selectCount(Wrappers.lambdaQuery(TenantDO.class)
+ .in(TenantDO::getPackageId, ids)) > 0, "存在关联租户无法删除");
}
}
\ No newline at end of file
diff --git a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantServiceImpl.java b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantServiceImpl.java
index 7b0622869..e45dc748d 100644
--- a/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantServiceImpl.java
+++ b/continew-plugin/continew-plugin-tenant/src/main/java/top/continew/admin/tenant/service/impl/TenantServiceImpl.java
@@ -88,7 +88,7 @@ protected void beforeAdd(TenantReq req) {
private String generateTenantSn() {
String tenantSn;
do {
- tenantSn = RandomUtil.randomString(6);
+ tenantSn = RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER_LOWER, 6);
} while (baseMapper.exists(Wrappers.lambdaQuery(TenantDO.class).eq(TenantDO::getTenantSn, tenantSn)));
return tenantSn;
}
diff --git a/continew-webapi/src/main/java/top/continew/admin/config/log/LogDaoLocalImpl.java b/continew-webapi/src/main/java/top/continew/admin/config/log/LogDaoLocalImpl.java
index cb7adc559..97e46eada 100644
--- a/continew-webapi/src/main/java/top/continew/admin/config/log/LogDaoLocalImpl.java
+++ b/continew-webapi/src/main/java/top/continew/admin/config/log/LogDaoLocalImpl.java
@@ -29,8 +29,9 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.scheduling.annotation.Async;
-import top.continew.admin.auth.model.req.AccountLoginReq;
import top.continew.admin.common.config.properties.TenantProperties;
+import top.continew.admin.auth.enums.AuthTypeEnum;
+import top.continew.admin.auth.model.req.*;
import top.continew.admin.common.constant.SysConstants;
import top.continew.admin.system.enums.LogStatusEnum;
import top.continew.admin.system.mapper.LogMapper;
@@ -160,10 +161,22 @@ private void setCreateUser(LogDO logDO, LogRequest logRequest, LogResponse logRe
// 解析登录接口信息
if (requestUri.startsWith(SysConstants.LOGIN_URI) && LogStatusEnum.SUCCESS.equals(logDO.getStatus())) {
String requestBody = logRequest.getBody();
- AccountLoginReq loginReq = JSONUtil.toBean(requestBody, AccountLoginReq.class);
- logDO.setCreateUser(ExceptionUtils.exToNull(() -> userService.getByUsername(loginReq.getUsername())
- .getId()));
- return;
+ logDO.setDescription(JSONUtil.toBean(requestBody, LoginReq.class).getAuthType().getDescription() + "登录");
+ // 解析账号登录用户为操作人
+ if (requestBody.contains(AuthTypeEnum.ACCOUNT.getValue())) {
+ AccountLoginReq authReq = JSONUtil.toBean(requestBody, AccountLoginReq.class);
+ logDO.setCreateUser(ExceptionUtils.exToNull(() -> userService.getByUsername(authReq.getUsername())
+ .getId()));
+ return;
+ } else if (requestBody.contains(AuthTypeEnum.EMAIL.getValue())) {
+ EmailLoginReq authReq = JSONUtil.toBean(requestBody, EmailLoginReq.class);
+ logDO.setCreateUser(ExceptionUtils.exToNull(() -> userService.getByEmail(authReq.getEmail()).getId()));
+ return;
+ } else if (requestBody.contains(AuthTypeEnum.PHONE.getValue())) {
+ PhoneLoginReq authReq = JSONUtil.toBean(requestBody, PhoneLoginReq.class);
+ logDO.setCreateUser(ExceptionUtils.exToNull(() -> userService.getByPhone(authReq.getPhone()).getId()));
+ return;
+ }
}
// 解析 Token 信息
Map requestHeaders = logRequest.getHeaders();
diff --git a/continew-webapi/src/main/java/top/continew/admin/config/tenant/DataSourceSwitchAspect.java b/continew-webapi/src/main/java/top/continew/admin/config/tenant/DataSourceSwitchAspect.java
new file mode 100644
index 000000000..deecf7435
--- /dev/null
+++ b/continew-webapi/src/main/java/top/continew/admin/config/tenant/DataSourceSwitchAspect.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package top.continew.admin.config.tenant;
+
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import top.continew.admin.common.constant.SysConstants;
+import top.continew.starter.core.constant.PropertiesConstants;
+import top.continew.starter.extension.tenant.context.TenantContextHolder;
+import top.continew.starter.extension.tenant.enums.TenantIsolationLevel;
+
+/**
+ * @description: 主数据源切面
+ * @author: 小熊
+ * @create: 2025-01-15 16:02
+ */
+@Aspect
+@Component
+@ConditionalOnProperty(prefix = PropertiesConstants.TENANT, name = PropertiesConstants.ENABLED, havingValue = "true")
+public class DataSourceSwitchAspect {
+
+ @Pointcut("execution(* top.continew.admin.tenant.mapper..*(..)) || " + "execution(* top.continew.admin.tenant.service..*(..)) || " + "execution(* top.continew.admin.system.mapper.ClientMapper.*(..)) || " + "execution(* top.continew.admin.system.service.ClientService.*(..)) || " + "execution(* top.continew.admin.system.mapper.DictMapper.*(..)) || " + "execution(* top.continew.admin.system.service.DictService.*(..)) || " + "execution(* top.continew.admin.system.mapper.DictItemMapper.*(..)) || " + "execution(* top.continew.admin.system.service.DictItemService.*(..)) || " + "execution(* top.continew.admin.system.mapper.OptionMapper.*(..)) || " + "execution(* top.continew.admin.system.service.OptionService.*(..)) || " + "execution(* top.continew.admin.system.mapper.StorageMapper.*(..)) || " + "execution(* top.continew.admin.system.service.StorageService.*(..))")
+ public void MasterDataSourceMethods() {
+ }
+
+ @Before("MasterDataSourceMethods()")
+ public void switchToMasterDataSource() {
+ if (TenantContextHolder.getIsolationLevel() == TenantIsolationLevel.DATASOURCE) {
+ DynamicDataSourceContextHolder.push(SysConstants.DEFAULT_DATASOURCE);
+ }
+ }
+
+ @After("MasterDataSourceMethods()")
+ public void clearDataSourceContext() {
+ if (TenantContextHolder.getIsolationLevel() == TenantIsolationLevel.DATASOURCE) {
+ DynamicDataSourceContextHolder.poll();
+ }
+ }
+
+}
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/auth/AuthController.java b/continew-webapi/src/main/java/top/continew/admin/controller/auth/AuthController.java
index 2127480e7..eb3187c88 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/auth/AuthController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/auth/AuthController.java
@@ -19,33 +19,28 @@
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
+import com.xkcoding.justauth.AuthRequestFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
+import me.zhyd.oauth.request.AuthRequest;
+import me.zhyd.oauth.utils.AuthStateUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-import top.continew.admin.auth.model.req.AccountLoginReq;
-import top.continew.admin.auth.model.req.EmailLoginReq;
-import top.continew.admin.auth.model.req.PhoneLoginReq;
+import top.continew.admin.auth.model.req.LoginReq;
import top.continew.admin.auth.model.resp.LoginResp;
import top.continew.admin.auth.model.resp.RouteResp;
+import top.continew.admin.auth.model.resp.SocialAuthAuthorizeResp;
import top.continew.admin.auth.model.resp.UserInfoResp;
-import top.continew.admin.auth.service.LoginService;
-import top.continew.admin.common.constant.CacheConstants;
-import top.continew.admin.common.constant.SysConstants;
+import top.continew.admin.auth.service.AuthService;
import top.continew.admin.common.context.UserContext;
import top.continew.admin.common.context.UserContextHolder;
-import top.continew.admin.common.util.SecureUtils;
import top.continew.admin.system.model.resp.user.UserDetailResp;
-import top.continew.admin.system.service.OptionService;
import top.continew.admin.system.service.UserService;
-import top.continew.admin.tenant.service.TenantService;
-import top.continew.starter.cache.redisson.util.RedisUtils;
-import top.continew.starter.core.util.ExceptionUtils;
-import top.continew.starter.core.validation.ValidationUtils;
+import top.continew.starter.core.exception.BadRequestException;
import top.continew.starter.log.annotation.Log;
import java.util.List;
@@ -56,71 +51,26 @@
* @author Charles7c
* @since 2022/12/21 20:37
*/
-@Log(module = "登录")
@Tag(name = "认证 API")
+@Log(module = "登录")
+@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/auth")
public class AuthController {
- private static final String CAPTCHA_EXPIRED = "验证码已失效";
- private static final String CAPTCHA_ERROR = "验证码错误";
- private final OptionService optionService;
- private final LoginService loginService;
+ private final AuthService authService;
private final UserService userService;
- private final TenantService tenantService;
-
- @SaIgnore
- @Operation(summary = "账号登录", description = "根据账号和密码进行登录认证")
- @PostMapping("/account")
- public LoginResp accountLogin(@Validated @RequestBody AccountLoginReq loginReq, HttpServletRequest request) {
- // 校验验证码
- int loginCaptchaEnabled = optionService.getValueByCode2Int("LOGIN_CAPTCHA_ENABLED");
- if (SysConstants.YES.equals(loginCaptchaEnabled)) {
- ValidationUtils.throwIfBlank(loginReq.getCaptcha(), "验证码不能为空");
- ValidationUtils.throwIfBlank(loginReq.getUuid(), "验证码标识不能为空");
- String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + loginReq.getUuid();
- String captcha = RedisUtils.get(captchaKey);
- ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
- RedisUtils.delete(captchaKey);
- ValidationUtils.throwIfNotEqualIgnoreCase(loginReq.getCaptcha(), captcha, CAPTCHA_ERROR);
- }
- // 用户登录
- String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(loginReq.getPassword()));
- ValidationUtils.throwIfBlank(rawPassword, "密码解密失败");
- String token = loginService.accountLogin(loginReq.getUsername(), rawPassword, request);
- return LoginResp.builder().token(token).build();
- }
+ private final AuthRequestFactory authRequestFactory;
@SaIgnore
- @Operation(summary = "手机号登录", description = "根据手机号和验证码进行登录认证")
- @PostMapping("/phone")
- public LoginResp phoneLogin(@Validated @RequestBody PhoneLoginReq loginReq) {
- String phone = loginReq.getPhone();
- String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + phone;
- String captcha = RedisUtils.get(captchaKey);
- ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
- ValidationUtils.throwIfNotEqualIgnoreCase(loginReq.getCaptcha(), captcha, CAPTCHA_ERROR);
- RedisUtils.delete(captchaKey);
- String token = loginService.phoneLogin(phone);
- return LoginResp.builder().token(token).build();
+ @Operation(summary = "登录", description = "用户登录")
+ @PostMapping("/login")
+ public LoginResp login(@Validated @RequestBody LoginReq req, HttpServletRequest request) {
+ return authService.login(req, request);
}
- @SaIgnore
- @Operation(summary = "邮箱登录", description = "根据邮箱和验证码进行登录认证")
- @PostMapping("/email")
- public LoginResp emailLogin(@Validated @RequestBody EmailLoginReq loginReq) {
- String email = loginReq.getEmail();
- String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + email;
- String captcha = RedisUtils.get(captchaKey);
- ValidationUtils.throwIfBlank(captcha, CAPTCHA_EXPIRED);
- ValidationUtils.throwIfNotEqualIgnoreCase(loginReq.getCaptcha(), captcha, CAPTCHA_ERROR);
- RedisUtils.delete(captchaKey);
- String token = loginService.emailLogin(email);
- return LoginResp.builder().token(token).build();
- }
-
- @Operation(summary = "用户退出", description = "注销用户的当前登录")
+ @Operation(summary = "登出", description = "注销用户的当前登录")
@Parameter(name = "Authorization", description = "令牌", required = true, example = "Bearer xxxx-xxxx-xxxx-xxxx", in = ParameterIn.HEADER)
@PostMapping("/logout")
public Object logout() {
@@ -129,6 +79,17 @@ public Object logout() {
return loginId;
}
+ @SaIgnore
+ @Operation(summary = "三方账号登录授权", description = "三方账号登录授权")
+ @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
+ @GetMapping("/{source}")
+ public SocialAuthAuthorizeResp authorize(@PathVariable String source) {
+ AuthRequest authRequest = this.getAuthRequest(source);
+ return SocialAuthAuthorizeResp.builder()
+ .authorizeUrl(authRequest.authorize(AuthStateUtils.createState()))
+ .build();
+ }
+
@Log(ignore = true)
@Operation(summary = "获取用户信息", description = "获取登录用户信息")
@GetMapping("/user/info")
@@ -144,8 +105,16 @@ public UserInfoResp getUserInfo() {
@Log(ignore = true)
@Operation(summary = "获取路由信息", description = "获取登录用户的路由信息")
- @GetMapping("/route")
+ @GetMapping("/user/route")
public List listRoute() {
- return loginService.buildRouteTree(UserContextHolder.getUserId());
+ return authService.buildRouteTree(UserContextHolder.getUserId());
+ }
+
+ private AuthRequest getAuthRequest(String source) {
+ try {
+ return authRequestFactory.get(source);
+ } catch (Exception e) {
+ throw new BadRequestException("暂不支持 [%s] 平台账号登录".formatted(source));
+ }
}
-}
\ No newline at end of file
+}
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/auth/SocialAuthController.java b/continew-webapi/src/main/java/top/continew/admin/controller/auth/SocialAuthController.java
deleted file mode 100644
index 953f0f6d1..000000000
--- a/continew-webapi/src/main/java/top/continew/admin/controller/auth/SocialAuthController.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package top.continew.admin.controller.auth;
-
-import cn.dev33.satoken.annotation.SaIgnore;
-import cn.dev33.satoken.stp.StpUtil;
-import com.xkcoding.justauth.AuthRequestFactory;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.enums.ParameterIn;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.RequiredArgsConstructor;
-import me.zhyd.oauth.model.AuthCallback;
-import me.zhyd.oauth.model.AuthResponse;
-import me.zhyd.oauth.model.AuthUser;
-import me.zhyd.oauth.request.AuthRequest;
-import me.zhyd.oauth.utils.AuthStateUtils;
-import org.springframework.web.bind.annotation.*;
-import top.continew.admin.auth.model.resp.LoginResp;
-import top.continew.admin.auth.model.resp.SocialAuthAuthorizeResp;
-import top.continew.admin.auth.service.LoginService;
-import top.continew.admin.tenant.service.TenantService;
-import top.continew.starter.core.exception.BadRequestException;
-import top.continew.starter.core.validation.ValidationUtils;
-import top.continew.starter.log.annotation.Log;
-
-/**
- * 三方账号认证 API
- *
- * @author Charles7c
- * @since 2023/10/8 22:52
- */
-@Log(module = "登录")
-@Tag(name = "三方账号认证 API")
-@SaIgnore
-@RestController
-@RequiredArgsConstructor
-@RequestMapping("/oauth")
-public class SocialAuthController {
-
- private final LoginService loginService;
- private final AuthRequestFactory authRequestFactory;
- private final TenantService tenantService;
-
- @Operation(summary = "三方账号登录授权", description = "三方账号登录授权")
- @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
- @GetMapping("/{source}")
- public SocialAuthAuthorizeResp authorize(@PathVariable String source) {
- AuthRequest authRequest = this.getAuthRequest(source);
- return SocialAuthAuthorizeResp.builder()
- .authorizeUrl(authRequest.authorize(AuthStateUtils.createState()))
- .build();
- }
-
- @Operation(summary = "三方账号登录", description = "三方账号登录")
- @Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
- @PostMapping("/{source}")
- public LoginResp login(@PathVariable String source, @RequestBody AuthCallback callback) {
- if (StpUtil.isLogin()) {
- StpUtil.logout();
- }
- AuthRequest authRequest = this.getAuthRequest(source);
- AuthResponse response = authRequest.login(callback);
- ValidationUtils.throwIf(!response.ok(), response.getMsg());
- AuthUser authUser = response.getData();
- String token = loginService.socialLogin(authUser);
- return LoginResp.builder().token(token).build();
- }
-
- private AuthRequest getAuthRequest(String source) {
- try {
- return authRequestFactory.get(source);
- } catch (Exception e) {
- throw new BadRequestException("暂不支持 [%s] 平台账号登录".formatted(source));
- }
- }
-}
\ No newline at end of file
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/code/GeneratorController.java b/continew-webapi/src/main/java/top/continew/admin/controller/code/GeneratorController.java
index 25165f191..600c0955d 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/code/GeneratorController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/code/GeneratorController.java
@@ -96,12 +96,20 @@ public List preview(@PathVariable List tableNames)
return baseService.preview(tableNames);
}
+ @Operation(summary = "生成下载代码", description = "生成下载代码")
+ @Parameter(name = "tableNames", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
+ @SaCheckPermission("code:generator:generate")
+ @PostMapping("/{tableNames}/download")
+ public void downloadCode(@PathVariable List tableNames, HttpServletResponse response) {
+ baseService.downloadCode(tableNames, response);
+ }
+
@Operation(summary = "生成代码", description = "生成代码")
@Parameter(name = "tableNames", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@SaCheckPermission("code:generator:generate")
@PostMapping("/{tableNames}")
- public void generate(@PathVariable List tableNames, HttpServletResponse response) {
- baseService.generate(tableNames, response);
+ public void generateCode(@PathVariable List tableNames) {
+ baseService.generateCode(tableNames);
}
@Operation(summary = "查询字典", description = "查询字典列表")
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/common/CaptchaController.java b/continew-webapi/src/main/java/top/continew/admin/controller/common/CaptchaController.java
index 27e491250..e4b74b0a1 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/common/CaptchaController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/common/CaptchaController.java
@@ -41,7 +41,6 @@
import org.dromara.sms4j.api.entity.SmsResponse;
import org.dromara.sms4j.comm.constant.SupplierConstant;
import org.dromara.sms4j.core.factory.SmsFactory;
-import org.redisson.api.RateIntervalUnit;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -68,6 +67,7 @@
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
/**
* 验证码 API
@@ -141,11 +141,11 @@ public CaptchaResp getImageCaptcha() {
@Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱")
@GetMapping("/mail")
@RateLimiters({
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "MIN", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 2, interval = 1, unit = RateIntervalUnit.MINUTES, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "HOUR", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 8, interval = 1, unit = RateIntervalUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "DAY'", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 20, interval = 24, unit = RateIntervalUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#email", rate = 100, interval = 24, unit = RateIntervalUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#email", rate = 30, interval = 1, unit = RateIntervalUnit.MINUTES, type = LimitType.IP, message = "获取验证码操作太频繁,请稍后再试")})
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "MIN", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 2, interval = 1, unit = TimeUnit.MINUTES, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "HOUR", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 8, interval = 1, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "DAY'", key = "#email + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.mail.templatePath')", rate = 20, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#email", rate = 100, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#email", rate = 30, interval = 1, unit = TimeUnit.MINUTES, type = LimitType.IP, message = "获取验证码操作太频繁,请稍后再试")})
public R getMailCaptcha(@NotBlank(message = "邮箱不能为空") @Pattern(regexp = RegexPool.EMAIL, message = "邮箱格式错误") String email,
CaptchaVO captchaReq) throws MessagingException {
// 行为验证码校验
@@ -188,11 +188,11 @@ public R getMailCaptcha(@NotBlank(message = "邮箱不能为空") @Pattern(regex
@Operation(summary = "获取短信验证码", description = "发送验证码到指定手机号")
@GetMapping("/sms")
@RateLimiters({
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "MIN", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 2, interval = 1, unit = RateIntervalUnit.MINUTES, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "HOUR", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 8, interval = 1, unit = RateIntervalUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "DAY'", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 20, interval = 24, unit = RateIntervalUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#phone", rate = 100, interval = 24, unit = RateIntervalUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
- @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#phone", rate = 30, interval = 1, unit = RateIntervalUnit.MINUTES, type = LimitType.IP, message = "获取验证码操作太频繁,请稍后再试")})
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "MIN", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 2, interval = 1, unit = TimeUnit.MINUTES, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "HOUR", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 8, interval = 1, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX + "DAY'", key = "#phone + ':' + T(cn.hutool.extra.spring.SpringUtil).getProperty('captcha.sms.templateId')", rate = 20, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#phone", rate = 100, interval = 24, unit = TimeUnit.HOURS, message = "获取验证码操作太频繁,请稍后再试"),
+ @RateLimiter(name = CacheConstants.CAPTCHA_KEY_PREFIX, key = "#phone", rate = 30, interval = 1, unit = TimeUnit.MINUTES, type = LimitType.IP, message = "获取验证码操作太频繁,请稍后再试")})
public R getSmsCaptcha(@NotBlank(message = "手机号不能为空") @Pattern(regexp = RegexPool.MOBILE, message = "手机号格式错误") String phone,
CaptchaVO captchaReq) {
// 行为验证码校验
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/monitor/OnlineUserController.java b/continew-webapi/src/main/java/top/continew/admin/controller/monitor/OnlineUserController.java
index d3de85eb1..4254c38ec 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/monitor/OnlineUserController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/monitor/OnlineUserController.java
@@ -16,19 +16,15 @@
package top.continew.admin.controller.monitor;
-import lombok.RequiredArgsConstructor;
-
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.stp.StpUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
-
+import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-
-import cn.dev33.satoken.annotation.SaCheckPermission;
-import cn.dev33.satoken.stp.StpUtil;
-
import top.continew.admin.auth.model.query.OnlineUserQuery;
import top.continew.admin.auth.model.resp.OnlineUserResp;
import top.continew.admin.auth.service.OnlineUserService;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/open/AppController.java b/continew-webapi/src/main/java/top/continew/admin/controller/open/AppController.java
index 5bfad28b7..9c7820ca0 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/open/AppController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/open/AppController.java
@@ -26,6 +26,7 @@
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.open.model.query.AppQuery;
import top.continew.admin.open.model.req.AppReq;
import top.continew.admin.open.model.resp.AppDetailResp;
@@ -33,7 +34,6 @@
import top.continew.admin.open.model.resp.AppSecretResp;
import top.continew.admin.open.service.AppService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
-import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/schedule/DemoEnvironmentJob.java b/continew-webapi/src/main/java/top/continew/admin/controller/schedule/DemoEnvironmentJob.java
index 6a7c15356..62365a163 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/schedule/DemoEnvironmentJob.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/schedule/DemoEnvironmentJob.java
@@ -25,10 +25,13 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import top.continew.admin.common.constant.CacheConstants;
+import top.continew.admin.open.mapper.AppMapper;
+import top.continew.admin.open.model.entity.AppDO;
import top.continew.admin.system.mapper.*;
import top.continew.admin.system.model.entity.*;
import top.continew.starter.cache.redisson.util.RedisUtils;
+import java.util.List;
import java.util.function.BooleanSupplier;
/**
@@ -56,15 +59,15 @@ public class DemoEnvironmentJob {
private final MenuMapper menuMapper;
private final DeptMapper deptMapper;
- private static final Long DICT_ITEM_FLAG = 4L;
- private static final Long DICT_FLAG = 2L;
- private static final Long STORAGE_FLAG = 2L;
- private static final Long NOTICE_FLAG = 7L;
+ private final AppMapper appMapper;
+ private final ClientMapper clientsMapper;
+
+ private static final Long DELETE_FLAG = 10000L;
private static final Long MESSAGE_FLAG = 0L;
- private static final Long[] USER_FLAG = {1L, 547889293968801831L};
- private static final Long ROLE_FLAG = 547888897925840928L;
- private static final Long MENU_FLAG = 10000L;
- private static final Long DEPT_FLAG = 547888580614160409L;
+ private static final List USER_FLAG = List
+ .of(1L, 547889293968801822L, 547889293968801823L, 547889293968801824L, 547889293968801825L, 547889293968801826L, 547889293968801827L, 547889293968801828L, 547889293968801829L, 547889293968801830L, 547889293968801831L);
+ private static final List ROLE_FLAG = List.of(1L, 547888897925840927L, 547888897925840928L);
+ private static final Long DEPT_FLAG = 547887852587843611L;
/**
* 重置演示环境数据
@@ -76,36 +79,42 @@ public void resetEnvironmentData() {
SnailJobLog.REMOTE.info("定时任务 [重置演示环境数据] 开始执行。");
// 检测待清理数据
SnailJobLog.REMOTE.info("开始检测演示环境待清理数据项,请稍候...");
- Long dictItemCount = dictItemMapper.lambdaQuery().gt(DictItemDO::getId, DICT_ITEM_FLAG).count();
+ Long dictItemCount = dictItemMapper.lambdaQuery().gt(DictItemDO::getId, DELETE_FLAG).count();
this.log(dictItemCount, "字典项");
- Long dictCount = dictMapper.lambdaQuery().gt(DictDO::getId, DICT_FLAG).count();
+ Long dictCount = dictMapper.lambdaQuery().gt(DictDO::getId, DELETE_FLAG).count();
this.log(dictCount, "字典");
- Long storageCount = storageMapper.lambdaQuery().gt(StorageDO::getId, STORAGE_FLAG).count();
+ Long storageCount = storageMapper.lambdaQuery().gt(StorageDO::getId, DELETE_FLAG).count();
this.log(storageCount, "存储");
- Long noticeCount = noticeMapper.lambdaQuery().gt(NoticeDO::getId, NOTICE_FLAG).count();
+ Long noticeCount = noticeMapper.lambdaQuery().gt(NoticeDO::getId, DELETE_FLAG).count();
this.log(noticeCount, "公告");
Long messageCount = messageMapper.lambdaQuery().count();
this.log(messageCount, "通知");
Long userCount = userMapper.lambdaQuery().notIn(UserDO::getId, USER_FLAG).count();
this.log(userCount, "用户");
- Long roleCount = roleMapper.lambdaQuery().gt(RoleDO::getId, ROLE_FLAG).count();
+ Long roleCount = roleMapper.lambdaQuery().notIn(RoleDO::getId, ROLE_FLAG).count();
this.log(roleCount, "角色");
- Long menuCount = menuMapper.lambdaQuery().gt(MenuDO::getId, MENU_FLAG).count();
+ Long menuCount = menuMapper.lambdaQuery().gt(MenuDO::getId, DELETE_FLAG).count();
this.log(menuCount, "菜单");
Long deptCount = deptMapper.lambdaQuery().gt(DeptDO::getId, DEPT_FLAG).count();
this.log(deptCount, "部门");
+ Long appCount = appMapper.lambdaQuery().gt(AppDO::getId, DELETE_FLAG).count();
+ this.log(appCount, "应用");
+ Long clientCount = clientsMapper.lambdaQuery().gt(ClientDO::getId, DELETE_FLAG).count();
+ this.log(clientCount, "客户端");
// 清理数据
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().blockAttack(true).build());
SnailJobLog.REMOTE.info("演示环境待清理数据项检测完成,开始执行清理。");
this.clean(dictItemCount, "字典项", null, () -> dictItemMapper.lambdaUpdate()
- .gt(DictItemDO::getId, DICT_ITEM_FLAG)
+ .gt(DictItemDO::getId, DELETE_FLAG)
+ .remove());
+ this.clean(dictCount, "字典", CacheConstants.DICT_KEY_PREFIX, () -> dictMapper.lambdaUpdate()
+ .gt(DictDO::getId, DELETE_FLAG)
.remove());
- this.clean(dictCount, "字典", null, () -> dictMapper.lambdaUpdate().gt(DictDO::getId, DICT_FLAG).remove());
this.clean(storageCount, "存储", null, () -> storageMapper.lambdaUpdate()
- .gt(StorageDO::getId, STORAGE_FLAG)
+ .gt(StorageDO::getId, DELETE_FLAG)
.remove());
this.clean(noticeCount, "公告", null, () -> noticeMapper.lambdaUpdate()
- .gt(NoticeDO::getId, NOTICE_FLAG)
+ .gt(NoticeDO::getId, DELETE_FLAG)
.remove());
this.clean(messageCount, "通知", null, () -> {
messageUserMapper.lambdaUpdate().gt(MessageUserDO::getMessageId, MESSAGE_FLAG).remove();
@@ -117,14 +126,18 @@ public void resetEnvironmentData() {
return userMapper.lambdaUpdate().notIn(UserDO::getId, USER_FLAG).remove();
});
this.clean(roleCount, "角色", null, () -> {
- roleDeptMapper.lambdaUpdate().ne(RoleDeptDO::getRoleId, ROLE_FLAG).remove();
- roleMenuMapper.lambdaUpdate().ne(RoleMenuDO::getRoleId, ROLE_FLAG).remove();
- return roleMapper.lambdaUpdate().gt(RoleDO::getId, ROLE_FLAG).remove();
+ roleDeptMapper.lambdaUpdate().notIn(RoleDeptDO::getRoleId, ROLE_FLAG).remove();
+ roleMenuMapper.lambdaUpdate().notIn(RoleMenuDO::getRoleId, ROLE_FLAG).remove();
+ return roleMapper.lambdaUpdate().notIn(RoleDO::getId, ROLE_FLAG).remove();
});
this.clean(menuCount, "菜单", CacheConstants.MENU_KEY_PREFIX, () -> menuMapper.lambdaUpdate()
- .gt(MenuDO::getId, MENU_FLAG)
+ .gt(MenuDO::getId, DELETE_FLAG)
.remove());
this.clean(deptCount, "部门", null, () -> deptMapper.lambdaUpdate().gt(DeptDO::getId, DEPT_FLAG).remove());
+ this.clean(appCount, "应用", null, () -> appMapper.lambdaUpdate().gt(AppDO::getId, DEPT_FLAG).remove());
+ this.clean(clientCount, "客户端", null, () -> clientsMapper.lambdaUpdate()
+ .gt(ClientDO::getId, DEPT_FLAG)
+ .remove());
SnailJobLog.REMOTE.info("演示环境数据已清理完成。");
SnailJobLog.REMOTE.info("定时任务 [重置演示环境数据] 执行结束。");
} finally {
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java b/continew-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java
index 826f6fe4c..4301572ef 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/schedule/JobLogController.java
@@ -26,10 +26,10 @@
import org.springframework.web.bind.annotation.*;
import top.continew.admin.schedule.model.JobInstanceLogPageResult;
import top.continew.admin.schedule.model.query.JobInstanceLogQuery;
-import top.continew.admin.schedule.model.query.JobLogQuery;
import top.continew.admin.schedule.model.query.JobInstanceQuery;
-import top.continew.admin.schedule.model.resp.JobLogResp;
+import top.continew.admin.schedule.model.query.JobLogQuery;
import top.continew.admin.schedule.model.resp.JobInstanceResp;
+import top.continew.admin.schedule.model.resp.JobLogResp;
import top.continew.admin.schedule.service.JobLogService;
import top.continew.starter.extension.crud.model.resp.PageResp;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/ClientController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/ClientController.java
new file mode 100644
index 000000000..245138b61
--- /dev/null
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/ClientController.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package top.continew.admin.controller.system;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.web.bind.annotation.RestController;
+import top.continew.admin.common.controller.BaseController;
+import top.continew.admin.system.model.query.ClientQuery;
+import top.continew.admin.system.model.req.ClientReq;
+import top.continew.admin.system.model.resp.ClientResp;
+import top.continew.admin.system.service.ClientService;
+import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
+import top.continew.starter.extension.crud.enums.Api;
+
+/**
+ * 客户端管理 API
+ *
+ * @author KAI
+ * @since 2024/12/03 16:04
+ */
+@Tag(name = "客户端管理 API")
+@RestController
+@CrudRequestMapping(value = "/system/client", api = {Api.PAGE, Api.DETAIL, Api.ADD, Api.UPDATE, Api.DELETE})
+public class ClientController extends BaseController {
+}
\ No newline at end of file
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/DeptController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/DeptController.java
index 7745b0b7a..24c66e297 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/DeptController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/DeptController.java
@@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.DeptQuery;
import top.continew.admin.system.model.req.DeptReq;
import top.continew.admin.system.model.resp.DeptResp;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/DictController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/DictController.java
index b14f39aa8..6f7de440d 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/DictController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/DictController.java
@@ -18,12 +18,12 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.DictQuery;
import top.continew.admin.system.model.req.DictReq;
import top.continew.admin.system.model.resp.DictResp;
import top.continew.admin.system.service.DictService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
-import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/DictItemController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/DictItemController.java
index cc63532c3..055387ef0 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/DictItemController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/DictItemController.java
@@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.DictItemQuery;
import top.continew.admin.system.model.req.DictItemReq;
import top.continew.admin.system.model.resp.DictItemResp;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/FileController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/FileController.java
index 6563dd8d7..8fc13c385 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/FileController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/FileController.java
@@ -22,7 +22,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.FileQuery;
import top.continew.admin.system.model.req.FileReq;
import top.continew.admin.system.model.resp.FileResp;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/MenuController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/MenuController.java
index e010f6455..1059edfa7 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/MenuController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/MenuController.java
@@ -20,7 +20,7 @@
import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.MenuQuery;
import top.continew.admin.system.model.req.MenuReq;
import top.continew.admin.system.model.resp.MenuResp;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java
index 2648e9b98..ef6c7890e 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/NoticeController.java
@@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.enums.NoticeScopeEnum;
import top.continew.admin.system.model.query.NoticeQuery;
import top.continew.admin.system.model.req.NoticeReq;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java
index 4f747cdbe..a3e7dfcfd 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/RoleController.java
@@ -21,12 +21,11 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
-
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.RoleQuery;
import top.continew.admin.system.model.req.RoleReq;
import top.continew.admin.system.model.resp.RoleDetailResp;
@@ -34,7 +33,6 @@
import top.continew.admin.system.service.RoleService;
import top.continew.admin.system.service.UserRoleService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
-import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import java.util.List;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java
index 277167e0b..e6d5f3c41 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/StorageController.java
@@ -18,12 +18,12 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.system.model.query.StorageQuery;
import top.continew.admin.system.model.req.StorageReq;
import top.continew.admin.system.model.resp.StorageResp;
import top.continew.admin.system.service.StorageService;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
-import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
/**
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java b/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java
index a4a1059b5..23b26c13f 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/system/UserController.java
@@ -29,6 +29,7 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.common.constant.RegexConstants;
import top.continew.admin.common.util.SecureUtils;
import top.continew.admin.system.model.query.UserQuery;
@@ -44,7 +45,6 @@
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
-import top.continew.admin.common.base.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
@@ -66,6 +66,7 @@
public class UserController extends BaseController {
@Override
+ @Operation(summary = "新增数据", description = "新增数据")
public BaseIdResp add(@Validated(CrudValidationGroup.Add.class) @RequestBody UserReq req) {
String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword()));
ValidationUtils.throwIfNull(rawPassword, "密码解密失败");
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantController.java b/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantController.java
index 7ab4e99cc..0141684cc 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantController.java
@@ -29,7 +29,7 @@
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.common.config.properties.TenantProperties;
import top.continew.admin.common.util.SecureUtils;
import top.continew.admin.system.model.entity.MenuDO;
@@ -51,7 +51,7 @@
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
import top.continew.starter.extension.crud.model.resp.BaseIdResp;
-import top.continew.starter.extension.crud.model.resp.BaseResp;
+import top.continew.admin.common.model.resp.BaseResp;
import top.continew.starter.extension.tenant.TenantHandler;
import java.util.List;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantDbConnectController.java b/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantDbConnectController.java
index 0f096833b..cf2f70425 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantDbConnectController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantDbConnectController.java
@@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.tenant.model.query.TenantDbConnectQuery;
import top.continew.admin.tenant.model.req.TenantDbConnectReq;
import top.continew.admin.tenant.model.resp.TenantDbConnectDetailResp;
diff --git a/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantPackageController.java b/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantPackageController.java
index ef2bae429..2945b42f0 100644
--- a/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantPackageController.java
+++ b/continew-webapi/src/main/java/top/continew/admin/controller/tenant/TenantPackageController.java
@@ -26,7 +26,7 @@
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import top.continew.admin.common.base.BaseController;
+import top.continew.admin.common.controller.BaseController;
import top.continew.admin.common.config.properties.TenantProperties;
import top.continew.admin.common.constant.CacheConstants;
import top.continew.admin.common.enums.DisEnableStatusEnum;
diff --git a/continew-webapi/src/main/resources/banner.txt b/continew-webapi/src/main/resources/banner.txt
index d4b9b07a3..0d84d235f 100644
--- a/continew-webapi/src/main/resources/banner.txt
+++ b/continew-webapi/src/main/resources/banner.txt
@@ -5,5 +5,5 @@
\____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_|
:: ${project.name} :: v${project.version}
- :: ContiNew Starter :: v2.8.0
+ :: ContiNew Starter :: v2.8.2
:: Spring Boot :: v${spring-boot.version}
diff --git a/continew-webapi/src/main/resources/config/application.yml b/continew-webapi/src/main/resources/config/application.yml
index 54f76e9c0..aa34b49c4 100644
--- a/continew-webapi/src/main/resources/config/application.yml
+++ b/continew-webapi/src/main/resources/config/application.yml
@@ -127,17 +127,17 @@ knife4j:
--- ### Sa-Token 配置
sa-token:
- # token 名称(同时也是 cookie 名称)
+ # Token 名称(同时也是 cookie 名称)
token-name: Authorization
- # token 有效期(单位:秒,默认 30 天,-1 代表永不过期)
+ # Token 有效期(单位:秒,默认 30 天,-1 代表永不过期)
timeout: 86400
- # token 最低活跃频率(单位:秒,默认 -1,代表不限制,永不冻结。如果 token 超过此时间没有访问系统就会被冻结)
+ # Token 最低活跃频率(单位:秒,默认 -1,代表不限制,永不冻结。如果 token 超过此时间没有访问系统就会被冻结)
active-timeout: 1800
# 是否打开自动续签(如果此值为 true,框架会在每次直接或间接调用 getLoginId() 时进行一次过期检查与续签操作)
auto-renew: true
# 是否允许同一账号多地同时登录(为 true 时允许一起登录,为 false 时新登录挤掉旧登录)
is-concurrent: true
- # 在多人登录同一账号时,是否共用一个 token(为 true 时所有登录共用一个 token,为 false 时每次登录新建一个 token)
+ # 在多人登录同一账号时,是否共用一个 Token(为 true 时所有登录共用一个 Token,为 false 时每次登录新建一个 Token)
is-share: false
# 是否输出操作日志
is-log: false
@@ -215,7 +215,7 @@ auth:
## 密码配置
password:
excludes:
- - /auth/route
+ - /auth/user/route
- /auth/user/info
- /auth/logout
- /system/user/password
@@ -303,6 +303,7 @@ continew-starter.tenant:
- sys_tenant_package
- sys_tenant_db_connect
- sys_app #应用
+ - sys_client #客户端管理
#租户不能使用的菜单
ignore-menus:
- 1050 #菜单
@@ -313,4 +314,5 @@ continew-starter.tenant:
- 3000 #任务调度
- 9000 #代码生成
- 10010 #租户管理
- - 7000 #能力开放
\ No newline at end of file
+ - 7000 #能力开放
+ - 1180 #客户端管理
\ No newline at end of file
diff --git a/continew-webapi/src/main/resources/db/changelog/mysql/main_data.sql b/continew-webapi/src/main/resources/db/changelog/mysql/main_data.sql
index 09cd2ecb7..769732677 100644
--- a/continew-webapi/src/main/resources/db/changelog/mysql/main_data.sql
+++ b/continew-webapi/src/main/resources/db/changelog/mysql/main_data.sql
@@ -1,6 +1,6 @@
-- liquibase formatted sql
--- changeset Charles7c:1
+-- changeset charles7c:1
-- comment 初始化表数据
-- 初始化默认菜单
INSERT INTO `sys_menu`
@@ -76,6 +76,13 @@ VALUES
(1114, '修改', 1110, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:update', 4, 1, 1, NOW()),
(1115, '删除', 1110, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:delete', 5, 1, 1, NOW()),
+( 1180, '客户端管理', 1000, 2, '/system/client', 'SystemClient', 'system/client/index', NULL, 'mobile', b'0', b'0', b'0', NULL, 9, 1, 1, NOW()),
+(1181, '列表', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:list', 1, 1, 1, NOW()),
+(1182, '详情', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:detail', 2, 1, 1, NOW()),
+(1183, '新增', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:add', 3, 1, 1, NOW()),
+(1184, '修改', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:update', 4, 1, 1, NOW()),
+(1185, '删除', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:delete', 5, 1, 1, NOW()),
+
(1190, '系统配置', 1000, 2, '/system/config', 'SystemConfig', 'system/config/index', NULL, 'config', b'0', b'0', b'0', NULL, 999, 1, 1, NOW()),
(1191, '查看', 1190, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:config:list', 1, 1, 1, NOW()),
(1192, '修改', 1190, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:config:update', 2, 1, 1, NOW()),
@@ -96,27 +103,57 @@ INSERT INTO `sys_dept`
(`id`, `name`, `parent_id`, `ancestors`, `description`, `sort`, `status`, `is_system`, `create_user`, `create_time`)
VALUES
(1, 'Xxx科技有限公司', 0, '0', '系统初始部门', 1, 1, b'1', 1, NOW()),
-(547887852587843590, '天津总部', 1, '0,1', NULL, 1, 1, b'0', 1, NOW()),
-(547888008188133385, '研发部', 547887852587843590, '0,1,547887852587843590', NULL, 1, 1, b'0', 1, NOW()),
-(547888460711591948, 'UI部', 547887852587843590, '0,1,547887852587843590', NULL, 2, 1, b'0', 1, NOW()),
-(547888483713155087, '测试部', 547887852587843590, '0,1,547887852587843590', NULL, 3, 1, b'0', 1, NOW()),
-(547888505959743506, '运维部', 547887852587843590, '0,1,547887852587843590', NULL, 4, 1, b'0', 1, NOW()),
-(547888556819873814, '研发一组', 547888008188133385, '0,1,547887852587843590,547888008188133385', NULL, 1, 1, b'0', 1, NOW()),
-(547888580614160409, '研发二组', 547888008188133385, '0,1,547887852587843590,547888008188133385', NULL, 2, 2, b'0', 1, NOW());
+(547887852587843590, 'Xxx(天津)科技有限公司', 1, '0,1', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843591, '研发部', 547887852587843590, '0,1,547887852587843590', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843592, 'UI部', 547887852587843590, '0,1,547887852587843590', NULL, 2, 1, b'0', 1, NOW()),
+(547887852587843593, '测试部', 547887852587843590, '0,1,547887852587843590', NULL, 3, 1, b'0', 1, NOW()),
+(547887852587843594, '运维部', 547887852587843590, '0,1,547887852587843590', NULL, 4, 1, b'0', 1, NOW()),
+(547887852587843595, '研发一组', 547887852587843591, '0,1,547887852587843590,547887852587843591', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843596, '研发二组', 547887852587843591, '0,1,547887852587843590,547887852587843591', NULL, 2, 2, b'0', 1, NOW()),
+
+(547887852587843597, 'Xxx(四川)科技有限公司', 1, '0,1', NULL, 2, 1, b'0', 1, NOW()),
+(547887852587843598, '研发部', 547887852587843597, '0,1,547887852587843597', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843599, '研发一组', 547887852587843598, '0,1,547887852587843597,547887852587843598', NULL, 1, 1, b'0', 1, NOW()),
+
+(547887852587843600, 'Xxx(江西)科技有限公司', 1, '0,1', NULL, 3, 1, b'0', 1, NOW()),
+(547887852587843601, '研发部', 547887852587843600, '0,1,547887852587843600', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843602, '研发一组', 547887852587843601, '0,1,547887852587843600,547887852587843601', NULL, 1, 1, b'0', 1, NOW()),
+
+(547887852587843603, 'Xxx(江苏)科技有限公司', 1, '0,1', NULL, 4, 1, b'0', 1, NOW()),
+(547887852587843604, '研发部', 547887852587843603, '0,1,547887852587843603', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843605, '研发一组', 547887852587843604, '0,1,547887852587843603,547887852587843604', NULL, 1, 1, b'0', 1, NOW()),
+
+(547887852587843606, 'Xxx(浙江)科技有限公司', 1, '0,1', NULL, 5, 1, b'0', 1, NOW()),
+(547887852587843607, '研发部', 547887852587843606, '0,1,547887852587843606', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843608, '研发一组', 547887852587843607, '0,1,547887852587843606,547887852587843607', NULL, 1, 1, b'0', 1, NOW()),
+
+(547887852587843609, 'Xxx(湖南)科技有限公司', 1, '0,1', NULL, 6, 1, b'0', 1, NOW()),
+(547887852587843610, '研发部', 547887852587843609, '0,1,547887852587843609', NULL, 1, 1, b'0', 1, NOW()),
+(547887852587843611, '研发一组', 547887852587843610, '0,1,547887852587843609,547887852587843610', NULL, 1, 1, b'0', 1, NOW());
-- 初始化默认角色
INSERT INTO `sys_role`
(`id`, `name`, `code`, `data_scope`, `description`, `sort`, `is_system`, `create_user`, `create_time`)
VALUES
(1, '系统管理员', 'admin', 1, '系统初始角色', 1, b'1', 1, NOW()),
-(547888897925840928, '测试人员', 'test', 5, NULL, 2, b'0', 1, NOW());
+(547888897925840927, '测试人员', 'tester', 5, NULL, 2, b'0', 1, NOW()),
+(547888897925840928, '研发人员', 'developer', 4, NULL, 3, b'0', 1, NOW());
-- 初始化默认用户:admin/admin123;test/test123
INSERT INTO `sys_user`
(`id`, `username`, `nickname`, `password`, `gender`, `email`, `phone`, `avatar`, `description`, `status`, `is_system`, `pwd_reset_time`, `dept_id`, `create_user`, `create_time`)
VALUES
(1, 'admin', '系统管理员', '{bcrypt}$2a$10$4jGwK2BMJ7FgVR.mgwGodey8.xR8FLoU1XSXpxJ9nZQt.pufhasSa', 1, '42190c6c5639d2ca4edb4150a35e058559ccf8270361a23745a2fd285a273c28', '5bda89a4609a65546422ea56bfe5eab4', NULL, '系统初始用户', 1, b'1', NOW(), 1, 1, NOW()),
-(547889293968801831, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 1, b'0', NOW(), 547888483713155087, 1, NOW());
+(547889293968801822, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 1, b'0', NOW(), 547887852587843593, 1, NOW()),
+(547889293968801823, 'Charles', 'Charles', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '代码写到极致,就是艺术。', 1, b'0', NOW(), 547887852587843595, 1, NOW()),
+(547889293968801824, 'Yoofff', 'Yoofff', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '弱小和无知不是生存的障碍,傲慢才是。', 1, b'0', NOW(), 1, 1, NOW()),
+(547889293968801825, 'Jasmine', 'Jasmine', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '干就完事了!', 1, b'0', NOW(), 547887852587843605, 1, NOW()),
+(547889293968801826, 'AutumnSail', '秋登', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '只有追求完美,才能创造奇迹。', 1, b'0', NOW(), 547887852587843602, 1, NOW()),
+(547889293968801827, 'Kils', 'Kils', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '可以摆烂,但不能真的菜。', 1, b'0', NOW(), 547887852587843599, 1, NOW()),
+(547889293968801828, 'mochou', '莫愁', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '万事莫愁,皆得所愿。', 1, b'0', NOW(), 547887852587843602, 1, NOW()),
+(547889293968801829, 'Jing', 'MS-Jing', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '路虽远,行则将至。', 2, b'0', NOW(), 547887852587843599, 1, NOW()),
+(547889293968801830, 'domw', '梓陌', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '胜利是奖赏,挫折是常态。', 1, b'0', NOW(), 547887852587843608, 1, NOW()),
+(547889293968801831, 'xtanyu', '小熊', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '不想上班。', 1, b'0', NOW(), 547887852587843611, 1, NOW());
-- 初始化默认参数
INSERT INTO `sys_option`
@@ -150,7 +187,8 @@ INSERT INTO `sys_dict`
(`id`, `name`, `code`, `description`, `is_system`, `create_user`, `create_time`)
VALUES
(1, '公告类型', 'notice_type', NULL, b'1', 1, NOW()),
-(2, '消息类型', 'message_type', NULL, b'1', 1, NOW());
+(2, '消息类型', 'message_type', NULL, b'1', 1, NOW()),
+(3, '客户端类型', 'client_type', NULL, b'1', 1, NOW());
INSERT INTO `sys_dict_item`
(`id`, `label`, `value`, `color`, `sort`, `description`, `status`, `dict_id`, `create_user`, `create_time`)
@@ -158,28 +196,47 @@ VALUES
(1, '通知', '1', 'blue', 1, NULL, 1, 1, 1, NOW()),
(2, '活动', '2', 'orangered', 2, NULL, 1, 1, 1, NOW()),
(3, '安全消息', '1', 'blue', 1, NULL, 1, 2, 1, NOW()),
-(4, '活动消息', '2', 'orangered', 2, NULL, 1, 2, 1, NOW());
+(4, '活动消息', '2', 'orangered', 2, NULL, 1, 2, 1, NOW()),
+(5, '桌面端', 'PC', 'blue', 1, NULL, 1, 3, 1, NOW()),
+(6, '安卓', 'ANDROID', '#148628', 2, NULL, 1, 3, 1, NOW()),
+(7, '小程序', 'XCX', '#7930AD', 3, NULL, 1, 3, 1, NOW());
-- 初始化默认用户和角色关联数据
INSERT INTO `sys_user_role`
(`user_id`, `role_id`)
VALUES
(1, 1),
+(547889293968801822, 547888897925840927),
+(547889293968801823, 547888897925840928),
+(547889293968801824, 547888897925840928),
+(547889293968801825, 547888897925840928),
+(547889293968801826, 547888897925840928),
+(547889293968801827, 547888897925840928),
+(547889293968801828, 547888897925840928),
+(547889293968801829, 547888897925840928),
+(547889293968801830, 547888897925840928),
(547889293968801831, 547888897925840928);
-- 初始化默认角色和菜单关联数据
INSERT INTO `sys_role_menu`
(`role_id`, `menu_id`)
VALUES
-(547888897925840928, 1000),
-(547888897925840928, 1010),
-(547888897925840928, 1011),
-(547888897925840928, 1012),
-(547888897925840928, 1013),
-(547888897925840928, 1014);
+(547888897925840927, 1000),
+(547888897925840927, 1010),
+(547888897925840927, 1011),
+(547888897925840927, 1012),
+(547888897925840927, 1013),
+(547888897925840927, 1014),
+(547888897925840928, 2000),
+(547888897925840928, 2010),
+(547888897925840928, 2011),
+(547888897925840928, 2020),
+(547888897925840928, 2021),
+(547888897925840928, 2022),
+(547888897925840928, 2023);
-- 初始化默认角色和部门关联数据
-INSERT INTO `sys_role_dept` (`role_id`, `dept_id`) VALUES (547888897925840928, 547888483713155087);
+INSERT INTO `sys_role_dept` (`role_id`, `dept_id`) VALUES (547888897925840927, 547887852587843593);
-- 初始化默认存储
INSERT INTO `sys_storage`
@@ -188,3 +245,8 @@ VALUES
(1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', b'1', 1, 1, 1, NOW()),
(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', b'0', 2, 2, 1, NOW());
+-- 初始化客户端数据
+INSERT INTO `sys_client`
+(`id`, `client_id`, `client_key`, `client_secret`, `auth_type`, `client_type`, `active_timeout`, `timeout`, `status`, `create_user`, `create_time`)
+VALUES
+(1, 'ef51c9a3e9046c4f2ea45142c8a8344a', 'pc', 'dd77ab1e353a027e0d60ce3b151e8642', '["ACCOUNT", "EMAIL", "PHONE", "SOCIAL"]', 'PC', 1800, 86400, 1, 1, NOW());
diff --git a/continew-webapi/src/main/resources/db/changelog/mysql/main_table.sql b/continew-webapi/src/main/resources/db/changelog/mysql/main_table.sql
index 95e77b8fe..d76c5be35 100644
--- a/continew-webapi/src/main/resources/db/changelog/mysql/main_table.sql
+++ b/continew-webapi/src/main/resources/db/changelog/mysql/main_table.sql
@@ -232,19 +232,19 @@ CREATE TABLE IF NOT EXISTS `sys_message_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息和用户关联表';
CREATE TABLE IF NOT EXISTS `sys_notice` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
- `title` varchar(150) NOT NULL COMMENT '标题',
- `content` mediumtext NOT NULL COMMENT '内容',
- `type` varchar(30) NOT NULL COMMENT '类型',
- `effective_time` datetime DEFAULT NULL COMMENT '生效时间',
- `terminate_time` datetime DEFAULT NULL COMMENT '终止时间',
- `notice_scope` int NOT NULL COMMENT '通知范围',
- `notice_users` json DEFAULT NULL COMMENT '通知用户',
- `sort` int NOT NULL DEFAULT 999 COMMENT '排序',
- `create_user` bigint(20) NOT NULL COMMENT '创建人',
- `create_time` datetime NOT NULL COMMENT '创建时间',
- `update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
- `update_time` datetime DEFAULT NULL COMMENT '修改时间',
+ `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
+ `title` varchar(150) NOT NULL COMMENT '标题',
+ `content` mediumtext NOT NULL COMMENT '内容',
+ `type` varchar(30) NOT NULL COMMENT '类型',
+ `effective_time` datetime DEFAULT NULL COMMENT '生效时间',
+ `terminate_time` datetime DEFAULT NULL COMMENT '终止时间',
+ `notice_scope` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '通知范围(1:所有人;2:指定用户)',
+ `notice_users` json DEFAULT NULL COMMENT '通知用户',
+ `sort` int NOT NULL DEFAULT 999 COMMENT '排序',
+ `create_user` bigint(20) NOT NULL COMMENT '创建人',
+ `create_time` datetime NOT NULL COMMENT '创建时间',
+ `update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
+ `update_time` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`),
INDEX `idx_create_user`(`create_user`),
INDEX `idx_update_user`(`update_user`)
@@ -294,3 +294,21 @@ CREATE TABLE IF NOT EXISTS `sys_file` (
INDEX `idx_create_user`(`create_user`),
INDEX `idx_update_user`(`update_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件表';
+
+CREATE TABLE IF NOT EXISTS `sys_client` (
+ `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
+ `client_id` varchar(50) NOT NULL COMMENT '客户端ID',
+ `client_key` varchar(255) NOT NULL COMMENT '客户端Key',
+ `client_secret` varchar(255) NOT NULL COMMENT '客户端秘钥',
+ `auth_type` json NOT NULL COMMENT '认证类型',
+ `client_type` varchar(50) NOT NULL COMMENT '客户端类型',
+ `active_timeout` bigint(20) DEFAULT -1 COMMENT 'Token最低活跃频率(单位:秒,-1:不限制,永不冻结)',
+ `timeout` bigint(20) DEFAULT 2592000 COMMENT 'Token有效期(单位:秒,-1:永不过期)',
+ `status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态(1:启用;2:禁用)',
+ `create_user` bigint(20) NOT NULL COMMENT '创建人',
+ `create_time` datetime NOT NULL COMMENT '创建时间',
+ `update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
+ `update_time` datetime DEFAULT NULL COMMENT '修改时间',
+ PRIMARY KEY (`id`),
+ UNIQUE INDEX `uk_client_id`(`client_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户端表';
diff --git a/continew-webapi/src/main/resources/db/changelog/postgresql/main_data.sql b/continew-webapi/src/main/resources/db/changelog/postgresql/main_data.sql
index b5d2f5439..2863e35f8 100644
--- a/continew-webapi/src/main/resources/db/changelog/postgresql/main_data.sql
+++ b/continew-webapi/src/main/resources/db/changelog/postgresql/main_data.sql
@@ -1,6 +1,6 @@
-- liquibase formatted sql
--- changeset Charles7c:1
+-- changeset charles7c:1
-- comment 初始化表数据
-- 初始化默认菜单
INSERT INTO "sys_menu"
@@ -76,6 +76,13 @@ VALUES
(1114, '修改', 1110, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:update', 4, 1, 1, NOW()),
(1115, '删除', 1110, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:storage:delete', 5, 1, 1, NOW()),
+( 1180, '客户端管理', 1000, 2, '/system/client', 'SystemClient', 'system/client/index', NULL, 'mobile', false, false, false, NULL, 9, 1, 1, NOW()),
+(1181, '列表', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:list', 1, 1, 1, NOW()),
+(1182, '详情', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:detail', 2, 1, 1, NOW()),
+(1183, '新增', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:add', 3, 1, 1, NOW()),
+(1184, '修改', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:update', 4, 1, 1, NOW()),
+(1185, '删除', 1180, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:client:delete', 5, 1, 1, NOW()),
+
(1190, '系统配置', 1000, 2, '/system/config', 'SystemConfig', 'system/config/index', NULL, 'config', false, false, false, NULL, 999, 1, 1, NOW()),
(1191, '查看', 1190, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:config:list', 1, 1, 1, NOW()),
(1192, '修改', 1190, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:config:update', 2, 1, 1, NOW()),
@@ -96,27 +103,57 @@ INSERT INTO "sys_dept"
("id", "name", "parent_id", "ancestors", "description", "sort", "status", "is_system", "create_user", "create_time")
VALUES
(1, 'Xxx科技有限公司', 0, '0', '系统初始部门', 1, 1, true, 1, NOW()),
-(547887852587843590, '天津总部', 1, '0,1', NULL, 1, 1, false, 1, NOW()),
-(547888008188133385, '研发部', 547887852587843590, '0,1,547887852587843590', NULL, 1, 1, false, 1, NOW()),
-(547888460711591948, 'UI部', 547887852587843590, '0,1,547887852587843590', NULL, 2, 1, false, 1, NOW()),
-(547888483713155087, '测试部', 547887852587843590, '0,1,547887852587843590', NULL, 3, 1, false, 1, NOW()),
-(547888505959743506, '运维部', 547887852587843590, '0,1,547887852587843590', NULL, 4, 1, false, 1, NOW()),
-(547888556819873814, '研发一组', 547888008188133385, '0,1,547887852587843590,547888008188133385', NULL, 1, 1, false, 1, NOW()),
-(547888580614160409, '研发二组', 547888008188133385, '0,1,547887852587843590,547888008188133385', NULL, 2, 2, false, 1, NOW());
+(547887852587843590, 'Xxx(天津)科技有限公司', 1, '0,1', NULL, 1, 1, false, 1, NOW()),
+(547887852587843591, '研发部', 547887852587843590, '0,1,547887852587843590', NULL, 1, 1, false, 1, NOW()),
+(547887852587843592, 'UI部', 547887852587843590, '0,1,547887852587843590', NULL, 2, 1, false, 1, NOW()),
+(547887852587843593, '测试部', 547887852587843590, '0,1,547887852587843590', NULL, 3, 1, false, 1, NOW()),
+(547887852587843594, '运维部', 547887852587843590, '0,1,547887852587843590', NULL, 4, 1, false, 1, NOW()),
+(547887852587843595, '研发一组', 547887852587843591, '0,1,547887852587843590,547887852587843591', NULL, 1, 1, false, 1, NOW()),
+(547887852587843596, '研发二组', 547887852587843591, '0,1,547887852587843590,547887852587843591', NULL, 2, 2, false, 1, NOW()),
+
+(547887852587843597, 'Xxx(四川)科技有限公司', 1, '0,1', NULL, 2, 1, false, 1, NOW()),
+(547887852587843598, '研发部', 547887852587843597, '0,1,547887852587843597', NULL, 1, 1, false, 1, NOW()),
+(547887852587843599, '研发一组', 547887852587843598, '0,1,547887852587843597,547887852587843598', NULL, 1, 1, false, 1, NOW()),
+
+(547887852587843600, 'Xxx(江西)科技有限公司', 1, '0,1', NULL, 3, 1, false, 1, NOW()),
+(547887852587843601, '研发部', 547887852587843600, '0,1,547887852587843600', NULL, 1, 1, false, 1, NOW()),
+(547887852587843602, '研发一组', 547887852587843601, '0,1,547887852587843600,547887852587843601', NULL, 1, 1, false, 1, NOW()),
+
+(547887852587843603, 'Xxx(江苏)科技有限公司', 1, '0,1', NULL, 4, 1, false, 1, NOW()),
+(547887852587843604, '研发部', 547887852587843603, '0,1,547887852587843603', NULL, 1, 1, false, 1, NOW()),
+(547887852587843605, '研发一组', 547887852587843604, '0,1,547887852587843603,547887852587843604', NULL, 1, 1, false, 1, NOW()),
+
+(547887852587843606, 'Xxx(浙江)科技有限公司', 1, '0,1', NULL, 5, 1, false, 1, NOW()),
+(547887852587843607, '研发部', 547887852587843606, '0,1,547887852587843606', NULL, 1, 1, false, 1, NOW()),
+(547887852587843608, '研发一组', 547887852587843607, '0,1,547887852587843606,547887852587843607', NULL, 1, 1, false, 1, NOW()),
+
+(547887852587843609, 'Xxx(湖南)科技有限公司', 1, '0,1', NULL, 6, 1, false, 1, NOW()),
+(547887852587843610, '研发部', 547887852587843609, '0,1,547887852587843609', NULL, 1, 1, false, 1, NOW()),
+(547887852587843611, '研发一组', 547887852587843610, '0,1,547887852587843609,547887852587843610', NULL, 1, 1, false, 1, NOW());
-- 初始化默认角色
INSERT INTO "sys_role"
("id", "name", "code", "data_scope", "description", "sort", "is_system", "create_user", "create_time")
VALUES
(1, '系统管理员', 'admin', 1, '系统初始角色', 1, true, 1, NOW()),
-(547888897925840928, '测试人员', 'test', 5, NULL, 2, false, 1, NOW());
+(547888897925840927, '测试人员', 'tester', 5, NULL, 2, false, 1, NOW()),
+(547888897925840928, '研发人员', 'developer', 4, NULL, 3, false, 1, NOW());
-- 初始化默认用户:admin/admin123;test/test123
INSERT INTO "sys_user"
("id", "username", "nickname", "password", "gender", "email", "phone", "avatar", "description", "status", "is_system", "pwd_reset_time", "dept_id", "create_user", "create_time")
VALUES
(1, 'admin', '系统管理员', '{bcrypt}$2a$10$4jGwK2BMJ7FgVR.mgwGodey8.xR8FLoU1XSXpxJ9nZQt.pufhasSa', 1, '42190c6c5639d2ca4edb4150a35e058559ccf8270361a23745a2fd285a273c28', '5bda89a4609a65546422ea56bfe5eab4', NULL, '系统初始用户', 1, true, NOW(), 1, 1, NOW()),
-(547889293968801831, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 1, false, NOW(), 547888483713155087, 1, NOW());
+(547889293968801822, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 1, false, NOW(), 547887852587843593, 1, NOW()),
+(547889293968801823, 'Charles', 'Charles', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '代码写到极致,就是艺术。', 1, false, NOW(), 547887852587843595, 1, NOW()),
+(547889293968801824, 'Yoofff', 'Yoofff', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '弱小和无知不是生存的障碍,傲慢才是。', 1, false, NOW(), 1, 1, NOW()),
+(547889293968801825, 'Jasmine', 'Jasmine', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '干就完事了!', 1, false, NOW(), 547887852587843605, 1, NOW()),
+(547889293968801826, 'AutumnSail', '秋登', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '只有追求完美,才能创造奇迹。', 1, false, NOW(), 547887852587843602, 1, NOW()),
+(547889293968801827, 'Kils', 'Kils', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '可以摆烂,但不能真的菜。', 1, false, NOW(), 547887852587843599, 1, NOW()),
+(547889293968801828, 'mochou', '莫愁', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '万事莫愁,皆得所愿。', 1, false, NOW(), 547887852587843602, 1, NOW()),
+(547889293968801829, 'Jing', 'MS-Jing', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '路虽远,行则将至。', 2, false, NOW(), 547887852587843599, 1, NOW()),
+(547889293968801830, 'domw', '梓陌', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '胜利是奖赏,挫折是常态。', 1, false, NOW(), 547887852587843608, 1, NOW()),
+(547889293968801831, 'xtanyu', '小熊', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 1, NULL, NULL, NULL, '不想上班。', 1, false, NOW(), 547887852587843611, 1, NOW());
-- 初始化默认参数
INSERT INTO "sys_option"
@@ -150,7 +187,8 @@ INSERT INTO "sys_dict"
("id", "name", "code", "description", "is_system", "create_user", "create_time")
VALUES
(1, '公告类型', 'notice_type', NULL, true, 1, NOW()),
-(2, '消息类型', 'message_type', NULL, true, 1, NOW());
+(2, '消息类型', 'message_type', NULL, true, 1, NOW()),
+(3, '客户端类型', 'client_type', NULL, true, 1, NOW());
INSERT INTO "sys_dict_item"
("id", "label", "value", "color", "sort", "description", "status", "dict_id", "create_user", "create_time")
@@ -158,28 +196,47 @@ VALUES
(1, '通知', '1', 'blue', 1, NULL, 1, 1, 1, NOW()),
(2, '活动', '2', 'orangered', 2, NULL, 1, 1, 1, NOW()),
(3, '安全消息', '1', 'blue', 1, NULL, 1, 2, 1, NOW()),
-(4, '活动消息', '2', 'orangered', 2, NULL, 1, 2, 1, NOW());
+(4, '活动消息', '2', 'orangered', 2, NULL, 1, 2, 1, NOW()),
+(5, '桌面端', 'PC', 'blue', 1, NULL, 1, 3, 1, NOW()),
+(6, '安卓', 'ANDROID', '#148628', 2, NULL, 1, 3, 1, NOW()),
+(7, '小程序', 'XCX', '#7930AD', 3, NULL, 1, 3, 1, NOW());
-- 初始化默认用户和角色关联数据
INSERT INTO "sys_user_role"
("user_id", "role_id")
VALUES
(1, 1),
+(547889293968801822, 547888897925840927),
+(547889293968801823, 547888897925840928),
+(547889293968801824, 547888897925840928),
+(547889293968801825, 547888897925840928),
+(547889293968801826, 547888897925840928),
+(547889293968801827, 547888897925840928),
+(547889293968801828, 547888897925840928),
+(547889293968801829, 547888897925840928),
+(547889293968801830, 547888897925840928),
(547889293968801831, 547888897925840928);
-- 初始化默认角色和菜单关联数据
INSERT INTO "sys_role_menu"
("role_id", "menu_id")
VALUES
-(547888897925840928, 1000),
-(547888897925840928, 1010),
-(547888897925840928, 1011),
-(547888897925840928, 1012),
-(547888897925840928, 1013),
-(547888897925840928, 1014);
+(547888897925840927, 1000),
+(547888897925840927, 1010),
+(547888897925840927, 1011),
+(547888897925840927, 1012),
+(547888897925840927, 1013),
+(547888897925840927, 1014),
+(547888897925840928, 2000),
+(547888897925840928, 2010),
+(547888897925840928, 2011),
+(547888897925840928, 2020),
+(547888897925840928, 2021),
+(547888897925840928, 2022),
+(547888897925840928, 2023);
-- 初始化默认角色和部门关联数据
-INSERT INTO "sys_role_dept" ("role_id", "dept_id") VALUES (547888897925840928, 547888483713155087);
+INSERT INTO "sys_role_dept" ("role_id", "dept_id") VALUES (547888897925840927, 547887852587843593);
-- 初始化默认存储
INSERT INTO "sys_storage"
@@ -187,3 +244,9 @@ INSERT INTO "sys_storage"
VALUES
(1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', true, 1, 1, 1, NOW()),
(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', false, 2, 2, 1, NOW());
+
+-- 初始化客户端数据
+INSERT INTO "sys_client"
+("id", "client_id", "client_key", "client_secret", "auth_type", "client_type", "active_timeout", "timeout", "status", "create_user", "create_time")
+VALUES
+(1, 'ef51c9a3e9046c4f2ea45142c8a8344a', 'pc', 'dd77ab1e353a027e0d60ce3b151e8642', '["ACCOUNT", "EMAIL", "PHONE", "SOCIAL"]', 'PC', 1800, 86400, 1, 1, NOW());
diff --git a/continew-webapi/src/main/resources/db/changelog/postgresql/main_table.sql b/continew-webapi/src/main/resources/db/changelog/postgresql/main_table.sql
index ee736ce26..7bb274d2b 100644
--- a/continew-webapi/src/main/resources/db/changelog/postgresql/main_table.sql
+++ b/continew-webapi/src/main/resources/db/changelog/postgresql/main_table.sql
@@ -1,6 +1,6 @@
-- liquibase formatted sql
--- changeset Charles7c:1
+-- changeset charles7c:1
-- comment 初始化表结构
CREATE TABLE IF NOT EXISTS "sys_menu" (
"id" int8 NOT NULL,
@@ -391,6 +391,8 @@ CREATE TABLE IF NOT EXISTS "sys_notice" (
"type" varchar(30) NOT NULL,
"effective_time" timestamp DEFAULT NULL,
"terminate_time" timestamp DEFAULT NULL,
+ "notice_scope" int2 NOT NULL DEFAULT 1,
+ "notice_users" json DEFAULT NULL,
"sort" int4 NOT NULL DEFAULT 999,
"create_user" int8 NOT NULL,
"create_time" timestamp NOT NULL,
@@ -406,6 +408,8 @@ COMMENT ON COLUMN "sys_notice"."content" IS '内容';
COMMENT ON COLUMN "sys_notice"."type" IS '类型';
COMMENT ON COLUMN "sys_notice"."effective_time" IS '生效时间';
COMMENT ON COLUMN "sys_notice"."terminate_time" IS '终止时间';
+COMMENT ON COLUMN "sys_notice"."notice_scope" IS '通知范围(1:所有人;2:指定用户)';
+COMMENT ON COLUMN "sys_notice"."notice_users" IS '通知用户';
COMMENT ON COLUMN "sys_notice"."sort" IS '排序';
COMMENT ON COLUMN "sys_notice"."create_user" IS '创建人';
COMMENT ON COLUMN "sys_notice"."create_time" IS '创建时间';
@@ -490,3 +494,34 @@ COMMENT ON COLUMN "sys_file"."update_user" IS '修改人';
COMMENT ON COLUMN "sys_file"."update_time" IS '修改时间';
COMMENT ON TABLE "sys_file" IS '文件表';
+CREATE TABLE IF NOT EXISTS "sys_client" (
+ "id" int8 NOT NULL,
+ "client_id" varchar(50) NOT NULL,
+ "client_key" varchar(255) NOT NULL,
+ "client_secret" varchar(255) NOT NULL,
+ "auth_type" json NOT NULL,
+ "client_type" varchar(50) NOT NULL,
+ "active_timeout" int8 NOT NULL DEFAULT -1,
+ "timeout" int8 NOT NULL DEFAULT 2592000,
+ "status" int2 NOT NULL DEFAULT 1,
+ "create_user" int8 NOT NULL,
+ "create_time" timestamp NOT NULL,
+ "update_user" int8 DEFAULT NULL,
+ "update_time" timestamp DEFAULT NULL,
+ PRIMARY KEY ("id")
+);
+CREATE UNIQUE INDEX "uk_client_client_id" ON "sys_client" ("client_id");
+COMMENT ON COLUMN "sys_client"."id" IS 'ID';
+COMMENT ON COLUMN "sys_client"."client_id" IS '客户端ID';
+COMMENT ON COLUMN "sys_client"."client_key" IS '客户端Key';
+COMMENT ON COLUMN "sys_client"."client_secret" IS '客户端秘钥';
+COMMENT ON COLUMN "sys_client"."auth_type" IS '认证类型';
+COMMENT ON COLUMN "sys_client"."client_type" IS '客户端类型';
+COMMENT ON COLUMN "sys_client"."active_timeout" IS 'Token最低活跃频率(单位:秒,-1:不限制,永不冻结)';
+COMMENT ON COLUMN "sys_client"."timeout" IS 'Token有效期(单位:秒,-1:永不过期)';
+COMMENT ON COLUMN "sys_client"."status" IS '状态(1:启用;2:禁用)';
+COMMENT ON COLUMN "sys_client"."create_user" IS '创建人';
+COMMENT ON COLUMN "sys_client"."create_time" IS '创建时间';
+COMMENT ON COLUMN "sys_client"."update_user" IS '修改人';
+COMMENT ON COLUMN "sys_client"."update_time" IS '修改时间';
+COMMENT ON TABLE "sys_client" IS '客户端表';
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 92d7ebd0b..0b69d5bdd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
top.continew
continew-starter
- 2.8.0
+ 2.8.2
top.continew