diff --git a/ARW.Model/Dto/Api/Advertisement/Notices/NoticeApiDto.cs b/ARW.Model/Dto/Api/Advertisement/Notices/NoticeApiDto.cs new file mode 100644 index 0000000..a8408dd --- /dev/null +++ b/ARW.Model/Dto/Api/Advertisement/Notices/NoticeApiDto.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.Advertisement.Notices; + +namespace ARW.Model.Dto.Api.Advertisement.Notices +{ + + /// + /// 公告查询对象Api + /// + /// @author lwh + /// @date 2023-10-09 + /// + public class NoticeQueryDtoApi : PagerInfo + { + public string NoticeTitle { get; set; } + } + +} diff --git a/ARW.Model/Dto/Business/Advertisement/Notices/NoticeDto.cs b/ARW.Model/Dto/Business/Advertisement/Notices/NoticeDto.cs new file mode 100644 index 0000000..7633abc --- /dev/null +++ b/ARW.Model/Dto/Business/Advertisement/Notices/NoticeDto.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.Advertisement.Notices; + +namespace ARW.Model.Dto.Business.Advertisement.Notices +{ + /// + /// 公告输入对象 + /// + /// @author lwh + /// @date 2023-10-09 + /// + public class NoticeDto + { + + public int NoticeId { get; set; } + + public long NoticeGuid { get; set; } + + [Required(ErrorMessage = "标题不能为空")] + public string NoticeTitle { get; set; } + + [Required(ErrorMessage = "内容不能为空")] + public string NoticeContent { get; set; } + + [Required(ErrorMessage = "排序不能为空")] + public int NoticeSort { get; set; } + + + + + + } + + + /// + /// 公告查询对象 + /// + /// @author lwh + /// @date 2023-10-09 + /// + public class NoticeQueryDto : PagerInfo + { + + public string NoticeTitle { get; set; } + + public string ids { get; set; } + } + + + + +} diff --git a/ARW.Model/Models/Business/Advertisement/Notices/Notice.cs b/ARW.Model/Models/Business/Advertisement/Notices/Notice.cs new file mode 100644 index 0000000..4e86f06 --- /dev/null +++ b/ARW.Model/Models/Business/Advertisement/Notices/Notice.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; +using Newtonsoft.Json; + +namespace ARW.Model.Models.Business.Advertisement.Notices +{ + /// + /// 公告,数据实体对象 + /// + /// @author lwh + /// @date 2023-10-09 + /// + [SugarTable("tb_notice")] + public class Notice : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "notice_id")] + public int NoticeId { get; set; } + + + /// + /// 描述 : + /// 空值 : false + /// + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "notice_guid")] + public long NoticeGuid { get; set; } + + + /// + /// 描述 :标题 + /// 空值 : false + /// + [SugarColumn(ColumnName = "notice_title")] + public string NoticeTitle { get; set; } + + + /// + /// 描述 :内容 + /// 空值 : false + /// + [SugarColumn(ColumnName = "notice_content")] + public string NoticeContent { get; set; } + + + /// + /// 描述 :排序 + /// 空值 : false + /// + [SugarColumn(ColumnName = "notice_sort")] + public int NoticeSort { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/Vo/Api/Advertisement/Notices/NoticeApiVo.cs b/ARW.Model/Vo/Api/Advertisement/Notices/NoticeApiVo.cs new file mode 100644 index 0000000..1ab7195 --- /dev/null +++ b/ARW.Model/Vo/Api/Advertisement/Notices/NoticeApiVo.cs @@ -0,0 +1,65 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Api.Advertisement.Notices +{ + /// + /// 公告展示对象Api + /// + /// @author lwh + /// @date 2023-10-09 + /// + public class NoticeVoApi + { + + + /// + /// 描述 : + /// + public int NoticeId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long NoticeGuid { get; set; } + + + /// + /// 描述 :标题 + /// + public string NoticeTitle { get; set; } + + + /// + /// 描述 :内容 + /// + public string NoticeContent { get; set; } + + + /// + /// 描述 :排序 + /// + public int NoticeSort { get; set; } + + } + + + /// + /// 公告详情展示对象Api + /// + public class NoticeApiDetailsVo + { + public int NoticeId { get; set; } + [JsonConverter(typeof(ValueToStringConverter))] + public long NoticeGuid { get; set; } + public string NoticeTitle { get; set; } + public string NoticeContent { get; set; } + public int NoticeSort { get; set; } + + } + +} diff --git a/ARW.Model/Vo/Business/Advertisement/Notices/NoticeVo.cs b/ARW.Model/Vo/Business/Advertisement/Notices/NoticeVo.cs new file mode 100644 index 0000000..5c1558b --- /dev/null +++ b/ARW.Model/Vo/Business/Advertisement/Notices/NoticeVo.cs @@ -0,0 +1,49 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.Advertisement.Notices +{ + /// + /// 公告展示对象 + /// + /// @author lwh + /// @date 2023-10-09 + /// + public class NoticeVo + { + + + /// + /// 描述 : + /// + public int NoticeId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long NoticeGuid { get; set; } + + + /// + /// 描述 :标题 + /// + public string NoticeTitle { get; set; } + + + /// + /// 描述 :内容 + /// + public string NoticeContent { get; set; } + + + /// + /// 描述 :排序 + /// + public int NoticeSort { get; set; } + + } +} diff --git a/ARW.Repository/Business/Advertisement/Notices/NoticeRepository.cs b/ARW.Repository/Business/Advertisement/Notices/NoticeRepository.cs new file mode 100644 index 0000000..8b357d6 --- /dev/null +++ b/ARW.Repository/Business/Advertisement/Notices/NoticeRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ARW.Repository.System; +using ARW.Model.Models.Business.Advertisement.Notices; + +namespace ARW.Repository.Business.Advertisement.Notices +{ + /// + /// 公告仓储 + /// + /// @author lwh + /// @date 2023-10-09 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class NoticeRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Api/BusinessService/Advertisement/Notices/NoticeServiceApi.cs b/ARW.Service/Api/BusinessService/Advertisement/Notices/NoticeServiceApi.cs new file mode 100644 index 0000000..01d60e2 --- /dev/null +++ b/ARW.Service/Api/BusinessService/Advertisement/Notices/NoticeServiceApi.cs @@ -0,0 +1,69 @@ +using Infrastructure.Attribute; +using Microsoft.AspNetCore.Http; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Repository; +using ARW.Repository.Business.Advertisement.Notices; +using ARW.Service.Api.IBusinessService.Advertisement.Notices; +using ARW.Model.Dto.Api.Advertisement.Notices; +using ARW.Model.Models.Business.Advertisement.Notices; +using ARW.Model.Vo.Api.Advertisement.Notices; + +namespace ARW.Service.Api.BusinessService.Advertisement.Notices +{ + /// + /// 公告接口实现类Api + /// + /// @author lwh + /// @date 2023-10-09 + /// + [AppService(ServiceType = typeof(INoticeServiceApi), ServiceLifetime = LifeTime.Transient)] + public class NoticeServiceImplApi : BaseService, INoticeServiceApi + { + private readonly NoticeRepository _NoticeRepository; + + public NoticeServiceImplApi(NoticeRepository NoticeRepository) + { + this._NoticeRepository = NoticeRepository; + } + + #region Api接口代码 + + + /// + /// 查询公告列表(Api) + /// + /// + /// + public async Task> GetNoticeListApi(NoticeQueryDtoApi parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + var query = _NoticeRepository + .Queryable() + .Where(predicate.ToExpression()) + .OrderBy(s => s.NoticeSort, OrderByType.Asc) + .Select(s => new NoticeVoApi + { + NoticeId = s.NoticeId, + NoticeGuid = s.NoticeGuid, + NoticeTitle = s.NoticeTitle, + NoticeContent = s.NoticeContent, + NoticeSort = s.NoticeSort, + }); + + + return await query.ToListAsync(); + } + + + #endregion + + } +} diff --git a/ARW.Service/Api/IBusinessService/Advertisement/Notices/INoticeServiceApi.cs b/ARW.Service/Api/IBusinessService/Advertisement/Notices/INoticeServiceApi.cs new file mode 100644 index 0000000..afc4ee9 --- /dev/null +++ b/ARW.Service/Api/IBusinessService/Advertisement/Notices/INoticeServiceApi.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Api.Advertisement.Notices; +using ARW.Model.Models.Business.Advertisement.Notices; +using ARW.Model.Vo.Api.Advertisement.Notices; + +namespace ARW.Service.Api.IBusinessService.Advertisement.Notices +{ + /// + /// 公告接口类Api + /// + /// @author lwh + /// @date 2023-10-09 + /// + public interface INoticeServiceApi : IBaseService + { + /// + /// 获取公告分页列表(Api) + /// + /// + /// + Task> GetNoticeListApi(NoticeQueryDtoApi parm); + + + } +} diff --git a/ARW.Service/Business/BusinessService/Advertisement/Notices/NoticeService.cs b/ARW.Service/Business/BusinessService/Advertisement/Notices/NoticeService.cs new file mode 100644 index 0000000..5f76b99 --- /dev/null +++ b/ARW.Service/Business/BusinessService/Advertisement/Notices/NoticeService.cs @@ -0,0 +1,93 @@ +using Infrastructure.Attribute; +using Microsoft.AspNetCore.Http; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Infrastructure; +using ARW.Model; +using ARW.Repository; +using ARW.Repository.Business.Advertisement.Notices; +using ARW.Service.Business.IBusinessService.Advertisement.Notices; +using ARW.Model.Dto.Business.Advertisement.Notices; +using ARW.Model.Models.Business.Advertisement.Notices; +using ARW.Model.Vo.Business.Advertisement.Notices; + +namespace ARW.Service.Business.BusinessService.Advertisement.Notices +{ + /// + /// 公告接口实现类 + /// + /// @author lwh + /// @date 2023-10-09 + /// + [AppService(ServiceType = typeof(INoticeService), ServiceLifetime = LifeTime.Transient)] + public class NoticeServiceImpl : BaseService, INoticeService + { + private readonly NoticeRepository _NoticeRepository; + + public NoticeServiceImpl(NoticeRepository NoticeRepository) + { + this._NoticeRepository = NoticeRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询公告分页列表 + /// + public async Task> GetNoticeList(NoticeQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NoticeTitle), s => s.NoticeTitle.Contains(parm.NoticeTitle)); + var query = _NoticeRepository + .Queryable() + .Where(predicate.ToExpression()) + .OrderBy(s => s.NoticeSort,OrderByType.Asc) + .Select(s => new NoticeVo + { + NoticeId = s.NoticeId, + NoticeGuid = s.NoticeGuid, + NoticeTitle = s.NoticeTitle, + NoticeContent = s.NoticeContent, + NoticeSort = s.NoticeSort, + }); + + + return await query.ToPageAsync(parm); + } + + /// + /// 添加或修改公告 + /// + public async Task AddOrUpdateNotice(Notice model) + { + if (model.NoticeId != 0) + { + var response = await _NoticeRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + + var response = await _NoticeRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + #region Excel处理 + + + #endregion + + + +#endregion + + } +} diff --git a/ARW.Service/Business/IBusinessService/Advertisement/Notices/INoticeService.cs b/ARW.Service/Business/IBusinessService/Advertisement/Notices/INoticeService.cs new file mode 100644 index 0000000..3d6271e --- /dev/null +++ b/ARW.Service/Business/IBusinessService/Advertisement/Notices/INoticeService.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Business.Advertisement.Notices; +using ARW.Model.Models.Business.Advertisement.Notices; +using ARW.Model.Vo.Business.Advertisement.Notices; + +namespace ARW.Service.Business.IBusinessService.Advertisement.Notices +{ + /// + /// 公告接口类 + /// + /// @author lwh + /// @date 2023-10-09 + /// + public interface INoticeService : IBaseService + { + /// + /// 获取公告分页列表 + /// + /// + /// + Task> GetNoticeList(NoticeQueryDto parm); + + + /// + /// 添加或修改公告 + /// + /// + /// + Task AddOrUpdateNotice(Notice parm); + + + + + + } +} diff --git a/ARW.WebApi/Controllers/Api/Advertisement/Notices/NoticeApiController.cs b/ARW.WebApi/Controllers/Api/Advertisement/Notices/NoticeApiController.cs new file mode 100644 index 0000000..28fff57 --- /dev/null +++ b/ARW.WebApi/Controllers/Api/Advertisement/Notices/NoticeApiController.cs @@ -0,0 +1,56 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Enums; +using Infrastructure.Model; +using Mapster; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using ARW.Admin.WebApi.Extensions; +using ARW.Admin.WebApi.Filters; +using ARW.Common; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Dto.Api.Advertisement.Notices; +using ARW.Service.Api.IBusinessService.Advertisement.Notices; +using ARW.Model.Models.Business.Advertisement.Notices; +using ARW.Model.Vo.Api.Advertisement.Notices; +using Microsoft.AspNetCore.Authorization; +using Geocoding; + +namespace ARW.WebApi.Controllers.Api.Advertisement.Notices +{ + /// + /// 公告控制器Api + /// + /// @author lwh + /// @date 2023-10-09 + /// + //[Verify] + [Route("api/[controller]")] + public class NoticeApiController : BaseController + { + private readonly INoticeServiceApi _NoticeServiceApi; + + /// + /// 依赖注入 + /// + /// 公告公告Api服务 + public NoticeApiController(INoticeServiceApi NoticeServiceApi) + { + _NoticeServiceApi = NoticeServiceApi; + } + + + /// + /// 获取公告列表(Api) + /// + /// 查询参数 + /// + [HttpGet("getNoticeList")] + public async Task GetNoticeListApi([FromQuery] NoticeQueryDtoApi parm) + { + var res = await _NoticeServiceApi.GetNoticeListApi(parm); + return SUCCESS(res); + } + + } +} diff --git a/ARW.WebApi/Controllers/Business/Advertisement/Notices/NoticeController.cs b/ARW.WebApi/Controllers/Business/Advertisement/Notices/NoticeController.cs new file mode 100644 index 0000000..0fa9515 --- /dev/null +++ b/ARW.WebApi/Controllers/Business/Advertisement/Notices/NoticeController.cs @@ -0,0 +1,98 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Enums; +using Infrastructure.Model; +using Mapster; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using ARW.Admin.WebApi.Extensions; +using ARW.Admin.WebApi.Filters; +using ARW.Common; +using ARW.Model.Dto.Business.Advertisement.Notices; +using ARW.Service.Business.IBusinessService.Advertisement.Notices; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Models.Business.Advertisement.Notices; +using ARW.Model.Vo.Business.Advertisement.Notices; +using Microsoft.AspNetCore.Authorization; +using ARW.Admin.WebApi.Framework; + + +namespace ARW.WebApi.Controllers.Business.Advertisement.Notices +{ + /// + /// 公告控制器 + /// + /// @author lwh + /// @date 2023-10-09 + /// + [Verify] + [Route("business/[controller]")] + public class NoticeController : BaseController + { + private readonly INoticeService _NoticeService; + + /// + /// 依赖注入 + /// + /// 公告服务 + public NoticeController(INoticeService NoticeService) + { + _NoticeService = NoticeService; + } + + + /// + /// 获取公告列表 + /// + /// 查询参数 + /// + [HttpGet("getNoticeList")] + [ActionPermissionFilter(Permission = "business:notice:list")] + public async Task GetNoticeList([FromQuery] NoticeQueryDto parm) + { + var res = await _NoticeService.GetNoticeList(parm); + return SUCCESS(res); + } + + /// + /// 添加或修改公告 + /// + /// + /// + [HttpPost("addOrUpdateNotice")] + [ActionPermissionFilter(Permission = "business:notice:addOrUpdate")] + [Log(Title = "添加或修改公告", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateNotice([FromBody] NoticeDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new Notice(); + if (parm.NoticeId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _NoticeService.AddOrUpdateNotice(modal); + return SUCCESS(res); + } + + /// + /// 删除公告 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:notice:delete")] + [Log(Title = "公告删除", BusinessType = BusinessType.DELETE)] + public IActionResult Delete(string ids) + { + long[] idsArr = Tools.SpitLongArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + var response = _NoticeService.Delete(idsArr); + return SUCCESS("删除成功!"); + } + + + + + + + } +}