ChainWrappers.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. */
  28. public final class ChainWrappers {
  29. private ChainWrappers() {
  30. // ignore
  31. }
  32. /**
  33. * 链式查询 普通
  34. *
  35. * @return QueryWrapper 的包装类
  36. */
  37. public static <T> QueryChainWrapper<T> chainQuery(BaseMapper<T> mapper) {
  38. return new QueryChainWrapper<>(mapper);
  39. }
  40. /**
  41. * 链式查询 lambda 式
  42. * <p>注意:不支持 Kotlin </p>
  43. *
  44. * @return LambdaQueryWrapper 的包装类
  45. */
  46. public static <T> LambdaQueryChainWrapper<T> chainLambdaQuery(BaseMapper<T> mapper) {
  47. return new LambdaQueryChainWrapper<>(mapper);
  48. }
  49. /**
  50. * 链式更改 普通
  51. *
  52. * @return UpdateWrapper 的包装类
  53. */
  54. public static <T> UpdateChainWrapper<T> chainUpdate(BaseMapper<T> mapper) {
  55. return new UpdateChainWrapper<>(mapper);
  56. }
  57. /**
  58. * 链式更改 lambda 式
  59. * <p>注意:不支持 Kotlin </p>
  60. *
  61. * @return LambdaUpdateWrapper 的包装类
  62. */
  63. public static <T> LambdaUpdateChainWrapper<T> chainLambdaUpdate(BaseMapper<T> mapper) {
  64. return new LambdaUpdateChainWrapper<>(mapper);
  65. }
  66. }