模板:修复主子表

This commit is contained in:
huangge1199 2024-07-09 14:19:58 +08:00
parent 79aa9ffab4
commit 778864f28c
11 changed files with 338 additions and 88 deletions

View File

@ -10,10 +10,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import com.jg.common.utils.QueryPage; import com.jg.common.utils.QueryPage;
import com.jg.framework.aspectj.lang.annotation.Log; import com.jg.framework.aspectj.lang.annotation.Log;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jg.framework.web.controller.BaseController; import com.jg.framework.web.controller.BaseController;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
@ -31,7 +28,7 @@ import com.jg.framework.web.domain.R;
@Slf4j @Slf4j
@Api(tags = "${functionName}") @Api(tags = "${functionName}")
@RestController @RestController
@RequestMapping("/${moduleName}") @RequestMapping("/${businessName}")
public class ${ClassName}Controller extends BaseController{ public class ${ClassName}Controller extends BaseController{
@Resource @Resource
@ -66,7 +63,7 @@ public class ${ClassName}Controller extends BaseController{
@ApiOperation(value = "${functionName}id详细信息", notes = "${functionName}id详细信息") @ApiOperation(value = "${functionName}id详细信息", notes = "${functionName}id详细信息")
@GetMapping("/query") @GetMapping("/query")
public R<${ClassName}> query(Long id) { public R<${ClassName}> query(Long id) {
${ClassName} queryinfo = ${className}Service.getById(id); ${ClassName} queryinfo = ${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
return R.ok(queryinfo); return R.ok(queryinfo);
} }
/** /**
@ -76,8 +73,8 @@ public class ${ClassName}Controller extends BaseController{
@ApiOperation(value = "${functionName}新增信息", notes = "${functionName}新增信息") @ApiOperation(value = "${functionName}新增信息", notes = "${functionName}新增信息")
@Log(title = "${functionName}", businessType = BusinessType.INSERT) @Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
public R<Boolean> add(${ClassName} ${className}) { public R<Integer> add(@RequestBody ${ClassName} ${className}) {
boolean res = ${className}Service.save(${className}); int res = ${className}Service.insert${ClassName}(${className});
return R.ok(res); return R.ok(res);
} }
/** /**
@ -87,8 +84,8 @@ public class ${ClassName}Controller extends BaseController{
@ApiOperation(value = "${functionName}修改信息", notes = "${functionName}修改信息") @ApiOperation(value = "${functionName}修改信息", notes = "${functionName}修改信息")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE) @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
public R<Boolean> edit(${ClassName} ${className}) { public R<Integer> edit(@RequestBody ${ClassName} ${className}) {
boolean res = ${className}Service.updateById(${className}); int res = ${className}Service.update${ClassName}(${className});
return R.ok(res); return R.ok(res);
} }
/** /**
@ -99,7 +96,19 @@ public class ${ClassName}Controller extends BaseController{
@Log(title = "${functionName}", businessType = BusinessType.DELETE) @Log(title = "${functionName}", businessType = BusinessType.DELETE)
@PostMapping("/remove") @PostMapping("/remove")
public R<Boolean> remove(Long id) { public R<Boolean> remove(Long id) {
boolean res = ${className}Service.removeById(id); boolean res = ${className}Service.delete${ClassName}By${pkColumn.capJavaField}(id);
return R.ok(res);
}
/**
* ${functionName}批量删除信息
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:removeBatch')")
@ApiOperation(value = "${functionName}批量删除信息", notes = "${functionName}批量删除信息")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@PostMapping("/removeBatch")
public R<Boolean> removeBatch(@RequestBody Long[] ids) {
boolean res = ${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(ids);
return R.ok(res); return R.ok(res);
} }

View File

@ -1,6 +1,5 @@
package ${packageName}.domain; package ${packageName}.domain;
import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
@ -15,8 +14,10 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
#if($table.sub)
import java.util.List;
#end
/** /**
* ${functionName}对象 ${tableName} * ${functionName}对象 ${tableName}
@ -30,7 +31,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@ApiModel("${functionName}表") @ApiModel("${functionName}表")
@TableName("${tableName}") @TableName("${tableName}")
public class ${ClassName}{ public class ${ClassName} implements Serializable {
private static final long serialVersionUID=1L; private static final long serialVersionUID=1L;
#foreach ($column in $columns) #foreach ($column in $columns)
@ -66,4 +67,11 @@ private static final long serialVersionUID=1L;
#end #end
#end #end
#end #end
#if($table.sub)
/** $table.subTable.functionName信息 */
@ApiModelProperty(value = "$table.subTable.functionName信息",hidden = true)
@TableField(exist = false)
private List<${subClassName}> ${subclassName}List;
#end
} }

View File

@ -11,6 +11,7 @@ import java.util.List;
* @date ${datetime} * @date ${datetime}
*/ */
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
/** /**
* 查询${functionName}分页列表 * 查询${functionName}分页列表
* *
@ -18,4 +19,23 @@ public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
* @return ${functionName}集合 * @return ${functionName}集合
*/ */
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
#if($table.sub)
/**
* 通过${functionName}主键删除${subTable.functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
#end
} }

View File

@ -18,4 +18,44 @@ public interface I${ClassName}Service extends IService<${ClassName}> {
* @return ${functionName}集合 * @return ${functionName}集合
*/ */
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
* @return 结果
*/
public boolean delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
public boolean delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
} }

View File

@ -4,6 +4,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
#if($table.sub)
import com.jg.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import ${packageName}.mapper.${subClassName}Mapper;
import ${packageName}.domain.${subClassName};
#end
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -20,6 +26,9 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
@Resource @Resource
private ${ClassName}Mapper ${className}Mapper; private ${ClassName}Mapper ${className}Mapper;
@Resource
private ${subClassName}Mapper ${subclassName}Mapper;
/** /**
* 查询${functionName}分页列表 * 查询${functionName}分页列表
* *
@ -31,4 +40,114 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
{ {
return ${className}Mapper.select${ClassName}List(${className}); return ${className}Mapper.select${ClassName}List(${className});
} }
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
@Override
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
}
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public int insert${ClassName}(${ClassName} ${className})
{
#if($table.sub)
int rows = ${className}Mapper.insert(${className});
insert${subClassName}(${className});
return rows;
#else
return ${className}Mapper.insert${ClassName}(${className});
#end
}
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public int update${ClassName}(${ClassName} ${className})
{
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
insert${subClassName}(${className});
#end
return ${className}Mapper.updateById(${className});
}
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public boolean delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}s) {
delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
}
return true;
}
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
#if($table.sub)
@Transactional
#end
@Override
public boolean delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
#end
${className}Mapper.deleteById(${pkColumn.javaField});
return true;
}
#if($table.sub)
/**
* 新增${subTable.functionName}信息
*
* @param ${className} ${functionName}对象
*/
public void insert${subClassName}(${ClassName} ${className})
{
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
if (StringUtils.isNotNull(${subclassName}List))
{
for (${subClassName} ${subclassName} : ${subclassName}List)
{
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
${subclassName}Mapper.insert(${subclassName});
}
}
}
#end
} }

View File

@ -1,20 +1,34 @@
package ${packageName}.domain; package ${packageName}.domain;
#foreach ($import in $subImportList) import com.baomidou.mybatisplus.annotation.IdType;
import ${import}; import com.baomidou.mybatisplus.annotation.TableField;
#end import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.builder.ToStringBuilder; import com.jg.framework.aspectj.lang.annotation.Excel;
import org.apache.commons.lang3.builder.ToStringStyle; import com.baomidou.mybatisplus.annotation.TableName;
import com.rchuing.common.annotation.Excel; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.rchuing.common.core.domain.BaseEntity; import io.swagger.annotations.ApiModel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/** /**
* ${subTable.functionName}对象 ${subTableName} * ${subTable.functionName}对象 ${subTableName}
* *
* @author ${author} * @author jg jg${author}
* @date ${datetime} * @date ${datetime}
*/ */
public class ${subClassName} extends BaseEntity { @Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel("${subTable.functionName}表")
@TableName("${subTableName}")
public class ${subClassName} implements Serializable {
private static final long serialVersionUID=1L; private static final long serialVersionUID=1L;
#foreach ($column in $subTable.columns) #foreach ($column in $subTable.columns)
@ -27,47 +41,27 @@ private static final long serialVersionUID = 1L;
#else #else
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end #end
#if($column.isPk == 1)
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("$column.columnComment")
@TableId(value = "$column.columnName" , type = IdType.ASSIGN_ID)
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end
#end
#foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) @ApiModelProperty("$column.columnComment")
@Excel(name = "$column.columnComment")
@TableField("$column.columnName")
private $column.javaType $column.javaField;
#end #end
public void set${AttrName}($column.javaType $column.javaField) {
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}() {
return $column.javaField;
}
#end
#end
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $subTable.columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #if($column.javaType == 'Date')
/** $column.columnComment */
@ApiModelProperty(value = "$column.columnComment",hidden = true)
@Excel(name = "$column.columnComment")
@TableField("$column.columnName")
@JsonSerialize(using = ToStringSerializer.class)
private String $column.javaField;
#end
#end #end
.append("${column.javaField}", get${AttrName}())
#end #end
.toString();
}
} }

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 查询${functionName}分列表 // 查询${functionName}分列表
export function listPage${BusinessName}(data) { export function listPage${BusinessName}(data) {
return request({ return request({
url: '/${moduleName}/listPage', url: '/${businessName}/listPage',
method: 'post', method: 'post',
params: data params: data
}) })
@ -11,14 +11,14 @@ export function listPage${BusinessName}(data) {
// 查询${functionName}列表 // 查询${functionName}列表
export function list${BusinessName}() { export function list${BusinessName}() {
return request({ return request({
url: '/${moduleName}/list', url: '/${businessName}/list',
method: 'get', method: 'get',
}) })
} }
// 查询${functionName}详细 // 查询${functionName}详细
export function get${BusinessName}(${pkColumn.javaField}) { export function get${BusinessName}(${pkColumn.javaField}) {
return request({ return request({
url: '/${moduleName}/query?id=' + ${pkColumn.javaField}, url: '/${businessName}/query?id=' + ${pkColumn.javaField},
method: 'get' method: 'get'
}) })
} }
@ -26,26 +26,35 @@ export function get${BusinessName}(${pkColumn.javaField}) {
// 新增${functionName} // 新增${functionName}
export function add${BusinessName}(data) { export function add${BusinessName}(data) {
return request({ return request({
url: '/${moduleName}/add', url: '/${businessName}/add',
method: 'post', method: 'post',
params: data data: data
}) })
} }
// 修改${functionName} // 修改${functionName}
export function update${BusinessName}(data) { export function update${BusinessName}(data) {
return request({ return request({
url: '/${moduleName}/edit', url: '/${businessName}/edit',
method: 'post', method: 'post',
params: data data: data
}) })
} }
// 删除${functionName} // 删除${functionName}
export function del${BusinessName}(${pkColumn.javaField}) { export function del${BusinessName}(${pkColumn.javaField}) {
return request({ return request({
url: '/${moduleName}/remove/', url: '/${businessName}/remove/',
method: 'post', method: 'post',
params: {id:${pkColumn.javaField}} params: {id:${pkColumn.javaField}}
}) })
} }
// 批量删除${functionName}
export function delBatch${BusinessName}(data) {
return request({
url: '/${businessName}/removeBatch/',
method: 'post',
data: data
})
}

View File

@ -1,11 +1,12 @@
-- 菜单 SQL -- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单'); values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:listPage', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
-- 按钮父菜单ID -- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID(); SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL -- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, ''); values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
@ -18,5 +19,8 @@ values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, ''); values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}批量删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:removeBatch', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, ''); values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');

View File

@ -99,8 +99,8 @@
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleBatchDelete"
v-hasPermi="['${moduleName}:${businessName}:remove']" v-hasPermi="['${moduleName}:${businessName}:removeBatch']"
>删除 >删除
</el-button> </el-button>
</el-col> </el-col>
@ -373,6 +373,7 @@
listPage${BusinessName}, listPage${BusinessName},
get${BusinessName}, get${BusinessName},
del${BusinessName}, del${BusinessName},
delBatch${BusinessName},
add${BusinessName}, add${BusinessName},
update${BusinessName} update${BusinessName}
} from "@/api/${moduleName}/${businessName}"; } from "@/api/${moduleName}/${businessName}";
@ -606,15 +607,30 @@
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ${pkColumn.javaField}s = row.$ const ${pkColumn.javaField} = row.$
{ {
pkColumn.javaField pkColumn.javaField
};
this.#[[$modal]]
#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField} + '"的数据项?').then(function () {
return del$
{
BusinessName
} }
|| (${pkColumn.javaField});
this.ids; }).then(() => {
this.getList();
this.#[[$modal]]
#.msgSuccess("删除成功");
}).catch(() => {
});
},
/** 批量删除按钮操作 */
handleBatchDelete() {
const ${pkColumn.javaField}s = this.ids;
this.#[[$modal]] this.#[[$modal]]
#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function () { #.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function () {
return del$ return delBatch$
{ {
BusinessName BusinessName
} }
@ -703,7 +719,7 @@
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() handleExport()
{ {
this.download('${moduleName}/export', { this.download('${businessName}/export', {
...this.queryParams ...this.queryParams
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
} }

View File

@ -92,8 +92,8 @@
plain plain
icon="Delete" icon="Delete"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleBatchDelete"
v-hasPermi="['${moduleName}:${businessName}:remove']" v-hasPermi="['${moduleName}:${businessName}:removeBatch']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
@ -344,7 +344,7 @@
</template> </template>
<script setup name="${BusinessName}"> <script setup name="${BusinessName}">
import { listPage${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; import { listPage${BusinessName}, get${BusinessName}, del${BusinessName}, delBatch${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
#if(${dicts} != '') #if(${dicts} != '')
@ -534,9 +534,20 @@ function submitForm() {
/** 删除按钮操作 */ /** 删除按钮操作 */
function handleDelete(row) { function handleDelete(row) {
const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value; const _${pkColumn.javaField} = row.${pkColumn.javaField};
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField} + '"的数据项?').then(function() {
return del${BusinessName}(_${pkColumn.javaField});
}).then(() => {
getList();
proxy.#[[$modal]]#.msgSuccess("删除成功");
}).catch(() => {});
}
/** 批量删除按钮操作 */
function handleBatchDelete() {
const _${pkColumn.javaField}s = ids.value;
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() { proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
return del${BusinessName}(_${pkColumn.javaField}s); return delBatch${BusinessName}(_${pkColumn.javaField}s);
}).then(() => { }).then(() => {
getList(); getList();
proxy.#[[$modal]]#.msgSuccess("删除成功"); proxy.#[[$modal]]#.msgSuccess("删除成功");

View File

@ -55,4 +55,24 @@
#end #end
</where> </where>
</select> </select>
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
#if($table.crud || $table.tree)
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
from ${tableName} a
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end
</select>
#if($table.sub)
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
</delete>
#end
</mapper> </mapper>