#临时提交 转到windows 开发

pull/432/head
廖金龙 2020-07-02 21:39:43 +08:00
parent 39fe0c3fc8
commit 41eadc4477
19 changed files with 319 additions and 56 deletions

View File

@ -1,12 +1,17 @@
package me.zhengjie.base.mybatis; package me.zhengjie.base;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import me.zhengjie.utils.WhereFun; import me.zhengjie.utils.WhereFun;
import me.zhengjie.utils.WrapperUtils; import me.zhengjie.utils.WrapperUtils;
import me.zhengjie.utils.enums.DbType; import me.zhengjie.utils.enums.DbType;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.lang.Nullable;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@ -17,12 +22,12 @@ import java.util.List;
* @author liaojinlong * @author liaojinlong
* @since 2020/6/29 10:22 * @since 2020/6/29 10:22
*/ */
public class BaseDao<I extends IService<T>, J extends JpaRepository<T, ID>, T, ID extends Serializable> { public class BaseRepository<I extends IService<T>, J extends JpaRepository<T, ID>, T, ID extends Serializable> {
protected I mpService; protected I mpService;
protected J jpaRepository; protected J jpaRepository;
protected DbType dbType = DbType.JPA; protected DbType dbType = DbType.JPA;
public BaseDao(I mpService, J jpaRepository) { public BaseRepository(I mpService, J jpaRepository) {
this.mpService = mpService; this.mpService = mpService;
this.jpaRepository = jpaRepository; this.jpaRepository = jpaRepository;
} }
@ -141,6 +146,48 @@ public class BaseDao<I extends IService<T>, J extends JpaRepository<T, ID>, T, I
return t; return t;
} }
public List<T> findAll(@Nullable Specification<T> spec) {
List<T> t = null;
switch (dbType) {
case JPA:
t = ((JpaSpecificationExecutor) jpaRepository).findAll(spec);
break;
case MYBATIS:
t = mpFindAll(spec, null);
break;
default:
throw new IllegalStateException("Unexpected value: " + dbType);
}
return t;
}
public Object findAll(@Nullable Specification<T> spec, Pageable pageable) {
Object t = null;
switch (dbType) {
case JPA:
t = ((JpaSpecificationExecutor) jpaRepository).findAll(spec, pageable);
break;
case MYBATIS:
t = mpFindAll(spec, pageable);
break;
default:
throw new IllegalStateException("Unexpected value: " + dbType);
}
return t;
}
/**
* Mp
*
* @param spec
* @param pageable
* @return
*/
protected List<T> mpFindAll(Specification<T> spec, Pageable pageable) {
final QueryWrapper<T> query = Wrappers.<T>query();
return mpService.page(null, null);
}
public I getMpService() { public I getMpService() {
return mpService; return mpService;
} }

View File

@ -0,0 +1,122 @@
/*
* Copyright 2019-2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.db;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
/**
* MyBatis & JPA
*
* @author liaojinlong
* @since 2020/7/2 19:18
*/
public class ElPredicate<T> implements Predicate<T> {
private Predicate<T> predicate;
private QueryWrapper queryWrapper;
public ElPredicate(Predicate<T> predicate, QueryWrapper queryWrapper) {
this.predicate = predicate;
this.queryWrapper = queryWrapper;
}
/**
* Evaluates this predicate on the given argument.
*
* @param o the input argument
* @return {@code true} if the input argument matches the predicate,
* otherwise {@code false}
*/
@Override
public boolean test(T o) {
return predicate.test(o);
}
/**
* Returns a composed predicate that represents a short-circuiting logical
* AND of this predicate and another. When evaluating the composed
* predicate, if this predicate is {@code false}, then the {@code other}
* predicate is not evaluated.
*
* <p>Any exceptions thrown during evaluation of either predicate are relayed
* to the caller; if evaluation of this predicate throws an exception, the
* {@code other} predicate will not be evaluated.
*
* @param other a predicate that will be logically-ANDed with this
* predicate
* @return a composed predicate that represents the short-circuiting logical
* AND of this predicate and the {@code other} predicate
* @throws NullPointerException if other is null
*/
@Override
public Predicate and(Predicate other) {
return predicate.and(other);
}
/**
* Returns a predicate that represents the logical negation of this
* predicate.
*
* @return a predicate that represents the logical negation of this
* predicate
*/
@Override
public Predicate negate() {
return predicate.negate();
}
/**
* Returns a composed predicate that represents a short-circuiting logical
* OR of this predicate and another. When evaluating the composed
* predicate, if this predicate is {@code true}, then the {@code other}
* predicate is not evaluated.
*
* <p>Any exceptions thrown during evaluation of either predicate are relayed
* to the caller; if evaluation of this predicate throws an exception, the
* {@code other} predicate will not be evaluated.
*
* @param other a predicate that will be logically-ORed with this
* predicate
* @return a composed predicate that represents the short-circuiting logical
* OR of this predicate and the {@code other} predicate
* @throws NullPointerException if other is null
*/
@Override
public Predicate or(Predicate other) {
return predicate.or(other);
}
public static synchronized <T> List<ElPredicate<T>> toConvert(List<Predicate<T>> predicates, List<QueryWrapper<T>> queryWrappers) {
Assert.isTrue(predicates.size() == queryWrappers.size(), "二者数量必须匹配");
List<ElPredicate<T>> result = new ArrayList<>(queryWrappers.size());
for (int i = 0; i < predicates.size(); i++) {
Predicate<T> tPredicate = predicates.get(i);
QueryWrapper<T> queryWrapper = queryWrappers.get(i);
result.add(toConvert(tPredicate, queryWrapper));
}
return result;
}
public static synchronized <T> ElPredicate<T> toConvert(Predicate<T> predicate, QueryWrapper<T> queryWrapper) {
return new ElPredicate<T>(predicate, queryWrapper);
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 2019-2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.db;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.data.jpa.domain.Specification;
/**
* @author liaojinlong
* @since 2020/7/2 19:39
*/
public abstract class ElSpecification<T> implements Specification {
protected QueryWrapper<T> queryWrapper;
}

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package me.zhengjie.mybatis.annotation.impl; package me.zhengjie.db.mybatis;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.FieldStrategy;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package me.zhengjie.mybatis.annotation.impl; package me.zhengjie.db.mybatis;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package me.zhengjie.mybatis.annotation.impl; package me.zhengjie.db.mybatis;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;

View File

@ -21,6 +21,7 @@ import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.DataPermission; import me.zhengjie.annotation.DataPermission;
import me.zhengjie.annotation.Query; import me.zhengjie.annotation.Query;
import javax.persistence.criteria.*; import javax.persistence.criteria.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
@ -30,25 +31,34 @@ import java.util.*;
* @date 2019-6-4 14:59:48 * @date 2019-6-4 14:59:48
*/ */
@Slf4j @Slf4j
@SuppressWarnings({"unchecked","all"}) @SuppressWarnings({"unchecked", "all"})
public class QueryHelp { public class QueryHelp {
/**
* JPA
*
* @param root
* @param query
* @param cb
* @param <R>
* @param <Q>
* @return /
*/
public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuilder cb) { public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<>(); List<Predicate> list = new ArrayList<>();
if(query == null){ if (query == null) {
return cb.and(list.toArray(new Predicate[0])); return cb.and(list.toArray(new Predicate[0]));
} }
// 数据权限验证 // 数据权限验证
DataPermission permission = query.getClass().getAnnotation(DataPermission.class); DataPermission permission = query.getClass().getAnnotation(DataPermission.class);
if(permission != null){ if (permission != null) {
// 获取数据权限 // 获取数据权限
List<Long> dataScopes = SecurityUtils.getCurrentUserDataScope(); List<Long> dataScopes = SecurityUtils.getCurrentUserDataScope();
if(CollectionUtil.isNotEmpty(dataScopes)){ if (CollectionUtil.isNotEmpty(dataScopes)) {
if(StringUtils.isNotBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) { if (StringUtils.isNotBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) {
Join join = root.join(permission.joinName(), JoinType.LEFT); Join join = root.join(permission.joinName(), JoinType.LEFT);
list.add(getExpression(permission.fieldName(),join, root).in(dataScopes)); list.add(getExpression(permission.fieldName(), join, root).in(dataScopes));
} else if (StringUtils.isBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) { } else if (StringUtils.isBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) {
list.add(getExpression(permission.fieldName(),null, root).in(dataScopes)); list.add(getExpression(permission.fieldName(), null, root).in(dataScopes));
} }
} }
} }
@ -87,79 +97,81 @@ public class QueryHelp {
for (String name : joinNames) { for (String name : joinNames) {
switch (q.join()) { switch (q.join()) {
case LEFT: case LEFT:
if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){ if (ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)) {
join = join.join(name, JoinType.LEFT); join = join.join(name, JoinType.LEFT);
} else { } else {
join = root.join(name, JoinType.LEFT); join = root.join(name, JoinType.LEFT);
} }
break; break;
case RIGHT: case RIGHT:
if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){ if (ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)) {
join = join.join(name, JoinType.RIGHT); join = join.join(name, JoinType.RIGHT);
} else { } else {
join = root.join(name, JoinType.RIGHT); join = root.join(name, JoinType.RIGHT);
} }
break; break;
case INNER: case INNER:
if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){ if (ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)) {
join = join.join(name, JoinType.INNER); join = join.join(name, JoinType.INNER);
} else { } else {
join = root.join(name, JoinType.INNER); join = root.join(name, JoinType.INNER);
} }
break; break;
default: break; default:
break;
} }
} }
} }
switch (q.type()) { switch (q.type()) {
case EQUAL: case EQUAL:
list.add(cb.equal(getExpression(attributeName,join,root) list.add(cb.equal(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType),val)); .as((Class<? extends Comparable>) fieldType), val));
break; break;
case GREATER_THAN: case GREATER_THAN:
list.add(cb.greaterThanOrEqualTo(getExpression(attributeName,join,root) list.add(cb.greaterThanOrEqualTo(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), (Comparable) val)); .as((Class<? extends Comparable>) fieldType), (Comparable) val));
break; break;
case LESS_THAN: case LESS_THAN:
list.add(cb.lessThanOrEqualTo(getExpression(attributeName,join,root) list.add(cb.lessThanOrEqualTo(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), (Comparable) val)); .as((Class<? extends Comparable>) fieldType), (Comparable) val));
break; break;
case LESS_THAN_NQ: case LESS_THAN_NQ:
list.add(cb.lessThan(getExpression(attributeName,join,root) list.add(cb.lessThan(getExpression(attributeName, join, root)
.as((Class<? extends Comparable>) fieldType), (Comparable) val)); .as((Class<? extends Comparable>) fieldType), (Comparable) val));
break; break;
case INNER_LIKE: case INNER_LIKE:
list.add(cb.like(getExpression(attributeName,join,root) list.add(cb.like(getExpression(attributeName, join, root)
.as(String.class), "%" + val.toString() + "%")); .as(String.class), "%" + val.toString() + "%"));
break; break;
case LEFT_LIKE: case LEFT_LIKE:
list.add(cb.like(getExpression(attributeName,join,root) list.add(cb.like(getExpression(attributeName, join, root)
.as(String.class), "%" + val.toString())); .as(String.class), "%" + val.toString()));
break; break;
case RIGHT_LIKE: case RIGHT_LIKE:
list.add(cb.like(getExpression(attributeName,join,root) list.add(cb.like(getExpression(attributeName, join, root)
.as(String.class), val.toString() + "%")); .as(String.class), val.toString() + "%"));
break; break;
case IN: case IN:
if (CollUtil.isNotEmpty((Collection<Long>)val)) { if (CollUtil.isNotEmpty((Collection<Long>) val)) {
list.add(getExpression(attributeName,join,root).in((Collection<Long>) val)); list.add(getExpression(attributeName, join, root).in((Collection<Long>) val));
} }
break; break;
case NOT_EQUAL: case NOT_EQUAL:
list.add(cb.notEqual(getExpression(attributeName,join,root), val)); list.add(cb.notEqual(getExpression(attributeName, join, root), val));
break; break;
case NOT_NULL: case NOT_NULL:
list.add(cb.isNotNull(getExpression(attributeName,join,root))); list.add(cb.isNotNull(getExpression(attributeName, join, root)));
break; break;
case IS_NULL: case IS_NULL:
list.add(cb.isNull(getExpression(attributeName,join,root))); list.add(cb.isNull(getExpression(attributeName, join, root)));
break; break;
case BETWEEN: case BETWEEN:
List<Object> between = new ArrayList<>((List<Object>)val); List<Object> between = new ArrayList<>((List<Object>) val);
list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()), list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
(Comparable) between.get(0), (Comparable) between.get(1))); (Comparable) between.get(0), (Comparable) between.get(1)));
break; break;
default: break; default:
break;
} }
} }
field.setAccessible(accessible); field.setAccessible(accessible);
@ -167,6 +179,7 @@ public class QueryHelp {
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
int size = list.size(); int size = list.size();
return cb.and(list.toArray(new Predicate[size])); return cb.and(list.toArray(new Predicate[size]));
} }

View File

@ -0,0 +1,49 @@
/*
* Copyright 2019-2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.utils;
import me.zhengjie.db.ElSpecification;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
/**
* @author liaojinlong
* @since 2020/7/2 19:44
*/
public class SpecificationUtils {
public static synchronized <T> ElSpecification getSpecification() {
return new ElSpecification<T>() {
/**
* Creates a WHERE clause for a query of the referenced entity in form of a {@link Predicate} for the given
* {@link Root} and {@link CriteriaQuery}.
*
* @param root must not be {@literal null}.
* @param query must not be {@literal null}.
* @param criteriaBuilder must not be {@literal null}.
* @return a {@link Predicate}, may be {@literal null}.
*/
@Override
public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) {
return QueryHelp.getPredicate(root, query, criteriaBuilder);
}
};
}
}

View File

@ -16,10 +16,10 @@
package me.zhengjie.repository; package me.zhengjie.repository;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import me.zhengjie.base.mybatis.BaseDao; import me.zhengjie.base.BaseRepository;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.repository.jpa.ColumnInfoRepository; import me.zhengjie.repository.jpa.ColumnInfoJpaRepository;
import me.zhengjie.repository.mp.ColumnInfoService; import me.zhengjie.repository.mp.ColumnInfoMpService;
import me.zhengjie.utils.enums.DbType; import me.zhengjie.utils.enums.DbType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -32,9 +32,9 @@ import java.util.List;
* @since 2020/6/28 14:59 * @since 2020/6/28 14:59
*/ */
@Component @Component
public class ColumnInfoDao extends BaseDao<ColumnInfoService, ColumnInfoRepository, ColumnInfo, Long> { public class ColumnInfoRepository extends BaseRepository<ColumnInfoMpService, ColumnInfoJpaRepository, ColumnInfo, Long> {
public ColumnInfoDao(ColumnInfoService baseService, ColumnInfoRepository jpaRepository) { public ColumnInfoRepository(ColumnInfoMpService baseService, ColumnInfoJpaRepository jpaRepository) {
super(baseService, jpaRepository); super(baseService, jpaRepository);
setDbType(DbType.MYBATIS); setDbType(DbType.MYBATIS);
} }

View File

@ -1,10 +1,10 @@
package me.zhengjie.repository; package me.zhengjie.repository;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import me.zhengjie.base.mybatis.BaseDao; import me.zhengjie.base.BaseRepository;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
import me.zhengjie.repository.jpa.GenConfigRepository; import me.zhengjie.repository.jpa.GenConfigJpaRepository;
import me.zhengjie.repository.mp.GenConfigService; import me.zhengjie.repository.mp.GenConfigMpService;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -15,8 +15,8 @@ import org.springframework.stereotype.Repository;
* @since 2020/7/1 23:00 * @since 2020/7/1 23:00
*/ */
@Repository @Repository
public class GenConfigDao extends BaseDao<GenConfigService, GenConfigRepository, GenConfig, Long> { public class GenConfigRepository extends BaseRepository<GenConfigMpService, GenConfigJpaRepository, GenConfig, Long> {
public GenConfigDao(GenConfigService mpService, GenConfigRepository jpaRepository) { public GenConfigRepository(GenConfigMpService mpService, GenConfigJpaRepository jpaRepository) {
super(mpService, jpaRepository); super(mpService, jpaRepository);
} }

View File

@ -17,16 +17,19 @@ package me.zhengjie.repository.jpa;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List; import java.util.List;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-01-14 * @date 2019-01-14
*/ */
public interface ColumnInfoRepository extends JpaRepository<ColumnInfo,Long> { public interface ColumnInfoJpaRepository extends JpaRepository<ColumnInfo, Long>, JpaSpecificationExecutor<ColumnInfo> {
/** /**
* *
*
* @param tableName * @param tableName
* @return * @return
*/ */

View File

@ -15,17 +15,20 @@
*/ */
package me.zhengjie.repository.jpa; package me.zhengjie.repository.jpa;
import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-01-14 * @date 2019-01-14
*/ */
public interface GenConfigRepository extends JpaRepository<GenConfig,Long> { public interface GenConfigJpaRepository extends JpaRepository<GenConfig, Long>, JpaSpecificationExecutor<ColumnInfo> {
/** /**
* *
*
* @param tableName * @param tableName
* @return / * @return /
*/ */

View File

@ -22,5 +22,5 @@ import me.zhengjie.domain.ColumnInfo;
* @author liaojinlong * @author liaojinlong
* @since 2020/6/28 14:57 * @since 2020/6/28 14:57
*/ */
public interface ColumnInfoMapper extends BaseMapper<ColumnInfo> { public interface ColumnInfoMpMapper extends BaseMapper<ColumnInfo> {
} }

View File

@ -24,5 +24,5 @@ import org.springframework.stereotype.Repository;
* @since 2020/6/28 14:57 * @since 2020/6/28 14:57
*/ */
@Repository @Repository
public class ColumnInfoService extends ServiceImpl<ColumnInfoMapper, ColumnInfo> { public class ColumnInfoMpService extends ServiceImpl<ColumnInfoMpMapper, ColumnInfo> {
} }

View File

@ -23,5 +23,5 @@ import me.zhengjie.domain.GenConfig;
* @author liaojinlong * @author liaojinlong
* @since 2020/6/28 14:57 * @since 2020/6/28 14:57
*/ */
public interface GenConfigMapper extends BaseMapper<GenConfig> { public interface GenConfigMpMapper extends BaseMapper<GenConfig> {
} }

View File

@ -24,5 +24,5 @@ import org.springframework.stereotype.Repository;
* @since 2020/6/28 14:57 * @since 2020/6/28 14:57
*/ */
@Repository @Repository
public class GenConfigService extends ServiceImpl<GenConfigMapper, GenConfig> { public class GenConfigMpService extends ServiceImpl<GenConfigMpMapper, GenConfig> {
} }

View File

@ -17,8 +17,7 @@ package me.zhengjie.service.impl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
import me.zhengjie.repository.GenConfigDao; import me.zhengjie.repository.GenConfigRepository;
import me.zhengjie.repository.jpa.GenConfigRepository;
import me.zhengjie.service.GenConfigService; import me.zhengjie.service.GenConfigService;
import me.zhengjie.utils.StringUtils; import me.zhengjie.utils.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,7 +31,7 @@ import java.io.File;
@RequiredArgsConstructor @RequiredArgsConstructor
public class GenConfigServiceImpl implements GenConfigService { public class GenConfigServiceImpl implements GenConfigService {
private final GenConfigDao genConfigDao; private final GenConfigRepository genConfigDao;
@Override @Override
public GenConfig find(String tableName) { public GenConfig find(String tableName) {

View File

@ -23,7 +23,7 @@ import me.zhengjie.domain.GenConfig;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.domain.vo.TableInfo; import me.zhengjie.domain.vo.TableInfo;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.repository.ColumnInfoDao; import me.zhengjie.repository.ColumnInfoRepository;
import me.zhengjie.service.GeneratorService; import me.zhengjie.service.GeneratorService;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.GenUtil; import me.zhengjie.utils.GenUtil;
@ -58,7 +58,7 @@ public class GeneratorServiceImpl implements GeneratorService {
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
private final ColumnInfoDao columnInfoDao; private final ColumnInfoRepository columnInfoDao;
@Override @Override
public Object getTables() { public Object getTables() {

View File

@ -19,8 +19,8 @@ import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.config.GlobalConfig; import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator; import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
import com.baomidou.mybatisplus.core.toolkit.*; import com.baomidou.mybatisplus.core.toolkit.*;
import me.zhengjie.mybatis.annotation.impl.TableFieldImp; import me.zhengjie.db.mybatis.TableFieldImp;
import me.zhengjie.mybatis.annotation.impl.TableIdImp; import me.zhengjie.db.mybatis.TableIdImp;
import org.apache.ibatis.builder.MapperBuilderAssistant; import org.apache.ibatis.builder.MapperBuilderAssistant;
import org.apache.ibatis.builder.StaticSqlSource; import org.apache.ibatis.builder.StaticSqlSource;
import org.apache.ibatis.executor.keygen.KeyGenerator; import org.apache.ibatis.executor.keygen.KeyGenerator;