修改代码生成模板

This commit is contained in:
izory 2021-09-10 18:06:07 +08:00
parent 37ea4fc0a0
commit 5fd4f17be9
8 changed files with 95 additions and 113 deletions

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using ZR.Admin.WebApi.Filters;
using ZR.Admin.WebApi.Controllers;
using ZR.Service;
using ZR.Service.Business;
using SqlSugar;
using Infrastructure;
using Infrastructure.Attribute;
@ -12,7 +12,8 @@ using Infrastructure.Enums;
using Infrastructure.Model;
using Mapster;
using ZR.Admin.WebApi.Extensions;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Model.Models;
namespace ZRAdmin.Controllers
{
@ -59,6 +60,7 @@ namespace ZRAdmin.Controllers
/// <param name="{primaryKey}"></param>
/// <returns></returns>
[HttpGet("{{primaryKey}}")]
[ActionPermissionFilter(Permission = "<#=Permission#>:query")]
public IActionResult Get({KeyTypeName} {primaryKey})
{
var response = _<#=ServiceName#>.GetId({primaryKey});

View File

@ -1,8 +1,7 @@
using System;
using ZR.Model.System;
using ZR.Model;
using ZR.Model.Models;
namespace {IServicsNamespace}
namespace {IServicsNamespace}.Business
{
/// <summary>
/// 定义{TableNameDesc}服务接口

View File

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using {ModelsNamespace};
using {ModelsNamespace}.Dto;
namespace {DtosNamespace}
namespace {DtosNamespace}.Dto
{
/// <summary>
/// {TableNameDesc}输入对象模型

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace {ModelsNamespace}
namespace {ModelsNamespace}.Models
{
/// <summary>
/// {TableNameDesc},数据实体对象

View File

@ -1,7 +1,7 @@
using System;
using Infrastructure.Attribute;
using {RepositoriesNamespace}.System;
using {ModelsNamespace};
using {ModelsNamespace}.Models;
namespace {RepositoriesNamespace}
{

View File

@ -7,11 +7,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZR.Common;
using ZR.Model;
using ZR.Model.Models;
using ZR.Repository;
using ZR.Service.IService;
namespace {ServicesNamespace}
namespace {ServicesNamespace}.Business
{
/// <summary>
/// {TableNameDesc}服务接口实现

View File

@ -1,85 +1,59 @@
import http from '@/utils/request'
import defaultSettings from '@/settings'
import request from '@/utils/request'
/**
* {ModelTypeDesc}分页查询
* @param {查询条件} data
*/
export function get{ModelTypeName}ListWithPager(data) {
return http.request({
url: '{ModelTypeName}/FindWithPagerAsync',
method: 'post',
data: data,
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
})
}/**
* 获取所有可用的{ModelTypeDesc}
*/
export function getAll{ModelTypeName}List() {
return http.request({
url: '{ModelTypeName}/GetAllEnable',
export function list{ModelTypeName}(data) {
return request({
url: 'bus/{ModelTypeName}/list',
method: 'get',
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
})
}
/**
* 新增或修改保存{ModelTypeDesc}
* @param data
*/
export function save{ModelTypeName}(data, url) {
return http.request({
url: url,
method: 'post',
data: data,
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
})
}
/**
* 获取{ModelTypeDesc}详情
* @param {Id} {ModelTypeDesc}Id
*/
export function get{ModelTypeName}Detail(id) {
return http({
url: '{ModelTypeName}/GetById',
method: 'get',
params: { id: id },
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
})
}
/**
* 批量设置启用状态
* @param {id集合} ids
*/
export function set{ModelTypeName}Enable(data) {
return http({
url: '{ModelTypeName}/SetEnabledMarktBatchAsync',
method: 'post',
data: data,
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
})
}
/**
* 批量软删除
* @param {id集合} ids
*/
export function deleteSoft{ModelTypeName}(data) {
return http({
url: '{ModelTypeName}/DeleteSoftBatchAsync',
method: 'post',
data: data,
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
params: data,
})
}
/**
* 批量删除
* @param {id集合} ids
* 新增{ModelTypeDesc}
* @param data
*/
export function delete{ModelTypeName}(data) {
return http({
url: '{ModelTypeName}/DeleteBatchAsync',
method: 'delete',
export function add{ModelTypeName}(data) {
return request({
url: '/bus/{ModelTypeName}',
method: 'post',
data: data,
baseURL: defaultSettings.api{fileClassName}Url // 直接通过覆盖的方式
})
}
/**
* 修改{ModelTypeDesc}
* @param data
*/
export function update{ModelTypeName}(data) {
return request({
url: '/bus/{ModelTypeName}',
method: 'PUT',
data: data,
})
}
/**
* 获取{ModelTypeDesc}详情
* @param {Id} {ModelTypeDesc}Id
*/
export function get{ModelTypeName}(id) {
return request({
url: '/bus/{ModelTypeName}/' + id,
method: 'get'
})
}
/**
* 删除
* @param {主键} pid
*/
export function del{ModelTypeName}(pid) {
return request({
url: '/bus/{ModelTypeName}/' + pid,
method: 'delete'
})
}

View File

@ -36,20 +36,14 @@
<!-- 工具区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" v-hasPermi="['{ModelTypeName}:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
<el-button type="primary" v-hasPermi="['{Permission}:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" v-hasPermi="['{ModelTypeName}:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
<el-button type="success" v-hasPermi="['{Permission}:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" v-hasPermi="['{ModelTypeName}:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
<el-button type="danger" v-hasPermi="['{Permission}:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-col> -->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -59,10 +53,9 @@
{VueViewListContent}
<el-table-column label="操作" align="center" width="200">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
<el-button size="mini" v-hasPermi="['{ModelTypeName}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button size="mini" v-hasPermi="['{Permission}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-popconfirm title="确定删除吗?" @onConfirm="handleDelete(scope.row)" style="margin-left:10px">
<el-button slot="reference" v-hasPermi="['{ModelTypeName}:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
<el-button slot="reference" v-hasPermi="['{Permission}:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
@ -70,8 +63,8 @@
<pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改菜单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-dialog :title="title" :visible.sync="open" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
{VueViewFromContent}
</el-form>
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
@ -83,15 +76,23 @@
</div>
</template>
<script>
import { list{ModelTypeName},add{ModelTypeName},del{ModelTypeName},edit{ModelTypeName} } from '@{ModelTypeName}.js'
import {
list{ModelTypeName},
add{ModelTypeName},
del{ModelTypeName},
update{ModelTypeName},
get{ModelTypeName}
} from '@/api/{fileClassName}.js'
export default {
name: '{ModelTypeName}',
data() {
return {
labelWidth: "70px",
labelWidth: "100px",
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 遮罩层
@ -166,6 +167,7 @@ export default {
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.{primaryKey});
this.single = selection.length!=1
this.multiple = !selection.length;
},
/** 搜索按钮操作 */
@ -190,26 +192,33 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.open = true;
this.title = "编辑";
//TODO 业务代码
console.log(JSON.stringify(row));
// TODO 给表单赋值
this.form = {
{VueViewEditFromBindContent}
};
const {primaryKey} = row.{primaryKey} || this.ids;
get{ModelTypeName}({primaryKey}).then((res) => {
if(res.code == 200){
this.form = res.data;
this.open = true;
this.title = "修改数据";
}
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
console.log(JSON.stringify(this.form));
// TODO 记得改成表的主键
if (this.form.{primaryKey} != undefined) {
//TODO 编辑业务代码
update{ModelTypeName}(this.form).then((res) => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
//TODO 新增业务代码
add{ModelTypeName}(this.form).then((res) => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
@ -225,9 +234,7 @@ export default {
name: row.name,
sortId: row.sortId,
};
},
handleImport() {},
handleExport() {},
}
},
};
</script>