Browse Source

Merge branch 'local_gen' into gsw

erp、
youjianchi 1 year ago
parent
commit
9e80ba418a
  1. 9
      ruoyi-generator/src/main/resources/vm/html/list.html.vm
  2. 25
      ruoyi-generator/src/main/resources/vm/java/controller.java.vm
  3. 17
      ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
  4. 14
      ruoyi-generator/src/main/resources/vm/java/service.java.vm
  5. 38
      ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
  6. 6
      ruoyi-generator/src/main/resources/vm/sql/sql.vm
  7. 8
      ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm

9
ruoyi-generator/src/main/resources/vm/html/list.html.vm

@ -88,6 +88,8 @@
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('${permissionPrefix}:edit')}]];
var removeFlag = [[${@permission.hasPermi('${permissionPrefix}:remove')}]];
var cancelFlag = [[${@permission.hasPermi('${permissionPrefix}:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('${permissionPrefix}:restore')}]];
#foreach($column in $columns)
#if(${column.dictType} != '')
var ${column.javaField}Datas = [[${@dict.getType('${column.dictType}')}]];
@ -101,6 +103,8 @@
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
cancelUrl: prefix + "/cancel/{id}",
restoreUrl: prefix + "/restore/{id}",
exportUrl: prefix + "/export",
modalName: "${functionName}",
columns: [{
@ -143,6 +147,11 @@
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.${pkColumn.javaField} + '\')"><i class="fa fa-remove"></i>删除</a> ');
if(row.delFlag == '0'){
actions.push('<a class="btn btn-danger btn-xs ' + cancelFlag + '" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a> ');
}else{
actions.push('<a class="btn btn-success btn-xs ' + restoreFlag + '" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.id + '\')"><i class="fa fa-window-restore"></i>恢复</a> ');
}
return actions.join('');
}
}]

25
ruoyi-generator/src/main/resources/vm/java/controller.java.vm

@ -158,6 +158,31 @@ public class ${ClassName}Controller extends BaseController
{
return toAjax(${className}Service.delete${ClassName}ByIds(ids));
}
/**
* 作废${functionName}
*/
@RequiresPermissions("${permissionPrefix}:cancel")
@Log(title = "${functionName}", businessType = BusinessType.CANCEL)
@GetMapping( "/cancel/{id}")
@ResponseBody
public AjaxResult cancel(@PathVariable("id") Long id){
return toAjax(${className}Service.cancel${ClassName}ById(id));
}
/**
* 恢复${functionName}
*/
@RequiresPermissions("${permissionPrefix}:restore")
@Log(title = "${functionName}", businessType = BusinessType.RESTORE)
@GetMapping( "/restore/{id}")
@ResponseBody
public AjaxResult restore(@PathVariable("id")Long id)
{
return toAjax(${className}Service.restore${ClassName}ById(id));
}
#elseif($table.tree)
/**
* 删除

17
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm

@ -61,6 +61,22 @@ public interface ${ClassName}Mapper
* @return 结果
*/
public int delete${ClassName}ByIds(String[] ${pkColumn.javaField}s);
/**
* 作废${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int cancel${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 恢复${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int restore${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
#if($table.sub)
/**
@ -79,7 +95,6 @@ public interface ${ClassName}Mapper
*/
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
/**
* 通过${functionName}ID删除${subTable.functionName}信息
*

14
ruoyi-generator/src/main/resources/vm/java/service.java.vm

@ -61,6 +61,20 @@ public interface I${ClassName}Service
* @return 结果
*/
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 作废${functionName}
* @param ${pkColumn.javaField} ${functionName}ID
* @return
*/
int cancel${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 恢复${functionName}
* @param ${pkColumn.javaField} ${functionName}ID
* @return
*/
int restore${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
#if($table.tree)
/**

38
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm

@ -11,6 +11,12 @@ import com.ruoyi.common.utils.DateUtils;
#break
#end
#end
#foreach ($column in $columns)
#if($column.javaField == 'createBy' || $column.javaField == 'updateBy')
import com.ruoyi.common.utils.ShiroUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#if($table.sub)
@ -73,6 +79,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
public int insert${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'createBy')
String loginName = ShiroUtils.getLoginName();
${className}.setCreateBy(loginName);
#end
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
@ -99,6 +109,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
public int update${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'updateBy')
String loginName = ShiroUtils.getLoginName();
${className}.setUpdateBy(loginName);
#end
#if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end
@ -142,6 +156,30 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
#end
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
}
/**
* 作废${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
@Override
public int cancel${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
{
return ${className}Mapper.cancel${ClassName}ById(${pkColumn.javaField});
}
/**
* 恢复${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
@Override
public int restore${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
{
return ${className}Mapper.restore${ClassName}ById(${pkColumn.javaField});
}
#if($table.tree)
/**

6
ruoyi-generator/src/main/resources/vm/sql/sql.vm

@ -18,5 +18,11 @@ values('${functionName}修改', @parentId, '3', '#', 'F', '0', '${permissionPr
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}删除', @parentId, '4', '#', 'F', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}作废', @parentId, '4', '#', 'F', '0', '${permissionPrefix}:cancel', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}恢复', @parentId, '4', '#', 'F', '0', '${permissionPrefix}:restore', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}导出', @parentId, '5', '#', 'F', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');

8
ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm

@ -123,6 +123,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{${pkColumn.javaField}}
</foreach>
</delete>
<update id="cancel${ClassName}ById" parameterType="${pkColumn.javaType}">
update ${tableName} set del_flag = '1' where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</update>
<update id="restore${ClassName}ById" parameterType="${pkColumn.javaType}">
update ${tableName} set del_flag = '0' where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</update>
#if($table.sub)
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">

Loading…
Cancel
Save