easycode怎么配置成mybatis-plus模板
发表于:2025-11-12 作者:千家信息网编辑
千家信息网最后更新 2025年11月12日,这篇文章主要介绍"easycode怎么配置成mybatis-plus模板",在日常操作中,相信很多人在easycode怎么配置成mybatis-plus模板问题上存在疑惑,小编查阅了各式资料,整理出简
千家信息网最后更新 2025年11月12日easycode怎么配置成mybatis-plus模板
这篇文章主要介绍"easycode怎么配置成mybatis-plus模板",在日常操作中,相信很多人在easycode怎么配置成mybatis-plus模板问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"easycode怎么配置成mybatis-plus模板"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
本文主要介绍了easycode配置成mybatis-plus模板的实现方法,分享给大家,具体如下:
entity.java
##导入宏定义$!define##保存文件(宏定义)#save("/entity", ".java")##包路径(宏定义)#setPackageSuffix("entity")##自动导入包(全局变量)$!autoImportimport com.baomidou.mybatisplus.annotation.IdType;import com.baomidou.mybatisplus.annotation.TableId;import io.swagger.annotations.ApiModel;import io.swagger.annotations.ApiModelProperty;import lombok.AllArgsConstructor;import lombok.Builder;import lombok.Data;import lombok.NoArgsConstructor;import java.io.Serializable;import java.util.Date;##表注释(宏定义)#tableComment("表实体类")@Data@Builder@AllArgsConstructor@NoArgsConstructor@ApiModel("$!{tableInfo.comment}")public class $!{tableInfo.name} implements Serializable {private static final long serialVersionUID = $!tool.serial();#foreach($column in $tableInfo.fullColumn) #if(${column.comment})/** * ${column.comment} */#end #if(${column.comment})@ApiModelProperty(value = "${column.comment}")#end #if($column.name.equals('id'))@TableId(type = IdType.AUTO)#end private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; #end}dao.java
##导入宏定义$!define##设置表后缀(宏定义)#setTableSuffix("Mapper")##保存文件(宏定义)#save("/mapper", "Mapper.java")##包路径(宏定义)#setPackageSuffix("mapper")import com.baomidou.mybatisplus.core.mapper.BaseMapper;import $!{tableInfo.savePackageName}.entity.$!tableInfo.name;##表注释(宏定义)#tableComment("表数据库访问层")public interface $!{tableName} extends BaseMapper<$!tableInfo.name> {}server.java
##导入宏定义$!define##设置表后缀(宏定义)#setTableSuffix("Service")##保存文件(宏定义)#save("/service", "Service.java")##包路径(宏定义)#setPackageSuffix("service")import com.baomidou.mybatisplus.extension.service.IService;import $!{tableInfo.savePackageName}.entity.$!tableInfo.name;##表注释(宏定义)#tableComment("表服务接口")public interface $!{tableName} extends IService<$!tableInfo.name> {}serverImpl.java
##导入宏定义$!define##设置表后缀(宏定义)#setTableSuffix("ServiceImpl")##保存文件(宏定义)#save("/service/impl", "ServiceImpl.java")##包路径(宏定义)#setPackageSuffix("service.impl")import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};import $!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper;import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;import lombok.extern.slf4j.Slf4j;import org.springframework.stereotype.Service;##表注释(宏定义)#tableComment("表服务实现类")@Slf4j@Servicepublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Mapper, $!{tableInfo.name}> implements $!{tableInfo.name}Service {}controller.java
##导入宏定义$!define##设置表后缀(宏定义)#setTableSuffix("Controller")##保存文件(宏定义)#save("/controller", "Controller.java")##包路径(宏定义)#setPackageSuffix("controller")##定义服务名#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service"))##定义实体对象名#set($entityName = $!tool.firstLowerCase($!tableInfo.name))import $!{tableInfo.savePackageName}.entity.$!tableInfo.name;import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;import io.swagger.annotations.ApiOperation;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;import com.baomidou.mybatisplus.core.metadata.IPage;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import com.baomidou.mybatisplus.extension.api.R;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.*;import java.io.Serializable;import java.util.List;##表注释(宏定义)#tableComment("表控制层[不建议修改,如果有新增的方法,写在子类中]")@RestControllerpublic class $!{tableName} { /** * 服务对象 */ @Autowired $!{tableInfo.name}Service $!{serviceName}; /** * 分页查询所有数据 * * @param page 分页对象 * @param $!entityName 查询实体 * @return 所有数据 */ @ApiOperation("分页查询所有数据") @GetMapping public R> selectAll(Page<$!tableInfo.name> page, $!tableInfo.name $!entityName) { return R.ok ($!{serviceName}.page(page, new QueryWrapper<>($!entityName))); } /** * 通过主键查询单条数据 * * @param id 主键 * @return 单条数据 */ @ApiOperation("通过主键查询单条数据") @GetMapping("{id}") public R<$!tableInfo.name> selectOne(@PathVariable Serializable id) { return R.ok($!{serviceName}.getById(id)); } /** * 新增数据 * * @param $!entityName 实体对象 * @return 新增结果 */ @ApiOperation("新增数据") @PostMapping public R insert(@RequestBody $!tableInfo.name $!entityName) { boolean rs = $!{serviceName}.save($!entityName); return R.ok(rs?$!{entityName}.getId():0); } /** * 修改数据 * * @param $!entityName 实体对象 * @return 修改结果 */ @ApiOperation("修改数据") @PutMapping public R update(@RequestBody $!tableInfo.name $!entityName) { return R.ok($!{serviceName}.updateById($!entityName)); } /** * 单条/批量删除数据 * * @param idList 主键集合 * @return 删除结果 */ @ApiOperation("单条/批量删除数据") @DeleteMapping public R delete(@RequestParam("idList") List idList) { return R.ok($!{serviceName}.removeByIds(idList)); }} mapper.xml
##引入mybatis支持$!mybatisSupport##设置保存名称与保存位置$!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.xml"))$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))##拿到主键#if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0))#end #foreach($column in $tableInfo.fullColumn) #end 修改签名
到此,关于"easycode怎么配置成mybatis-plus模板"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
数据
模板
配置
实体
对象
文件
注释
路径
查询
后缀
学习
服务
方法
结果
更多
帮助
实用
接下来
位置
全局
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
vivo采购网络安全红线
当前主流的数据库是
网络安全防护技能活动
三国杀服务器登录错误代码75
独立软件开发文档设计
郑州科技互联网环境怎么样
甘肃专升本数据库应用能力
建行网络安全应急措施
微软香港服务器怎么样
中国数据库技术发展
pg数据库迁移教程
动态ipv4服务器
山西一对一网络技术咨询口碑推荐
丽江服务器上门回收价格表
宜宾市委网络安全和信息委员会
云服务器是不是可以当虚拟主机用
互联网的根服务器与网络安全
深圳专业软件开发回收价
天津网络数据库技术
多用户网络版数据库
网络安全治理理念
阿联酋5g网络技术
php查询数据库集合
火河科技服务器
青少年网络安全知识心得
西宁app软件开发制作
昌邑租房软件开发
公安里面的网络安全管理部门
网络安全方面知识手抄报
服务器销售渠道