-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd1563c
commit 0b1f60f
Showing
15 changed files
with
748 additions
and
9 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...erator/src/main/java/com/baomidou/mybatisplus/generator/IGenerateMapperMethodHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2011-2024, baomidou ([email protected]). | ||
* | ||
* 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.generator; | ||
|
||
import com.baomidou.mybatisplus.generator.config.po.TableInfo; | ||
import com.baomidou.mybatisplus.generator.model.MapperMethod; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Mapper层方法生成处理器 | ||
* | ||
* @author nieqiurong | ||
* @since 3.5.10 | ||
*/ | ||
public interface IGenerateMapperMethodHandler { | ||
|
||
/** | ||
* 获取生成方法 | ||
* | ||
* @param tableInfo 表信息 | ||
* @return 索引方法 | ||
*/ | ||
List<MapperMethod> getMethodList(TableInfo tableInfo); | ||
|
||
/** | ||
* 获取需要导入的包 | ||
* | ||
* @param tableInfo 表信息 | ||
* @return 导包列表 | ||
*/ | ||
Set<String> getImportPackages(TableInfo tableInfo); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...r/src/main/java/com/baomidou/mybatisplus/generator/index/AbstractMapperMethodHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2011-2024, baomidou ([email protected]). | ||
* | ||
* 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.generator.index; | ||
|
||
import com.baomidou.mybatisplus.generator.IGenerateMapperMethodHandler; | ||
|
||
/** | ||
* @author nieqiurong | ||
* @since 3.5.10 | ||
*/ | ||
public abstract class AbstractMapperMethodHandler implements IGenerateMapperMethodHandler { | ||
|
||
/** | ||
* 生成Java方法(default) | ||
* <pre> | ||
* default ${returnValue} ${methodName}(${args}) { | ||
* return ${returnBody}; | ||
* } | ||
* <pre/> | ||
* Example: | ||
* <pre> | ||
* default UserInfo selectByCardNo(String cardNo) { | ||
* return selectOne(Wrappers.<UserInfo>query().eq(TUserInfo.CARD_NO, cardNo)); | ||
* } | ||
* </pre> | ||
*/ | ||
public String buildMethod(String methodName, String args, String returnValue, String returnBody) { | ||
return "default" + " " + | ||
returnValue + " " + methodName + "(" + args + ")" + " " + "{" + "\n" + | ||
" return " + returnBody + ";" + "\n" + | ||
" }\n"; | ||
} | ||
|
||
/** | ||
* 构建Kotlin方法 | ||
* <pre> | ||
* fun ${methodName}(${args}) :${returnValue} { | ||
* return ${returnBody}; | ||
* } | ||
* </pre> | ||
* Example: | ||
* <pre> | ||
* fun selectByCardNo(cardNo: String) :UserInfo? { | ||
* return selectOne(Wrappers.query<UserInfo>().eq(UserInfo.CARD_NO, cardNo)); | ||
* } | ||
* </pre> | ||
* | ||
* @param methodName 方法名 | ||
* @param args 参数列表 | ||
* @param returnValue 返回值 | ||
* @param returnBody 返回体 | ||
* @return 方法 | ||
*/ | ||
public String buildKotlinMethod(String methodName, String args, String returnValue, String returnBody) { | ||
return "fun " + methodName + "(" + args + ")" + " :" + returnValue + " {" + "\n" + | ||
" return " + returnBody + ";" + "\n" + | ||
" }\n"; | ||
} | ||
|
||
} |
Oops, something went wrong.