修复已知问题,兼容旧版本导入导出。优化默认模板

This commit is contained in:
makejava 2021-08-17 14:34:55 +08:00
parent 0192ae2f91
commit 505f4af206
31 changed files with 208 additions and 85 deletions

View File

@ -1,5 +1,6 @@
package com.sjhy.plugin.dto; package com.sjhy.plugin.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.intellij.ide.fileTemplates.impl.UrlUtil; import com.intellij.ide.fileTemplates.impl.UrlUtil;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.sjhy.plugin.dict.GlobalDict; import com.sjhy.plugin.dict.GlobalDict;
@ -130,6 +131,7 @@ public class SettingsStorageDTO {
/** /**
* 类型映射组 * 类型映射组
*/ */
@JsonProperty("typeMapper")
private Map<String, TypeMapperGroup> typeMapperGroupMap; private Map<String, TypeMapperGroup> typeMapperGroupMap;
/** /**
* 当前模板组名 * 当前模板组名
@ -138,6 +140,7 @@ public class SettingsStorageDTO {
/** /**
* 模板组 * 模板组
*/ */
@JsonProperty("template")
private Map<String, TemplateGroup> templateGroupMap; private Map<String, TemplateGroup> templateGroupMap;
/** /**
* 当前配置表组名 * 当前配置表组名
@ -146,6 +149,7 @@ public class SettingsStorageDTO {
/** /**
* 配置表组 * 配置表组
*/ */
@JsonProperty("columnConfig")
private Map<String, ColumnConfigGroup> columnConfigGroupMap; private Map<String, ColumnConfigGroup> columnConfigGroupMap;
/** /**
* 当前全局配置组名 * 当前全局配置组名
@ -154,6 +158,7 @@ public class SettingsStorageDTO {
/** /**
* 全局配置组 * 全局配置组
*/ */
@JsonProperty("globalConfig")
private Map<String, GlobalConfigGroup> globalConfigGroupMap; private Map<String, GlobalConfigGroup> globalConfigGroupMap;
public void fillDefaultVal() { public void fillDefaultVal() {

View File

@ -153,7 +153,7 @@ public class GlobalConfigSettingForm implements Configurable, BaseSettings {
@Override @Override
public void apply() { public void apply() {
getSettingsStorage().setGlobalConfigGroupMap(this.globalConfigGroupMap); getSettingsStorage().setGlobalConfigGroupMap(this.globalConfigGroupMap);
getSettingsStorage().setCurrTypeMapperGroupName(this.currGlobalConfigGroup.getName()); getSettingsStorage().setCurrGlobalConfigGroupName(this.currGlobalConfigGroup.getName());
// 保存包后重新加载配置 // 保存包后重新加载配置
this.loadSettingsStore(getSettingsStorage()); this.loadSettingsStore(getSettingsStorage());
} }

View File

@ -8,7 +8,7 @@
<properties/> <properties/>
<border type="none"/> <border type="none"/>
<children> <children>
<grid id="e3588" layout-manager="GridLayoutManager" row-count="10" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="e3588" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@ -74,7 +74,7 @@
</component> </component>
<grid id="7831c" binding="templatePanel" layout-manager="BorderLayout" hgap="0" vgap="0"> <grid id="7831c" binding="templatePanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints> <constraints>
<grid row="4" column="1" row-span="6" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="4" column="1" row-span="5" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties/> <properties/>
<border type="none"/> <border type="none"/>
@ -82,7 +82,7 @@
</grid> </grid>
<component id="91ae2" class="javax.swing.JLabel"> <component id="91ae2" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="4" column="0" row-span="6" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="4" column="0" row-span="5" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text resource-bundle="string" key="label.template"/> <text resource-bundle="string" key="label.template"/>
@ -90,7 +90,7 @@
</component> </component>
<vspacer id="98aa7"> <vspacer id="98aa7">
<constraints> <constraints>
<grid row="9" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="8" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> </vspacer>
<component id="caddc" class="javax.swing.JLabel"> <component id="caddc" class="javax.swing.JLabel">

View File

@ -157,7 +157,7 @@ public class TemplateSettingForm implements Configurable, BaseSettings {
@Override @Override
public void apply() { public void apply() {
getSettingsStorage().setTemplateGroupMap(this.templateGroupMap); getSettingsStorage().setTemplateGroupMap(this.templateGroupMap);
getSettingsStorage().setCurrTypeMapperGroupName(this.currTemplateGroup.getName()); getSettingsStorage().setCurrTemplateGroupName(this.currTemplateGroup.getName());
// 保存包后重新加载配置 // 保存包后重新加载配置
this.loadSettingsStore(getSettingsStorage()); this.loadSettingsStore(getSettingsStorage());
} }

View File

@ -93,8 +93,8 @@ public class ConfigTableModel extends DefaultTableModel implements EditableModel
if (columnInfo == null) { if (columnInfo == null) {
return; return;
} }
// 非自定义数据不允许修改列名 // 非自定义数据不允许修改
if (!columnInfo.getCustom() && column == 0) { if (!columnInfo.getCustom() && column <= 2) {
return; return;
} }
switch (column) { switch (column) {
@ -125,6 +125,9 @@ public class ConfigTableModel extends DefaultTableModel implements EditableModel
break; break;
default: default:
ColumnConfig columnConfig = CurrGroupUtils.getCurrColumnConfigGroup().getElementList().get(column - 3); ColumnConfig columnConfig = CurrGroupUtils.getCurrColumnConfigGroup().getElementList().get(column - 3);
if (columnInfo.getExt() == null) {
columnInfo.setExt(new HashMap<>(16));
}
columnInfo.getExt().put(columnConfig.getTitle(), value); columnInfo.getExt().put(columnConfig.getTitle(), value);
break; break;
} }

View File

@ -5,6 +5,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.ui.ex.MultiLineLabel; import com.intellij.openapi.ui.ex.MultiLineLabel;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.sjhy.plugin.dict.GlobalDict; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.entity.AbstractGroup; import com.sjhy.plugin.entity.AbstractGroup;
@ -166,6 +167,19 @@ public class ExportImportComponent {
mainPanel.add(handler.getRadioComponent()); mainPanel.add(handler.getRadioComponent());
} }
} }
// 没有需要选择处理的分组则不构建Dialog
boolean anyMatch = allHandlerList.stream().anyMatch(item -> item.getRadioComponent() != null);
if (!anyMatch) {
// 执行每个处理器
for (Handler handler : allHandlerList) {
handler.execute();
}
// 执行回调
if (callback != null) {
callback.run();
}
return;
}
// 构建dialog // 构建dialog
DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject()); DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject());
dialogBuilder.setTitle(GlobalDict.TITLE_INFO); dialogBuilder.setTitle(GlobalDict.TITLE_INFO);
@ -184,6 +198,7 @@ public class ExportImportComponent {
} }
// 关闭并退出 // 关闭并退出
dialogWrapper.close(DialogWrapper.OK_EXIT_CODE); dialogWrapper.close(DialogWrapper.OK_EXIT_CODE);
Messages.showInfoMessage("导入完成", GlobalDict.TITLE_INFO);
} }
}); });
// 显示窗口 // 显示窗口
@ -191,6 +206,9 @@ public class ExportImportComponent {
} }
private <T extends AbstractGroup> void addRadioComponent(List<Handler> allHandlerList, String groupName, Map<String, T> localMap, Map<String, T> remoteMap) { private <T extends AbstractGroup> void addRadioComponent(List<Handler> allHandlerList, String groupName, Map<String, T> localMap, Map<String, T> remoteMap) {
if (CollectionUtil.isEmpty(remoteMap)) {
return;
}
for (String key : remoteMap.keySet()) { for (String key : remoteMap.keySet()) {
if (localMap.containsKey(key)) { if (localMap.containsKey(key)) {
ListRadioComponent listRadioComponent = new ListRadioComponent(groupName + "->" + key, Stream.of(Operator.values()).map(item -> StringUtils.capitalize(item.name())).collect(Collectors.toList())); ListRadioComponent listRadioComponent = new ListRadioComponent(groupName + "->" + key, Stream.of(Operator.values()).map(item -> StringUtils.capitalize(item.name())).collect(Collectors.toList()));

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,9 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/controller"))
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -31,15 +34,60 @@ public class $!{tableName} {
@Resource @Resource
private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service; private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;
/**
* 分页查询
*
* @param actualFlightInfo 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@GetMapping
public ResponseEntity<Page<$!{tableInfo.name}>> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) {
return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryByPage($!{tool.firstLowerCase($tableInfo.name)}, pageRequest));
}
/** /**
* 通过主键查询单条数据 * 通过主键查询单条数据
* *
* @param id 主键 * @param id 主键
* @return 单条数据 * @return 单条数据
*/ */
@GetMapping("selectOne") @GetMapping("{id}")
public $!{tableInfo.name} selectOne($!pk.shortType id) { public ResponseEntity<$!{tableInfo.name}> queryById(@PathVariable("id") $!pk.shortType id) {
return this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id); return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id));
}
/**
* 新增数据
*
* @param $!{tool.firstLowerCase($tableInfo.name)} 实体
* @return 新增结果
*/
@PostMapping
public ResponseEntity<$!{tableInfo.name}> add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)}));
}
/**
* 编辑数据
*
* @param $!{tool.firstLowerCase($tableInfo.name)} 实体
* @return 编辑结果
*/
@PutMapping
public ResponseEntity<$!{tableInfo.name}> edit($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.update($!{tool.firstLowerCase($tableInfo.name)}));
}
/**
* 删除数据
*
* @param id 主键
* @return 删除是否成功
*/
@DeleteMapping
public ResponseEntity<Boolean> deleteById($!pk.shortType id) {
return ResponseEntity.ok(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id));
} }
} }

View File

@ -13,6 +13,7 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/dao"))
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
/** /**
@ -34,20 +35,19 @@ public interface $!{tableName} {
/** /**
* 查询指定行数据 * 查询指定行数据
* *
* @param offset 查询起始位置 * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件
* @param limit 查询条数 * @param pageable 分页对象
* @return 对象列表 * @return 对象列表
*/ */
List<$!{tableInfo.name}> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit); List<$!{tableInfo.name}> queryAllByLimit($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), @Param("pageable") Pageable pageable);
/** /**
* 通过实体作为筛选条件查询 * 统计总行数
* *
* @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象 * @param $!tool.firstLowerCase($!{tableInfo.name}) 查询条件
* @return 对象列表 * @return 总行数
*/ */
List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})); long count($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/** /**
* 新增数据 * 新增数据

View File

@ -1,3 +1,6 @@
// 禁止将生成结果写入到文件
$!callback.setWriteFile(false)
//调试表原始对象 //调试表原始对象
$!tool.debug($tableInfo.obj) $!tool.debug($tableInfo.obj)

View File

@ -1,5 +1,5 @@
##引入宏定义 ##引入宏定义
$!define $!{define.vm}
##使用宏定义设置回调(保存位置与文件后缀) ##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", ".java") #save("/entity", ".java")
@ -8,7 +8,7 @@ $!define
#setPackageSuffix("entity") #setPackageSuffix("entity")
##使用全局变量实现默认包导入 ##使用全局变量实现默认包导入
$!autoImport $!{autoImport.vm}
import java.io.Serializable; import java.io.Serializable;
##使用宏定义实现类注释信息 ##使用宏定义实现类注释信息
@ -17,8 +17,8 @@ public class $!{tableInfo.name} implements Serializable {
private static final long serialVersionUID = $!tool.serial(); private static final long serialVersionUID = $!tool.serial();
#foreach($column in $tableInfo.fullColumn) #foreach($column in $tableInfo.fullColumn)
#if(${column.comment})/** #if(${column.comment})/**
* ${column.comment} * ${column.comment}
*/#end */#end
private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end #end
@ -28,4 +28,4 @@ public class $!{tableInfo.name} implements Serializable {
#getSetMethod($column) #getSetMethod($column)
#end #end
} }

View File

@ -1,5 +1,5 @@
##引入mybatis支持 ##引入mybatis支持
$!mybatisSupport $!{mybatisSupport.vm}
##设置保存名称与保存位置 ##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml")) $!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))
@ -25,7 +25,7 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
select select
#allSqlColumn() #allSqlColumn()
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name from $!tableInfo.obj.name
where $!pk.obj.name = #{$!pk.name} where $!pk.obj.name = #{$!pk.name}
</select> </select>
@ -34,16 +34,7 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
select select
#allSqlColumn() #allSqlColumn()
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name from $!tableInfo.obj.name
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="$!{tableInfo.name}Map">
select
#allSqlColumn()
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name
<where> <where>
#foreach($column in $tableInfo.fullColumn) #foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end"> <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
@ -51,16 +42,24 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
</if> </if>
#end #end
</where> </where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from $!tableInfo.obj.name
<include refid="queryWhere"/>
</select> </select>
<!--新增所有列--> <!--新增所有列-->
<insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true"> <insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($velocityHasNext), #end#end) values (#foreach($column in $tableInfo.otherColumn)#{$!{column.name}}#if($velocityHasNext), #end#end)
</insert> </insert>
<insert id="insertBatch" keyProperty="$!pk.name" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
(#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end) (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)
@ -68,18 +67,20 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
</insert> </insert>
<insert id="insertOrUpdateBatch" keyProperty="$!pk.name" useGeneratedKeys="true"> <insert id="insertOrUpdateBatch" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end) insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.otherColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
(#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end) (#foreach($column in $tableInfo.otherColumn)#{entity.$!{column.name}}#if($velocityHasNext), #end#end)
</foreach> </foreach>
on duplicate key update on duplicate key update
#foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name) #if($velocityHasNext), #end#end #foreach($column in $tableInfo.otherColumn)$!column.obj.name = values($!column.obj.name)#if($velocityHasNext),
#end#end
</insert> </insert>
<!--通过主键修改数据--> <!--通过主键修改数据-->
<update id="update"> <update id="update">
update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} update $!{tableInfo.obj.name}
<set> <set>
#foreach($column in $tableInfo.otherColumn) #foreach($column in $tableInfo.otherColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end"> <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
@ -92,7 +93,7 @@ $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
<!--通过主键删除--> <!--通过主键删除-->
<delete id="deleteById"> <delete id="deleteById">
delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name} delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}
</delete> </delete>
</mapper> </mapper>

View File

@ -12,7 +12,8 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/service"))
#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service; #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import java.util.List; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
/** /**
* $!{tableInfo.comment}($!{tableInfo.name})表服务接口 * $!{tableInfo.comment}($!{tableInfo.name})表服务接口
@ -31,13 +32,13 @@ public interface $!{tableName} {
$!{tableInfo.name} queryById($!pk.shortType $!pk.name); $!{tableInfo.name} queryById($!pk.shortType $!pk.name);
/** /**
* 查询多条数据 * 分页查询
* *
* @param offset 查询起始位置 * @param $!tool.firstLowerCase($!{tableInfo.name}) 筛选条件
* @param limit 查询条数 * @param pageRequest 分页对象
* @return 对象列表 * @return 查询结果
*/ */
List<$!{tableInfo.name}> queryAllByLimit(int offset, int limit); Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}), PageRequest pageRequest);
/** /**
* 新增数据 * 新增数据

View File

@ -15,9 +15,11 @@ import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao; import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* $!{tableInfo.comment}($!{tableInfo.name})表服务实现类 * $!{tableInfo.comment}($!{tableInfo.name})表服务实现类
@ -42,15 +44,16 @@ public class $!{tableName} implements $!{tableInfo.name}Service {
} }
/** /**
* 查询多条数据 * 分页查询
* *
* @param offset 查询起始位置 * @param $!{tool.firstLowerCase($tableInfo.name)} 筛选条件
* @param limit 查询条数 * @param pageRequest 分页对象
* @return 对象列表 * @return 查询结果
*/ */
@Override @Override
public List<$!{tableInfo.name}> queryAllByLimit(int offset, int limit) { public Page<$!{tableInfo.name}> queryByPage($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}, PageRequest pageRequest) {
return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAllByLimit(offset, limit); long total = this.$!{tool.firstLowerCase($tableInfo.name)}Dao.count($!{tool.firstLowerCase($tableInfo.name)});
return new PageImpl<>(this.$!{tool.firstLowerCase($tableInfo.name)}Dao.queryAllByLimit($!{tool.firstLowerCase($tableInfo.name)}, pageRequest), pageRequest, total);
} }
/** /**

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("Controller") #setTableSuffix("Controller")
@ -94,4 +94,4 @@ public class $!{tableName} extends ApiController {
public R delete(@RequestParam("idList") List<Long> idList) { public R delete(@RequestParam("idList") List<Long> idList) {
return success(this.$!{serviceName}.removeByIds(idList)); return success(this.$!{serviceName}.removeByIds(idList));
} }
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("Dao") #setTableSuffix("Dao")

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##保存文件(宏定义) ##保存文件(宏定义)
#save("/entity", ".java") #save("/entity", ".java")
@ -38,4 +38,4 @@ public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {
} }
#break #break
#end #end
} }

View File

@ -1,5 +1,5 @@
##引入mybatis支持 ##引入mybatis支持
$!mybatisSupport $!{mybatisSupport.vm}
##设置保存名称与保存位置 ##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml")) $!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("Service") #setTableSuffix("Service")
@ -17,4 +17,4 @@ import $!{tableInfo.savePackageName}.entity.$!tableInfo.name;
#tableComment("表服务接口") #tableComment("表服务接口")
public interface $!{tableName} extends IService<$!tableInfo.name> { public interface $!{tableName} extends IService<$!tableInfo.name> {
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("ServiceImpl") #setTableSuffix("ServiceImpl")
@ -21,4 +21,4 @@ import org.springframework.stereotype.Service;
@Service("$!tool.firstLowerCase($tableInfo.name)Service") @Service("$!tool.firstLowerCase($tableInfo.name)Service")
public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service { public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("Controller") #setTableSuffix("Controller")
@ -94,4 +94,4 @@ public class $!{tableName} extends ApiController {
public R delete(@RequestParam("idList") List<Long> idList) { public R delete(@RequestParam("idList") List<Long> idList) {
return success(this.$!{serviceName}.removeByIds(idList)); return success(this.$!{serviceName}.removeByIds(idList));
} }
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("Dao") #setTableSuffix("Dao")
@ -17,4 +17,4 @@ import $!{tableInfo.savePackageName}.entity.$!tableInfo.name;
#tableComment("表数据库访问层") #tableComment("表数据库访问层")
public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { public interface $!{tableName} extends BaseMapper<$!tableInfo.name> {
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##保存文件(宏定义) ##保存文件(宏定义)
#save("/entity", ".java") #save("/entity", ".java")
@ -8,7 +8,7 @@ $!define
#setPackageSuffix("entity") #setPackageSuffix("entity")
##自动导入包(全局变量) ##自动导入包(全局变量)
$!autoImport $!{autoImport.vm}
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable; import java.io.Serializable;
@ -38,4 +38,4 @@ public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {
} }
#break #break
#end #end
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("Service") #setTableSuffix("Service")
@ -17,4 +17,4 @@ import $!{tableInfo.savePackageName}.entity.$!tableInfo.name;
#tableComment("表服务接口") #tableComment("表服务接口")
public interface $!{tableName} extends IService<$!tableInfo.name> { public interface $!{tableName} extends IService<$!tableInfo.name> {
} }

View File

@ -1,5 +1,5 @@
##导入宏定义 ##导入宏定义
$!define $!{define.vm}
##设置表后缀(宏定义) ##设置表后缀(宏定义)
#setTableSuffix("ServiceImpl") #setTableSuffix("ServiceImpl")
@ -21,4 +21,4 @@ import org.springframework.stereotype.Service;
@Service("$!tool.firstLowerCase($tableInfo.name)Service") @Service("$!tool.firstLowerCase($tableInfo.name)Service")
public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service { public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {
} }

View File

@ -1,5 +1,5 @@
##导入宏定义、设置包名、类名、文件名##导入宏定义 ##导入宏定义、设置包名、类名、文件名##导入宏定义
$!define $!{define.vm}
#setPackageSuffix("controller") #setPackageSuffix("controller")
#setTableSuffix("Controller") #setTableSuffix("Controller")
#save("/controller", "Controller.java") #save("/controller", "Controller.java")

View File

@ -0,0 +1,31 @@
##引入宏定义
$!{define.vm}
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", ".java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!{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
}

View File

@ -1,5 +1,5 @@
##导入宏定义、设置包名、类名、文件名##导入宏定义 ##导入宏定义、设置包名、类名、文件名##导入宏定义
$!define $!{define.vm}
#setPackageSuffix("repository") #setPackageSuffix("repository")
#setTableSuffix("Repository") #setTableSuffix("Repository")
#save("/repository", "Repository.java") #save("/repository", "Repository.java")
@ -27,4 +27,4 @@ import org.springframework.data.mongodb.repository.MongoRepository;
*/ */
public interface $!{tableName} extends MongoRepository<$entityShortType, $pkShortType> { public interface $!{tableName} extends MongoRepository<$entityShortType, $pkShortType> {
} }

View File

@ -1,5 +1,5 @@
##导入宏定义、设置包名、类名、文件名##导入宏定义 ##导入宏定义、设置包名、类名、文件名##导入宏定义
$!define $!{define.vm}
#setPackageSuffix("service") #setPackageSuffix("service")
#setTableSuffix("Service") #setTableSuffix("Service")
#save("/service", "Service.java") #save("/service", "Service.java")
@ -30,7 +30,7 @@ import java.util.List;
* @since $!time.currTime() * @since $!time.currTime()
*/ */
public interface $!{tableName} { public interface $!{tableName} {
void save($entityShortType $entityVarName); void save($entityShortType $entityVarName);
void deleteById($pkShortType id); void deleteById($pkShortType id);
@ -41,4 +41,4 @@ public interface $!{tableName} {
Page<$entityShortType> list(Pageable page); Page<$entityShortType> list(Pageable page);
} }

View File

@ -1,5 +1,5 @@
##导入宏定义、设置包名、类名、文件名 ##导入宏定义、设置包名、类名、文件名
$!define $!{define.vm}
#setPackageSuffix("service.impl") #setPackageSuffix("service.impl")
#setTableSuffix("ServiceImpl") #setTableSuffix("ServiceImpl")
#save("/service/impl", "ServiceImpl.java") #save("/service/impl", "ServiceImpl.java")
@ -73,4 +73,4 @@ public class $!{tableName} implements $!serviceSortType {
return $!{repositoryVarName}.findAll(page); return $!{repositoryVarName}.findAll(page);
} }
} }

View File

@ -44,6 +44,11 @@
"columnType": "bigint(\\(\\d+\\))?", "columnType": "bigint(\\(\\d+\\))?",
"javaType": "java.lang.Long" "javaType": "java.lang.Long"
}, },
{
"matchType": "ORDINARY",
"columnType": "date",
"javaType": "java.util.Date"
},
{ {
"matchType": "ORDINARY", "matchType": "ORDINARY",
"columnType": "datetime", "columnType": "datetime",
@ -54,6 +59,11 @@
"columnType": "timestamp", "columnType": "timestamp",
"javaType": "java.util.Date" "javaType": "java.util.Date"
}, },
{
"matchType": "ORDINARY",
"columnType": "time",
"javaType": "java.time.LocalTime"
},
{ {
"matchType": "ORDINARY", "matchType": "ORDINARY",
"columnType": "boolean", "columnType": "boolean",