IService.java 4.74 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
/**
* Copyright (c) 2011-2016, hubin (jobob@qq.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.baomidou.mybatisplus.service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;

/**
* <p>
* 顶级 Service
* </p>
*
* @author hubin
* @Date 2016-04-20
*/
public interface IService<T> {

/**
* <p>
* 插入一条记录
* </p>
*
* @param entity
* 实体对象
* @return boolean
*/
boolean insert(T entity);

/**
* <p>
* 插入(批量),该方法不适合 Oracle
* </p>
*
* @param entityList
* 实体对象列表
* @return boolean
*/
boolean insertBatch(List<T> entityList);

/**
* <p>
* 插入(批量)
* </p>
*
* @param entityList
* 实体对象列表
* @param batchSize
*
* @return boolean
*/
boolean insertBatch(List<T> entityList, int batchSize);

/**
* <p>
* 批量修改插入
* </p>
*
* @param entityList
* 实体对象列表
* @return boolean
*/
boolean insertOrUpdateBatch(List<T> entityList);

/**
* <p>
* 批量修改插入
* </p>
*
* @param entityList
* 实体对象列表
* @param batchSize
*
* @return boolean
*/
boolean insertOrUpdateBatch(List<T> entityList, int batchSize);

/**
* <p>
* 根据 ID 删除
* </p>
*
* @param id
* 主键ID
* @return boolean
*/
boolean deleteById(Serializable id);

/**
* <p>
* 根据 columnMap 条件,删除记录
* </p>
*
* @param columnMap
* 表字段 map 对象
* @return boolean
*/
boolean deleteByMap(Map<String, Object> columnMap);

/**
* <p>
* 根据 entity 条件,删除记录
* </p>
*
* @param wrapper
* 实体包装类 {@link Wrapper}
* @return boolean
*/
boolean delete(Wrapper<T> wrapper);

/**
* <p>
* 删除(根据ID 批量删除)
* </p>
*
* @param idList
* 主键ID列表
* @return boolean
*/
boolean deleteBatchIds(List<? extends Serializable> idList);

/**
* <p>
* 根据 ID 修改
* </p>
*
* @param entity
* 实体对象
* @return boolean
*/
boolean updateById(T entity);

/**
* <p>
* 根据 whereEntity 条件,更新记录
* </p>
*
* @param entity
* 实体对象
* @param wrapper
* 实体包装类 {@link Wrapper}
* @return boolean
*/
boolean update(T entity, Wrapper<T> wrapper);

/**
* <p>
* 根据ID 批量更新
* </p>
*
* @param entityList
* 实体对象列表
* @return boolean
*/
boolean updateBatchById(List<T> entityList);

/**
* <p>
* TableId 注解存在更新记录,否插入一条记录
* </p>
*
* @param entity
* 实体对象
* @return boolean
*/
boolean insertOrUpdate(T entity);

/**
* <p>
* 根据 ID 查询
* </p>
*
* @param id
* 主键ID
* @return T
*/
T selectById(Serializable id);

/**
* <p>
* 查询(根据ID 批量查询)
* </p>
*
* @param idList
* 主键ID列表
* @return List<T>
*/
List<T> selectBatchIds(List<? extends Serializable> idList);

/**
* <p>
* 查询(根据 columnMap 条件)
* </p>
*
* @param columnMap
* 表字段 map 对象
* @return List<T>
*/
List<T> selectByMap(Map<String, Object> columnMap);

/**
* <p>
* 根据 Wrapper,查询一条记录
* </p>
*
* @param wrapper
* 实体对象
* @return T
*/
T selectOne(Wrapper<T> wrapper);

/**
* <p>
* 根据 Wrapper 条件,查询总记录数
* </p>
*
* @param wrapper
* 实体对象
* @return int
*/
int selectCount(Wrapper<T> wrapper);

/**
* <p>
* 查询列表
* </p>
*
* @param wrapper
* 实体包装类 {@link Wrapper}
* @return
*/
List<T> selectList(Wrapper<T> wrapper);

/**
* <p>
* 翻页查询
* </p>
*
* @param page
* 翻页对象
* @return
*/
Page<T> selectPage(Page<T> page);

/**
* <p>
* 翻页查询
* </p>
*
* @param page
* 翻页对象
* @param wrapper
* 实体包装类 {@link Wrapper}
* @return
*/
Page<T> selectPage(Page<T> page, Wrapper<T> wrapper);

}