李昊 4 years ago
parent
commit
2c2b29219c

+ 52 - 0
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminAppStartPage.cs

@@ -0,0 +1,52 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using GxPress.Repository.Interface.AppStartPage;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace GxPress.Api.AdminControllers
+{
+    /// <summary>
+    /// app启动页管理
+    /// </summary>
+    [Route("api/admin/app-start-page")]
+    [ApiController]
+    [Authorize]
+    public class AdminAppStartPage : Controller
+    {
+        private readonly IAppStartPageRepository appStartPageRepository;
+        public AdminAppStartPage(IAppStartPageRepository appStartPageRepository)
+        {
+            this.appStartPageRepository = appStartPageRepository;
+        }
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("list")]
+        public async Task<IEnumerable<Entity.tede2.AppStartPage.AppStartPage>> GetAllAsync()
+        {
+            return await appStartPageRepository.GetAllAsync();
+        }
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpDelete("{id}")]
+        public async Task<bool> DeleteAsync(int id)
+        {
+            return await appStartPageRepository.DeleteAsync(id);
+        }
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPut("")]
+        public async Task<bool> UpdateAsync(Entity.tede2.AppStartPage.AppStartPage model)
+        {
+            return await appStartPageRepository.UpdateAsync(model);
+        }
+    }
+}

+ 80 - 0
gx_api/GxPress/Model/GxPress.Entity/tede2/AppStartPage/AppStartPage.cs

@@ -0,0 +1,80 @@
+using Datory.Annotations;
+
+namespace GxPress.Entity.tede2.AppStartPage
+{
+    /// <summary>
+    /// APP启动页
+    /// </summary>
+    [DataTable("tede_app_start_page")]
+    public class AppStartPage : Datory.Entity
+    {
+        /// <summary>
+        /// 图片
+        /// </summary>
+        [DataColumn]
+        public string ImageUrl { get; set; }
+        /// <summary>
+        /// 标题
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string Title { get; set; }
+        /// <summary>
+        /// 操作人
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string Creator { get; set; }
+
+        /// <summary>
+        /// 操作人姓名
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int AdminId { get; set; }
+        /// <summary>
+        /// App类型 1 ios 2 android
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int AppTypeId { get; set; }
+        /// <summary>
+        /// 连接类型 1 内部 2 外部
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int TypeId { get; set; }
+        /// <summary>
+        /// 外部连接地址
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string Url { get; set; }
+        /// <summary>
+        /// 数据类型ID
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int DataTypeId { get; set; }
+
+        /// <summary>
+        /// 数据ID
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int DataId { get; set; }
+
+        /// <summary>
+        /// 是否禁用
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public bool IsDisable { get; set; }
+        /// <summary>
+        /// 启动秒
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int Second { get; set; }
+    }
+}

+ 0 - 1
gx_api/GxPress/Model/GxPress.Entity/tede2/Media/Media.cs

@@ -195,7 +195,6 @@ namespace GxPress.Entity.tede2.Media
         [DataColumn]
         public AttachTypeConst AttachType { get; set; }
 
-
         /// <summary>
         /// 类型 1名栏 2公众号 
         /// </summary>

+ 72 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/AppStartPage/AppStartPageRepository.cs

@@ -0,0 +1,72 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using AutoMapper;
+using Datory;
+using GxPress.Common.AppOptions;
+using GxPress.Common.Tools;
+using GxPress.Repository.Interface.AppStartPage;
+using Microsoft.Extensions.Options;
+
+namespace GxPress.Repository.Implement.AppStartPage
+{
+ 
+    public class AppStartPageRepository : IAppStartPageRepository
+    {
+        private readonly Repository<Entity.tede2.AppStartPage.AppStartPage> _repository;
+        private readonly IMapper _mapper;
+        private readonly string _connectionString;
+        private readonly string _databaseTypestr;
+        public AppStartPageRepository(IOptionsMonitor<DatabaseOptions> dbOptionsAccessor, IMapper mapper)
+        {
+            _databaseTypestr = dbOptionsAccessor.CurrentValue.DatabaseType;
+            _connectionString = dbOptionsAccessor.CurrentValue.ConnectionString;
+            var databaseType =
+                StringUtils.ToEnum<DatabaseType>(dbOptionsAccessor.CurrentValue.DatabaseType, DatabaseType.MySql);
+            var database = new Database(databaseType, dbOptionsAccessor.CurrentValue.ConnectionString);
+            _repository = new Repository<Entity.tede2.AppStartPage.AppStartPage>(database);
+            _mapper = mapper;
+        }
+
+        public IDatabase Database => _repository.Database;
+        public string TableName => _repository.TableName;
+        public List<TableColumn> TableColumns => _repository.TableColumns;
+
+        /// <summary>
+        /// 获取 APP启动 1IOS 2Android
+        /// </summary>
+        /// <param name="appTypeId"></param>
+        /// <returns></returns>
+        public async Task<Entity.tede2.AppStartPage.AppStartPage> GetAsync(int appTypeId)
+        {
+
+            return await _repository.GetAsync(Q.Where(nameof(Entity.tede2.AppStartPage.AppStartPage.AppTypeId), appTypeId).Where(nameof(Entity.tede2.AppStartPage.AppStartPage.IsDisable), false).OrderByDesc(nameof(Entity.tede2.AppStartPage.AppStartPage.CreatedDate)));
+        }
+
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <returns></returns>
+        public async Task<IEnumerable<Entity.tede2.AppStartPage.AppStartPage>> GetAllAsync()
+        {
+            return await _repository.GetAllAsync(Q.OrderByDesc(nameof(Entity.tede2.AppStartPage.AppStartPage.CreatedDate)));
+        }
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public async Task<bool> DeleteAsync(int id)
+        {
+            return await _repository.DeleteAsync(id);
+        }
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public async Task<bool> UpdateAsync(Entity.tede2.AppStartPage.AppStartPage model)
+        {
+            return await _repository.UpdateAsync(model);
+        }
+    }
+}

+ 34 - 0
gx_api/GxPress/Repository/GxPress.Repository.Interface/AppStartPage/IAppStartPageRepository.cs

@@ -0,0 +1,34 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Datory;
+
+namespace GxPress.Repository.Interface.AppStartPage
+{
+    public interface IAppStartPageRepository : IRepository
+    {
+        /// <summary>
+        /// 获取 APP启动 1IOS 2Android
+        /// </summary>
+        /// <param name="appTypeId"></param>
+        /// <returns></returns>
+        Task<Entity.tede2.AppStartPage.AppStartPage> GetAsync(int appTypeId);
+
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <returns></returns>
+        Task<IEnumerable<Entity.tede2.AppStartPage.AppStartPage>> GetAllAsync();
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        Task<bool> DeleteAsync(int id);
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        Task<bool> UpdateAsync(Entity.tede2.AppStartPage.AppStartPage model);
+    }
+}