优化代码生成功能
This commit is contained in:
parent
59b44b3928
commit
b077e1da8f
@ -1,138 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ZR.Admin.WebApi.Filters;
|
|
||||||
using ZR.Admin.WebApi.Controllers;
|
|
||||||
using ZR.Service.Business;
|
|
||||||
using SqlSugar;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using Infrastructure.Enums;
|
|
||||||
using Infrastructure.Model;
|
|
||||||
using Mapster;
|
|
||||||
using ZR.Admin.WebApi.Extensions;
|
|
||||||
using ZR.Model.Dto;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZRAdmin.Controllers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 代码自动生成
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
//[Verify]
|
|
||||||
[Route("bus/gendemo")]
|
|
||||||
public class GendemoController : BaseController
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 接口
|
|
||||||
/// </summary>
|
|
||||||
private readonly IGendemoService _GendemoService;
|
|
||||||
|
|
||||||
public GendemoController(IGendemoService GendemoService)
|
|
||||||
{
|
|
||||||
_GendemoService = GendemoService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("list")]
|
|
||||||
[ActionPermissionFilter(Permission = "gendemo:list")]
|
|
||||||
public IActionResult Query([FromQuery] GendemoQueryDto parm)
|
|
||||||
{
|
|
||||||
//开始拼装查询条件
|
|
||||||
var predicate = Expressionable.Create<Gendemo>();
|
|
||||||
|
|
||||||
//TODO 搜索条件
|
|
||||||
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
|
||||||
|
|
||||||
var response = _GendemoService.GetPages(predicate.ToExpression(), parm);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询详情
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("{Id}")]
|
|
||||||
[ActionPermissionFilter(Permission = "gendemo:query")]
|
|
||||||
public IActionResult Get(int Id)
|
|
||||||
{
|
|
||||||
var response = _GendemoService.GetId(Id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
[ActionPermissionFilter(Permission = "gendemo:add")]
|
|
||||||
[Log(Title = "添加", BusinessType = BusinessType.INSERT)]
|
|
||||||
public IActionResult Create([FromBody] GendemoDto parm)
|
|
||||||
{
|
|
||||||
if (parm == null)
|
|
||||||
{
|
|
||||||
throw new CustomException("请求参数错误");
|
|
||||||
}
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var addModel = parm.Adapt<Gendemo>().ToCreate();
|
|
||||||
//addModel.CreateID = User.Identity.Name;
|
|
||||||
|
|
||||||
return SUCCESS(_GendemoService.Add(addModel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPut]
|
|
||||||
[ActionPermissionFilter(Permission = "gendemo:update")]
|
|
||||||
[Log(Title = "修改", BusinessType = BusinessType.UPDATE)]
|
|
||||||
public IActionResult Update([FromBody] GendemoDto parm)
|
|
||||||
{
|
|
||||||
if (parm == null)
|
|
||||||
{
|
|
||||||
throw new CustomException("请求实体不能为空");
|
|
||||||
}
|
|
||||||
//从 Dto 映射到 实体
|
|
||||||
var updateModel = parm.Adapt<Gendemo>().ToCreate();
|
|
||||||
//updateModel.CreateID = User.Identity.Name;
|
|
||||||
|
|
||||||
var response = _GendemoService.Update(w => w.Id == updateModel.Id, it => new Gendemo()
|
|
||||||
{
|
|
||||||
//TODO 字段映射
|
|
||||||
Name = parm.Name,
|
|
||||||
Icon = parm.Icon,
|
|
||||||
ShowStatus = parm.ShowStatus,
|
|
||||||
AddTime = parm.AddTime,
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete("{Id}")]
|
|
||||||
[ActionPermissionFilter(Permission = "gendemo:delete")]
|
|
||||||
[Log(Title = "删除", BusinessType = BusinessType.DELETE)]
|
|
||||||
public IActionResult Delete(int Id = 0)
|
|
||||||
{
|
|
||||||
if (Id <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
|
||||||
|
|
||||||
// 删除
|
|
||||||
var response = _GendemoService.Delete(Id);
|
|
||||||
|
|
||||||
return SUCCESS(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -6,6 +6,7 @@ using {ModelsNamespace}.Models;
|
|||||||
namespace {RepositoriesNamespace}
|
namespace {RepositoriesNamespace}
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 代码生成器生成
|
||||||
/// {TableNameDesc}仓储接口的实现
|
/// {TableNameDesc}仓储接口的实现
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
|
|||||||
@ -14,7 +14,7 @@ using {ServicesNamespace}.IService;
|
|||||||
namespace {ServicesNamespace}.Business
|
namespace {ServicesNamespace}.Business
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// {TableNameDesc}服务接口实现
|
/// 代码生成器生成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(I{ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
|
[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
|
||||||
@ -24,5 +24,9 @@ namespace {ServicesNamespace}.Business
|
|||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 业务逻辑代码
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Conn_Admin": "server=127.0.0.1;user=zr;pwd=abc;database=admin",
|
"Conn_Admin": "server=127.0.0.1;user=zr;pwd=abc;database=admin",
|
||||||
"ConnDynamic": "server=127.0.0.1;user=zr;pwd=abc;database={database}"//代码生成私用
|
"ConnDynamic": "server=127.0.0.1;user=zr;pwd=abc;database={database}"//代码生成使用
|
||||||
},
|
},
|
||||||
"urls": "http://localhost:8888", //启动url
|
"urls": "http://localhost:8888", //启动url
|
||||||
"sysConfig": {
|
"sysConfig": {
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using ZR.Model.Dto;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZR.Model.Dto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 输入对象模型
|
|
||||||
/// </summary>
|
|
||||||
public class GendemoDto
|
|
||||||
{
|
|
||||||
public int? Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Icon { get; set; }
|
|
||||||
public int? ShowStatus { get; set; }
|
|
||||||
public DateTime? AddTime { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GendemoQueryDto: PagerInfo
|
|
||||||
{
|
|
||||||
public DateTime? BeginTime { get; set; }
|
|
||||||
public DateTime? EndTime { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace ZR.Model.Models
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// ,数据实体对象
|
|
||||||
/// </summary>
|
|
||||||
[SqlSugar.SugarTable("gen_demo")]
|
|
||||||
public class Gendemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :自增id
|
|
||||||
/// 空值 :False
|
|
||||||
/// 默认 :
|
|
||||||
/// </summary>
|
|
||||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
|
||||||
public int? Id { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :名称
|
|
||||||
/// 空值 :False
|
|
||||||
/// 默认 :
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :图片
|
|
||||||
/// 空值 :True
|
|
||||||
/// 默认 :
|
|
||||||
/// </summary>
|
|
||||||
public string Icon { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :显示状态
|
|
||||||
/// 空值 :False
|
|
||||||
/// 默认 :
|
|
||||||
/// </summary>
|
|
||||||
public int? ShowStatus { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :添加时间
|
|
||||||
/// 空值 :True
|
|
||||||
/// 默认 :
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? AddTime { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZR.Repository
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 仓储接口的实现
|
|
||||||
/// </summary>
|
|
||||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
|
||||||
public class GendemoRepository : BaseRepository
|
|
||||||
{
|
|
||||||
public GendemoRepository()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 业务逻辑代码
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -29,7 +29,7 @@ namespace ZR.Repository.System
|
|||||||
.WhereIF(!string.IsNullOrEmpty(user.UserName), it => it.UserName.Contains(user.UserName))
|
.WhereIF(!string.IsNullOrEmpty(user.UserName), it => it.UserName.Contains(user.UserName))
|
||||||
.WhereIF(!string.IsNullOrEmpty(user.Status), it => it.Status == user.Status)
|
.WhereIF(!string.IsNullOrEmpty(user.Status), it => it.Status == user.Status)
|
||||||
.WhereIF(user.BeginTime != DateTime.MinValue && user.BeginTime != null, it => it.Create_time >= user.BeginTime)
|
.WhereIF(user.BeginTime != DateTime.MinValue && user.BeginTime != null, it => it.Create_time >= user.BeginTime)
|
||||||
.WhereIF(user.EndTime != DateTime.MinValue && user.BeginTime != null, it => it.EndTime <= user.EndTime)
|
.WhereIF(user.EndTime != DateTime.MinValue && user.BeginTime != null, it => it.Create_time <= user.EndTime)
|
||||||
.WhereIF(user.DeptId != 0, it => it.DeptId == user.DeptId)
|
.WhereIF(user.DeptId != 0, it => it.DeptId == user.DeptId)
|
||||||
.OrderBy(it => it.UserId)
|
.OrderBy(it => it.UserId)
|
||||||
.ToPageList(pager.PageNum, pager.PageSize, ref totalCount);
|
.ToPageList(pager.PageNum, pager.PageSize, ref totalCount);
|
||||||
|
|||||||
@ -1,28 +0,0 @@
|
|||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Attribute;
|
|
||||||
using Infrastructure.Extensions;
|
|
||||||
using SqlSugar;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using ZR.Common;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
using ZR.Repository;
|
|
||||||
using ZR.Service.IService;
|
|
||||||
|
|
||||||
namespace ZR.Service.Business
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 服务接口实现
|
|
||||||
/// </summary>
|
|
||||||
[AppService(ServiceType = typeof(IGendemoService), ServiceLifetime = LifeTime.Transient)]
|
|
||||||
public class GendemoService: BaseService<Gendemo>, IGendemoService
|
|
||||||
{
|
|
||||||
private readonly GendemoRepository _repository;
|
|
||||||
public GendemoService(GendemoRepository repository)
|
|
||||||
{
|
|
||||||
_repository = repository;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using ZR.Model.Models;
|
|
||||||
|
|
||||||
namespace ZR.Service.Business
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 定义服务接口
|
|
||||||
/// </summary>
|
|
||||||
public interface IGendemoService: IBaseService<Gendemo>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,11 +2,9 @@ import Vue from 'vue'
|
|||||||
|
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
|
|
||||||
|
|
||||||
import Element from 'element-ui'
|
import Element from 'element-ui'
|
||||||
import './assets/styles/element-variables.scss'
|
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
|
||||||
|
import '@/assets/styles/element-variables.scss'
|
||||||
import '@/assets/styles/index.scss' // global css
|
import '@/assets/styles/index.scss' // global css
|
||||||
|
|
||||||
import App from './App'
|
import App from './App'
|
||||||
@ -62,7 +60,7 @@ Vue.use(permission)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Vue.use(Element, {
|
Vue.use(Element, {
|
||||||
size: Cookies.get('size') || 'mini' // set element-ui default size
|
size: Cookies.get('size') || 'medium' // set element-ui default size
|
||||||
})
|
})
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export const constantRoutes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/demo',
|
path: '/demo',
|
||||||
component: (resolve) => require(['@/views/gendemo/index'], resolve),
|
component: (resolve) => require(['@/views/demo'], resolve),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
41
ZRAdmin.xml
41
ZRAdmin.xml
@ -920,46 +920,5 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:ZRAdmin.Controllers.GendemoController">
|
|
||||||
<summary>
|
|
||||||
代码自动生成
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="F:ZRAdmin.Controllers.GendemoController._GendemoService">
|
|
||||||
<summary>
|
|
||||||
接口
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZRAdmin.Controllers.GendemoController.Query(ZR.Model.Dto.GendemoQueryDto)">
|
|
||||||
<summary>
|
|
||||||
查询列表
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZRAdmin.Controllers.GendemoController.Get(System.Int32)">
|
|
||||||
<summary>
|
|
||||||
查询详情
|
|
||||||
</summary>
|
|
||||||
<param name="Id"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZRAdmin.Controllers.GendemoController.Create(ZR.Model.Dto.GendemoDto)">
|
|
||||||
<summary>
|
|
||||||
添加
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZRAdmin.Controllers.GendemoController.Update(ZR.Model.Dto.GendemoDto)">
|
|
||||||
<summary>
|
|
||||||
更新
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:ZRAdmin.Controllers.GendemoController.Delete(System.Int32)">
|
|
||||||
<summary>
|
|
||||||
删除
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
|||||||
Binary file not shown.
@ -315,8 +315,8 @@ INSERT INTO sys_menu VALUES (2052, '删除', 105, 3, '#', NULL, 0, 0, 'F', '0',
|
|||||||
|
|
||||||
INSERT INTO sys_menu VALUES (2054, '用户修改', 100, 3, '#', NULL, 0, 0, 'F', '0', '0', 'system:user:edit', '', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (2054, '用户修改', 100, 3, '#', NULL, 0, 0, 'F', '0', '0', 'system:user:edit', '', '', SYSDATE(), '', NULL, NULL);
|
||||||
|
|
||||||
INSERT INTO sys_menu VALUES (2056, '创建文章', 5, 999, 'publish', 'article/publish', 0, 0, 'C', '1', '0', 'system:article:publish', 'log', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (2056, '创建文章', 5, 999, 'publish', 'system/article/publish', 0, 0, 'C', '1', '0', 'system:article:publish', 'log', '', SYSDATE(), '', NULL, NULL);
|
||||||
INSERT INTO sys_menu VALUES (2057, '文章列表', 5, 999, 'manager', 'article/manager', 0, 0, 'C', '0', '0', 'system:article:list', 'documentation', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (2057, '文章列表', 5, 999, 'manager', 'system/article/manager', 0, 0, 'C', '0', '0', 'system:article:list', 'documentation', '', SYSDATE(), '', NULL, NULL);
|
||||||
INSERT INTO sys_menu VALUES (2060, '任务日志', 2, 2, '/job/log', 'monitor/job/log', 0, 0, 'C', '0', '0', NULL, 'log', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (2060, '任务日志', 2, 2, '/job/log', 'monitor/job/log', 0, 0, 'C', '0', '0', NULL, 'log', '', SYSDATE(), '', NULL, NULL);
|
||||||
INSERT INTO sys_menu VALUES (2062, '新增', 2057, 1, '#', NULL, 0, 0, 'F', '0', '0', 'system:article:add', '', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (2062, '新增', 2057, 1, '#', NULL, 0, 0, 'F', '0', '0', 'system:article:add', '', '', SYSDATE(), '', NULL, NULL);
|
||||||
INSERT INTO sys_menu VALUES (2063, '修改', 2057, 2, '#', NULL, 0, 0, 'F', '0', '0', 'system:article:update', '', '', SYSDATE(), '', NULL, NULL);
|
INSERT INTO sys_menu VALUES (2063, '修改', 2057, 2, '#', NULL, 0, 0, 'F', '0', '0', 'system:article:update', '', '', SYSDATE(), '', NULL, NULL);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user