代码生成新增加查询功能一键生成
This commit is contained in:
@@ -15,6 +15,7 @@ using {ApiControllerNamespace}.Extensions;
|
||||
using {ApiControllerNamespace}.Filters;
|
||||
using ZR.Common;
|
||||
using Infrastructure.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace {ApiControllerNamespace}.Controllers
|
||||
{
|
||||
@@ -51,7 +52,7 @@ namespace {ApiControllerNamespace}.Controllers
|
||||
|
||||
//TODO 自己实现搜索条件查询语法参考Sqlsugar,默认查询所有
|
||||
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
||||
|
||||
{QueryCondition}
|
||||
var response = _{ModelName}Service.GetPages(predicate.ToExpression(), parm);
|
||||
|
||||
return SUCCESS(response);
|
||||
@@ -66,8 +67,8 @@ namespace {ApiControllerNamespace}.Controllers
|
||||
[ActionPermissionFilter(Permission = "{Permission}:query")]
|
||||
public IActionResult Get{ModelName}({PKCsharpType} {PrimaryKey})
|
||||
{
|
||||
var response = _{ModelName}Service.GetId({PrimaryKey});
|
||||
|
||||
var response = _{ModelName}Service.GetFirst(x => x.{PrimaryKey} == {PrimaryKey});
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
@@ -134,5 +135,20 @@ namespace {ApiControllerNamespace}.Controllers
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {FunctionName}导出
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title = "{FunctionName}")]
|
||||
[HttpGet("export")]
|
||||
[ActionPermissionFilter(Permission = "{Permission}:export")]
|
||||
public IActionResult Export()
|
||||
{
|
||||
var list = _{ModelName}Service.GetAll();
|
||||
|
||||
string sFileName = ExportExcel(list, "{ModelName}", "{FunctionName}");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
|
||||
namespace {ModelsNamespace}.Models
|
||||
{
|
||||
@@ -9,7 +10,7 @@ namespace {ModelsNamespace}.Models
|
||||
/// @author {Author}
|
||||
/// @date {DateTime}
|
||||
/// </summary>
|
||||
[SqlSugar.SugarTable("{TableName}")]
|
||||
[SugarTable("{TableName}")]
|
||||
public class {ModelTypeName}
|
||||
{
|
||||
{PropertyName}
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace {ServicesNamespace}.Business
|
||||
/// @date {DateTime}
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(I{ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
|
||||
public class {ModelTypeName}Service: BaseService<{ModelTypeName}>, I{ModelTypeName}Service
|
||||
public class {ModelTypeName}Service : BaseService<{ModelTypeName}>, I{ModelTypeName}Service
|
||||
{
|
||||
private readonly {ModelTypeName}Repository _{ModelTypeName}repository;
|
||||
public {ModelTypeName}Service({ModelTypeName}Repository repository)
|
||||
public {ModelTypeName}Service({ModelTypeName}Repository repository) : base(repository)
|
||||
{
|
||||
_{ModelTypeName}repository = repository;
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ VALUES ('{FunctionName}删除', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', '{Pe
|
||||
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
|
||||
VALUES ('{FunctionName}修改', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:update', '', '', GETDATE(), '', NULL, NULL);
|
||||
|
||||
SELECT * FROM sys_menu WHERE parentId = {ParentId};
|
||||
SELECT * FROM sys_menu WHERE parentId = @menuId;
|
||||
SELECT * FROM sys_menu WHERE menuId = @menuId;
|
||||
@@ -1,9 +1,9 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* {FunctionName}分页查询
|
||||
* @param {查询条件} data
|
||||
*/
|
||||
* {FunctionName}分页查询
|
||||
* @param {查询条件} data
|
||||
*/
|
||||
export function list{ModelTypeName}(query) {
|
||||
return request({
|
||||
url: '{ModuleName}/{ModelTypeName}/list',
|
||||
@@ -13,9 +13,9 @@ export function list{ModelTypeName}(query) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增{FunctionName}
|
||||
* @param data
|
||||
*/
|
||||
* 新增{FunctionName}
|
||||
* @param data
|
||||
*/
|
||||
export function add{ModelTypeName}(data) {
|
||||
return request({
|
||||
url: '{ModuleName}/{ModelTypeName}',
|
||||
@@ -25,9 +25,9 @@ export function add{ModelTypeName}(data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改{FunctionName}
|
||||
* @param data
|
||||
*/
|
||||
* 修改{FunctionName}
|
||||
* @param data
|
||||
*/
|
||||
export function update{ModelTypeName}(data) {
|
||||
return request({
|
||||
url: '{ModuleName}/{ModelTypeName}',
|
||||
@@ -37,9 +37,9 @@ export function update{ModelTypeName}(data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{FunctionName}详情
|
||||
* @param {Id} {FunctionName}Id
|
||||
*/
|
||||
* 获取{FunctionName}详情
|
||||
* @param {Id} {FunctionName}Id
|
||||
*/
|
||||
export function get{ModelTypeName}(id) {
|
||||
return request({
|
||||
url: '{ModuleName}/{ModelTypeName}/' + id,
|
||||
@@ -48,12 +48,20 @@ export function get{ModelTypeName}(id) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param {主键} pid
|
||||
*/
|
||||
* 删除
|
||||
* @param {主键} pid
|
||||
*/
|
||||
export function del{ModelTypeName}(pid) {
|
||||
return request({
|
||||
url: '{ModuleName}/{ModelTypeName}/' + pid,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
// 导出
|
||||
export function export{ModelTypeName}(query) {
|
||||
return request({
|
||||
url: '{ModuleName}/{ModelTypeName}/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user