Cat.Business/Cat.Service/BaseService.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Cat.Data.Repository;
using Cat.Entity;
using Cat.Entity.CrmManage;
using Cat.Util;
using Cat.Util.Extension;
using System.Threading.Tasks;

namespace Cat.Service
{
    public class BaseService<T> : RepositoryFactory where T : BaseEntity
    {
        public async Task<T> GetEntity(long id)
        {
            return await this.BaseRepository().FindEntity<T>(id);
        }

        /// <summary>
        /// 物料删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public async Task Delete(string ids)
        {
            long[] idArr = TextHelper.SplitToArray<long>(ids, ',');
            await this.BaseRepository().Delete<T>(idArr);
        }
    }

    public class BaseCreateService<T> : BaseService<T> where T : BaseCreateEntity
    {
        public async Task Save(T entity)
        {
            if (entity.Id.IsNullOrZero())
            {
                await entity.Create();
                await this.BaseRepository().Insert(entity);
            }
            else
            {
                await this.BaseRepository().Update(entity);
            }
        }
    }

    public class BaseModifyService<T> : BaseService<T> where T : BaseModifyEntity
    {
        public async Task Save(T entity)
        {
            if (entity.Id.IsNullOrZero())
            {
                await entity.Create();
                await this.BaseRepository().Insert(entity);
            }
            else
            {
                await entity.Modify();
                await this.BaseRepository().Update(entity);
            }
        }
    }
后面还有 20 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。