mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
remove IService to core module and add ServiceImpl for solon
This commit is contained in:
parent
6e0c00d2e7
commit
5e5210c638
@ -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;
|
||||
|
||||
@ -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<T> {
|
||||
* @param entities 实体类对象
|
||||
* @return {@code true} 保存成功,{@code false} 保存失败。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
default boolean saveBatch(Collection<T> entities) {
|
||||
return SqlUtil.toBool(getMapper().insertBatch(new ArrayList<>(entities)));
|
||||
}
|
||||
@ -92,7 +90,6 @@ public interface IService<T> {
|
||||
* @param size 每次保存切分的数量
|
||||
* @return {@code true} 保存成功,{@code false} 保存失败。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
default boolean saveBatch(Collection<T> entities, int size) {
|
||||
return SqlUtil.toBool(getMapper().insertBatch(new ArrayList<>(entities), size));
|
||||
}
|
||||
@ -133,7 +130,6 @@ public interface IService<T> {
|
||||
* @param ids 数据主键
|
||||
* @return {@code true} 删除成功,{@code false} 删除失败。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
default boolean removeByIds(Collection<? extends Serializable> ids) {
|
||||
if (CollectionUtil.isEmpty(ids)) {
|
||||
return false;
|
||||
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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<M extends BaseMapper<T>, T> implements IService<T> {
|
||||
|
||||
@Inject
|
||||
protected M mapper;
|
||||
|
||||
@Override
|
||||
public BaseMapper<T> getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user