diff --git a/ZR.Admin.WebApi/Controllers/BaseController.cs b/ZR.Admin.WebApi/Controllers/BaseController.cs index 5436fb8..119d7c4 100644 --- a/ZR.Admin.WebApi/Controllers/BaseController.cs +++ b/ZR.Admin.WebApi/Controllers/BaseController.cs @@ -16,7 +16,7 @@ namespace ZR.Admin.WebApi.Controllers public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss"; public static string TIME_FORMAT_FULL_2 = "MM-dd HH:mm:ss"; - protected IActionResult SUCCESS(object data, string timeFormatStr = "MM-dd HH:mm:ss") + protected IActionResult SUCCESS(object data, string timeFormatStr = "yyyy-MM-dd HH:mm:ss") { string jsonStr = GetJsonStr(GetApiResult(data != null ? ResultCode.SUCCESS : ResultCode.FAIL, data), timeFormatStr); return Content(jsonStr, "application/json"); @@ -34,13 +34,13 @@ namespace ZR.Admin.WebApi.Controllers /// /// /// - protected IActionResult OutputJson(ApiResult apiResult, string timeFormatStr = "MM-dd HH:mm:ss") + protected IActionResult OutputJson(ApiResult apiResult, string timeFormatStr = "yyyy-MM-dd HH:mm:ss") { string jsonStr = GetJsonStr(apiResult, timeFormatStr); return Content(jsonStr, "application/json"); } - protected IActionResult OutputJson(long rows, string timeFormatStr = "MM-dd HH:mm:ss") + protected IActionResult OutputJson(long rows, string timeFormatStr = "yyyy-MM-dd HH:mm:ss") { string jsonStr = GetJsonStr(ToJson(rows), timeFormatStr); diff --git a/ZR.Admin.WebApi/Controllers/business/GendemoController.cs b/ZR.Admin.WebApi/Controllers/business/GendemoController.cs new file mode 100644 index 0000000..6cb7021 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/business/GendemoController.cs @@ -0,0 +1,138 @@ +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 +{ + /// + /// 代码自动生成 + /// + + //[Verify] + [Route("bus/gendemo")] + public class GendemoController : BaseController + { + /// + /// 接口 + /// + private readonly IGendemoService _GendemoService; + + public GendemoController(IGendemoService GendemoService) + { + _GendemoService = GendemoService; + } + + /// + /// 查询列表 + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "gendemo:list")] + public IActionResult Query([FromQuery] GendemoQueryDto parm) + { + //开始拼装查询条件 + var predicate = Expressionable.Create(); + + //TODO 搜索条件 + //predicate = predicate.And(m => m.Name.Contains(parm.Name)); + + var response = _GendemoService.GetPages(predicate.ToExpression(), parm); + + return SUCCESS(response); + } + + /// + /// 查询详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "gendemo:query")] + public IActionResult Get(int Id) + { + var response = _GendemoService.GetId(Id); + + return SUCCESS(response); + } + + /// + /// 添加 + /// + /// + [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().ToCreate(); + //addModel.CreateID = User.Identity.Name; + + return SUCCESS(_GendemoService.Add(addModel)); + } + + /// + /// 更新 + /// + /// + [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().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); + } + + /// + /// 删除 + /// + /// + [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); + } + } +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/Template/VueTemplate.txt b/ZR.Admin.WebApi/Template/VueTemplate.txt index 08a3ce8..ac347d3 100644 --- a/ZR.Admin.WebApi/Template/VueTemplate.txt +++ b/ZR.Admin.WebApi/Template/VueTemplate.txt @@ -32,7 +32,7 @@ 新增 - 修改 + 修改 删除 @@ -53,7 +53,7 @@ - + @@ -232,14 +232,4 @@ export default { .table-td-thumb { width: 80px; } -.icon { - width: 100px; -} -.uploader-icon { - width: 50px; - height: 50px; - line-height: 50px; - border: 1px dashed #ccc; - margin-bottom: 10px; -} diff --git a/ZR.Model/Dto/GendemoDto.cs b/ZR.Model/Dto/GendemoDto.cs new file mode 100644 index 0000000..2ccaf55 --- /dev/null +++ b/ZR.Model/Dto/GendemoDto.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using ZR.Model.Dto; +using ZR.Model.Models; + +namespace ZR.Model.Dto +{ + /// + /// 输入对象模型 + /// + 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; } + } +} diff --git a/ZR.Model/Models/Gendemo.cs b/ZR.Model/Models/Gendemo.cs new file mode 100644 index 0000000..41c4327 --- /dev/null +++ b/ZR.Model/Models/Gendemo.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; + +namespace ZR.Model.Models +{ + /// + /// ,数据实体对象 + /// + [SqlSugar.SugarTable("gen_demo")] + public class Gendemo + { + /// + /// 描述 :自增id + /// 空值 :False + /// 默认 : + /// + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int? Id { get; set; } + /// + /// 描述 :名称 + /// 空值 :False + /// 默认 : + /// + public string Name { get; set; } + /// + /// 描述 :图片 + /// 空值 :True + /// 默认 : + /// + public string Icon { get; set; } + /// + /// 描述 :显示状态 + /// 空值 :False + /// 默认 : + /// + public int? ShowStatus { get; set; } + /// + /// 描述 :添加时间 + /// 空值 :True + /// 默认 : + /// + public DateTime? AddTime { get; set; } + + } +} diff --git a/ZR.Repository/Repositories/GendemoRepository.cs b/ZR.Repository/Repositories/GendemoRepository.cs new file mode 100644 index 0000000..c443c7f --- /dev/null +++ b/ZR.Repository/Repositories/GendemoRepository.cs @@ -0,0 +1,24 @@ +using System; +using Infrastructure.Attribute; +using ZR.Repository.System; +using ZR.Model.Models; + +namespace ZR.Repository +{ + /// + /// 仓储接口的实现 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class GendemoRepository : BaseRepository + { + public GendemoRepository() + { + } + + #region 业务逻辑代码 + + + + #endregion + } +} \ No newline at end of file diff --git a/ZR.Service/Business/GendemoService.cs b/ZR.Service/Business/GendemoService.cs new file mode 100644 index 0000000..a4cc21c --- /dev/null +++ b/ZR.Service/Business/GendemoService.cs @@ -0,0 +1,28 @@ +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 +{ + /// + /// 服务接口实现 + /// + [AppService(ServiceType = typeof(IGendemoService), ServiceLifetime = LifeTime.Transient)] + public class GendemoService: BaseService, IGendemoService + { + private readonly GendemoRepository _repository; + public GendemoService(GendemoRepository repository) + { + _repository = repository; + } + } +} \ No newline at end of file diff --git a/ZR.Service/Business/IBusService/IGendemoService.cs b/ZR.Service/Business/IBusService/IGendemoService.cs new file mode 100644 index 0000000..0e4cb5e --- /dev/null +++ b/ZR.Service/Business/IBusService/IGendemoService.cs @@ -0,0 +1,12 @@ +using System; +using ZR.Model.Models; + +namespace ZR.Service.Business +{ + /// + /// 定义服务接口 + /// + public interface IGendemoService: IBaseService + { + } +} diff --git a/ZR.Vue/package.json b/ZR.Vue/package.json index ed507b8..48dafb0 100644 --- a/ZR.Vue/package.json +++ b/ZR.Vue/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "@riophae/vue-treeselect": "0.4.0", - "axios": "^0.21.1", + "axios": "^0.21.4", "clipboard": "2.0.4", "core-js": "3.6.5", "echarts": "^5.1.1", diff --git a/ZR.Vue/src/api/gendemo.js b/ZR.Vue/src/api/gendemo.js new file mode 100644 index 0000000..a7c6c3d --- /dev/null +++ b/ZR.Vue/src/api/gendemo.js @@ -0,0 +1,59 @@ +import request from '@/utils/request' + +/** + * 分页查询 + * @param {查询条件} data + */ +export function listGendemo(data) { + return request({ + url: '/bus/Gendemo/list', + method: 'get', + params: data, + }) +} + +/** + * 新增 + * @param data + */ +export function addGendemo(data) { + return request({ + url: '/bus/Gendemo', + method: 'post', + data: data, + }) +} + +/** + * 修改 + * @param data + */ +export function updateGendemo(data) { + return request({ + url: '/bus/Gendemo', + method: 'PUT', + data: data, + }) +} + +/** + * 获取详情 + * @param {Id} Id + */ +export function getGendemo(id) { + return request({ + url: '/bus/Gendemo/' + id, + method: 'get' + }) +} + +/** + * 删除 + * @param {主键} pid + */ +export function delGendemo(pid) { + return request({ + url: '/bus/Gendemo/' + pid, + method: 'delete' + }) +} diff --git a/ZR.Vue/src/router/index.js b/ZR.Vue/src/router/index.js index cd682e2..3dd9d34 100644 --- a/ZR.Vue/src/router/index.js +++ b/ZR.Vue/src/router/index.js @@ -44,7 +44,7 @@ export const constantRoutes = [ }, { path: '/demo', - component: (resolve) => require(['@/views/userInfo/index'], resolve), + component: (resolve) => require(['@/views/gendemo/index'], resolve), hidden: true }, { diff --git a/ZR.Vue/src/views/gendemo/index.vue b/ZR.Vue/src/views/gendemo/index.vue new file mode 100644 index 0000000..8bb4ec9 --- /dev/null +++ b/ZR.Vue/src/views/gendemo/index.vue @@ -0,0 +1,279 @@ + + + diff --git a/ZRAdmin.xml b/ZRAdmin.xml index 3440c32..f8b63ac 100644 --- a/ZRAdmin.xml +++ b/ZRAdmin.xml @@ -920,42 +920,42 @@ - + 代码自动生成 - + 接口 - + 查询列表 - + 查询详情 - + - + 添加 - + 更新 - + 删除