后端代码优化

This commit is contained in:
inrgihc
2023-11-14 21:43:13 +08:00
parent 7ba2c26e4b
commit f90c2a13a5
46 changed files with 328 additions and 380 deletions

View File

@@ -419,7 +419,7 @@ spring:
uri-encoding: UTF-8 uri-encoding: UTF-8
max-http-header-size: 8096 max-http-header-size: 8096
mvc: mvc:
throw-exception-if-no-handler-found: true throw-exception-if-no-handler-found: false
static-path-pattern: /statics/** static-path-pattern: /statics/**
datasource: datasource:
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
@@ -441,10 +441,6 @@ mybatis:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper:
wrap-keyword: "`{0}`"
enable-method-annotation: true
dbswitch: dbswitch:
configuration: configuration:
# 驱动JAR文件所在的目录位置 # 驱动JAR文件所在的目录位置

View File

@@ -8,7 +8,7 @@ spring:
uri-encoding: UTF-8 uri-encoding: UTF-8
max-http-header-size: 8096 max-http-header-size: 8096
mvc: mvc:
throw-exception-if-no-handler-found: true throw-exception-if-no-handler-found: false
static-path-pattern: /statics/** static-path-pattern: /statics/**
datasource: datasource:
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
@@ -30,10 +30,6 @@ mybatis:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper:
wrap-keyword: "`{0}`"
enable-method-annotation: true
dbswitch: dbswitch:
configuration: configuration:
drivers-base-path: ${APP_DRIVERS_PATH} drivers-base-path: ${APP_DRIVERS_PATH}

View File

@@ -94,8 +94,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>com.baomidou</groupId>
<artifactId>mapper-spring-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -9,13 +9,14 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin; package com.gitee.dbswitch.admin;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.Banner; import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling @EnableScheduling
@tk.mybatis.spring.annotation.MapperScan("com.gitee.dbswitch.admin.mapper") @MapperScan({"com.gitee.dbswitch.admin.mapper"})
@SpringBootApplication @SpringBootApplication
public class AdminApplication { public class AdminApplication {

View File

@@ -10,7 +10,6 @@
package com.gitee.dbswitch.admin.controller.converter; package com.gitee.dbswitch.admin.controller.converter;
import cn.hutool.extra.spring.SpringUtil; 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.AssignmentConfigDAO;
import com.gitee.dbswitch.admin.dao.DatabaseConnectionDAO; import com.gitee.dbswitch.admin.dao.DatabaseConnectionDAO;
import com.gitee.dbswitch.admin.entity.AssignmentConfigEntity; 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.entity.DatabaseConnectionEntity;
import com.gitee.dbswitch.admin.model.response.AssignmentDetailResponse; import com.gitee.dbswitch.admin.model.response.AssignmentDetailResponse;
import com.gitee.dbswitch.admin.type.IncludeExcludeEnum; import com.gitee.dbswitch.admin.type.IncludeExcludeEnum;
import java.util.Objects; import com.gitee.dbswitch.common.converter.AbstractConverter;
public class AssignmentDetailConverter extends public class AssignmentDetailConverter extends
AbstractConverter<AssignmentTaskEntity, AssignmentDetailResponse> { AbstractConverter<AssignmentTaskEntity, AssignmentDetailResponse> {
@Override @Override
public AssignmentDetailResponse convert(AssignmentTaskEntity assignmentTaskEntity) { public AssignmentDetailResponse convert(AssignmentTaskEntity assignmentTaskEntity) {
if (Objects.isNull(assignmentTaskEntity)) {
return null;
}
DatabaseConnectionDAO databaseConnectionDAO = SpringUtil.getBean(DatabaseConnectionDAO.class); DatabaseConnectionDAO databaseConnectionDAO = SpringUtil.getBean(DatabaseConnectionDAO.class);
AssignmentConfigDAO assignmentConfigDAO = SpringUtil.getBean(AssignmentConfigDAO.class); AssignmentConfigDAO assignmentConfigDAO = SpringUtil.getBean(AssignmentConfigDAO.class);
AssignmentConfigEntity taskConfig = assignmentConfigDAO.getByAssignmentTaskId( AssignmentConfigEntity taskConfig = assignmentConfigDAO.getByAssignmentTaskId(

View File

@@ -9,9 +9,9 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.controller.converter; 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.entity.AssignmentTaskEntity;
import com.gitee.dbswitch.admin.model.response.AssignmentInfoResponse; import com.gitee.dbswitch.admin.model.response.AssignmentInfoResponse;
import com.gitee.dbswitch.common.converter.AbstractConverter;
public class AssignmentInfoConverter extends public class AssignmentInfoConverter extends
AbstractConverter<AssignmentTaskEntity, AssignmentInfoResponse> { AbstractConverter<AssignmentTaskEntity, AssignmentInfoResponse> {

View File

@@ -9,20 +9,15 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.controller.converter; 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.entity.DatabaseConnectionEntity;
import com.gitee.dbswitch.admin.model.response.DbConnectionDetailResponse; import com.gitee.dbswitch.admin.model.response.DbConnectionDetailResponse;
import java.util.Objects; import com.gitee.dbswitch.common.converter.AbstractConverter;
public class DbConnectionDetailConverter extends public class DbConnectionDetailConverter extends
AbstractConverter<DatabaseConnectionEntity, DbConnectionDetailResponse> { AbstractConverter<DatabaseConnectionEntity, DbConnectionDetailResponse> {
@Override @Override
public DbConnectionDetailResponse convert(DatabaseConnectionEntity databaseConnectionEntity) { public DbConnectionDetailResponse convert(DatabaseConnectionEntity databaseConnectionEntity) {
if (Objects.isNull(databaseConnectionEntity)) {
return null;
}
DbConnectionDetailResponse response = new DbConnectionDetailResponse(); DbConnectionDetailResponse response = new DbConnectionDetailResponse();
response.setId(databaseConnectionEntity.getId()); response.setId(databaseConnectionEntity.getId());
response.setName(databaseConnectionEntity.getName()); response.setName(databaseConnectionEntity.getName());

View File

@@ -9,20 +9,15 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.controller.converter; 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.entity.SystemLogEntity;
import com.gitee.dbswitch.admin.model.response.SystemLogDetailResponse; import com.gitee.dbswitch.admin.model.response.SystemLogDetailResponse;
import java.util.Objects; import com.gitee.dbswitch.common.converter.AbstractConverter;
public class SystemLogDetailConverter extends public class SystemLogDetailConverter extends
AbstractConverter<SystemLogEntity, SystemLogDetailResponse> { AbstractConverter<SystemLogEntity, SystemLogDetailResponse> {
@Override @Override
public SystemLogDetailResponse convert(SystemLogEntity systemLogEntity) { public SystemLogDetailResponse convert(SystemLogEntity systemLogEntity) {
if (Objects.isNull(systemLogEntity)) {
return null;
}
SystemLogDetailResponse response = new SystemLogDetailResponse(); SystemLogDetailResponse response = new SystemLogDetailResponse();
response.setId(systemLogEntity.getId()); response.setId(systemLogEntity.getId());
response.setUsername(systemLogEntity.getUsername()); response.setUsername(systemLogEntity.getUsername());

View File

@@ -9,20 +9,15 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.controller.converter; 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.entity.SystemUserEntity;
import com.gitee.dbswitch.admin.model.response.SystemUserDetailResponse; import com.gitee.dbswitch.admin.model.response.SystemUserDetailResponse;
import java.util.Objects; import com.gitee.dbswitch.common.converter.AbstractConverter;
public class SystemUserDetailConverter extends public class SystemUserDetailConverter extends
AbstractConverter<SystemUserEntity, SystemUserDetailResponse> { AbstractConverter<SystemUserEntity, SystemUserDetailResponse> {
@Override @Override
public SystemUserDetailResponse convert(SystemUserEntity user) { public SystemUserDetailResponse convert(SystemUserEntity user) {
if (Objects.isNull(user)) {
return null;
}
SystemUserDetailResponse response = new SystemUserDetailResponse(); SystemUserDetailResponse response = new SystemUserDetailResponse();
response.setId(user.getId()); response.setId(user.getId());
response.setUsername(user.getUsername()); response.setUsername(user.getUsername());

View File

@@ -9,23 +9,17 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.controller.converter; 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.entity.AssignmentJobEntity;
import com.gitee.dbswitch.admin.model.response.TaskJobDetailResponse; import com.gitee.dbswitch.admin.model.response.TaskJobDetailResponse;
import com.gitee.dbswitch.admin.type.JobStatusEnum; import com.gitee.dbswitch.admin.type.JobStatusEnum;
import com.gitee.dbswitch.admin.type.ScheduleModeEnum; import com.gitee.dbswitch.admin.type.ScheduleModeEnum;
import java.util.Objects; import com.gitee.dbswitch.common.converter.AbstractConverter;
public class TaskJobDetailConverter extends public class TaskJobDetailConverter extends
AbstractConverter<AssignmentJobEntity, TaskJobDetailResponse> { AbstractConverter<AssignmentJobEntity, TaskJobDetailResponse> {
@Override @Override
public TaskJobDetailResponse convert(AssignmentJobEntity assignmentJobEntity) { public TaskJobDetailResponse convert(AssignmentJobEntity assignmentJobEntity) {
if (Objects.isNull(assignmentJobEntity)) {
return null;
}
//ScheduleService scheduleService = SpringUtil.getBean(ScheduleService.class);
TaskJobDetailResponse response = new TaskJobDetailResponse(); TaskJobDetailResponse response = new TaskJobDetailResponse();
response.setJobId(assignmentJobEntity.getId()); response.setJobId(assignmentJobEntity.getId());
response.setAssignmentId(assignmentJobEntity.getAssignmentId()); response.setAssignmentId(assignmentJobEntity.getAssignmentId());

View File

@@ -9,12 +9,11 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.AssignmentConfigEntity;
import com.gitee.dbswitch.admin.mapper.AssignmentConfigMapper; import com.gitee.dbswitch.admin.mapper.AssignmentConfigMapper;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
@Repository @Repository
public class AssignmentConfigDAO { public class AssignmentConfigDAO {
@@ -23,28 +22,27 @@ public class AssignmentConfigDAO {
private AssignmentConfigMapper assignmentConfigMapper; private AssignmentConfigMapper assignmentConfigMapper;
public void insert(AssignmentConfigEntity assignmentConfigEntity) { public void insert(AssignmentConfigEntity assignmentConfigEntity) {
assignmentConfigMapper.insertSelective(assignmentConfigEntity); assignmentConfigMapper.insert(assignmentConfigEntity);
} }
public AssignmentConfigEntity getById(Long id) { public AssignmentConfigEntity getById(Long id) {
return assignmentConfigMapper.selectByPrimaryKey(id); return assignmentConfigMapper.selectById(id);
} }
public AssignmentConfigEntity getByAssignmentTaskId(Long assignmentId) { public AssignmentConfigEntity getByAssignmentTaskId(Long taskId) {
AssignmentConfigEntity record = new AssignmentConfigEntity(); QueryWrapper<AssignmentConfigEntity> queryWrapper = new QueryWrapper<>();
record.setAssignmentId(assignmentId); queryWrapper.lambda().eq(AssignmentConfigEntity::getAssignmentId, taskId);
return assignmentConfigMapper.selectOne(record); return assignmentConfigMapper.selectOne(queryWrapper);
} }
public void updateSelective(AssignmentConfigEntity assignmentConfigEntity) { public void updateSelective(AssignmentConfigEntity assignmentConfigEntity) {
assignmentConfigMapper.updateByPrimaryKeySelective(assignmentConfigEntity); assignmentConfigMapper.updateById(assignmentConfigEntity);
} }
public void deleteByAssignmentTaskId(Long taskId) { public void deleteByAssignmentTaskId(Long taskId) {
Example example = Example.builder(AssignmentConfigEntity.class) QueryWrapper<AssignmentConfigEntity> queryWrapper = new QueryWrapper<>();
.andWhere(Sqls.custom().andEqualTo("assignmentId", taskId)) queryWrapper.lambda().eq(AssignmentConfigEntity::getAssignmentId, taskId);
.build(); assignmentConfigMapper.delete(queryWrapper);
assignmentConfigMapper.deleteByExample(example);
} }
} }

View File

@@ -9,17 +9,15 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.AssignmentJobEntity;
import com.gitee.dbswitch.admin.mapper.AssignmentJobMapper; import com.gitee.dbswitch.admin.mapper.AssignmentJobMapper;
import com.gitee.dbswitch.admin.model.ops.OpsTaskJobTrend; import com.gitee.dbswitch.admin.model.ops.OpsTaskJobTrend;
import com.gitee.dbswitch.admin.type.JobStatusEnum; import com.gitee.dbswitch.admin.type.JobStatusEnum;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
import java.util.Objects;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
@Repository @Repository
public class AssignmentJobDAO { public class AssignmentJobDAO {
@@ -36,42 +34,33 @@ public class AssignmentJobDAO {
assignmentJobEntity.setStartTime(new Timestamp(System.currentTimeMillis())); assignmentJobEntity.setStartTime(new Timestamp(System.currentTimeMillis()));
assignmentJobEntity.setFinishTime(new Timestamp(System.currentTimeMillis())); assignmentJobEntity.setFinishTime(new Timestamp(System.currentTimeMillis()));
assignmentJobEntity.setStatus(JobStatusEnum.RUNNING.getValue()); assignmentJobEntity.setStatus(JobStatusEnum.RUNNING.getValue());
assignmentJobMapper.insertSelective(assignmentJobEntity); assignmentJobMapper.insert(assignmentJobEntity);
return assignmentJobEntity; return assignmentJobEntity;
} }
public AssignmentJobEntity getById(Long id) { public AssignmentJobEntity getById(Long id) {
return assignmentJobMapper.selectByPrimaryKey(id); return assignmentJobMapper.selectById(id);
} }
public List<AssignmentJobEntity> getByAssignmentId(Long assignmentId) { public List<AssignmentJobEntity> getByAssignmentId(Long assignmentId) {
Objects.requireNonNull(assignmentId, "assignmentId不能为null"); QueryWrapper<AssignmentJobEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(AssignmentJobEntity::getAssignmentId, assignmentId)
AssignmentJobEntity condition = new AssignmentJobEntity(); .orderByDesc(AssignmentJobEntity::getCreateTime);
condition.setAssignmentId(assignmentId); return assignmentJobMapper.selectList(queryWrapper);
Example example = new Example(AssignmentJobEntity.class);
example.createCriteria().andEqualTo(condition);
example.orderBy("createTime").desc();
return assignmentJobMapper.selectByExample(example);
} }
public void updateSelective(AssignmentJobEntity assignmentJobEntity) { public void updateSelective(AssignmentJobEntity assignmentJobEntity) {
Objects.requireNonNull(assignmentJobEntity.getId(), "AssignmentJob的id不能为null"); assignmentJobMapper.updateById(assignmentJobEntity);
assignmentJobMapper.updateByPrimaryKeySelective(assignmentJobEntity);
} }
public int getCountByStatus(JobStatusEnum status) { public int getCountByStatus(JobStatusEnum status) {
AssignmentJobEntity condition = new AssignmentJobEntity(); QueryWrapper<AssignmentJobEntity> queryWrapper = new QueryWrapper<>();
condition.setStatus(status.getValue()); queryWrapper.lambda().eq(AssignmentJobEntity::getStatus, status);
return assignmentJobMapper.selectCount(queryWrapper).intValue();
Example example = new Example(AssignmentJobEntity.class);
example.createCriteria().andEqualTo(condition);
return assignmentJobMapper.selectCountByExample(example);
} }
public int getTotalCount() { public int getTotalCount() {
return assignmentJobMapper.selectCountByExample(null); return assignmentJobMapper.selectCount(null).intValue();
} }
public List<OpsTaskJobTrend> queryTaskJobTrend(Integer days) { public List<OpsTaskJobTrend> queryTaskJobTrend(Integer days) {
@@ -84,10 +73,9 @@ public class AssignmentJobDAO {
if (JobStatusEnum.FAIL.equals(targetStatus)) { if (JobStatusEnum.FAIL.equals(targetStatus)) {
updateSet.setErrorLog(errorLog); updateSet.setErrorLog(errorLog);
} }
Example condition = Example.builder(AssignmentJobEntity.class) QueryWrapper<AssignmentJobEntity> queryWrapper = new QueryWrapper<>();
.where(Sqls.custom().andEqualTo("status", originalStatus.getValue())) queryWrapper.lambda().eq(AssignmentJobEntity::getStatus, originalStatus.getValue());
.build(); assignmentJobMapper.update(updateSet, queryWrapper);
assignmentJobMapper.updateByExampleSelective(updateSet, condition);
} }
} }

View File

@@ -9,16 +9,14 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.AssignmentTaskEntity;
import com.gitee.dbswitch.admin.mapper.AssignmentTaskMapper; import com.gitee.dbswitch.admin.mapper.AssignmentTaskMapper;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
@Repository @Repository
public class AssignmentTaskDAO { public class AssignmentTaskDAO {
@@ -27,43 +25,37 @@ public class AssignmentTaskDAO {
private AssignmentTaskMapper assignmentTaskMapper; private AssignmentTaskMapper assignmentTaskMapper;
public void insert(AssignmentTaskEntity assignment) { public void insert(AssignmentTaskEntity assignment) {
assignmentTaskMapper.insertSelective(assignment); assignmentTaskMapper.insert(assignment);
} }
public void updateById(AssignmentTaskEntity assignment) { public void updateById(AssignmentTaskEntity assignment) {
assignmentTaskMapper.updateByPrimaryKeySelective(assignment); assignmentTaskMapper.updateById(assignment);
} }
public List<AssignmentTaskEntity> listAll(String searchText) { public List<AssignmentTaskEntity> listAll(String searchText) {
Example example = new Example(AssignmentTaskEntity.class); return assignmentTaskMapper.selectList(
if (!StringUtils.isEmpty(searchText)) { Wrappers.<AssignmentTaskEntity>lambdaQuery()
Criteria criteria = example.createCriteria(); .like(StringUtils.hasText(searchText), AssignmentTaskEntity::getName, searchText)
criteria.andLike("name", "%" + searchText + "%"); .orderByDesc(AssignmentTaskEntity::getCreateTime)
} );
example.orderBy("createTime").desc();
return assignmentTaskMapper.selectByExample(example);
} }
public AssignmentTaskEntity getById(Long id) { public AssignmentTaskEntity getById(Long id) {
return assignmentTaskMapper.selectByPrimaryKey(id); return assignmentTaskMapper.selectById(id);
} }
public void deleteById(Long id) { public void deleteById(Long id) {
assignmentTaskMapper.deleteByPrimaryKey(id); assignmentTaskMapper.deleteById(id);
} }
public int getTotalCount() { public int getTotalCount() {
return Optional.ofNullable(assignmentTaskMapper.selectAll()) return assignmentTaskMapper.selectList(null).size();
.orElseGet(ArrayList::new).size();
} }
public int getPublishedCount() { public int getPublishedCount() {
AssignmentTaskEntity condition = new AssignmentTaskEntity(); QueryWrapper<AssignmentTaskEntity> queryWrapper = new QueryWrapper<>();
condition.setPublished(Boolean.TRUE); queryWrapper.lambda().eq(AssignmentTaskEntity::getPublished, Boolean.TRUE);
return assignmentTaskMapper.selectCount(queryWrapper).intValue();
Example example = new Example(AssignmentTaskEntity.class);
example.createCriteria().andEqualTo(condition);
return assignmentTaskMapper.selectCountByExample(example);
} }
} }

View File

@@ -9,14 +9,14 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.DatabaseConnectionEntity;
import com.gitee.dbswitch.admin.mapper.DatabaseConnectionMapper; import com.gitee.dbswitch.admin.mapper.DatabaseConnectionMapper;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
@Repository @Repository
public class DatabaseConnectionDAO { public class DatabaseConnectionDAO {
@@ -25,39 +25,37 @@ public class DatabaseConnectionDAO {
private DatabaseConnectionMapper databaseConnectionMapper; private DatabaseConnectionMapper databaseConnectionMapper;
public void insert(DatabaseConnectionEntity databaseConnectionEntity) { public void insert(DatabaseConnectionEntity databaseConnectionEntity) {
databaseConnectionMapper.insertSelective(databaseConnectionEntity); databaseConnectionMapper.insert(databaseConnectionEntity);
} }
public DatabaseConnectionEntity getById(Long id) { public DatabaseConnectionEntity getById(Long id) {
return databaseConnectionMapper.selectByPrimaryKey(id); return databaseConnectionMapper.selectById(id);
} }
public DatabaseConnectionEntity getByName(String name) { public DatabaseConnectionEntity getByName(String name) {
DatabaseConnectionEntity record = new DatabaseConnectionEntity(); QueryWrapper<DatabaseConnectionEntity> queryWrapper = new QueryWrapper<>();
record.setName(name); queryWrapper.lambda().eq(DatabaseConnectionEntity::getName, name);
return databaseConnectionMapper.selectOne(record); return databaseConnectionMapper.selectOne(queryWrapper);
} }
public List<DatabaseConnectionEntity> listAll(String searchText) { public List<DatabaseConnectionEntity> listAll(String searchText) {
Example example = new Example(DatabaseConnectionEntity.class); return databaseConnectionMapper.selectList(
if (!StringUtils.isEmpty(searchText)) { Wrappers.<DatabaseConnectionEntity>lambdaQuery()
Criteria criteria = example.createCriteria(); .like(StringUtils.hasText(searchText), DatabaseConnectionEntity::getName, searchText)
criteria.andLike("name", "%" + searchText + "%"); .orderByDesc(DatabaseConnectionEntity::getCreateTime)
} );
example.orderBy("createTime").desc();
return databaseConnectionMapper.selectByExample(example);
} }
public void updateById(DatabaseConnectionEntity databaseConnectionEntity) { public void updateById(DatabaseConnectionEntity databaseConnectionEntity) {
databaseConnectionMapper.updateByPrimaryKeySelective(databaseConnectionEntity); databaseConnectionMapper.updateById(databaseConnectionEntity);
} }
public void deleteById(Long id) { public void deleteById(Long id) {
databaseConnectionMapper.deleteByPrimaryKey(id); databaseConnectionMapper.deleteById(id);
} }
public int getTotalCount() { public int getTotalCount() {
return databaseConnectionMapper.selectCount(null); return databaseConnectionMapper.selectCount(null).intValue();
} }
} }

View File

@@ -9,6 +9,7 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.JobLogbackEntity;
import com.gitee.dbswitch.admin.mapper.JobLogbackMapper; import com.gitee.dbswitch.admin.mapper.JobLogbackMapper;
import java.util.Collections; import java.util.Collections;
@@ -16,8 +17,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
@Repository @Repository
public class JobLogbackDAO { public class JobLogbackDAO {
@@ -26,26 +25,28 @@ public class JobLogbackDAO {
private JobLogbackMapper jobLogbackMapper; private JobLogbackMapper jobLogbackMapper;
public void insert(String uuid, String content) { 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) { public List<JobLogbackEntity> getTailByUuid(String uuid) {
Example example = Example.builder(JobLogbackEntity.class) List<JobLogbackEntity> result = jobLogbackMapper.selectList(
.select("id", "content") Wrappers.<JobLogbackEntity>lambdaQuery()
.andWhere(Sqls.custom().andEqualTo("uuid", uuid)) .select(JobLogbackEntity::getId, JobLogbackEntity::getContent)
.orderByDesc("id") .eq(JobLogbackEntity::getUuid, uuid)
.build(); .orderByDesc(JobLogbackEntity::getId)
List<JobLogbackEntity> result = jobLogbackMapper.selectByExample(example); );
Collections.reverse(result); Collections.reverse(result);
return result; return result;
} }
public List<JobLogbackEntity> getNextByUuid(String uuid, Long baseId) { public List<JobLogbackEntity> getNextByUuid(String uuid, Long baseId) {
Example example = Example.builder(JobLogbackEntity.class) return jobLogbackMapper.selectList(
.select("id", "content") Wrappers.<JobLogbackEntity>lambdaQuery()
.andWhere(Sqls.custom().andGreaterThan("id", baseId).andEqualTo("uuid", uuid)) .select(JobLogbackEntity::getId, JobLogbackEntity::getContent)
.build(); .eq(JobLogbackEntity::getUuid, uuid)
return jobLogbackMapper.selectByExample(example); .gt(JobLogbackEntity::getId, baseId)
.orderByAsc(JobLogbackEntity::getId)
);
} }
public void deleteOldest(Integer days) { public void deleteOldest(Integer days) {

View File

@@ -9,14 +9,13 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.SystemLogEntity;
import com.gitee.dbswitch.admin.mapper.SystemLogMapper; import com.gitee.dbswitch.admin.mapper.SystemLogMapper;
import com.gitee.dbswitch.admin.type.LogTypeEnum; import com.gitee.dbswitch.admin.type.LogTypeEnum;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
@Repository @Repository
public class SystemLogDAO { public class SystemLogDAO {
@@ -25,23 +24,18 @@ public class SystemLogDAO {
private SystemLogMapper systemLogMapper; private SystemLogMapper systemLogMapper;
public void insert(SystemLogEntity systemLogEntity) { public void insert(SystemLogEntity systemLogEntity) {
systemLogMapper.insertSelective(systemLogEntity); systemLogMapper.insert(systemLogEntity);
} }
public List<SystemLogEntity> listAll(LogTypeEnum logType) { public List<SystemLogEntity> listAll(LogTypeEnum logType) {
Example example = new Example(SystemLogEntity.class); QueryWrapper<SystemLogEntity> queryWrapper = new QueryWrapper<>();
Criteria criteria = example.createCriteria(); queryWrapper.lambda().eq(SystemLogEntity::getType, logType.getValue())
.orderByDesc(SystemLogEntity::getCreateTime);
SystemLogEntity condition = new SystemLogEntity(); return systemLogMapper.selectList(queryWrapper);
condition.setType(logType.getValue());
criteria.andEqualTo(condition);
example.orderBy("createTime").desc();
return systemLogMapper.selectByExample(example);
} }
public SystemLogEntity getById(Long id) { public SystemLogEntity getById(Long id) {
return systemLogMapper.selectByPrimaryKey(id); return systemLogMapper.selectById(id);
} }
} }

View File

@@ -9,13 +9,12 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.dao; 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.entity.SystemUserEntity;
import com.gitee.dbswitch.admin.mapper.SystemUserMapper; import com.gitee.dbswitch.admin.mapper.SystemUserMapper;
import java.util.Objects; import java.util.Objects;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
@Repository @Repository
public class SystemUserDAO { public class SystemUserDAO {
@@ -24,25 +23,20 @@ public class SystemUserDAO {
private SystemUserMapper systemUserMapper; private SystemUserMapper systemUserMapper;
public SystemUserEntity getById(Long id) { public SystemUserEntity getById(Long id) {
return systemUserMapper.selectByPrimaryKey(id); return systemUserMapper.selectById(id);
} }
public SystemUserEntity findByUsername(String username) { public SystemUserEntity findByUsername(String username) {
return systemUserMapper.selectOneByExample( QueryWrapper<SystemUserEntity> queryWrapper = new QueryWrapper<>();
Example.builder(SystemUserEntity.class) queryWrapper.lambda().eq(SystemUserEntity::getUsername, username);
.where( return systemUserMapper.selectOne(queryWrapper);
Sqls.custom()
.andEqualTo("username", username)
)
.build()
);
} }
public void updateUserPassword(String username, String newPassword) { public void updateUserPassword(String username, String newPassword) {
SystemUserEntity userEntity = findByUsername(username); SystemUserEntity userEntity = findByUsername(username);
if (Objects.nonNull(userEntity)) { if (Objects.nonNull(userEntity)) {
userEntity.setPassword(newPassword); userEntity.setPassword(newPassword);
systemUserMapper.updateByPrimaryKeySelective(userEntity); systemUserMapper.updateById(userEntity);
} }
} }

View File

@@ -9,84 +9,81 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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.admin.handler.ListTypeHandler;
import com.gitee.dbswitch.common.entity.PatternMapper; import com.gitee.dbswitch.common.entity.PatternMapper;
import com.gitee.dbswitch.common.type.CaseConvertEnum; import com.gitee.dbswitch.common.type.CaseConvertEnum;
import com.gitee.dbswitch.common.type.ProductTableEnum; import com.gitee.dbswitch.common.type.ProductTableEnum;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import tk.mybatis.mapper.annotation.ColumnType; import org.apache.ibatis.type.EnumTypeHandler;
import tk.mybatis.mapper.annotation.KeySql;
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_ASSIGNMENT_CONFIG") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_ASSIGNMENT_CONFIG")
public class AssignmentConfigEntity { public class AssignmentConfigEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "assignment_id") @TableField("assignment_id")
private Long assignmentId; private Long assignmentId;
@Column(name = "source_connection_id") @TableField("source_connection_id")
private Long sourceConnectionId; private Long sourceConnectionId;
@Column(name = "source_schema") @TableField("source_schema")
private String sourceSchema; private String sourceSchema;
@Column(name = "table_type") @TableField(value = "table_type", typeHandler = EnumTypeHandler.class)
private ProductTableEnum tableType; private ProductTableEnum tableType;
@Column(name = "source_tables") @TableField(value = "source_tables", typeHandler = ListTypeHandler.class)
@ColumnType(typeHandler = ListTypeHandler.class)
private List<String> sourceTables; private List<String> sourceTables;
@Column(name = "excluded") @TableField("excluded")
private Boolean excluded; private Boolean excluded;
@Column(name = "target_connection_id") @TableField("target_connection_id")
private Long targetConnectionId; private Long targetConnectionId;
@Column(name = "target_schema") @TableField("target_schema")
private String targetSchema; private String targetSchema;
@Column(name = "table_name_case") @TableField(value = "table_name_case", typeHandler = EnumTypeHandler.class)
private CaseConvertEnum tableNameCase; private CaseConvertEnum tableNameCase;
@Column(name = "column_name_case") @TableField(value = "column_name_case", typeHandler = EnumTypeHandler.class)
private CaseConvertEnum columnNameCase; private CaseConvertEnum columnNameCase;
@Column(name = "table_name_map") @TableField(value = "table_name_map")
@ColumnType(typeHandler = ListPatternHandler.class)
private List<PatternMapper> tableNameMap; private List<PatternMapper> tableNameMap;
@Column(name = "column_name_map") @TableField(value = "column_name_map")
@ColumnType(typeHandler = ListPatternHandler.class)
private List<PatternMapper> columnNameMap; private List<PatternMapper> columnNameMap;
@Column(name = "target_drop_table") @TableField("target_drop_table")
private Boolean targetDropTable; private Boolean targetDropTable;
@Column(name = "target_only_create") @TableField("target_only_create")
private Boolean targetOnlyCreate; private Boolean targetOnlyCreate;
@Column(name = "batch_size") @TableField("batch_size")
private Integer batchSize; private Integer batchSize;
@Column(name = "first_flag") @TableField("first_flag")
private Boolean firstFlag; private Boolean firstFlag;
@Column(name = "create_time", insertable = false, updatable = false) @TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp createTime; private Timestamp createTime;
} }

View File

@@ -9,50 +9,51 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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 java.sql.Timestamp;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import tk.mybatis.mapper.annotation.KeySql;
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_ASSIGNMENT_JOB") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_ASSIGNMENT_JOB")
public class AssignmentJobEntity { public class AssignmentJobEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "assignment_id") @TableField("assignment_id")
private Long assignmentId; private Long assignmentId;
@Column(name = "job_key") @TableField("job_key")
private String jobKey; private String jobKey;
@Column(name = "schedule_mode") @TableField("schedule_mode")
private Integer scheduleMode; private Integer scheduleMode;
@Column(name = "start_time") @TableField("start_time")
private Timestamp startTime; private Timestamp startTime;
@Column(name = "finish_time") @TableField("finish_time")
private Timestamp finishTime; private Timestamp finishTime;
@Column(name = "status") @TableField("status")
private Integer status; private Integer status;
@Column(name = "error_log") @TableField("error_log")
private String errorLog; private String errorLog;
@Column(name = "create_time", insertable = false, updatable = false) @TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp createTime; private Timestamp createTime;
@Column(name = "update_time", insertable = false, updatable = false) @TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp updateTime; private Timestamp updateTime;
} }

View File

@@ -9,51 +9,53 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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 com.gitee.dbswitch.admin.type.ScheduleModeEnum;
import java.sql.Timestamp; import java.sql.Timestamp;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import tk.mybatis.mapper.annotation.KeySql; import org.apache.ibatis.type.EnumTypeHandler;
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_ASSIGNMENT_TASK") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_ASSIGNMENT_TASK")
public class AssignmentTaskEntity { public class AssignmentTaskEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "name") @TableField("name")
private String name; private String name;
@Column(name = "description") @TableField("description")
private String description; private String description;
@Column(name = "schedule_mode") @TableField(value = "schedule_mode", typeHandler = EnumTypeHandler.class)
private ScheduleModeEnum scheduleMode; private ScheduleModeEnum scheduleMode;
@Column(name = "cron_expression") @TableField("cron_expression")
private String cronExpression; private String cronExpression;
@Column(name = "published") @TableField("published")
private Boolean published; private Boolean published;
@Column(name = "content") @TableField("content")
private String content; private String content;
@Column(name = "job_key") @TableField("job_key")
private String jobKey; private String jobKey;
@Column(name = "create_time", insertable = false, updatable = false) @TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp createTime; private Timestamp createTime;
@Column(name = "update_time", insertable = false, updatable = false) @TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp updateTime; private Timestamp updateTime;
} }

View File

@@ -9,53 +9,53 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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 com.gitee.dbswitch.common.type.ProductTypeEnum;
import java.sql.Timestamp; import java.sql.Timestamp;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import org.apache.ibatis.type.EnumTypeHandler;
import tk.mybatis.mapper.annotation.KeySql;
@SuperBuilder
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_DATABASE_CONNECTION") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_DATABASE_CONNECTION")
public class DatabaseConnectionEntity { public class DatabaseConnectionEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "name") @TableField("name")
private String name; private String name;
@Column(name = "type") @TableField(value = "type", typeHandler = EnumTypeHandler.class)
private ProductTypeEnum type; private ProductTypeEnum type;
@Column(name = "version") @TableField("version")
private String version; private String version;
@Column(name = "driver") @TableField("driver")
private String driver; private String driver;
@Column(name = "url") @TableField("url")
private String url; private String url;
@Column(name = "username") @TableField("username")
private String username; private String username;
@Column(name = "password") @TableField("password")
private String 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; private Timestamp createTime;
@Column(name = "update_time", insertable = false, updatable = false) @TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp updateTime; private Timestamp updateTime;
} }

View File

@@ -9,34 +9,33 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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 java.sql.Timestamp;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import tk.mybatis.mapper.annotation.KeySql;
@SuperBuilder
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_JOB_LOGBACK") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_JOB_LOGBACK")
public class JobLogbackEntity { public class JobLogbackEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "uuid") @TableField("uuid")
private String uuid; private String uuid;
@Column(name = "content") @TableField("content")
private String 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; private Timestamp createTime;
} }

View File

@@ -9,58 +9,57 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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 java.sql.Timestamp;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import tk.mybatis.mapper.annotation.KeySql;
@SuperBuilder
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_SYSTEM_LOG") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_SYSTEM_LOG")
public class SystemLogEntity { public class SystemLogEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "type") @TableField("type")
private Integer type; private Integer type;
@Column(name = "username") @TableField("username")
private String username; private String username;
@Column(name = "ip_address") @TableField("ip_address")
private String ipAddress; private String ipAddress;
@Column(name = "module_name") @TableField("module_name")
private String moduleName; private String moduleName;
@Column(name = "content") @TableField("content")
private String content; private String content;
@Column(name = "url_path") @TableField("url_path")
private String urlPath; private String urlPath;
@Column(name = "user_agent") @TableField("user_agent")
private String userAgent; private String userAgent;
@Column(name = "failed") @TableField("failed")
private Boolean failed; private Boolean failed;
@Column(name = "exception") @TableField("exception")
private String exception; private String exception;
@Column(name = "elapse_seconds") @TableField("elapse_seconds")
private Long elapseSeconds; private Long elapseSeconds;
@Column(name = "create_time", insertable = false, updatable = false) @TableField(value = "create_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp createTime; private Timestamp createTime;
} }

View File

@@ -9,53 +9,52 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.entity; 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 java.sql.Timestamp;
import javax.persistence.Column; import lombok.AllArgsConstructor;
import javax.persistence.Entity; import lombok.Builder;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import tk.mybatis.mapper.annotation.KeySql;
@SuperBuilder
@NoArgsConstructor
@Data @Data
@Entity @Builder
@Table(name = "DBSWITCH_SYSTEM_USER") @NoArgsConstructor
@AllArgsConstructor
@TableName("DBSWITCH_SYSTEM_USER")
public class SystemUserEntity { public class SystemUserEntity {
@Id @TableId(value = "id", type = IdType.AUTO)
@KeySql(useGeneratedKeys = true)
@Column(name = "id", insertable = false, updatable = false)
private Long id; private Long id;
@Column(name = "username") @TableField("username")
private String username; private String username;
@Column(name = "password") @TableField("password")
private String password; private String password;
@Column(name = "salt") @TableField("salt")
private String salt; private String salt;
@Column(name = "real_name") @TableField("real_name")
private String realName; private String realName;
@Column(name = "email") @TableField("email")
private String email; private String email;
@Column(name = "address") @TableField("address")
private String address; private String address;
@Column(name = "locked") @TableField("locked")
private Boolean 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; private Timestamp createTime;
@Column(name = "update_time", insertable = false, updatable = false) @TableField(value = "update_time", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private Timestamp updateTime; private Timestamp updateTime;
} }

View File

@@ -10,8 +10,8 @@
package com.gitee.dbswitch.admin.mapper; package com.gitee.dbswitch.admin.mapper;
import com.gitee.dbswitch.admin.entity.AssignmentConfigEntity; 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> {
} }

View File

@@ -9,6 +9,7 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.mapper; 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.entity.AssignmentJobEntity;
import com.gitee.dbswitch.admin.model.ops.OpsTaskJobTrend; import com.gitee.dbswitch.admin.model.ops.OpsTaskJobTrend;
import java.util.List; 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.Result;
import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select; 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>" @Select("<script>"
+ "<if test='_databaseId == \"mysql\" '>" + "<if test='_databaseId == \"mysql\" '>"

View File

@@ -9,9 +9,9 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.mapper; package com.gitee.dbswitch.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gitee.dbswitch.admin.entity.AssignmentTaskEntity; 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> {
} }

View File

@@ -9,9 +9,9 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.mapper; package com.gitee.dbswitch.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gitee.dbswitch.admin.entity.DatabaseConnectionEntity; 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> {
} }

View File

@@ -9,12 +9,12 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.mapper; package com.gitee.dbswitch.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gitee.dbswitch.admin.entity.JobLogbackEntity; import com.gitee.dbswitch.admin.entity.JobLogbackEntity;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param; 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>" @Delete("<script>"
+ "<if test='_databaseId == \"mysql\" '>" + "<if test='_databaseId == \"mysql\" '>"

View File

@@ -9,9 +9,9 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.mapper; package com.gitee.dbswitch.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gitee.dbswitch.admin.entity.SystemLogEntity; 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> {
} }

View File

@@ -9,9 +9,9 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.mapper; package com.gitee.dbswitch.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gitee.dbswitch.admin.entity.SystemUserEntity; 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> {
} }

View File

@@ -9,7 +9,6 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
package com.gitee.dbswitch.admin.service; 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.PageResult;
import com.gitee.dbswitch.admin.common.response.Result; import com.gitee.dbswitch.admin.common.response.Result;
import com.gitee.dbswitch.admin.common.response.ResultCode; 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.model.response.SystemLogDetailResponse;
import com.gitee.dbswitch.admin.type.LogTypeEnum; import com.gitee.dbswitch.admin.type.LogTypeEnum;
import com.gitee.dbswitch.admin.util.PageUtils; import com.gitee.dbswitch.admin.util.PageUtils;
import com.gitee.dbswitch.common.converter.ConverterFactory;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.function.Supplier; import java.util.function.Supplier;

View File

@@ -8,7 +8,7 @@ spring:
uri-encoding: UTF-8 uri-encoding: UTF-8
max-http-header-size: 8096 max-http-header-size: 8096
mvc: mvc:
throw-exception-if-no-handler-found: true throw-exception-if-no-handler-found: false
static-path-pattern: /statics/** static-path-pattern: /statics/**
datasource: datasource:
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
@@ -30,10 +30,6 @@ mybatis:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper:
wrap-keyword: "`{0}`"
enable-method-annotation: true
dbswitch: dbswitch:
configuration: configuration:
drivers-base-path: ${APP_DRIVERS_PATH} drivers-base-path: ${APP_DRIVERS_PATH}

View File

@@ -8,7 +8,7 @@ spring:
uri-encoding: UTF-8 uri-encoding: UTF-8
max-http-header-size: 8096 max-http-header-size: 8096
mvc: mvc:
throw-exception-if-no-handler-found: true throw-exception-if-no-handler-found: false
static-path-pattern: /statics/** static-path-pattern: /statics/**
datasource: datasource:
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
@@ -30,10 +30,6 @@ mybatis:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper:
wrap-keyword: "`{0}`"
enable-method-annotation: true
dbswitch: dbswitch:
configuration: configuration:
drivers-base-path: ${APP_DRIVERS_PATH} drivers-base-path: ${APP_DRIVERS_PATH}

View File

@@ -8,7 +8,7 @@ spring:
uri-encoding: UTF-8 uri-encoding: UTF-8
max-http-header-size: 8096 max-http-header-size: 8096
mvc: mvc:
throw-exception-if-no-handler-found: true throw-exception-if-no-handler-found: false
static-path-pattern: /statics/** static-path-pattern: /statics/**
datasource: datasource:
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
@@ -30,10 +30,6 @@ mybatis:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper:
wrap-keyword: "\"{0}\""
enable-method-annotation: true
dbswitch: dbswitch:
configuration: configuration:
drivers-base-path: ${APP_DRIVERS_PATH} drivers-base-path: ${APP_DRIVERS_PATH}

View File

@@ -284,7 +284,7 @@ public class ClickhouseMetadataQueryProvider extends AbstractMetadataProvider {
} }
if (withRemarks && StringUtils.isNotBlank(v.getRemarks())) { if (withRemarks && StringUtils.isNotBlank(v.getRemarks())) {
retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", "\\'")); retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", ""));
} }
if (addCr) { if (addCr) {

View File

@@ -220,7 +220,7 @@ public class DB2MetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ", .format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), td.getSchemaName(), td.getTableName(),
td.getRemarks().replace("\"", "\\\""))); td.getRemarks().replace("'", "")));
} }
for (ColumnDescription cd : cds) { for (ColumnDescription cd : cds) {
@@ -228,7 +228,7 @@ public class DB2MetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ", .format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), cd.getFieldName(), td.getSchemaName(), td.getTableName(), cd.getFieldName(),
cd.getRemarks().replace("\"", "\\\""))); cd.getRemarks().replace("'", "")));
} }
} }

View File

@@ -180,7 +180,7 @@ public class DmMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ", .format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), td.getSchemaName(), td.getTableName(),
td.getRemarks().replace("\"", "\\\""))); td.getRemarks().replace("'", "")));
} }
for (ColumnDescription cd : cds) { for (ColumnDescription cd : cds) {
@@ -188,7 +188,7 @@ public class DmMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ", .format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), cd.getFieldName(), td.getSchemaName(), td.getTableName(), cd.getFieldName(),
cd.getRemarks().replace("\"", "\\\""))); cd.getRemarks().replace("'", "")));
} }
} }

View File

@@ -154,7 +154,7 @@ public class HiveMetadataQueryProvider extends AbstractMetadataProvider {
} }
if (withRemarks && StringUtils.isNotBlank(v.getRemarks())) { if (withRemarks && StringUtils.isNotBlank(v.getRemarks())) {
retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", "\\'")); retval += String.format(" COMMENT '%s' ", v.getRemarks().replace("'", ""));
} }
if (addCr) { if (addCr) {

View File

@@ -187,7 +187,7 @@ public class KingbaseMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ", .format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), td.getSchemaName(), td.getTableName(),
td.getRemarks().replace("\"", "\\\""))); td.getRemarks().replace("'", "")));
} }
for (ColumnDescription cd : cds) { for (ColumnDescription cd : cds) {
@@ -195,7 +195,7 @@ public class KingbaseMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ", .format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), cd.getFieldName(), td.getSchemaName(), td.getTableName(), cd.getFieldName(),
cd.getRemarks().replace("\"", "\\\""))); cd.getRemarks().replace("'", "")));
} }
} }

View File

@@ -37,6 +37,8 @@ public class MysqlMetadataQueryProvider extends AbstractMetadataProvider {
private static final String QUERY_TABLE_LIST_SQL = private static final String QUERY_TABLE_LIST_SQL =
"SELECT `TABLE_SCHEMA`,`TABLE_NAME`,`TABLE_TYPE`,`TABLE_COMMENT` " "SELECT `TABLE_SCHEMA`,`TABLE_NAME`,`TABLE_TYPE`,`TABLE_COMMENT` "
+ "FROM `information_schema`.`TABLES` where `TABLE_SCHEMA`= ? "; + "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) { public MysqlMetadataQueryProvider(ProductFactoryProvider factoryProvider) {
super(factoryProvider); super(factoryProvider);
@@ -85,17 +87,20 @@ public class MysqlMetadataQueryProvider extends AbstractMetadataProvider {
@Override @Override
public TableDescription queryTableMeta(Connection connection, String schemaName, String tableName) { public TableDescription queryTableMeta(Connection connection, String schemaName, String tableName) {
try (ResultSet tables = connection.getMetaData() try (PreparedStatement ps = connection.prepareStatement(QUERY_TABLE_COMMENT_SQL)) {
.getTables(schemaName, null, tableName, new String[]{"TABLE"})) { ps.setString(1, schemaName);
while (tables.next()) { ps.setString(2, tableName);
try (ResultSet rs = ps.executeQuery();) {
while (rs.next()) {
TableDescription td = new TableDescription(); TableDescription td = new TableDescription();
td.setSchemaName(schemaName); td.setSchemaName(schemaName);
td.setTableName(tableName); td.setTableName(tableName);
td.setRemarks(tables.getString("REMARKS")); td.setRemarks(rs.getString(1));
td.setTableType(tables.getString("TABLE_TYPE").toUpperCase()); td.setTableType("TABLE");
return td; return td;
} }
return null; return null;
}
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(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 @Override
public List<String> queryTablePrimaryKeys(Connection connection, String schemaName, String tableName) { public List<String> queryTablePrimaryKeys(Connection connection, String schemaName, String tableName) {
List<String> ret = new ArrayList<>(); List<String> ret = new ArrayList<>();

View File

@@ -225,7 +225,7 @@ public class OracleMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ", .format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), td.getSchemaName(), td.getTableName(),
td.getRemarks().replace("\"", "\\\""))); td.getRemarks().replace("'", "")));
} }
for (ColumnDescription cd : cds) { for (ColumnDescription cd : cds) {
@@ -233,7 +233,7 @@ public class OracleMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ", .format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), cd.getFieldName(), td.getSchemaName(), td.getTableName(), cd.getFieldName(),
cd.getRemarks().replace("\"", "\\\""))); cd.getRemarks().replace("'", "")));
} }
} }

View File

@@ -190,7 +190,7 @@ public class OscarMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ", .format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), td.getSchemaName(), td.getTableName(),
td.getRemarks().replace("\"", "\\\""))); td.getRemarks().replace("'", "")));
} }
for (ColumnDescription cd : cds) { for (ColumnDescription cd : cds) {
@@ -198,7 +198,7 @@ public class OscarMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ", .format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), cd.getFieldName(), td.getSchemaName(), td.getTableName(), cd.getFieldName(),
cd.getRemarks().replace("\"", "\\\""))); cd.getRemarks().replace("'", "")));
} }
} }

View File

@@ -225,7 +225,7 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ", .format("COMMENT ON TABLE \"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), td.getSchemaName(), td.getTableName(),
td.getRemarks().replace("\"", "\\\""))); td.getRemarks().replace("'", "")));
} }
for (ColumnDescription cd : cds) { for (ColumnDescription cd : cds) {
@@ -233,7 +233,7 @@ public class PostgresMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ", .format("COMMENT ON COLUMN \"%s\".\"%s\".\"%s\" IS '%s' ",
td.getSchemaName(), td.getTableName(), cd.getFieldName(), td.getSchemaName(), td.getTableName(), cd.getFieldName(),
cd.getRemarks().replace("\"", "\\\""))); cd.getRemarks().replace("'", "")));
} }
} }

View File

@@ -312,7 +312,7 @@ public class SqlserverMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format( .format(
"EXEC [sys].sp_addextendedproperty 'MS_Description', N'%s', 'schema', N'%s', 'table', N'%s' ", "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) { for (ColumnDescription cd : cds) {
@@ -320,7 +320,7 @@ public class SqlserverMetadataQueryProvider extends AbstractMetadataProvider {
results.add(String results.add(String
.format( .format(
"EXEC [sys].sp_addextendedproperty 'MS_Description', N'%s', 'schema', N'%s', 'table', N'%s', 'column', N'%s' ", "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())); cd.getFieldName()));
} }
} }

View File

@@ -99,9 +99,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>tk.mybatis</groupId> <groupId>com.baomidou</groupId>
<artifactId>mapper-spring-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>4.2.1</version> <version>3.5.4.1</version>
</dependency> </dependency>
<dependency> <dependency>