From 26fc652d33fb82a75d6ec7771ca50ee414b21723 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期二, 11 一月 2022 16:58:47 +0800 Subject: [PATCH] update 统一代码间隔符 --- ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java | 268 ++++++++++++++++++++++++++-------------------------- 1 files changed, 134 insertions(+), 134 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java index 740cc28..50f8480 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/core/ServicePlusImpl.java @@ -31,172 +31,172 @@ @SuppressWarnings("unchecked") public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceImpl<M, T> implements IServicePlus<T, V> { - @Autowired - protected M baseMapper; + @Autowired + protected M baseMapper; - @Override - public M getBaseMapper() { - return baseMapper; - } + @Override + public M getBaseMapper() { + return baseMapper; + } - protected Class<T> entityClass = currentModelClass(); + protected Class<T> entityClass = currentModelClass(); - @Override - public Class<T> getEntityClass() { - return entityClass; - } + @Override + public Class<T> getEntityClass() { + return entityClass; + } - protected Class<M> mapperClass = currentMapperClass(); + protected Class<M> mapperClass = currentMapperClass(); - protected Class<V> voClass = currentVoClass(); + protected Class<V> voClass = currentVoClass(); - public Class<V> getVoClass() { - return voClass; - } + public Class<V> getVoClass() { + return voClass; + } - @Override - protected Class<M> currentMapperClass() { - return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0); - } + @Override + protected Class<M> currentMapperClass() { + return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0); + } - @Override - protected Class<T> currentModelClass() { - return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1); - } + @Override + protected Class<T> currentModelClass() { + return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1); + } - protected Class<V> currentVoClass() { - return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2); - } + protected Class<V> currentVoClass() { + return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2); + } - /** - * 鍗曟潯鎵ц鎬ц兘宸� 閫傜敤浜庡垪琛ㄥ璞″唴瀹逛笉纭畾 - */ - @Override - public boolean saveBatch(Collection<T> entityList, int batchSize) { - return super.saveBatch(entityList, batchSize); - } + /** + * 鍗曟潯鎵ц鎬ц兘宸� 閫傜敤浜庡垪琛ㄥ璞″唴瀹逛笉纭畾 + */ + @Override + public boolean saveBatch(Collection<T> entityList, int batchSize) { + return super.saveBatch(entityList, batchSize); + } - @Override - public boolean saveOrUpdate(T entity) { - return super.saveOrUpdate(entity); - } + @Override + public boolean saveOrUpdate(T entity) { + return super.saveOrUpdate(entity); + } - /** - * 鍗曟潯鎵ц鎬ц兘宸� 閫傜敤浜庡垪琛ㄥ璞″唴瀹逛笉纭畾 - */ - @Override - public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) { - return super.saveOrUpdateBatch(entityList, batchSize); - } + /** + * 鍗曟潯鎵ц鎬ц兘宸� 閫傜敤浜庡垪琛ㄥ璞″唴瀹逛笉纭畾 + */ + @Override + public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) { + return super.saveOrUpdateBatch(entityList, batchSize); + } - @Override - public boolean updateBatchById(Collection<T> entityList, int batchSize) { - return super.updateBatchById(entityList, batchSize); - } + @Override + public boolean updateBatchById(Collection<T> entityList, int batchSize) { + return super.updateBatchById(entityList, batchSize); + } - /** - * 鍗晄ql鎵归噺鎻掑叆( 鍏ㄩ噺濉厖 鏃犺鏁版嵁搴撻粯璁ゅ�� ) - * 閫傜敤浜庢棤鑴戞彃鍏� - */ - @Override - public boolean saveBatch(Collection<T> entityList) { - return saveBatch(entityList, DEFAULT_BATCH_SIZE); - } + /** + * 鍗晄ql鎵归噺鎻掑叆( 鍏ㄩ噺濉厖 鏃犺鏁版嵁搴撻粯璁ゅ�� ) + * 閫傜敤浜庢棤鑴戞彃鍏� + */ + @Override + public boolean saveBatch(Collection<T> entityList) { + return saveBatch(entityList, DEFAULT_BATCH_SIZE); + } - @Override - public boolean saveOrUpdateBatch(Collection<T> entityList) { - return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE); - } + @Override + public boolean saveOrUpdateBatch(Collection<T> entityList) { + return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE); + } - @Override - public boolean updateBatchById(Collection<T> entityList) { - return updateBatchById(entityList, DEFAULT_BATCH_SIZE); - } + @Override + public boolean updateBatchById(Collection<T> entityList) { + return updateBatchById(entityList, DEFAULT_BATCH_SIZE); + } - /** - * 鍗晄ql鎵归噺鎻掑叆( 鍏ㄩ噺濉厖 ) - */ - @Override - public boolean saveAll(Collection<T> entityList) { - if (CollUtil.isEmpty(entityList)) { - return false; - } - return baseMapper.insertAll(entityList) == entityList.size(); - } + /** + * 鍗晄ql鎵归噺鎻掑叆( 鍏ㄩ噺濉厖 ) + */ + @Override + public boolean saveAll(Collection<T> entityList) { + if (CollUtil.isEmpty(entityList)) { + return false; + } + return baseMapper.insertAll(entityList) == entityList.size(); + } - /** - * 鍏ㄩ噺淇濆瓨鎴栨洿鏂� ( 鎸変富閿尯鍒� ) - */ - @Override - public boolean saveOrUpdateAll(Collection<T> entityList) { - if (CollUtil.isEmpty(entityList)) { - return false; - } - TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass); - Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); - String keyProperty = tableInfo.getKeyProperty(); - Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); - List<T> addList = new ArrayList<>(); - List<T> updateList = new ArrayList<>(); - int row = 0; - for (T entity : entityList) { - Object id = ReflectUtils.invokeGetter(entity, keyProperty); - if (ObjectUtil.isNull(id)) { - addList.add(entity); - } else { - updateList.add(entity); - } - } - if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) { - row += updateList.size(); - } + /** + * 鍏ㄩ噺淇濆瓨鎴栨洿鏂� ( 鎸変富閿尯鍒� ) + */ + @Override + public boolean saveOrUpdateAll(Collection<T> entityList) { + if (CollUtil.isEmpty(entityList)) { + return false; + } + TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass); + Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); + String keyProperty = tableInfo.getKeyProperty(); + Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); + List<T> addList = new ArrayList<>(); + List<T> updateList = new ArrayList<>(); + int row = 0; + for (T entity : entityList) { + Object id = ReflectUtils.invokeGetter(entity, keyProperty); + if (ObjectUtil.isNull(id)) { + addList.add(entity); + } else { + updateList.add(entity); + } + } + if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) { + row += updateList.size(); + } if (CollUtil.isNotEmpty(addList)) { row += baseMapper.insertAll(addList); } - return row == entityList.size(); - } + return row == entityList.size(); + } - /** - * 鏍规嵁 ID 鏌ヨ - */ - @Override - public V getVoById(Serializable id) { + /** + * 鏍规嵁 ID 鏌ヨ + */ + @Override + public V getVoById(Serializable id) { return getBaseMapper().selectVoById(id, voClass); - } + } - /** - * 鏌ヨ锛堟牴鎹甀D 鎵归噺鏌ヨ锛� - */ - @Override - public List<V> listVoByIds(Collection<? extends Serializable> idList) { + /** + * 鏌ヨ锛堟牴鎹甀D 鎵归噺鏌ヨ锛� + */ + @Override + public List<V> listVoByIds(Collection<? extends Serializable> idList) { return getBaseMapper().selectVoBatchIds(idList, voClass); - } + } - /** - * 鏌ヨ锛堟牴鎹� columnMap 鏉′欢锛� - */ - @Override - public List<V> listVoByMap(Map<String, Object> columnMap) { + /** + * 鏌ヨ锛堟牴鎹� columnMap 鏉′欢锛� + */ + @Override + public List<V> listVoByMap(Map<String, Object> columnMap) { return getBaseMapper().selectVoByMap(columnMap, voClass); - } + } - /** - * 鏍规嵁 Wrapper锛屾煡璇竴鏉¤褰� <br/> - * <p>缁撴灉闆嗭紝濡傛灉鏄涓細鎶涘嚭寮傚父锛岄殢鏈哄彇涓�鏉″姞涓婇檺鍒舵潯浠� wrapper.last("LIMIT 1")</p> - */ - @Override - public V getVoOne(Wrapper<T> queryWrapper) { + /** + * 鏍规嵁 Wrapper锛屾煡璇竴鏉¤褰� <br/> + * <p>缁撴灉闆嗭紝濡傛灉鏄涓細鎶涘嚭寮傚父锛岄殢鏈哄彇涓�鏉″姞涓婇檺鍒舵潯浠� wrapper.last("LIMIT 1")</p> + */ + @Override + public V getVoOne(Wrapper<T> queryWrapper) { return getBaseMapper().selectVoOne(queryWrapper, voClass); - } + } - /** - * 鏌ヨ鍒楄〃 - */ - @Override - public List<V> listVo(Wrapper<T> queryWrapper) { + /** + * 鏌ヨ鍒楄〃 + */ + @Override + public List<V> listVo(Wrapper<T> queryWrapper) { return getBaseMapper().selectVoList(queryWrapper, voClass); - } + } /** * 缈婚〉鏌ヨ -- Gitblit v1.9.3