-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
|2021.08.07|新增当前模板保持功能,重新生成代码后依然会保持在当前选择模板。<br>新增renren-fast模板。|
|2021.08.05|解决 update 方法语法错误;调整部分语句避免sonarLint告警(感谢@Henry586的PR);<br>add swagger-yml.ftl(感谢@fuuqiu的PR);<br>支持common-mapper&修复entity和plusentity的swagger引包错误(感谢@chentianming11的PR)|
- Loading branch information
1 parent
6aa41d5
commit 45d380c
Showing
14 changed files
with
496 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
17 changes: 17 additions & 0 deletions
17
generator-web/src/main/resources/templates/code-generator/renren-fast/menu-sql.ftl
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,17 @@ | ||
-- 菜单SQL | ||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) | ||
VALUES ('1', '${classInfo.classComment}', 'generator/${classInfo.className?uncap_first}', NULL, '1', 'config', '6'); | ||
|
||
-- 按钮父菜单ID | ||
set @parentId = @@identity; | ||
|
||
-- 菜单对应按钮SQL | ||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) | ||
SELECT @parentId, '查看', null, 'generator:${classInfo.className?uncap_first}:list,generator:${classInfo.className?uncap_first}:info', '2', null, '6'; | ||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) | ||
SELECT @parentId, '新增', null, 'generator:${classInfo.className?uncap_first}:save', '2', null, '6'; | ||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) | ||
SELECT @parentId, '修改', null, 'generator:${classInfo.className?uncap_first}:update', '2', null, '6'; | ||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) | ||
SELECT @parentId, '删除', null, 'generator:${classInfo.className?uncap_first}:delete', '2', null, '6'; | ||
|
89 changes: 89 additions & 0 deletions
89
generator-web/src/main/resources/templates/code-generator/renren-fast/rr-controller.ftl
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,89 @@ | ||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller;</#if> | ||
<#if isAutoImport?exists && isAutoImport==true> | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
|
||
import org.apache.shiro.authz.annotation.RequiresPermissions; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import ${packageName}.entity.${classInfo.className}Entity; | ||
import ${packageName}.service.${classInfo.className}Service; | ||
import ${packageName}.common.utils.PageUtils; | ||
import ${packageName}.common.utils.R; | ||
</#if> | ||
|
||
|
||
/** | ||
* @description ${classInfo.classComment}控制器 | ||
* @author ${authorName} | ||
* @date ${.now?string('yyyy-MM-dd')} | ||
*/ | ||
@RestController | ||
@RequestMapping("generator/${classInfo.className?uncap_first}") | ||
public class ${classInfo.className}Controller { | ||
|
||
@Autowired | ||
private ${classInfo.className}Service ${classInfo.className?uncap_first}Service; | ||
|
||
/** | ||
* 列表 | ||
*/ | ||
@RequestMapping("/list") | ||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:list") | ||
public R list(@RequestParam Map<String, Object> params){ | ||
PageUtils page = ${classInfo.className?uncap_first}Service.queryPage(params); | ||
|
||
return R.ok().put("page", page); | ||
} | ||
|
||
|
||
/** | ||
* 信息 | ||
*/ | ||
@RequestMapping("/info/{${classInfo.className?uncap_first}Id}") | ||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:info") | ||
public R info(@PathVariable("${classInfo.className?uncap_first}Id") int ${classInfo.className?uncap_first}Id){ | ||
${classInfo.className}Entity ${classInfo.className?uncap_first} = ${classInfo.className?uncap_first}Service.getById(${classInfo.className?uncap_first}Id); | ||
|
||
return R.ok().put("${classInfo.className?uncap_first}", ${classInfo.className?uncap_first}); | ||
} | ||
|
||
/** | ||
* 保存 | ||
*/ | ||
@RequestMapping("/save") | ||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:save") | ||
public R save(@RequestBody ${classInfo.className}Entity ${classInfo.className?uncap_first}){ | ||
${classInfo.className?uncap_first}Service.save(${classInfo.className?uncap_first}); | ||
|
||
return R.ok(); | ||
} | ||
|
||
/** | ||
* 修改 | ||
*/ | ||
@RequestMapping("/update") | ||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:update") | ||
public R update(@RequestBody ${classInfo.className}Entity ${classInfo.className?uncap_first}){ | ||
${classInfo.className?uncap_first}Service.updateById(${classInfo.className?uncap_first}); | ||
|
||
return R.ok(); | ||
} | ||
|
||
/** | ||
* 删除 | ||
*/ | ||
@RequestMapping("/delete") | ||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:delete") | ||
public R delete(@RequestBody int[] ${classInfo.className?uncap_first}Ids){ | ||
${classInfo.className?uncap_first}Service.removeByIds(Arrays.asList(${classInfo.className?uncap_first}Ids)); | ||
|
||
return R.ok(); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
generator-web/src/main/resources/templates/code-generator/renren-fast/rr-dao.ftl
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,15 @@ | ||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if> | ||
<#if isAutoImport?exists && isAutoImport==true> | ||
import ${packageName}.entity.${classInfo.className}Entity; | ||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
import org.apache.ibatis.annotations.Mapper; | ||
</#if> | ||
/** | ||
* @description ${classInfo.classComment}Mapper | ||
* @author ${authorName} | ||
* @date ${.now?string('yyyy-MM-dd')} | ||
*/ | ||
@Mapper | ||
public interface ${classInfo.className}Dao extends BaseMapper<${classInfo.className}Entity> { | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
generator-web/src/main/resources/templates/code-generator/renren-fast/rr-daoxml.ftl
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,15 @@ | ||
<?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="${packageName}.dao.${classInfo.className}Dao"> | ||
|
||
<!-- 可根据自己的需求,是否要使用 --> | ||
<resultMap type="${packageName}.entity.${classInfo.className}Entity" id="${classInfo.className}Map"> | ||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0> | ||
<#list classInfo.fieldList as fieldItem > | ||
<result property="${fieldItem.fieldName}" column="${fieldItem.fieldName}"/> | ||
</#list> | ||
</#if> | ||
</resultMap> | ||
|
||
</mapper> |
Empty file.
28 changes: 28 additions & 0 deletions
28
generator-web/src/main/resources/templates/code-generator/renren-fast/rr-service.ftl
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,28 @@ | ||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.service;</#if> | ||
<#if isAutoImport?exists && isAutoImport==true> | ||
import org.springframework.stereotype.Service; | ||
import java.util.Map; | ||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
import com.baomidou.mybatisplus.core.metadata.IPage; | ||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||
import ${packageName}.common.utils.PageUtils; | ||
import ${packageName}.common.utils.Query; | ||
|
||
import ${packageName}.dao.${classInfo.className}Dao; | ||
import ${packageName}.entity.${classInfo.className}Entity; | ||
</#if> | ||
|
||
@Service("${classInfo.className?uncap_first}Service") | ||
public class ${classInfo.className}Service extends ServiceImpl<${classInfo.className}Dao, ${classInfo.className}Entity> { | ||
|
||
@Override | ||
public PageUtils queryPage(Map<String, Object> params) { | ||
IPage<${classInfo.className}Entity> page = this.page( | ||
new Query<${classInfo.className}Entity>().getPage(params), | ||
new QueryWrapper<${classInfo.className}Entity>() | ||
); | ||
|
||
return new PageUtils(page); | ||
} | ||
|
||
} |
Oops, something went wrong.