From 5e5210c6386128fefd241cce42110a3d709e709f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90=E6=B5=B7=E5=93=A5?= Date: Fri, 19 May 2023 11:19:26 +0800 Subject: [PATCH] remove IService to core module and add ServiceImpl for solon --- .../codegen/config/GlobalConfig.java | 2 +- .../mybatisflex/core}/service/IService.java | 6 +--- .../solon/service/impl/ServiceImpl.java | 32 +++++++++++++++++++ .../spring/service/impl/ServiceImpl.java | 2 +- 4 files changed, 35 insertions(+), 7 deletions(-) rename {mybatis-flex-spring/src/main/java/com/mybatisflex/spring => mybatis-flex-core/src/main/java/com/mybatisflex/core}/service/IService.java (98%) create mode 100644 mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java index 438b3de0..3f244b93 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/GlobalConfig.java @@ -19,7 +19,7 @@ import com.mybatisflex.codegen.template.EnjoyTemplate; import com.mybatisflex.codegen.template.ITemplate; import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.util.StringUtil; -import com.mybatisflex.spring.service.IService; +import com.mybatisflex.core.service.IService; import com.mybatisflex.spring.service.impl.ServiceImpl; import java.io.Serializable; diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/IService.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java similarity index 98% rename from mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/IService.java rename to mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java index 224d34f4..8b72f592 100644 --- a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/IService.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.mybatisflex.spring.service; +package com.mybatisflex.core.service; import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.paginate.Page; @@ -24,7 +24,6 @@ import com.mybatisflex.core.row.RowMapper; import com.mybatisflex.core.util.ClassUtil; import com.mybatisflex.core.util.CollectionUtil; import com.mybatisflex.core.util.SqlUtil; -import org.springframework.transaction.annotation.Transactional; import java.io.Serializable; import java.util.*; @@ -78,7 +77,6 @@ public interface IService { * @param entities 实体类对象 * @return {@code true} 保存成功,{@code false} 保存失败。 */ - @Transactional(rollbackFor = Exception.class) default boolean saveBatch(Collection entities) { return SqlUtil.toBool(getMapper().insertBatch(new ArrayList<>(entities))); } @@ -92,7 +90,6 @@ public interface IService { * @param size 每次保存切分的数量 * @return {@code true} 保存成功,{@code false} 保存失败。 */ - @Transactional(rollbackFor = Exception.class) default boolean saveBatch(Collection entities, int size) { return SqlUtil.toBool(getMapper().insertBatch(new ArrayList<>(entities), size)); } @@ -133,7 +130,6 @@ public interface IService { * @param ids 数据主键 * @return {@code true} 删除成功,{@code false} 删除失败。 */ - @Transactional(rollbackFor = Exception.class) default boolean removeByIds(Collection ids) { if (CollectionUtil.isEmpty(ids)) { return false; diff --git a/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java new file mode 100644 index 00000000..0e91f0d6 --- /dev/null +++ b/mybatis-flex-solon-plugin/src/main/java/com/mybatisflex/solon/service/impl/ServiceImpl.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *

+ * 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 com.mybatisflex.solon.service.impl; + +import com.mybatisflex.core.BaseMapper; +import com.mybatisflex.core.service.IService; +import org.noear.solon.annotation.Inject; + +public class ServiceImpl, T> implements IService { + + @Inject + protected M mapper; + + @Override + public BaseMapper getMapper() { + return mapper; + } + +} \ No newline at end of file diff --git a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/ServiceImpl.java b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/ServiceImpl.java index 91a748d3..0ab81c33 100644 --- a/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/ServiceImpl.java +++ b/mybatis-flex-spring/src/main/java/com/mybatisflex/spring/service/impl/ServiceImpl.java @@ -16,7 +16,7 @@ package com.mybatisflex.spring.service.impl; import com.mybatisflex.core.BaseMapper; -import com.mybatisflex.spring.service.IService; +import com.mybatisflex.core.service.IService; import org.springframework.beans.factory.annotation.Autowired; /**