|
@@ -0,0 +1,21 @@
|
|
|
+package com.szwl.service.base;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
+
|
|
|
+public interface MyIService<T> extends IService<T> {
|
|
|
+ /**
|
|
|
+ * 仅有一条数据
|
|
|
+ * @param wrapper
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ default T getOnly(QueryWrapper<T> wrapper){
|
|
|
+ wrapper.last("limit 1");
|
|
|
+ return this.getOne(wrapper);
|
|
|
+ };
|
|
|
+ default T getOnly(LambdaQueryWrapper<T> wrapper){
|
|
|
+ wrapper.last("limit 1");
|
|
|
+ return this.getOne(wrapper);
|
|
|
+ };
|
|
|
+}
|