ChainWrappers.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. * <p>
  8. * https://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.baomidou.mybatisplus.extension.toolkit;
  17. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  18. import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
  19. import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
  20. import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
  21. import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
  22. /**
  23. * 快捷构造 chain 式调用的工具类
  24. *
  25. * @author miemie
  26. * @since 2019-11-28
  27. * @since 3.2.1
  28. */
  29. public final class ChainWrappers {
  30. private ChainWrappers() {
  31. // ignore
  32. }
  33. /**
  34. * 链式查询 普通
  35. *
  36. * @return QueryWrapper 的包装类
  37. */
  38. public static <T> QueryChainWrapper<T> queryChain(BaseMapper<T> mapper) {
  39. return new QueryChainWrapper<>(mapper);
  40. }
  41. /**
  42. * 链式查询 lambda 式
  43. * <p>注意:不支持 Kotlin </p>
  44. *
  45. * @return LambdaQueryWrapper 的包装类
  46. */
  47. public static <T> LambdaQueryChainWrapper<T> lambdaQueryChain(BaseMapper<T> mapper) {
  48. return new LambdaQueryChainWrapper<>(mapper);
  49. }
  50. /**
  51. * 链式更改 普通
  52. *
  53. * @return UpdateWrapper 的包装类
  54. */
  55. public static <T> UpdateChainWrapper<T> updateChain(BaseMapper<T> mapper) {
  56. return new UpdateChainWrapper<>(mapper);
  57. }
  58. /**
  59. * 链式更改 lambda 式
  60. * <p>注意:不支持 Kotlin </p>
  61. *
  62. * @return LambdaUpdateWrapper 的包装类
  63. */
  64. public static <T> LambdaUpdateChainWrapper<T> lambdaUpdateChain(BaseMapper<T> mapper) {
  65. return new LambdaUpdateChainWrapper<>(mapper);
  66. }
  67. }