easycode模版-基于ruoyi-cloud
- ##定义初始变量
- #set($tableName = $tool.append($tableInfo.name, "Controller"))
- ##设置回调
- $!callback.setFileName($tool.append($tableName, ".java"))
- $!callback.setSavePath($tool.append($tableInfo.savePath, "/controller"))
- ##拿到主键
- #if(!$tableInfo.pkColumn.isEmpty())
- #set($pk = $tableInfo.pkColumn.get(0))
- #end
- #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;
- import com.ruoyi.common.core.web.page.TableDataInfo;
- import $!{tableInfo.savePackageName}.domain.$!{tableInfo.name};
- import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
- import org.springframework.web.bind.annotation.*;
- import com.ruoyi.common.core.web.domain.AjaxResult;
- import com.ruoyi.common.core.web.controller.BaseController;
- import java.util.List;
- import javax.annotation.Resource;
- /**
- * $!{tableInfo.comment}($!{tableInfo.name})表控制层
- *
- * @author $!author
- * @since $!time.currTime()
- */
- @RestController
- @RequestMapping("$!tool.firstLowerCase($tableInfo.name)")
- public class $!{tableName} extends BaseController {
- /**
- * 服务对象
- */
- @Resource
- private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;
- /**
- * 分页查询
- *
- * @param $!{tool.firstLowerCase($tableInfo.name)} 筛选条件
- * @return 查询结果
- */
- @GetMapping("list")
- public TableDataInfo<$!{tableInfo.name}> listPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
- startPage();
- List<$!{tableInfo.name}> list = this.$!{tool.firstLowerCase($tableInfo.name)}Service.list($!{tool.firstLowerCase($tableInfo.name)});
- return getDataTable(list);
- }
- /**
- * 通过主键查询单条数据
- *
- * @param id 主键
- * @return 单条数据
- */
- @GetMapping("{id}")
- public AjaxResult<$!{tableInfo.name}> query(@PathVariable("id") $!pk.shortType id) {
- return AjaxResult.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.getById(id));
- }
- /**
- * 新增数据
- *
- * @param $!{tool.firstLowerCase($tableInfo.name)} 实体
- * @return 新增结果
- */
- @PostMapping
- public AjaxResult add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
- return this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)}) ? AjaxResult.success() : AjaxResult.error400();
- }
- /**
- * 编辑数据
- *
- * @param $!{tool.firstLowerCase($tableInfo.name)} 实体
- * @return 编辑结果
- */
- @PutMapping
- public AjaxResult edit($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
- return this.$!{tool.firstLowerCase($tableInfo.name)}Service.update($!{tool.firstLowerCase($tableInfo.name)}) ? AjaxResult.success() : AjaxResult.error400();
- }
- /**
- * 删除数据
- *
- * @param id 主键
- * @return 删除是否成功
- */
- @DeleteMapping
- public AjaxResult deleteById($!pk.shortType id) {
- return this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id) ? AjaxResult.success() : AjaxResult.error400();
- }
- }
- ##定义初始变量
- #set($tableName = $tool.append($tableInfo.name, "Mapper"))
- ##设置回调
- $!callback.setFileName($tool.append($tableName, ".java"))
- $!callback.setSavePath($tool.append($tableInfo.savePath, "/mapper"))
- ##拿到主键
- #if(!$tableInfo.pkColumn.isEmpty())
- #set($pk = $tableInfo.pkColumn.get(0))
- #end
- #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}mapper;
- import $!{tableInfo.savePackageName}.domain.$!{tableInfo.name};
- import org.apache.ibatis.annotations.Param;
- import java.util.List;
- /**
- * $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层
- *
- * @author $!author
- * @since $!time.currTime()
- */
- public interface $!{tableName} {
- /**
- * 通过ID查询单条数据
- *
- * @param $!pk.name 主键
- * @return 实例对象
- */
- $!{tableInfo.name} getById($!pk.shortType $!pk.name);
- /**
- * 查询指定行数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件
- * @return 对象列表
- */
- List<$!{tableInfo.name}> list($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 统计总行数
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件
- * @return 总行数
- */
- long count($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 新增数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
- * @return 影响行数
- */
- int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 批量新增数据(MyBatis原生foreach方法)
- *
- * @param entities List<$!{tableInfo.name}> 实例对象列表
- * @return 影响行数
- */
- int insertBatch(@Param("entities") List<$!{tableInfo.name}> entities);
- /**
- * 批量新增或按主键更新数据(MyBatis原生foreach方法)
- *
- * @param entities List<$!{tableInfo.name}> 实例对象列表
- * @return 影响行数
- * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
- */
- int insertOrUpdateBatch(@Param("entities") List<$!{tableInfo.name}> entities);
- /**
- * 修改数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
- * @return 影响行数
- */
- int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 通过主键删除数据
- *
- * @param $!pk.name 主键
- * @return 影响行数
- */
- int deleteById($!pk.shortType $!pk.name);
- }
- ##引入宏定义
- $!{define.vm}
- ##使用宏定义设置回调(保存位置与文件后缀)
- #save("/domain", ".java")
- ##使用宏定义设置包后缀
- #setPackageSuffix("domain")
- ##使用全局变量实现默认包导入
- $!{autoImport.vm}
- import java.io.Serializable;
- ##使用宏定义实现类注释信息
- #tableComment("实体类")
- public class $!{tableInfo.name} implements Serializable {
- private static final long serialVersionUID = $!tool.serial();
- #foreach($column in $tableInfo.fullColumn)
- #if(${column.comment})/**
- * ${column.comment}
- */#end
- private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
- #end
- #foreach($column in $tableInfo.fullColumn)
- ##使用宏定义实现get,set方法
- #getSetMethod($column)
- #end
- }
##引入mybatis支持
$!{mybatisSupport.vm}
##设置保存名称与保存位置
$!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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper">
<resultMap id="$!{tableInfo.name}Po" type="$!{tableInfo.savePackageName}.domain.$!{tableInfo.name}">
<!--@Table $!{tableInfo.obj.name}-->
#foreach($column in $tableInfo.fullColumn)
<result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/>
#end
</resultMap>
<sql id="selectPo">
select
#allSqlColumn()
from $!tableInfo.obj.name
</sql>
<!--查询单个-->
<select id="getById" resultMap="$!{tableInfo.name}Po">
<include refid="selectPo"/>
where $!pk.obj.name = #{$!pk.name}
</select>
<!--查询指定行数据-->
<select id="list" resultMap="$!{tableInfo.name}Po">
<include refid="selectPo"/>
<where>
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
and $!column.obj.name = #{$!column.name}
</if>
#end
</where>
order by $!pk.obj.name desc
</select>
<!-- 新增选择列 -->
<insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.name}
<trim prefix="(" suffix=")" suffixOverrides="," >
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">`$!column.obj.name`,</if>
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">#{$!column.name},</if>
#end
</trim>
</insert>
<insert id="insertBatch" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values
<foreach collection="entities" item="entity" separator=",">
(#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values
<foreach collection="entities" item="entity" separator=",">
(#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)
</foreach>
on duplicate key update
#foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name)#if($velocityHasNext),
#end#end
</insert>
<!--通过主键修改数据-->
<update id="update">
update $!{tableInfo.obj.name}
<set>
#foreach($column in $tableInfo.otherColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">$!column.obj.name = #{$!column.name},</if>
#end
</set>
where $!pk.obj.name = #{$!pk.name}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}
</delete>
</mapper>
- ##定义初始变量
- #set($tableName = $tool.append($tableInfo.name, "Service"))
- ##设置回调
- $!callback.setFileName($tool.append($tableName, ".java"))
- $!callback.setSavePath($tool.append($tableInfo.savePath, "/service"))
- ##拿到主键
- #if(!$tableInfo.pkColumn.isEmpty())
- #set($pk = $tableInfo.pkColumn.get(0))
- #end
- #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;
- import $!{tableInfo.savePackageName}.domain.$!{tableInfo.name};
- import java.util.List;
- /**
- * $!{tableInfo.comment}($!{tableInfo.name})表服务接口
- *
- * @author $!author
- * @since $!time.currTime()
- */
- public interface $!{tableName} {
- /**
- * 通过ID查询单条数据
- *
- * @param $!pk.name 主键
- * @return 实例对象
- */
- $!{tableInfo.name} getById($!pk.shortType $!pk.name);
- /**
- * 分页查询
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 筛选条件
- * @return 查询结果
- */
- List<$!{tableInfo.name}> list($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 新增数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
- * @return 实例对象
- */
- boolean insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 修改数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
- * @return 实例对象
- */
- boolean update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
- /**
- * 通过主键删除数据
- *
- * @param $!pk.name 主键
- * @return 是否成功
- */
- boolean deleteById($!pk.shortType $!pk.name);
- }
- ##定义初始变量
- #set($tableName = $tool.append($tableInfo.name, "ServiceImpl"))
- ##设置回调
- $!callback.setFileName($tool.append($tableName, ".java"))
- $!callback.setSavePath($tool.append($tableInfo.savePath, "/service/impl"))
- ##拿到主键
- #if(!$tableInfo.pkColumn.isEmpty())
- #set($pk = $tableInfo.pkColumn.get(0))
- #end
- #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;
- import $!{tableInfo.savePackageName}.domain.$!{tableInfo.name};
- import $!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper;
- import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
- import org.springframework.stereotype.Service;
- import java.util.List;
- import javax.annotation.Resource;
- /**
- * $!{tableInfo.comment}($!{tableInfo.name})表服务实现类
- *
- * @author $!author
- * @since $!time.currTime()
- */
- @Service("$!tool.firstLowerCase($!{tableInfo.name})Service")
- public class $!{tableName} implements $!{tableInfo.name}Service {
- @Resource
- private $!{tableInfo.name}Mapper $!tool.firstLowerCase($!{tableInfo.name})Mapper;
- /**
- * 通过ID查询单条数据
- *
- * @param $!pk.name 主键
- * @return 实例对象
- */
- @Override
- public $!{tableInfo.name} getById($!pk.shortType $!pk.name) {
- return this.$!{tool.firstLowerCase($!{tableInfo.name})}Mapper.getById($!pk.name);
- }
- /**
- * 分页查询
- *
- * @param $!{tool.firstLowerCase($tableInfo.name)} 筛选条件
- * @return 查询结果
- */
- @Override
- public List<$!{tableInfo.name}> list($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
- return this.$!{tool.firstLowerCase($tableInfo.name)}Mapper.list($!{tool.firstLowerCase($tableInfo.name)});
- }
- /**
- * 新增数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
- * @return 实例对象
- */
- @Override
- public boolean insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
- return this.$!{tool.firstLowerCase($!{tableInfo.name})}Mapper.insert($!tool.firstLowerCase($!{tableInfo.name})) > 0;
- }
- /**
- * 修改数据
- *
- * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
- * @return 实例对象
- */
- @Override
- public boolean update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
- return this.$!{tool.firstLowerCase($!{tableInfo.name})}Mapper.update($!tool.firstLowerCase($!{tableInfo.name})) > 0;
- }
- /**
- * 通过主键删除数据
- *
- * @param $!pk.name 主键
- * @return 是否成功
- */
- @Override
- public boolean deleteById($!pk.shortType $!pk.name) {
- return this.$!{tool.firstLowerCase($!{tableInfo.name})}Mapper.deleteById($!pk.name) > 0;
- }
- }
easycode模版-基于ruoyi-cloud的更多相关文章
- 基于Spring Cloud和Netflix OSS 构建微服务-Part 1
前一篇文章<微服务操作模型>中,我们定义了微服务使用的操作模型.这篇文章中,我们将开始使用Spring Cloud和Netflix OSS实现这一模型,包含核心部分:服务发现(Servic ...
- 基于Spring Cloud和Netflix OSS构建微服务,Part 2
在上一篇文章中,我们已使用Spring Cloud和Netflix OSS中的核心组件,如Eureka.Ribbon和Zuul,部分实现了操作模型(operations model),允许单独部署的微 ...
- 基于Spring Cloud、JWT 的微服务权限系统设计
基于Spring Cloud.JWT 的微服务权限系统设计 https://gitee.com/log4j/pig https://github.com/kioyong/spring-cloud-de ...
- 基于Spring cloud Ribbon和Eureka实现客户端负载均衡
前言 本案例将基于Spring cloud Ribbon和Eureka实现客户端负载均衡,其中Ribbon用于实现客户端负载均衡,Eureka主要是用于服务注册及发现: 传统的服务端负载均衡 常见的服 ...
- 基于Spring Cloud的微服务入门教程
(本教程的原地址发布在本人的简书上:http://www.jianshu.com/p/947d57d042e7,若各位看官有什么问题或不同看法请在这里或简书留言,谢谢!) 本人也是前段时间才开始接触S ...
- 干货|基于 Spring Cloud 的微服务落地
转自 微服务架构模式的核心在于如何识别服务的边界,设计出合理的微服务.但如果要将微服务架构运用到生产项目上,并且能够发挥该架构模式的重要作用,则需要微服务框架的支持. 在Java生态圈,目前使用较多的 ...
- 基于Spring Cloud的微服务落地
微服务架构模式的核心在于如何识别服务的边界,设计出合理的微服务.但如果要将微服务架构运用到生产项目上,并且能够发挥该架构模式的重要作用,则需要微服务框架的支持. 在Java生态圈,目前使用较多的微服务 ...
- Weshop基于Spring Cloud开发的小程序商城系统
WESHOP | 基于微服务的小程序商城系统 Weshop是基于Spring Cloud(Greenwich)开发的小程序商城系统,提供整套公共微服务服务模块,包含用户中心.商品中心.订单中心.营销中 ...
- 基于Spring Cloud 几行配置完成单点登录开发
单点登录概念 单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统. ...
- 基于 Spring Cloud 的微服务架构实践指南(下)
show me the code and talk to me,做的出来更要说的明白 本文源码,请点击learnSpringCloud 我是布尔bl,你的支持是我分享的动力! 一.引入 上回 基于 S ...
随机推荐
- Finance财务软件(权限管理专题)
我们支持按模块对用户授权 如上所示,我们对用户test进行授权.test登录系统后将看不到未授权的菜单:
- C++时间日期相关
// 计时 #pragma once #include <iostream> #include <thread> #include <chrono> #includ ...
- visual studio 2015 IOS开发连接mac时提示错误couldn't connect to xxxx, please try again的一个方法
本人使用虚拟机MAC.原本使用虚拟机中的VS2015连接正常没有问题. 但是当把MAC的虚拟机文件COPY到另一个机器上,提示"couldn't connect to xxxx, plea ...
- go读取excel的内容
import "github.com/360EntSecGroup-Skylar/excelize" func SimulationDataHandler(){ f, err := ...
- windows 批量杀进程
1 import psutil 2 from subprocess import Popen, PIPE 3 4 process_name ="bsmr.exe,fxclient.exe,F ...
- 根据STM32CubeMX软件创建STM32芯片的Altium Designer原理图库教程-转载
(24条消息) 根据STM32CubeMX软件创建STM32芯片的Altium Designer原理图库教程_奥比克_阿彦少爷的博客-CSDN博客_stm32原理图库 1所需软件及环境1.STM32C ...
- vue中key
使用key维护列表的状态 当列表的数据变化时,默认情况下,vue尽可能的服用已存在的DOM元素,从而提升渲染的性能.但这种默认的性能优化策略,会导致由状态的列表无法被正确更新. key的使用注意事项: ...
- Python打包时包含静态文件处理方法
Python打包时包含静态文件处理方法 使用场景 已搭建了PyPI私有库,上传公共库包含静态文件,如需要使用sql静态文件初始化数据库. 打包python包,给其他人使用,但项目中包含静态文件,如ht ...
- java 类对象四种方法加载方式
public static void main(String[] args) throws Exception { //第一种 //这里需要做异常处理,或的加载类的类对象类. Class<?&g ...
- idea常用快捷键记录
实用编写代码辅助快捷键 Ctrl+Alt+V 提出选中内容为局部变量 Ctrl+Backspace 按单词删除 Ctrl+D 复制行 Ctrl+Y 删除当前行 Ctr+Shift+U 大小写转化 Sh ...