mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-14 13:50:24 +00:00
后端代码优化
This commit is contained in:
@@ -419,7 +419,7 @@ spring:
|
||||
uri-encoding: UTF-8
|
||||
max-http-header-size: 8096
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
throw-exception-if-no-handler-found: false
|
||||
static-path-pattern: /statics/**
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
@@ -441,10 +441,6 @@ mybatis:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
mapper:
|
||||
wrap-keyword: "`{0}`"
|
||||
enable-method-annotation: true
|
||||
|
||||
dbswitch:
|
||||
configuration:
|
||||
# 驱动JAR文件所在的目录位置
|
||||
|
@@ -8,7 +8,7 @@ spring:
|
||||
uri-encoding: UTF-8
|
||||
max-http-header-size: 8096
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
throw-exception-if-no-handler-found: false
|
||||
static-path-pattern: /statics/**
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
@@ -30,10 +30,6 @@ mybatis:
|
||||
map-underscore-to-camel-case: true
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
mapper:
|
||||
wrap-keyword: "`{0}`"
|
||||
enable-method-annotation: true
|
||||
|
||||
dbswitch:
|
||||
configuration:
|
||||
drivers-base-path: ${APP_DRIVERS_PATH}
|
@@ -94,8 +94,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -9,13 +9,14 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.Banner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableScheduling
|
||||
@tk.mybatis.spring.annotation.MapperScan("com.gitee.dbswitch.admin.mapper")
|
||||
@MapperScan({"com.gitee.dbswitch.admin.mapper"})
|
||||
@SpringBootApplication
|
||||
public class AdminApplication {
|
||||
|
||||
|
@@ -10,7 +10,6 @@
|
||||
package com.gitee.dbswitch.admin.controller.converter;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
import com.gitee.dbswitch.admin.dao.AssignmentConfigDAO;
|
||||
import com.gitee.dbswitch.admin.dao.DatabaseConnectionDAO;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentConfigEntity;
|
||||
@@ -18,17 +17,13 @@ import com.gitee.dbswitch.admin.entity.AssignmentTaskEntity;
|
||||
import com.gitee.dbswitch.admin.entity.DatabaseConnectionEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.AssignmentDetailResponse;
|
||||
import com.gitee.dbswitch.admin.type.IncludeExcludeEnum;
|
||||
import java.util.Objects;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
|
||||
public class AssignmentDetailConverter extends
|
||||
AbstractConverter<AssignmentTaskEntity, AssignmentDetailResponse> {
|
||||
|
||||
@Override
|
||||
public AssignmentDetailResponse convert(AssignmentTaskEntity assignmentTaskEntity) {
|
||||
if (Objects.isNull(assignmentTaskEntity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DatabaseConnectionDAO databaseConnectionDAO = SpringUtil.getBean(DatabaseConnectionDAO.class);
|
||||
AssignmentConfigDAO assignmentConfigDAO = SpringUtil.getBean(AssignmentConfigDAO.class);
|
||||
AssignmentConfigEntity taskConfig = assignmentConfigDAO.getByAssignmentTaskId(
|
||||
|
@@ -9,9 +9,9 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.controller.converter;
|
||||
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentTaskEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.AssignmentInfoResponse;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
|
||||
public class AssignmentInfoConverter extends
|
||||
AbstractConverter<AssignmentTaskEntity, AssignmentInfoResponse> {
|
||||
|
@@ -9,20 +9,15 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.controller.converter;
|
||||
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
import com.gitee.dbswitch.admin.entity.DatabaseConnectionEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.DbConnectionDetailResponse;
|
||||
import java.util.Objects;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
|
||||
public class DbConnectionDetailConverter extends
|
||||
AbstractConverter<DatabaseConnectionEntity, DbConnectionDetailResponse> {
|
||||
|
||||
@Override
|
||||
public DbConnectionDetailResponse convert(DatabaseConnectionEntity databaseConnectionEntity) {
|
||||
if (Objects.isNull(databaseConnectionEntity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DbConnectionDetailResponse response = new DbConnectionDetailResponse();
|
||||
response.setId(databaseConnectionEntity.getId());
|
||||
response.setName(databaseConnectionEntity.getName());
|
||||
|
@@ -9,20 +9,15 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.controller.converter;
|
||||
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
import com.gitee.dbswitch.admin.entity.SystemLogEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.SystemLogDetailResponse;
|
||||
import java.util.Objects;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
|
||||
public class SystemLogDetailConverter extends
|
||||
AbstractConverter<SystemLogEntity, SystemLogDetailResponse> {
|
||||
|
||||
@Override
|
||||
public SystemLogDetailResponse convert(SystemLogEntity systemLogEntity) {
|
||||
if (Objects.isNull(systemLogEntity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SystemLogDetailResponse response = new SystemLogDetailResponse();
|
||||
response.setId(systemLogEntity.getId());
|
||||
response.setUsername(systemLogEntity.getUsername());
|
||||
|
@@ -9,20 +9,15 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.controller.converter;
|
||||
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
import com.gitee.dbswitch.admin.entity.SystemUserEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.SystemUserDetailResponse;
|
||||
import java.util.Objects;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
|
||||
public class SystemUserDetailConverter extends
|
||||
AbstractConverter<SystemUserEntity, SystemUserDetailResponse> {
|
||||
|
||||
@Override
|
||||
public SystemUserDetailResponse convert(SystemUserEntity user) {
|
||||
if (Objects.isNull(user)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
SystemUserDetailResponse response = new SystemUserDetailResponse();
|
||||
response.setId(user.getId());
|
||||
response.setUsername(user.getUsername());
|
||||
|
@@ -9,23 +9,17 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.controller.converter;
|
||||
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentJobEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.TaskJobDetailResponse;
|
||||
import com.gitee.dbswitch.admin.type.JobStatusEnum;
|
||||
import com.gitee.dbswitch.admin.type.ScheduleModeEnum;
|
||||
import java.util.Objects;
|
||||
import com.gitee.dbswitch.common.converter.AbstractConverter;
|
||||
|
||||
public class TaskJobDetailConverter extends
|
||||
AbstractConverter<AssignmentJobEntity, TaskJobDetailResponse> {
|
||||
|
||||
@Override
|
||||
public TaskJobDetailResponse convert(AssignmentJobEntity assignmentJobEntity) {
|
||||
if (Objects.isNull(assignmentJobEntity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//ScheduleService scheduleService = SpringUtil.getBean(ScheduleService.class);
|
||||
TaskJobDetailResponse response = new TaskJobDetailResponse();
|
||||
response.setJobId(assignmentJobEntity.getId());
|
||||
response.setAssignmentId(assignmentJobEntity.getAssignmentId());
|
||||
|
@@ -9,12 +9,11 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentConfigEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.AssignmentConfigMapper;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.util.Sqls;
|
||||
|
||||
@Repository
|
||||
public class AssignmentConfigDAO {
|
||||
@@ -23,28 +22,27 @@ public class AssignmentConfigDAO {
|
||||
private AssignmentConfigMapper assignmentConfigMapper;
|
||||
|
||||
public void insert(AssignmentConfigEntity assignmentConfigEntity) {
|
||||
assignmentConfigMapper.insertSelective(assignmentConfigEntity);
|
||||
assignmentConfigMapper.insert(assignmentConfigEntity);
|
||||
}
|
||||
|
||||
public AssignmentConfigEntity getById(Long id) {
|
||||
return assignmentConfigMapper.selectByPrimaryKey(id);
|
||||
return assignmentConfigMapper.selectById(id);
|
||||
}
|
||||
|
||||
public AssignmentConfigEntity getByAssignmentTaskId(Long assignmentId) {
|
||||
AssignmentConfigEntity record = new AssignmentConfigEntity();
|
||||
record.setAssignmentId(assignmentId);
|
||||
return assignmentConfigMapper.selectOne(record);
|
||||
public AssignmentConfigEntity getByAssignmentTaskId(Long taskId) {
|
||||
QueryWrapper<AssignmentConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AssignmentConfigEntity::getAssignmentId, taskId);
|
||||
return assignmentConfigMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
public void updateSelective(AssignmentConfigEntity assignmentConfigEntity) {
|
||||
assignmentConfigMapper.updateByPrimaryKeySelective(assignmentConfigEntity);
|
||||
assignmentConfigMapper.updateById(assignmentConfigEntity);
|
||||
}
|
||||
|
||||
public void deleteByAssignmentTaskId(Long taskId) {
|
||||
Example example = Example.builder(AssignmentConfigEntity.class)
|
||||
.andWhere(Sqls.custom().andEqualTo("assignmentId", taskId))
|
||||
.build();
|
||||
assignmentConfigMapper.deleteByExample(example);
|
||||
QueryWrapper<AssignmentConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AssignmentConfigEntity::getAssignmentId, taskId);
|
||||
assignmentConfigMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,17 +9,15 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentJobEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.AssignmentJobMapper;
|
||||
import com.gitee.dbswitch.admin.model.ops.OpsTaskJobTrend;
|
||||
import com.gitee.dbswitch.admin.type.JobStatusEnum;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.util.Sqls;
|
||||
|
||||
@Repository
|
||||
public class AssignmentJobDAO {
|
||||
@@ -36,42 +34,33 @@ public class AssignmentJobDAO {
|
||||
assignmentJobEntity.setStartTime(new Timestamp(System.currentTimeMillis()));
|
||||
assignmentJobEntity.setFinishTime(new Timestamp(System.currentTimeMillis()));
|
||||
assignmentJobEntity.setStatus(JobStatusEnum.RUNNING.getValue());
|
||||
assignmentJobMapper.insertSelective(assignmentJobEntity);
|
||||
assignmentJobMapper.insert(assignmentJobEntity);
|
||||
return assignmentJobEntity;
|
||||
}
|
||||
|
||||
public AssignmentJobEntity getById(Long id) {
|
||||
return assignmentJobMapper.selectByPrimaryKey(id);
|
||||
return assignmentJobMapper.selectById(id);
|
||||
}
|
||||
|
||||
public List<AssignmentJobEntity> getByAssignmentId(Long assignmentId) {
|
||||
Objects.requireNonNull(assignmentId, "assignmentId不能为null");
|
||||
|
||||
AssignmentJobEntity condition = new AssignmentJobEntity();
|
||||
condition.setAssignmentId(assignmentId);
|
||||
|
||||
Example example = new Example(AssignmentJobEntity.class);
|
||||
example.createCriteria().andEqualTo(condition);
|
||||
example.orderBy("createTime").desc();
|
||||
return assignmentJobMapper.selectByExample(example);
|
||||
QueryWrapper<AssignmentJobEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AssignmentJobEntity::getAssignmentId, assignmentId)
|
||||
.orderByDesc(AssignmentJobEntity::getCreateTime);
|
||||
return assignmentJobMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public void updateSelective(AssignmentJobEntity assignmentJobEntity) {
|
||||
Objects.requireNonNull(assignmentJobEntity.getId(), "AssignmentJob的id不能为null");
|
||||
assignmentJobMapper.updateByPrimaryKeySelective(assignmentJobEntity);
|
||||
assignmentJobMapper.updateById(assignmentJobEntity);
|
||||
}
|
||||
|
||||
public int getCountByStatus(JobStatusEnum status) {
|
||||
AssignmentJobEntity condition = new AssignmentJobEntity();
|
||||
condition.setStatus(status.getValue());
|
||||
|
||||
Example example = new Example(AssignmentJobEntity.class);
|
||||
example.createCriteria().andEqualTo(condition);
|
||||
return assignmentJobMapper.selectCountByExample(example);
|
||||
QueryWrapper<AssignmentJobEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AssignmentJobEntity::getStatus, status);
|
||||
return assignmentJobMapper.selectCount(queryWrapper).intValue();
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return assignmentJobMapper.selectCountByExample(null);
|
||||
return assignmentJobMapper.selectCount(null).intValue();
|
||||
}
|
||||
|
||||
public List<OpsTaskJobTrend> queryTaskJobTrend(Integer days) {
|
||||
@@ -84,10 +73,9 @@ public class AssignmentJobDAO {
|
||||
if (JobStatusEnum.FAIL.equals(targetStatus)) {
|
||||
updateSet.setErrorLog(errorLog);
|
||||
}
|
||||
Example condition = Example.builder(AssignmentJobEntity.class)
|
||||
.where(Sqls.custom().andEqualTo("status", originalStatus.getValue()))
|
||||
.build();
|
||||
assignmentJobMapper.updateByExampleSelective(updateSet, condition);
|
||||
QueryWrapper<AssignmentJobEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AssignmentJobEntity::getStatus, originalStatus.getValue());
|
||||
assignmentJobMapper.update(updateSet, queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,16 +9,14 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentTaskEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.AssignmentTaskMapper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.util.StringUtils;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.entity.Example.Criteria;
|
||||
|
||||
@Repository
|
||||
public class AssignmentTaskDAO {
|
||||
@@ -27,43 +25,37 @@ public class AssignmentTaskDAO {
|
||||
private AssignmentTaskMapper assignmentTaskMapper;
|
||||
|
||||
public void insert(AssignmentTaskEntity assignment) {
|
||||
assignmentTaskMapper.insertSelective(assignment);
|
||||
assignmentTaskMapper.insert(assignment);
|
||||
}
|
||||
|
||||
public void updateById(AssignmentTaskEntity assignment) {
|
||||
assignmentTaskMapper.updateByPrimaryKeySelective(assignment);
|
||||
assignmentTaskMapper.updateById(assignment);
|
||||
}
|
||||
|
||||
public List<AssignmentTaskEntity> listAll(String searchText) {
|
||||
Example example = new Example(AssignmentTaskEntity.class);
|
||||
if (!StringUtils.isEmpty(searchText)) {
|
||||
Criteria criteria = example.createCriteria();
|
||||
criteria.andLike("name", "%" + searchText + "%");
|
||||
}
|
||||
example.orderBy("createTime").desc();
|
||||
return assignmentTaskMapper.selectByExample(example);
|
||||
return assignmentTaskMapper.selectList(
|
||||
Wrappers.<AssignmentTaskEntity>lambdaQuery()
|
||||
.like(StringUtils.hasText(searchText), AssignmentTaskEntity::getName, searchText)
|
||||
.orderByDesc(AssignmentTaskEntity::getCreateTime)
|
||||
);
|
||||
}
|
||||
|
||||
public AssignmentTaskEntity getById(Long id) {
|
||||
return assignmentTaskMapper.selectByPrimaryKey(id);
|
||||
return assignmentTaskMapper.selectById(id);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
assignmentTaskMapper.deleteByPrimaryKey(id);
|
||||
assignmentTaskMapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return Optional.ofNullable(assignmentTaskMapper.selectAll())
|
||||
.orElseGet(ArrayList::new).size();
|
||||
return assignmentTaskMapper.selectList(null).size();
|
||||
}
|
||||
|
||||
public int getPublishedCount() {
|
||||
AssignmentTaskEntity condition = new AssignmentTaskEntity();
|
||||
condition.setPublished(Boolean.TRUE);
|
||||
|
||||
Example example = new Example(AssignmentTaskEntity.class);
|
||||
example.createCriteria().andEqualTo(condition);
|
||||
return assignmentTaskMapper.selectCountByExample(example);
|
||||
QueryWrapper<AssignmentTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AssignmentTaskEntity::getPublished, Boolean.TRUE);
|
||||
return assignmentTaskMapper.selectCount(queryWrapper).intValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,14 +9,14 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.gitee.dbswitch.admin.entity.DatabaseConnectionEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.DatabaseConnectionMapper;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.util.StringUtils;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.entity.Example.Criteria;
|
||||
|
||||
@Repository
|
||||
public class DatabaseConnectionDAO {
|
||||
@@ -25,39 +25,37 @@ public class DatabaseConnectionDAO {
|
||||
private DatabaseConnectionMapper databaseConnectionMapper;
|
||||
|
||||
public void insert(DatabaseConnectionEntity databaseConnectionEntity) {
|
||||
databaseConnectionMapper.insertSelective(databaseConnectionEntity);
|
||||
databaseConnectionMapper.insert(databaseConnectionEntity);
|
||||
}
|
||||
|
||||
public DatabaseConnectionEntity getById(Long id) {
|
||||
return databaseConnectionMapper.selectByPrimaryKey(id);
|
||||
return databaseConnectionMapper.selectById(id);
|
||||
}
|
||||
|
||||
public DatabaseConnectionEntity getByName(String name) {
|
||||
DatabaseConnectionEntity record = new DatabaseConnectionEntity();
|
||||
record.setName(name);
|
||||
return databaseConnectionMapper.selectOne(record);
|
||||
QueryWrapper<DatabaseConnectionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(DatabaseConnectionEntity::getName, name);
|
||||
return databaseConnectionMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
public List<DatabaseConnectionEntity> listAll(String searchText) {
|
||||
Example example = new Example(DatabaseConnectionEntity.class);
|
||||
if (!StringUtils.isEmpty(searchText)) {
|
||||
Criteria criteria = example.createCriteria();
|
||||
criteria.andLike("name", "%" + searchText + "%");
|
||||
}
|
||||
example.orderBy("createTime").desc();
|
||||
return databaseConnectionMapper.selectByExample(example);
|
||||
return databaseConnectionMapper.selectList(
|
||||
Wrappers.<DatabaseConnectionEntity>lambdaQuery()
|
||||
.like(StringUtils.hasText(searchText), DatabaseConnectionEntity::getName, searchText)
|
||||
.orderByDesc(DatabaseConnectionEntity::getCreateTime)
|
||||
);
|
||||
}
|
||||
|
||||
public void updateById(DatabaseConnectionEntity databaseConnectionEntity) {
|
||||
databaseConnectionMapper.updateByPrimaryKeySelective(databaseConnectionEntity);
|
||||
databaseConnectionMapper.updateById(databaseConnectionEntity);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
databaseConnectionMapper.deleteByPrimaryKey(id);
|
||||
databaseConnectionMapper.deleteById(id);
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return databaseConnectionMapper.selectCount(null);
|
||||
return databaseConnectionMapper.selectCount(null).intValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.gitee.dbswitch.admin.entity.JobLogbackEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.JobLogbackMapper;
|
||||
import java.util.Collections;
|
||||
@@ -16,8 +17,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.util.Sqls;
|
||||
|
||||
@Repository
|
||||
public class JobLogbackDAO {
|
||||
@@ -26,26 +25,28 @@ public class JobLogbackDAO {
|
||||
private JobLogbackMapper jobLogbackMapper;
|
||||
|
||||
public void insert(String uuid, String content) {
|
||||
jobLogbackMapper.insertSelective(JobLogbackEntity.builder().uuid(uuid).content(content).build());
|
||||
jobLogbackMapper.insert(JobLogbackEntity.builder().uuid(uuid).content(content).build());
|
||||
}
|
||||
|
||||
public List<JobLogbackEntity> getTailByUuid(String uuid) {
|
||||
Example example = Example.builder(JobLogbackEntity.class)
|
||||
.select("id", "content")
|
||||
.andWhere(Sqls.custom().andEqualTo("uuid", uuid))
|
||||
.orderByDesc("id")
|
||||
.build();
|
||||
List<JobLogbackEntity> result = jobLogbackMapper.selectByExample(example);
|
||||
List<JobLogbackEntity> result = jobLogbackMapper.selectList(
|
||||
Wrappers.<JobLogbackEntity>lambdaQuery()
|
||||
.select(JobLogbackEntity::getId, JobLogbackEntity::getContent)
|
||||
.eq(JobLogbackEntity::getUuid, uuid)
|
||||
.orderByDesc(JobLogbackEntity::getId)
|
||||
);
|
||||
Collections.reverse(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<JobLogbackEntity> getNextByUuid(String uuid, Long baseId) {
|
||||
Example example = Example.builder(JobLogbackEntity.class)
|
||||
.select("id", "content")
|
||||
.andWhere(Sqls.custom().andGreaterThan("id", baseId).andEqualTo("uuid", uuid))
|
||||
.build();
|
||||
return jobLogbackMapper.selectByExample(example);
|
||||
return jobLogbackMapper.selectList(
|
||||
Wrappers.<JobLogbackEntity>lambdaQuery()
|
||||
.select(JobLogbackEntity::getId, JobLogbackEntity::getContent)
|
||||
.eq(JobLogbackEntity::getUuid, uuid)
|
||||
.gt(JobLogbackEntity::getId, baseId)
|
||||
.orderByAsc(JobLogbackEntity::getId)
|
||||
);
|
||||
}
|
||||
|
||||
public void deleteOldest(Integer days) {
|
||||
|
@@ -9,14 +9,13 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gitee.dbswitch.admin.entity.SystemLogEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.SystemLogMapper;
|
||||
import com.gitee.dbswitch.admin.type.LogTypeEnum;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.entity.Example.Criteria;
|
||||
|
||||
@Repository
|
||||
public class SystemLogDAO {
|
||||
@@ -25,23 +24,18 @@ public class SystemLogDAO {
|
||||
private SystemLogMapper systemLogMapper;
|
||||
|
||||
public void insert(SystemLogEntity systemLogEntity) {
|
||||
systemLogMapper.insertSelective(systemLogEntity);
|
||||
systemLogMapper.insert(systemLogEntity);
|
||||
}
|
||||
|
||||
public List<SystemLogEntity> listAll(LogTypeEnum logType) {
|
||||
Example example = new Example(SystemLogEntity.class);
|
||||
Criteria criteria = example.createCriteria();
|
||||
|
||||
SystemLogEntity condition = new SystemLogEntity();
|
||||
condition.setType(logType.getValue());
|
||||
|
||||
criteria.andEqualTo(condition);
|
||||
example.orderBy("createTime").desc();
|
||||
return systemLogMapper.selectByExample(example);
|
||||
QueryWrapper<SystemLogEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SystemLogEntity::getType, logType.getValue())
|
||||
.orderByDesc(SystemLogEntity::getCreateTime);
|
||||
return systemLogMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public SystemLogEntity getById(Long id) {
|
||||
return systemLogMapper.selectByPrimaryKey(id);
|
||||
return systemLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,13 +9,12 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gitee.dbswitch.admin.entity.SystemUserEntity;
|
||||
import com.gitee.dbswitch.admin.mapper.SystemUserMapper;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
import tk.mybatis.mapper.util.Sqls;
|
||||
|
||||
@Repository
|
||||
public class SystemUserDAO {
|
||||
@@ -24,25 +23,20 @@ public class SystemUserDAO {
|
||||
private SystemUserMapper systemUserMapper;
|
||||
|
||||
public SystemUserEntity getById(Long id) {
|
||||
return systemUserMapper.selectByPrimaryKey(id);
|
||||
return systemUserMapper.selectById(id);
|
||||
}
|
||||
|
||||
public SystemUserEntity findByUsername(String username) {
|
||||
return systemUserMapper.selectOneByExample(
|
||||
Example.builder(SystemUserEntity.class)
|
||||
.where(
|
||||
Sqls.custom()
|
||||
.andEqualTo("username", username)
|
||||
)
|
||||
.build()
|
||||
);
|
||||
QueryWrapper<SystemUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SystemUserEntity::getUsername, username);
|
||||
return systemUserMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
public void updateUserPassword(String username, String newPassword) {
|
||||
SystemUserEntity userEntity = findByUsername(username);
|
||||
if (Objects.nonNull(userEntity)) {
|
||||
userEntity.setPassword(newPassword);
|
||||
systemUserMapper.updateByPrimaryKeySelective(userEntity);
|
||||
systemUserMapper.updateById(userEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,84 +9,81 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.gitee.dbswitch.admin.handler.ListPatternHandler;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.gitee.dbswitch.admin.handler.ListTypeHandler;
|
||||
import com.gitee.dbswitch.common.entity.PatternMapper;
|
||||
import com.gitee.dbswitch.common.type.CaseConvertEnum;
|
||||
import com.gitee.dbswitch.common.type.ProductTableEnum;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.ColumnType;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import org.apache.ibatis.type.EnumTypeHandler;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_ASSIGNMENT_CONFIG")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_ASSIGNMENT_CONFIG")
|
||||
public class AssignmentConfigEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "assignment_id")
|
||||
@TableField("assignment_id")
|
||||
private Long assignmentId;
|
||||
|
||||
@Column(name = "source_connection_id")
|
||||
@TableField("source_connection_id")
|
||||
private Long sourceConnectionId;
|
||||
|
||||
@Column(name = "source_schema")
|
||||
@TableField("source_schema")
|
||||
private String sourceSchema;
|
||||
|
||||
@Column(name = "table_type")
|
||||
@TableField(value = "table_type", typeHandler = EnumTypeHandler.class)
|
||||
private ProductTableEnum tableType;
|
||||
|
||||
@Column(name = "source_tables")
|
||||
@ColumnType(typeHandler = ListTypeHandler.class)
|
||||
@TableField(value = "source_tables", typeHandler = ListTypeHandler.class)
|
||||
private List<String> sourceTables;
|
||||
|
||||
@Column(name = "excluded")
|
||||
@TableField("excluded")
|
||||
private Boolean excluded;
|
||||
|
||||
@Column(name = "target_connection_id")
|
||||
@TableField("target_connection_id")
|
||||
private Long targetConnectionId;
|
||||
|
||||
@Column(name = "target_schema")
|
||||
@TableField("target_schema")
|
||||
private String targetSchema;
|
||||
|
||||
@Column(name = "table_name_case")
|
||||
@TableField(value = "table_name_case", typeHandler = EnumTypeHandler.class)
|
||||
private CaseConvertEnum tableNameCase;
|
||||
|
||||
@Column(name = "column_name_case")
|
||||
@TableField(value = "column_name_case", typeHandler = EnumTypeHandler.class)
|
||||
private CaseConvertEnum columnNameCase;
|
||||
|
||||
@Column(name = "table_name_map")
|
||||
@ColumnType(typeHandler = ListPatternHandler.class)
|
||||
@TableField(value = "table_name_map")
|
||||
private List<PatternMapper> tableNameMap;
|
||||
|
||||
@Column(name = "column_name_map")
|
||||
@ColumnType(typeHandler = ListPatternHandler.class)
|
||||
@TableField(value = "column_name_map")
|
||||
private List<PatternMapper> columnNameMap;
|
||||
|
||||
@Column(name = "target_drop_table")
|
||||
@TableField("target_drop_table")
|
||||
private Boolean targetDropTable;
|
||||
|
||||
@Column(name = "target_only_create")
|
||||
@TableField("target_only_create")
|
||||
private Boolean targetOnlyCreate;
|
||||
|
||||
@Column(name = "batch_size")
|
||||
@TableField("batch_size")
|
||||
private Integer batchSize;
|
||||
|
||||
@Column(name = "first_flag")
|
||||
@TableField("first_flag")
|
||||
private Boolean firstFlag;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
}
|
||||
|
@@ -9,50 +9,51 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.sql.Timestamp;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_ASSIGNMENT_JOB")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_ASSIGNMENT_JOB")
|
||||
public class AssignmentJobEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "assignment_id")
|
||||
@TableField("assignment_id")
|
||||
private Long assignmentId;
|
||||
|
||||
@Column(name = "job_key")
|
||||
@TableField("job_key")
|
||||
private String jobKey;
|
||||
|
||||
@Column(name = "schedule_mode")
|
||||
@TableField("schedule_mode")
|
||||
private Integer scheduleMode;
|
||||
|
||||
@Column(name = "start_time")
|
||||
@TableField("start_time")
|
||||
private Timestamp startTime;
|
||||
|
||||
@Column(name = "finish_time")
|
||||
@TableField("finish_time")
|
||||
private Timestamp finishTime;
|
||||
|
||||
@Column(name = "status")
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "error_log")
|
||||
@TableField("error_log")
|
||||
private String errorLog;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "update_time", insertable = false, updatable = false)
|
||||
@TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp updateTime;
|
||||
}
|
||||
|
@@ -9,51 +9,53 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.gitee.dbswitch.admin.type.ScheduleModeEnum;
|
||||
import java.sql.Timestamp;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import org.apache.ibatis.type.EnumTypeHandler;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_ASSIGNMENT_TASK")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_ASSIGNMENT_TASK")
|
||||
public class AssignmentTaskEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "name")
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "description")
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "schedule_mode")
|
||||
@TableField(value = "schedule_mode", typeHandler = EnumTypeHandler.class)
|
||||
private ScheduleModeEnum scheduleMode;
|
||||
|
||||
@Column(name = "cron_expression")
|
||||
@TableField("cron_expression")
|
||||
private String cronExpression;
|
||||
|
||||
@Column(name = "published")
|
||||
@TableField("published")
|
||||
private Boolean published;
|
||||
|
||||
@Column(name = "content")
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
@Column(name = "job_key")
|
||||
@TableField("job_key")
|
||||
private String jobKey;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "update_time", insertable = false, updatable = false)
|
||||
@TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp updateTime;
|
||||
}
|
||||
|
@@ -9,53 +9,53 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||
import java.sql.Timestamp;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import org.apache.ibatis.type.EnumTypeHandler;
|
||||
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_DATABASE_CONNECTION")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_DATABASE_CONNECTION")
|
||||
public class DatabaseConnectionEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "name")
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "type")
|
||||
@TableField(value = "type", typeHandler = EnumTypeHandler.class)
|
||||
private ProductTypeEnum type;
|
||||
|
||||
@Column(name = "version")
|
||||
@TableField("version")
|
||||
private String version;
|
||||
|
||||
@Column(name = "driver")
|
||||
@TableField("driver")
|
||||
private String driver;
|
||||
|
||||
@Column(name = "url")
|
||||
@TableField("url")
|
||||
private String url;
|
||||
|
||||
@Column(name = "username")
|
||||
@TableField("username")
|
||||
private String username;
|
||||
|
||||
@Column(name = "password")
|
||||
@TableField("password")
|
||||
private String password;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "update_time", insertable = false, updatable = false)
|
||||
@TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp updateTime;
|
||||
}
|
||||
|
@@ -9,34 +9,33 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.sql.Timestamp;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_JOB_LOGBACK")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_JOB_LOGBACK")
|
||||
public class JobLogbackEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "uuid")
|
||||
@TableField("uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name = "content")
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
}
|
||||
|
@@ -9,58 +9,57 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.sql.Timestamp;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_SYSTEM_LOG")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_SYSTEM_LOG")
|
||||
public class SystemLogEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "type")
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
|
||||
@Column(name = "username")
|
||||
@TableField("username")
|
||||
private String username;
|
||||
|
||||
@Column(name = "ip_address")
|
||||
@TableField("ip_address")
|
||||
private String ipAddress;
|
||||
|
||||
@Column(name = "module_name")
|
||||
@TableField("module_name")
|
||||
private String moduleName;
|
||||
|
||||
@Column(name = "content")
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
@Column(name = "url_path")
|
||||
@TableField("url_path")
|
||||
private String urlPath;
|
||||
|
||||
@Column(name = "user_agent")
|
||||
@TableField("user_agent")
|
||||
private String userAgent;
|
||||
|
||||
@Column(name = "failed")
|
||||
@TableField("failed")
|
||||
private Boolean failed;
|
||||
|
||||
@Column(name = "exception")
|
||||
@TableField("exception")
|
||||
private String exception;
|
||||
|
||||
@Column(name = "elapse_seconds")
|
||||
@TableField("elapse_seconds")
|
||||
private Long elapseSeconds;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
}
|
||||
|
@@ -9,53 +9,52 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.sql.Timestamp;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "DBSWITCH_SYSTEM_USER")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("DBSWITCH_SYSTEM_USER")
|
||||
public class SystemUserEntity {
|
||||
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
@Column(name = "id", insertable = false, updatable = false)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "username")
|
||||
@TableField("username")
|
||||
private String username;
|
||||
|
||||
@Column(name = "password")
|
||||
@TableField("password")
|
||||
private String password;
|
||||
|
||||
@Column(name = "salt")
|
||||
@TableField("salt")
|
||||
private String salt;
|
||||
|
||||
@Column(name = "real_name")
|
||||
@TableField("real_name")
|
||||
private String realName;
|
||||
|
||||
@Column(name = "email")
|
||||
@TableField("email")
|
||||
private String email;
|
||||
|
||||
@Column(name = "address")
|
||||
@TableField("address")
|
||||
private String address;
|
||||
|
||||
@Column(name = "locked")
|
||||
@TableField("locked")
|
||||
private Boolean locked;
|
||||
|
||||
@Column(name = "create_time", insertable = false, updatable = false)
|
||||
@TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "update_time", insertable = false, updatable = false)
|
||||
@TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||
private Timestamp updateTime;
|
||||
|
||||
}
|
||||
|
@@ -10,8 +10,8 @@
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentConfigEntity;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface AssignmentConfigMapper extends Mapper<AssignmentConfigEntity> {
|
||||
public interface AssignmentConfigMapper extends BaseMapper<AssignmentConfigEntity> {
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentJobEntity;
|
||||
import com.gitee.dbswitch.admin.model.ops.OpsTaskJobTrend;
|
||||
import java.util.List;
|
||||
@@ -16,9 +17,8 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface AssignmentJobMapper extends Mapper<AssignmentJobEntity> {
|
||||
public interface AssignmentJobMapper extends BaseMapper<AssignmentJobEntity> {
|
||||
|
||||
@Select("<script>"
|
||||
+ "<if test='_databaseId == \"mysql\" '>"
|
||||
|
@@ -9,9 +9,9 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitee.dbswitch.admin.entity.AssignmentTaskEntity;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface AssignmentTaskMapper extends Mapper<AssignmentTaskEntity> {
|
||||
public interface AssignmentTaskMapper extends BaseMapper<AssignmentTaskEntity> {
|
||||
|
||||
}
|
||||
|
@@ -9,9 +9,9 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitee.dbswitch.admin.entity.DatabaseConnectionEntity;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface DatabaseConnectionMapper extends Mapper<DatabaseConnectionEntity> {
|
||||
public interface DatabaseConnectionMapper extends BaseMapper<DatabaseConnectionEntity> {
|
||||
|
||||
}
|
||||
|
@@ -9,12 +9,12 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitee.dbswitch.admin.entity.JobLogbackEntity;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface JobLogbackMapper extends Mapper<JobLogbackEntity> {
|
||||
public interface JobLogbackMapper extends BaseMapper<JobLogbackEntity> {
|
||||
|
||||
@Delete("<script>"
|
||||
+ "<if test='_databaseId == \"mysql\" '>"
|
||||
|
@@ -9,9 +9,9 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitee.dbswitch.admin.entity.SystemLogEntity;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface SystemLogMapper extends Mapper<SystemLogEntity> {
|
||||
public interface SystemLogMapper extends BaseMapper<SystemLogEntity> {
|
||||
|
||||
}
|
||||
|
@@ -9,9 +9,9 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gitee.dbswitch.admin.entity.SystemUserEntity;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface SystemUserMapper extends Mapper<SystemUserEntity> {
|
||||
public interface SystemUserMapper extends BaseMapper<SystemUserEntity> {
|
||||
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.service;
|
||||
|
||||
import com.gitee.dbswitch.common.converter.ConverterFactory;
|
||||
import com.gitee.dbswitch.admin.common.response.PageResult;
|
||||
import com.gitee.dbswitch.admin.common.response.Result;
|
||||
import com.gitee.dbswitch.admin.common.response.ResultCode;
|
||||
@@ -19,6 +18,7 @@ import com.gitee.dbswitch.admin.entity.SystemLogEntity;
|
||||
import com.gitee.dbswitch.admin.model.response.SystemLogDetailResponse;
|
||||
import com.gitee.dbswitch.admin.type.LogTypeEnum;
|
||||
import com.gitee.dbswitch.admin.util.PageUtils;
|
||||
import com.gitee.dbswitch.common.converter.ConverterFactory;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
@@ -8,7 +8,7 @@ spring:
|
||||
uri-encoding: UTF-8
|
||||
max-http-header-size: 8096
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
throw-exception-if-no-handler-found: false
|
||||
static-path-pattern: /statics/**
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
@@ -30,10 +30,6 @@ mybatis:
|
||||
map-underscore-to-camel-case: true
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
mapper:
|
||||
wrap-keyword: "`{0}`"
|
||||
enable-method-annotation: true
|
||||
|
||||
dbswitch:
|
||||
configuration:
|
||||
drivers-base-path: ${APP_DRIVERS_PATH}
|
||||
|
@@ -8,7 +8,7 @@ spring:
|
||||
uri-encoding: UTF-8
|
||||
max-http-header-size: 8096
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
throw-exception-if-no-handler-found: false
|
||||
static-path-pattern: /statics/**
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
@@ -30,10 +30,6 @@ mybatis:
|
||||
map-underscore-to-camel-case: true
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
mapper:
|
||||
wrap-keyword: "`{0}`"
|
||||
enable-method-annotation: true
|
||||
|
||||
dbswitch:
|
||||
configuration:
|
||||
drivers-base-path: ${APP_DRIVERS_PATH}
|
||||
|
@@ -8,7 +8,7 @@ spring:
|
||||
uri-encoding: UTF-8
|
||||
max-http-header-size: 8096
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
throw-exception-if-no-handler-found: false
|
||||
static-path-pattern: /statics/**
|
||||
datasource:
|
||||
driver-class-name: org.postgresql.Driver
|
||||
@@ -30,10 +30,6 @@ mybatis:
|
||||
map-underscore-to-camel-case: true
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
mapper:
|
||||
wrap-keyword: "\"{0}\""
|
||||
enable-method-annotation: true
|
||||
|
||||
dbswitch:
|
||||
configuration:
|
||||
drivers-base-path: ${APP_DRIVERS_PATH}
|
||||
|
@@ -284,7 +284,7 @@ public class ClickhouseMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
}
|
||||
|
||||
if (withRemarks && StringUtils.isNotBlank(v.getRemarks())) {
|
||||
retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", "\\'"));
|
||||
retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", ""));
|
||||
}
|
||||
|
||||
if (addCr) {
|
||||
|
@@ -220,7 +220,7 @@ public class DB2MetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(),
|
||||
td.getRemarks().replace("\"", "\\\"")));
|
||||
td.getRemarks().replace("'", "")));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -228,7 +228,7 @@ public class DB2MetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(), cd.getFieldName(),
|
||||
cd.getRemarks().replace("\"", "\\\"")));
|
||||
cd.getRemarks().replace("'", "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -180,7 +180,7 @@ public class DmMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(),
|
||||
td.getRemarks().replace("\"", "\\\"")));
|
||||
td.getRemarks().replace("'", "")));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -188,7 +188,7 @@ public class DmMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(), cd.getFieldName(),
|
||||
cd.getRemarks().replace("\"", "\\\"")));
|
||||
cd.getRemarks().replace("'", "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -154,7 +154,7 @@ public class HiveMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
}
|
||||
|
||||
if (withRemarks && StringUtils.isNotBlank(v.getRemarks())) {
|
||||
retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", "\\'"));
|
||||
retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", ""));
|
||||
}
|
||||
|
||||
if (addCr) {
|
||||
|
@@ -187,7 +187,7 @@ public class KingbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(),
|
||||
td.getRemarks().replace("\"", "\\\"")));
|
||||
td.getRemarks().replace("'", "")));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -195,7 +195,7 @@ public class KingbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(), cd.getFieldName(),
|
||||
cd.getRemarks().replace("\"", "\\\"")));
|
||||
cd.getRemarks().replace("'", "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,8 @@ public class MysqlMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
private static final String QUERY_TABLE_LIST_SQL =
|
||||
"SELECT `TABLE_SCHEMA`,`TABLE_NAME`,`TABLE_TYPE`,`TABLE_COMMENT` "
|
||||
+ "FROM `information_schema`.`TABLES` where `TABLE_SCHEMA`= ? ";
|
||||
private static final String QUERY_TABLE_COMMENT_SQL =
|
||||
"SELECT TABLE_COMMENT from information_schema.`TABLES` where TABLE_SCHEMA = ? and TABLE_NAME = ?";
|
||||
|
||||
public MysqlMetadataQueryProvider(ProductFactoryProvider factoryProvider) {
|
||||
super(factoryProvider);
|
||||
@@ -85,17 +87,20 @@ public class MysqlMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
|
||||
@Override
|
||||
public TableDescription queryTableMeta(Connection connection, String schemaName, String tableName) {
|
||||
try (ResultSet tables = connection.getMetaData()
|
||||
.getTables(schemaName, null, tableName, new String[]{"TABLE"})) {
|
||||
while (tables.next()) {
|
||||
TableDescription td = new TableDescription();
|
||||
td.setSchemaName(schemaName);
|
||||
td.setTableName(tableName);
|
||||
td.setRemarks(tables.getString("REMARKS"));
|
||||
td.setTableType(tables.getString("TABLE_TYPE").toUpperCase());
|
||||
return td;
|
||||
try (PreparedStatement ps = connection.prepareStatement(QUERY_TABLE_COMMENT_SQL)) {
|
||||
ps.setString(1, schemaName);
|
||||
ps.setString(2, tableName);
|
||||
try (ResultSet rs = ps.executeQuery();) {
|
||||
while (rs.next()) {
|
||||
TableDescription td = new TableDescription();
|
||||
td.setSchemaName(schemaName);
|
||||
td.setTableName(tableName);
|
||||
td.setRemarks(rs.getString(1));
|
||||
td.setTableType("TABLE");
|
||||
return td;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -115,6 +120,32 @@ public class MysqlMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ColumnDescription> queryTableColumnMeta(Connection connection, String schemaName,
|
||||
String tableName) {
|
||||
String sql = this.getTableFieldsQuerySQL(schemaName, tableName);
|
||||
List<ColumnDescription> ret = this.querySelectSqlColumnMeta(connection, sql);
|
||||
|
||||
// 补充一下注释信息
|
||||
try (ResultSet columns = connection.getMetaData()
|
||||
.getColumns(schemaName, null, tableName, null)) {
|
||||
while (columns.next()) {
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
String remarks = columns.getString("REMARKS");
|
||||
for (ColumnDescription cd : ret) {
|
||||
if (columnName.equals(cd.getFieldName())) {
|
||||
cd.setRemarks(remarks);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> queryTablePrimaryKeys(Connection connection, String schemaName, String tableName) {
|
||||
List<String> ret = new ArrayList<>();
|
||||
|
@@ -225,7 +225,7 @@ public class OracleMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(),
|
||||
td.getRemarks().replace("\"", "\\\"")));
|
||||
td.getRemarks().replace("'", "")));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -233,7 +233,7 @@ public class OracleMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(), cd.getFieldName(),
|
||||
cd.getRemarks().replace("\"", "\\\"")));
|
||||
cd.getRemarks().replace("'", "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -190,7 +190,7 @@ public class OscarMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(),
|
||||
td.getRemarks().replace("\"", "\\\"")));
|
||||
td.getRemarks().replace("'", "")));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -198,7 +198,7 @@ public class OscarMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(), cd.getFieldName(),
|
||||
cd.getRemarks().replace("\"", "\\\"")));
|
||||
cd.getRemarks().replace("'", "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -225,7 +225,7 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(),
|
||||
td.getRemarks().replace("\"", "\\\"")));
|
||||
td.getRemarks().replace("'", "")));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -233,7 +233,7 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
|
||||
td.getSchemaName(), td.getTableName(), cd.getFieldName(),
|
||||
cd.getRemarks().replace("\"", "\\\"")));
|
||||
cd.getRemarks().replace("'", "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -312,7 +312,7 @@ public class SqlserverMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format(
|
||||
"EXEC [sys].sp_addextendedproperty 'MS_Description', N'%s', 'schema', N'%s', 'table', N'%s' ",
|
||||
td.getRemarks().replace("\"", "\\\""), td.getSchemaName(), td.getTableName()));
|
||||
td.getRemarks().replace("'", ""), td.getSchemaName(), td.getTableName()));
|
||||
}
|
||||
|
||||
for (ColumnDescription cd : cds) {
|
||||
@@ -320,7 +320,7 @@ public class SqlserverMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
results.add(String
|
||||
.format(
|
||||
"EXEC [sys].sp_addextendedproperty 'MS_Description', N'%s', 'schema', N'%s', 'table', N'%s', 'column', N'%s' ",
|
||||
cd.getRemarks().replace("\"", "\\\""), td.getSchemaName(), td.getTableName(),
|
||||
cd.getRemarks().replace("'", ""), td.getSchemaName(), td.getTableName(),
|
||||
cd.getFieldName()));
|
||||
}
|
||||
}
|
||||
|
6
pom.xml
6
pom.xml
@@ -99,9 +99,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||
<version>4.2.1</version>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
Reference in New Issue
Block a user