代码生成路径调整
This commit is contained in:
112
ruoyi-generator/src/main/resources/vm/java/Controller.java.vm
Normal file
112
ruoyi-generator/src/main/resources/vm/java/Controller.java.vm
Normal file
@ -0,0 +1,112 @@
|
||||
package ${package}.web.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import ${package}.domain.${className};
|
||||
import ${package}.service.I${className}Service;
|
||||
import com.ruoyi.web.core.base.BaseController;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.base.AjaxResult;
|
||||
|
||||
/**
|
||||
* ${tableComment} 信息操作处理
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/${moduleName}/${classname}")
|
||||
public class ${className}Controller extends BaseController
|
||||
{
|
||||
private String prefix = "${moduleName}/${classname}";
|
||||
|
||||
@Autowired
|
||||
private I${className}Service ${classname}Service;
|
||||
|
||||
@RequiresPermissions("${moduleName}:${classname}:view")
|
||||
@GetMapping()
|
||||
public String ${classname}()
|
||||
{
|
||||
return prefix + "/${classname}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(${className} ${classname})
|
||||
{
|
||||
startPage();
|
||||
List<${className}> list = ${classname}Service.select${className}List(${classname});
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存${tableComment}
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:add")
|
||||
@Log(title = "${tableComment}", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(${className} ${classname})
|
||||
{
|
||||
return toAjax(${classname}Service.insert${className}(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*/
|
||||
@GetMapping("/edit/{${primaryKey.attrname}}")
|
||||
public String edit(@PathVariable("${primaryKey.attrname}") ${primaryKey.attrType} ${primaryKey.attrname}, ModelMap mmap)
|
||||
{
|
||||
${className} ${classname} = ${classname}Service.select${className}ById(${primaryKey.attrname});
|
||||
mmap.put("${classname}", ${classname});
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存${tableComment}
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:edit")
|
||||
@Log(title = "${tableComment}", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(${className} ${classname})
|
||||
{
|
||||
return toAjax(${classname}Service.update${className}(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${tableComment}
|
||||
*/
|
||||
@RequiresPermissions("${moduleName}:${classname}:remove")
|
||||
@Log(title = "${tableComment}", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(${classname}Service.delete${className}ByIds(ids));
|
||||
}
|
||||
|
||||
}
|
62
ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm
Normal file
62
ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm
Normal file
@ -0,0 +1,62 @@
|
||||
package ${package}.mapper;
|
||||
|
||||
import ${package}.domain.${className};
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment} 数据层
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${className}Mapper
|
||||
{
|
||||
/**
|
||||
* 查询${tableComment}信息
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return ${tableComment}信息
|
||||
*/
|
||||
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return ${tableComment}集合
|
||||
*/
|
||||
public List<${className}> select${className}List(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 删除${tableComment}
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
|
||||
|
||||
/**
|
||||
* 批量删除${tableComment}
|
||||
*
|
||||
* @param ${primaryKey.attrname}s 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${className}ByIds(String[] ${primaryKey.attrname}s);
|
||||
|
||||
}
|
54
ruoyi-generator/src/main/resources/vm/java/Service.java.vm
Normal file
54
ruoyi-generator/src/main/resources/vm/java/Service.java.vm
Normal file
@ -0,0 +1,54 @@
|
||||
package ${package}.service;
|
||||
|
||||
import ${package}.domain.${className};
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${tableComment} 服务层
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${className}Service
|
||||
{
|
||||
/**
|
||||
* 查询${tableComment}信息
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return ${tableComment}信息
|
||||
*/
|
||||
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return ${tableComment}集合
|
||||
*/
|
||||
public List<${className}> select${className}List(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${className}(${className} ${classname});
|
||||
|
||||
/**
|
||||
* 删除${tableComment}信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${className}ByIds(String ids);
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package ${package}.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ${package}.mapper.${className}Mapper;
|
||||
import ${package}.domain.${className};
|
||||
import ${package}.service.I${className}Service;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
|
||||
/**
|
||||
* ${tableComment} 服务层实现
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${className}ServiceImpl implements I${className}Service
|
||||
{
|
||||
@Autowired
|
||||
private ${className}Mapper ${classname}Mapper;
|
||||
|
||||
/**
|
||||
* 查询${tableComment}信息
|
||||
*
|
||||
* @param ${primaryKey.attrname} ${tableComment}ID
|
||||
* @return ${tableComment}信息
|
||||
*/
|
||||
@Override
|
||||
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname})
|
||||
{
|
||||
return ${classname}Mapper.select${className}ById(${primaryKey.attrname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询${tableComment}列表
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return ${tableComment}集合
|
||||
*/
|
||||
@Override
|
||||
public List<${className}> select${className}List(${className} ${classname})
|
||||
{
|
||||
return ${classname}Mapper.select${className}List(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insert${className}(${className} ${classname})
|
||||
{
|
||||
return ${classname}Mapper.insert${className}(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${tableComment}
|
||||
*
|
||||
* @param ${classname} ${tableComment}信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int update${className}(${className} ${classname})
|
||||
{
|
||||
return ${classname}Mapper.update${className}(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${tableComment}对象
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int delete${className}ByIds(String ids)
|
||||
{
|
||||
return ${classname}Mapper.delete${className}ByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
}
|
47
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
Normal file
47
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
Normal file
@ -0,0 +1,47 @@
|
||||
package ${package}.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.base.BaseEntity;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.attrType == 'Date')
|
||||
import java.util.Date;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${tableComment}表 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public class ${className} extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
/** $column.columnComment */
|
||||
private $column.attrType $column.attrname;
|
||||
#end
|
||||
|
||||
#foreach ($column in $columns)
|
||||
public void set${column.attrName}($column.attrType $column.attrname)
|
||||
{
|
||||
this.$column.attrname = $column.attrname;
|
||||
}
|
||||
|
||||
public $column.attrType get${column.attrName}()
|
||||
{
|
||||
return $column.attrname;
|
||||
}
|
||||
#end
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $columns)
|
||||
.append("${column.attrname}", get${column.attrName}())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user