mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-06 01:36:46 +08:00
Add Team Interface
This commit is contained in:
@ -17,10 +17,6 @@
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-tools-base</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>ai.chat2db</groupId>-->
|
||||
<!-- <artifactId>chat2db-server-domain-support</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
@ -0,0 +1,36 @@
|
||||
package ai.chat2db.server.domain.api.enums;
|
||||
|
||||
import ai.chat2db.server.tools.base.enums.BaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Access Object Type
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Getter
|
||||
public enum AccessObjectTypeEnum implements BaseEnum<String> {
|
||||
/**
|
||||
* TEAM
|
||||
*/
|
||||
TEAM("TEAM"),
|
||||
|
||||
/**
|
||||
* USER
|
||||
*/
|
||||
USER("USER"),
|
||||
|
||||
;
|
||||
|
||||
final String description;
|
||||
|
||||
AccessObjectTypeEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package ai.chat2db.server.domain.api.enums;
|
||||
|
||||
import ai.chat2db.server.tools.base.enums.BaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Environment
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Getter
|
||||
public enum EnvironmentEnum implements BaseEnum<Long> {
|
||||
/**
|
||||
* RELEASE
|
||||
*/
|
||||
RELEASE(1L, "RELEASE"),
|
||||
|
||||
/**
|
||||
* TEST
|
||||
*/
|
||||
TEST(2L, "TEST"),
|
||||
|
||||
;
|
||||
final Long code;
|
||||
final String description;
|
||||
|
||||
EnvironmentEnum(Long code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package ai.chat2db.server.domain.api.enums;
|
||||
|
||||
import ai.chat2db.server.tools.base.enums.BaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Environment
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Getter
|
||||
public enum EnvironmentStyleEnum implements BaseEnum<String> {
|
||||
/**
|
||||
* RELEASE
|
||||
*/
|
||||
RELEASE("RELEASE"),
|
||||
|
||||
/**
|
||||
* TEST
|
||||
*/
|
||||
TEST("TEST"),
|
||||
|
||||
;
|
||||
final String description;
|
||||
|
||||
EnvironmentStyleEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package ai.chat2db.server.domain.api.enums;
|
||||
|
||||
import ai.chat2db.server.tools.base.enums.BaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* role code
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Getter
|
||||
public enum RoleCodeEnum implements BaseEnum<String> {
|
||||
/**
|
||||
* DESKTOP
|
||||
*/
|
||||
DESKTOP("DESKTOP"),
|
||||
|
||||
/**
|
||||
* USER
|
||||
*/
|
||||
USER("USER"),
|
||||
|
||||
/**
|
||||
* ADMIN
|
||||
*/
|
||||
ADMIN("ADMIN"),
|
||||
|
||||
;
|
||||
final String description;
|
||||
|
||||
RoleCodeEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package ai.chat2db.server.domain.api.enums;
|
||||
|
||||
import ai.chat2db.server.tools.base.enums.BaseEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Is it a valid enumeration
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Getter
|
||||
public enum ValidStatusEnum implements BaseEnum<String> {
|
||||
/**
|
||||
* VALID
|
||||
*/
|
||||
VALID("VALID"),
|
||||
|
||||
/**
|
||||
* INVALID
|
||||
*/
|
||||
INVALID("INVALID"),
|
||||
|
||||
;
|
||||
final String description;
|
||||
|
||||
ValidStatusEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
@ -99,7 +99,6 @@ public class DataSource {
|
||||
*/
|
||||
private String jdbc;
|
||||
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
@ -110,14 +109,23 @@ public class DataSource {
|
||||
*/
|
||||
private DriverConfig driverConfig;
|
||||
|
||||
/**
|
||||
* 环境id
|
||||
*/
|
||||
private Long environmentId;
|
||||
|
||||
public LinkedHashMap<String,Object> getExtendMap() {
|
||||
/**
|
||||
* 环境
|
||||
*/
|
||||
private Environment environment;
|
||||
|
||||
public LinkedHashMap<String, Object> getExtendMap() {
|
||||
if (ObjectUtils.isEmpty(extendInfo)) {
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
LinkedHashMap<String,Object> map = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
for (KeyValue keyValue : extendInfo) {
|
||||
map.put(keyValue.getKey(),keyValue.getValue());
|
||||
map.put(keyValue.getKey(), keyValue.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
package ai.chat2db.server.domain.api.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccess implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@NotNull
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@NotNull
|
||||
private LocalDateTime gmtModified;
|
||||
|
||||
/**
|
||||
* 创建人用户id
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 修改人用户id
|
||||
*/
|
||||
private Long modifiedUserId;
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@NotNull
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
@NotNull
|
||||
private String accessObjectType;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
@NotNull
|
||||
private Long accessObjectId;
|
||||
|
||||
/**
|
||||
* 授权对象
|
||||
*/
|
||||
@NotNull
|
||||
private DataSourceAccessObject accessObject;
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package ai.chat2db.server.domain.api.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
* It could be a user or a team
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessObject implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The name of the code that belongs to the authorization type, such as user account, team code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Code that belongs to the authorization type, such as user name, team name
|
||||
*/
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package ai.chat2db.server.domain.api.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.EnvironmentStyleEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* Environment
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Environment implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 环境名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 环境缩写
|
||||
*/
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 样式类型
|
||||
*
|
||||
* @see EnvironmentStyleEnum
|
||||
*/
|
||||
private String style;
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package ai.chat2db.server.domain.api.model;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.RoleCodeEnum;
|
||||
import ai.chat2db.server.domain.api.enums.ValidStatusEnum;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -18,26 +21,44 @@ public class User {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@NotNull
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@NotNull
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@NotNull
|
||||
private String nickName;
|
||||
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@NotNull
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*
|
||||
* @see RoleCodeEnum
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*
|
||||
* @see ValidStatusEnum
|
||||
*/
|
||||
private String status;
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import lombok.Setter;
|
||||
* 数据源连接表
|
||||
* </p>
|
||||
*
|
||||
* @author ali-dbhub
|
||||
* @since 2023-03-05
|
||||
* @author chat2db
|
||||
* @since 2023-07-30
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ -58,4 +58,14 @@ public class DbhubUserDO implements Serializable {
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*/
|
||||
private String status;
|
||||
}
|
||||
|
@ -64,6 +64,11 @@ public class TeamDO implements Serializable {
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 团队描述
|
||||
*/
|
||||
|
@ -1,61 +0,0 @@
|
||||
package ai.chat2db.server.domain.repository.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 团队角色表
|
||||
* </p>
|
||||
*
|
||||
* @author chat2db
|
||||
* @since 2023-07-30
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("TEAM_ROLE")
|
||||
public class TeamRoleDO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "ID", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime gmtModified;
|
||||
|
||||
/**
|
||||
* 创建人用户id
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 修改人用户id
|
||||
*/
|
||||
private Long modifiedUserId;
|
||||
|
||||
/**
|
||||
* 团队id
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
}
|
@ -8,8 +8,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* 数据源连接表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ali-dbhub
|
||||
* @since 2023-03-05
|
||||
* @author chat2db
|
||||
* @since 2023-07-30
|
||||
*/
|
||||
public interface DbhubUserMapper extends BaseMapper<DbhubUserDO> {
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
package ai.chat2db.server.domain.repository.mapper;
|
||||
|
||||
import ai.chat2db.server.domain.repository.entity.TeamRoleDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 团队角色表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chat2db
|
||||
* @since 2023-07-30
|
||||
*/
|
||||
public interface TeamRoleMapper extends BaseMapper<TeamRoleDO> {
|
||||
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ai.chat2db.server.domain.repository.mapper.TeamRoleMapper">
|
||||
|
||||
</mapper>
|
@ -23,6 +23,16 @@ VALUES (2, 1, 1, '测试环境', '测试', 'TEST');
|
||||
ALTER TABLE `data_source`
|
||||
ADD COLUMN `environment_id` bigint(20) unsigned NOT NULL DEFAULT 2 COMMENT '环境id';
|
||||
|
||||
ALTER TABLE `dbhub_user`
|
||||
ADD COLUMN `role_code` varchar(32) DEFAULT NULL COMMENT '角色编码';
|
||||
|
||||
ALTER TABLE `dbhub_user`
|
||||
ADD `status` varchar(32) NOT NULL DEFAULT 'VALID' COMMENT '用户状态';
|
||||
|
||||
update dbhub_user
|
||||
set role_code= 'DESKTOP'
|
||||
where id = 1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `team`
|
||||
(
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
@ -33,6 +43,7 @@ CREATE TABLE IF NOT EXISTS `team`
|
||||
`code` varchar(128) DEFAULT NOT NULL COMMENT '团队编码',
|
||||
`name` varchar(512) DEFAULT NULL COMMENT '团队名称',
|
||||
`status` varchar(32) NOT NULL DEFAULT 'VALID' COMMENT '团队状态',
|
||||
`role_code` varchar(32) DEFAULT NULL COMMENT '角色编码',
|
||||
`description` text DEFAULT NULL COMMENT '团队描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
@ -59,22 +70,6 @@ CREATE TABLE IF NOT EXISTS `team_dbhub_user`
|
||||
create INDEX idx_team_dbhub_user_team_id on team_dbhub_user (`team_id`);
|
||||
create INDEX idx_team_dbhub_user_dbhub_user_id on team_dbhub_user (`dbhub_user_id`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `team_role`
|
||||
(
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
`create_user_id` bigint(20) unsigned NOT NULL COMMENT '创建人用户id',
|
||||
`modified_user_id` bigint(20) unsigned NOT NULL COMMENT '修改人用户id',
|
||||
`team_id` bigint(20) unsigned NOT NULL COMMENT '团队id',
|
||||
`role_code` varchar(32) NOT NULL COMMENT '角色编码',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='团队角色表'
|
||||
;
|
||||
|
||||
create INDEX team_role_team_id on team_role (`team_id`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `data_source_access`
|
||||
(
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
@ -91,4 +86,4 @@ CREATE TABLE IF NOT EXISTS `data_source_access`
|
||||
;
|
||||
|
||||
create INDEX data_source_access_data_source_id on data_source_access (`data_source_id`);
|
||||
create INDEX data_source_access_access_object_id on data_source_access (`access_object_type`,`access_object_id`);
|
||||
create INDEX data_source_access_access_object_id on data_source_access (`access_object_type`, `access_object_id`);
|
||||
|
@ -32,7 +32,7 @@ public class MybatisGeneratorTest extends BaseTest {
|
||||
//doGenerator(Lists.newArrayList("data_source"));
|
||||
//doGenerator(Lists.newArrayList("operation_log"));
|
||||
//doGenerator(Lists.newArrayList("operation_saved"));
|
||||
doGenerator(Lists.newArrayList("environment","data_source","team","team_dbhub_user","team_role","data_source_access"));
|
||||
doGenerator(Lists.newArrayList("environment","data_source","team","team_dbhub_user","data_source_access","dbhub_user"));
|
||||
}
|
||||
|
||||
private void doGenerator(List<String> tableList) {
|
||||
|
@ -22,6 +22,10 @@
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-common-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-core</artifactId>
|
||||
|
@ -0,0 +1,41 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.common;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.common.request.TeamUserPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.common.vo.TeamUserListVO;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.converter.DataSourceAdminConverter;
|
||||
import ai.chat2db.server.domain.api.service.DataSourceService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.web.WebPageResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Some general data queries
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@RequestMapping("/api/admin/common")
|
||||
@RestController
|
||||
public class CommonController {
|
||||
|
||||
@Resource
|
||||
private DataSourceService dataSourceService;
|
||||
@Resource
|
||||
private DataSourceAdminConverter dataSourceAdminConverter;
|
||||
|
||||
/**
|
||||
* Fuzzy query of users or teams
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@GetMapping("/team-user/list")
|
||||
public WebPageResult<TeamUserListVO> teamUserList(@Valid TeamUserPageQueryRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource.request;
|
||||
package ai.chat2db.server.admin.api.controller.common.request;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.request.PageQueryRequest;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Pagination query
|
||||
* Common pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class DataSourcePageQueryRequest extends PageQueryRequest {
|
||||
public class CommonPageQueryRequest extends PageQueryRequest {
|
||||
|
||||
/**
|
||||
* searchKey
|
@ -0,0 +1,27 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.common.request;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.wrapper.request.PageQueryRequest;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Common pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class TeamUserPageQueryRequest extends PageQueryRequest {
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* searchKey
|
||||
*/
|
||||
private String searchKey;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.common.vo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
* It could be a user or a team
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TeamUserListVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The name of the code that belongs to the authorization type, such as user account, team code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Code that belongs to the authorization type, such as user name, team name
|
||||
*/
|
||||
private String name;
|
||||
}
|
@ -2,16 +2,11 @@
|
||||
package ai.chat2db.server.admin.api.controller.datasource;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.datasource.converter.DataSourceAdminConverter;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceCloneRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceCreateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourcePageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceUpdateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.vo.DataSourcePageQueryVO;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceCreateParam;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceUpdateParam;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceAccessBatchCreateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceAccessPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.vo.DataSourceAccessPageQueryVO;
|
||||
import ai.chat2db.server.domain.api.service.DataSourceService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.web.WebPageResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
@ -45,46 +40,20 @@ public class DataSourceAccessController {
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public WebPageResult<DataSourcePageQueryVO> page(@Valid DataSourcePageQueryRequest request) {
|
||||
return dataSourceService.queryPage(dataSourceAdminConverter.request2param(request), null)
|
||||
.mapToWeb(dataSourceAdminConverter::dto2vo);
|
||||
public WebPageResult<DataSourceAccessPageQueryVO> page(@Valid DataSourceAccessPageQueryRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* create
|
||||
* batch
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public DataResult<Long> create(@RequestBody DataSourceCreateRequest request) {
|
||||
DataSourceCreateParam param = dataSourceAdminConverter.createReq2param(request);
|
||||
return dataSourceService.create(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* update
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ActionResult update(@RequestBody DataSourceUpdateRequest request) {
|
||||
DataSourceUpdateParam param = dataSourceAdminConverter.updateReq2param(request);
|
||||
return dataSourceService.update(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* clone
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/clone")
|
||||
public DataResult<Long> clone(@RequestBody DataSourceCloneRequest request) {
|
||||
return dataSourceService.copyById(request.getId());
|
||||
@PostMapping("/batch-create")
|
||||
public ActionResult batchCreate(@RequestBody DataSourceAccessBatchCreateRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +64,7 @@ public class DataSourceAccessController {
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable Long id) {
|
||||
return dataSourceService.delete(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.common.request.CommonPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.converter.DataSourceAdminConverter;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceCloneRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceCreateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourcePageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceUpdateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.vo.DataSourcePageQueryVO;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceCreateParam;
|
||||
@ -45,7 +45,7 @@ public class DataSourceController {
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public WebPageResult<DataSourcePageQueryVO> page(@Valid DataSourcePageQueryRequest request) {
|
||||
public WebPageResult<DataSourcePageQueryVO> page(@Valid CommonPageQueryRequest request) {
|
||||
return dataSourceService.queryPage(dataSourceAdminConverter.request2param(request), null)
|
||||
.mapToWeb(dataSourceAdminConverter::dto2vo);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ai.chat2db.server.admin.api.controller.datasource.converter;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.common.request.CommonPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceCreateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourcePageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.request.DataSourceUpdateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.datasource.vo.DataSourcePageQueryVO;
|
||||
import ai.chat2db.server.domain.api.model.DataSource;
|
||||
@ -26,7 +26,15 @@ public abstract class DataSourceAdminConverter {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public abstract DataSourcePageQueryParam request2param(DataSourcePageQueryRequest request);
|
||||
public abstract DataSourcePageQueryParam request2param(CommonPageQueryRequest request);
|
||||
|
||||
/**
|
||||
* conversion
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public abstract DataSourcePageQueryParam request2paramAccess(CommonPageQueryRequest request);
|
||||
|
||||
/**
|
||||
* conversion
|
||||
|
@ -0,0 +1,35 @@
|
||||
package ai.chat2db.server.admin.api.controller.datasource.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* create
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessBatchCreateRequest {
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@NotNull
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
*/
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private List<DataSourceAccessObjectRequest> accessObjectList;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource.request;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
* It could be a user or a team
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessObjectRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource.request;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.request.PageQueryRequest;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Common pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceAccessPageQueryRequest extends PageQueryRequest {
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@NotNull
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* searchKey
|
||||
*/
|
||||
private String searchKey;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource.vo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
* It could be a user or a team
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessObjectVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The name of the code that belongs to the authorization type, such as user account, team code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Code that belongs to the authorization type, such as user name, team name
|
||||
*/
|
||||
private String name;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource.vo;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@ -12,17 +14,27 @@ import lombok.Data;
|
||||
public class DataSourceAccessPageQueryVO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
* 主键
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
@NotNull
|
||||
private String accessObjectType;
|
||||
|
||||
/**
|
||||
* 连接别名
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private String alias;
|
||||
@NotNull
|
||||
private Long accessObjectId;
|
||||
|
||||
/**
|
||||
* 连接地址
|
||||
* 授权对象
|
||||
*/
|
||||
private String url;
|
||||
@NotNull
|
||||
private DataSourceAccessObjectVO accessObject;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.datasource.vo;
|
||||
|
||||
import ai.chat2db.server.common.api.controller.vo.EnvironmentVO;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@ -25,4 +26,14 @@ public class DataSourcePageQueryVO {
|
||||
* 连接地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 环境id
|
||||
*/
|
||||
private Long environmentId;
|
||||
|
||||
/**
|
||||
* 环境
|
||||
*/
|
||||
private EnvironmentVO environment;
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.user.converter.DataSourceAdminConverter;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.DataSourceAccessBatchCreateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.DataSourceAccessPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.vo.DataSourceAccessPageQueryVO;
|
||||
import ai.chat2db.server.domain.api.service.DataSourceService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.web.WebPageResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Data Source Access Management
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@RequestMapping("/api/admin/data/source/access")
|
||||
@RestController
|
||||
public class DataSourceAccessController {
|
||||
|
||||
@Resource
|
||||
private DataSourceService dataSourceService;
|
||||
@Resource
|
||||
private DataSourceAdminConverter dataSourceAdminConverter;
|
||||
|
||||
/**
|
||||
* Pagination query
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public WebPageResult<DataSourceAccessPageQueryVO> page(@Valid DataSourceAccessPageQueryRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* batch
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@PostMapping("/batch-create")
|
||||
public ActionResult batchCreate(@RequestBody DataSourceAccessBatchCreateRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.common.request.CommonPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.converter.DataSourceAdminConverter;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.DataSourceCloneRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.DataSourceUpdateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.UserCreateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.vo.UserPageQueryVO;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceCreateParam;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceUpdateParam;
|
||||
import ai.chat2db.server.domain.api.service.DataSourceService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.web.WebPageResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* User Management
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@RequestMapping("/api/admin/user")
|
||||
@RestController
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private DataSourceService dataSourceService;
|
||||
@Resource
|
||||
private DataSourceAdminConverter dataSourceAdminConverter;
|
||||
|
||||
/**
|
||||
* Pagination query
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public WebPageResult<UserPageQueryVO> page(@Valid CommonPageQueryRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* create
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public DataResult<Long> create(@RequestBody UserCreateRequest request) {
|
||||
DataSourceCreateParam param = dataSourceAdminConverter.createReq2param(request);
|
||||
return dataSourceService.create(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* update
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @version 2.1.0
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ActionResult update(@RequestBody DataSourceUpdateRequest request) {
|
||||
DataSourceUpdateParam param = dataSourceAdminConverter.updateReq2param(request);
|
||||
return dataSourceService.update(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* clone
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/clone")
|
||||
public DataResult<Long> clone(@RequestBody DataSourceCloneRequest request) {
|
||||
return dataSourceService.copyById(request.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* delete
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable Long id) {
|
||||
return dataSourceService.delete(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package ai.chat2db.server.admin.api.controller.user.converter;
|
||||
|
||||
import ai.chat2db.server.admin.api.controller.common.request.CommonPageQueryRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.DataSourceUpdateRequest;
|
||||
import ai.chat2db.server.admin.api.controller.user.request.UserCreateRequest;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceCreateParam;
|
||||
import ai.chat2db.server.domain.api.param.DataSourcePageQueryParam;
|
||||
import ai.chat2db.server.domain.api.param.DataSourceUpdateParam;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
|
||||
/**
|
||||
* converter
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public abstract class DataSourceAdminConverter {
|
||||
|
||||
/**
|
||||
* conversion
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public abstract DataSourcePageQueryParam request2param(CommonPageQueryRequest request);
|
||||
|
||||
/**
|
||||
* conversion
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public abstract DataSourcePageQueryParam request2paramAccess(CommonPageQueryRequest request);
|
||||
|
||||
///**
|
||||
// * conversion
|
||||
// *
|
||||
// * @param dto
|
||||
// * @return
|
||||
// */
|
||||
//public abstract DataSourcePageQueryVO dto2vo(DataSource dto);
|
||||
|
||||
/**
|
||||
* 参数转换
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Mappings({
|
||||
@Mapping(source = "user", target = "userName")
|
||||
})
|
||||
public abstract DataSourceCreateParam createReq2param(UserCreateRequest request);
|
||||
|
||||
/**
|
||||
* 参数转换
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Mappings({
|
||||
@Mapping(source = "user", target = "userName")
|
||||
})
|
||||
public abstract DataSourceUpdateParam updateReq2param(DataSourceUpdateRequest request);
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package ai.chat2db.server.admin.api.controller.user.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* create
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessBatchCreateRequest {
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@NotNull
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
*/
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private List<DataSourceAccessObjectRequest> accessObjectList;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user.request;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
* It could be a user or a team
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessObjectRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user.request;
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.request.PageQueryRequest;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Common pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceAccessPageQueryRequest extends PageQueryRequest {
|
||||
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
@NotNull
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* searchKey
|
||||
*/
|
||||
private String searchKey;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ai.chat2db.server.admin.api.controller.user.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author moji
|
||||
* @version ConnectionCloneRequest.java, v 0.1 2022年09月16日 14:23 moji Exp $
|
||||
* @date 2022/09/16
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceCloneRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package ai.chat2db.server.admin.api.controller.user.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ai.chat2db.server.tools.base.enums.EnvTypeEnum;
|
||||
import ai.chat2db.spi.config.DriverConfig;
|
||||
import ai.chat2db.spi.model.KeyValue;
|
||||
import ai.chat2db.spi.model.SSHInfo;
|
||||
import ai.chat2db.spi.model.SSLInfo;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author moji
|
||||
* @version ConnectionCreateRequest.java, v 0.1 2022年09月16日 14:23 moji Exp $
|
||||
* @date 2022/09/16
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceUpdateRequest {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 连接别名
|
||||
*/
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
* 连接地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 连接用户
|
||||
*/
|
||||
private String user;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 连接类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 环境类型
|
||||
* @see EnvTypeEnum
|
||||
*/
|
||||
private String envType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* host
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* port
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* ssh
|
||||
*/
|
||||
private SSHInfo ssh;
|
||||
|
||||
/**
|
||||
* ssh
|
||||
*/
|
||||
private SSLInfo ssl;
|
||||
|
||||
/**
|
||||
* sid
|
||||
*/
|
||||
private String sid;
|
||||
|
||||
/**
|
||||
* driver
|
||||
*/
|
||||
private String driver;
|
||||
|
||||
|
||||
/**
|
||||
* jdbc版本
|
||||
*/
|
||||
private String jdbc;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
private List<KeyValue> extendInfo;
|
||||
|
||||
/**
|
||||
* 驱动配置
|
||||
*/
|
||||
private DriverConfig driverConfig;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package ai.chat2db.server.admin.api.controller.user.request;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* create
|
||||
*@author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class UserCreateRequest {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@NotNull
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@NotNull
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@NotNull
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@NotNull
|
||||
private String email;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user.vo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* DataSource Access Object
|
||||
* It could be a user or a team
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceAccessObjectVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The name of the code that belongs to the authorization type, such as user account, team code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Code that belongs to the authorization type, such as user name, team name
|
||||
*/
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user.vo;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.AccessObjectTypeEnum;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceAccessPageQueryVO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
/**
|
||||
* 授权类型
|
||||
*
|
||||
* @see AccessObjectTypeEnum
|
||||
*/
|
||||
@NotNull
|
||||
private String accessObjectType;
|
||||
|
||||
/**
|
||||
* 授权id,根据类型区分是用户还是团队
|
||||
*/
|
||||
@NotNull
|
||||
private Long accessObjectId;
|
||||
|
||||
/**
|
||||
* 授权对象
|
||||
*/
|
||||
@NotNull
|
||||
private DataSourceAccessObjectVO accessObject;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
|
||||
package ai.chat2db.server.admin.api.controller.user.vo;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.ValidStatusEnum;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Pagination query
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
public class UserPageQueryVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@NotNull
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@NotNull
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*
|
||||
* @see ValidStatusEnum
|
||||
*/
|
||||
private String status;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>chat2db-server-common-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>chat2db-server-common-api</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-tools-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,48 @@
|
||||
package ai.chat2db.server.common.api.controller.vo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import ai.chat2db.server.domain.api.enums.EnvironmentStyleEnum;
|
||||
import ai.chat2db.server.tools.base.constant.EasyToolsConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* Environment
|
||||
*
|
||||
* @author Jiaju Zhuang
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EnvironmentVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = EasyToolsConstant.SERIAL_VERSION_UID;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 环境名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 环境缩写
|
||||
*/
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 样式类型
|
||||
*
|
||||
* @see EnvironmentStyleEnum
|
||||
*/
|
||||
private String style;
|
||||
}
|
@ -22,6 +22,10 @@
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-common-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-core</artifactId>
|
||||
|
@ -15,6 +15,7 @@
|
||||
<modules>
|
||||
<module>chat2db-server-web-api</module>
|
||||
<module>chat2db-server-admin-api</module>
|
||||
<module>chat2db-server-common-api</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -55,6 +55,16 @@
|
||||
<artifactId>chat2db-server-web-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-admin-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-common-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.chat2db</groupId>
|
||||
<artifactId>chat2db-server-domain-api</artifactId>
|
||||
|
Reference in New Issue
Block a user