forked from CodePhiliaX/Chat2DB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e8a56b
commit efd9aa4
Showing
32 changed files
with
595 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...erver-domain-api/src/main/java/ai/chat2db/server/domain/api/param/MetaDataQueryParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ai.chat2db.server.domain.api.param; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class MetaDataQueryParam { | ||
|
||
@NotNull | ||
private Long dataSourceId; | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...2db-server-domain-api/src/main/java/ai/chat2db/server/domain/api/param/PinTableParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ai.chat2db.server.domain.api.param; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class PinTableParam { | ||
|
||
@NotNull | ||
private Long dataSourceId; | ||
|
||
/** | ||
* DB名称 | ||
*/ | ||
private String databaseName; | ||
|
||
/** | ||
* 表所在空间 | ||
*/ | ||
private String schemaName; | ||
|
||
/** | ||
* tableName | ||
*/ | ||
private String tableName; | ||
|
||
/** | ||
* pin userId | ||
*/ | ||
private Long userId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,5 @@ public class SchemaQueryParam { | |
@NotNull | ||
private Long dataSourceId; | ||
|
||
@NotNull | ||
private String dataBaseName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...t2db-server-domain-api/src/main/java/ai/chat2db/server/domain/api/service/PinService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ai.chat2db.server.domain.api.service; | ||
|
||
import ai.chat2db.server.domain.api.param.PinTableParam; | ||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
|
||
import java.util.List; | ||
|
||
public interface PinService { | ||
|
||
/** | ||
* User pin table | ||
* @param param | ||
* @return | ||
*/ | ||
ActionResult pinTable(PinTableParam param); | ||
|
||
|
||
/** | ||
* Delete pin table | ||
* @param param | ||
* @return | ||
*/ | ||
ActionResult deletePinTable(PinTableParam param); | ||
|
||
|
||
/** | ||
* Query user pin tables | ||
* @param param | ||
* @return | ||
*/ | ||
ListResult<String> queryPinTables(PinTableParam param); | ||
} |
21 changes: 21 additions & 0 deletions
21
...-domain-core/src/main/java/ai/chat2db/server/domain/core/converter/PinTableConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ai.chat2db.server.domain.core.converter; | ||
|
||
import ai.chat2db.server.domain.api.param.PinTableParam; | ||
import ai.chat2db.server.domain.api.param.TablePageQueryParam; | ||
import ai.chat2db.server.domain.repository.entity.PinTableDO; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper(componentModel = "spring") | ||
public abstract class PinTableConverter { | ||
|
||
/** | ||
* | ||
* @param param | ||
* @return | ||
*/ | ||
public abstract PinTableDO param2do(PinTableParam param); | ||
|
||
|
||
|
||
public abstract PinTableParam toPinTableParam (TablePageQueryParam param); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...b-server-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/PinServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package ai.chat2db.server.domain.core.impl; | ||
|
||
import ai.chat2db.server.domain.api.param.PinTableParam; | ||
import ai.chat2db.server.domain.api.service.PinService; | ||
import ai.chat2db.server.domain.core.converter.PinTableConverter; | ||
import ai.chat2db.server.domain.repository.entity.PinTableDO; | ||
import ai.chat2db.server.domain.repository.mapper.PinTableMapper; | ||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
public class PinServiceImpl implements PinService { | ||
|
||
@Autowired | ||
private PinTableConverter pinTableConverter; | ||
|
||
@Autowired | ||
private PinTableMapper pinTableMapper; | ||
|
||
@Override | ||
public ActionResult pinTable(PinTableParam param) { | ||
PinTableDO entity = pinTableConverter.param2do(param); | ||
pinTableMapper.insert(entity); | ||
return ActionResult.isSuccess(); | ||
} | ||
|
||
@Override | ||
public ActionResult deletePinTable(PinTableParam param) { | ||
LambdaUpdateWrapper<PinTableDO> updateWrapper = new LambdaUpdateWrapper<>(); | ||
updateWrapper.eq(PinTableDO::getUserId, param.getUserId()); | ||
updateWrapper.eq(PinTableDO::getDataSourceId, param.getDataSourceId()); | ||
if (StringUtils.isNotBlank(param.getDatabaseName())) { | ||
updateWrapper.eq(PinTableDO::getDatabaseName, param.getDatabaseName()); | ||
} | ||
if (StringUtils.isNotBlank(param.getSchemaName())) { | ||
updateWrapper.eq(PinTableDO::getSchemaName, param.getSchemaName()); | ||
} | ||
if (StringUtils.isNotBlank(param.getTableName())) { | ||
updateWrapper.eq(PinTableDO::getTableName, param.getTableName()); | ||
} | ||
pinTableMapper.delete(updateWrapper); | ||
return ActionResult.isSuccess(); | ||
} | ||
|
||
@Override | ||
public ListResult<String> queryPinTables(PinTableParam param) { | ||
List<String> result = new ArrayList<>(); | ||
LambdaQueryWrapper<PinTableDO> queryWrapper = new LambdaQueryWrapper<>(); | ||
queryWrapper.eq(PinTableDO::getUserId, param.getUserId()); | ||
queryWrapper.eq(PinTableDO::getDataSourceId, param.getDataSourceId()); | ||
if (StringUtils.isNotBlank(param.getDatabaseName())) { | ||
queryWrapper.eq(PinTableDO::getDatabaseName, param.getDatabaseName()); | ||
} | ||
if (StringUtils.isNotBlank(param.getSchemaName())) { | ||
queryWrapper.eq(PinTableDO::getSchemaName, param.getSchemaName()); | ||
} | ||
if (StringUtils.isNotBlank(param.getTableName())) { | ||
queryWrapper.eq(PinTableDO::getTableName, param.getTableName()); | ||
} | ||
queryWrapper.orderByDesc(PinTableDO::getGmtModified); | ||
List<PinTableDO> list = pinTableMapper.selectList(queryWrapper); | ||
if (!CollectionUtils.isEmpty(list)) { | ||
result = list.stream().map(pinTableDO -> pinTableDO.getTableName()).collect(Collectors.toList()); | ||
} | ||
return ListResult.of(result); | ||
} | ||
} |
Oops, something went wrong.