12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading.Tasks;
- using YiSha.Data.Repository;
- using YiSha.Entity.SystemManage;
- using YiSha.Enum;
- using YiSha.Model.Param.SystemManage;
- using YiSha.Util;
- using YiSha.Util.Extension;
- using YiSha.Util.Model;
- namespace YiSha.Service.SystemManage
- {
- public partial class MenuAuthorizeService
- {
- private IRepositoryFactory _baseRepository;
- public MenuAuthorizeService(IRepositoryFactory baseRepository)
- {
- _baseRepository = baseRepository;
- }
- #region 获取数据
- public async Task<List<MenuAuthorizeEntity>> GetListPartial(MenuAuthorizeEntity param)
- {
- var expression = LinqExtensions.True<MenuAuthorizeEntity>();
- expression = expression.And(t => t.BaseIsDelete == (int)IsDeleteEnum.No);
- if (param != null)
- {
- if (param.AuthorizeId.ParseToLong() > 0)
- {
- expression = expression.And(t => t.AuthorizeId == param.AuthorizeId);
- }
- if (param.AuthorizeType.ParseToInt() > 0)
- {
- expression = expression.And(t => t.AuthorizeType == param.AuthorizeType);
- }
- if (!param.AuthorizeIds.IsEmpty())
- {
- int[] authorizeIdArr = TextHelper.SplitToArray<int>(param.AuthorizeIds, ',');
- expression = expression.And(t => authorizeIdArr.Contains(t.AuthorizeId ?? 0));
- }
- }
- var list = await _baseRepository.BaseRepository(dbConnectType).FindList<MenuAuthorizeEntity>(expression);
- return list.ToList();
- }
- public async Task<MenuAuthorizeEntity> GetEntityPartial(int id)
- {
- return await _baseRepository.BaseRepository(dbConnectType).FindEntity<MenuAuthorizeEntity>(id);
- }
- #endregion
- #region 提交数据
- public async Task SaveFormPartial(MenuAuthorizeEntity entity)
- {
- if (entity.Id.IsNullOrZero())
- {
- await entity.Create();
- await _baseRepository.BaseRepository(dbConnectType).Insert(entity);
- }
- else
- {
- await _baseRepository.BaseRepository(dbConnectType).Update(entity);
- }
- }
- #endregion
- /// <summary>
- /// 列表条件过滤
- /// 建议该方法放在Partial部分类中,因为代码生成时当前类会被覆盖(该方法在生成时将会被注释)
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- private Expression<Func<MenuAuthorizeEntity, bool>> ListFilterPartial(MenuAuthorizeListParam param)
- {
- var expression = LinqExtensions.True<MenuAuthorizeEntity>();
- expression = expression.And(t => t.BaseIsDelete == (int)IsDeleteEnum.No);
- if (param != null)
- {
- }
- return expression;
- }
- }
- }
|