/// <summary>
        ///     检查值的唯一性
        /// </summary>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="name"></param>
        /// <param name="field"></param>
        protected override void CheckUnique <TValue>(string name, Expression <Func <TData, TValue> > field)
        {
            if (!RequestArgumentConvert.TryGet(name, out string no))
            {
                SetFailed(name + "为空");
                return;
            }

            var id = RequestArgumentConvert.GetInt("id", 0);
            Expression <Func <TData, bool> > condition;

            if (id == 0)
            {
                condition = p => p.DataState < DataStateType.Delete;
            }
            else
            {
                condition = p => !Equals(p.Id, id) && p.DataState < DataStateType.Delete;
            }
            if (Business.Access.IsUnique(field, no, condition))
            {
                SetFailed(name + "[" + no + "]不唯一");
            }
            else
            {
                GlobalContext.Current.Status.LastMessage = name + "[" + no + "]唯一";
            }
        }
Пример #2
0
        /// <summary>
        ///     取得列表数据
        /// </summary>
        protected override ApiPageData <TData> GetListData(LambdaItem <TData> lambda)
        {
            if (!RequestArgumentConvert.TryGet("_audit_", out int audit) || audit == 0x100 || audit < 0)
            {
                return(base.GetListData(lambda));
            }

            if (audit <= (int)AuditStateType.End)
            {
                lambda.AddRoot(p => p.AuditState == (AuditStateType)audit);
                return(base.GetListData(lambda));
            }

            switch (audit)
            {
            case 0x10:     //废弃
            case 0xFF:     //删除
                RequestArgumentConvert.SetArgument("_state_", audit);
                break;

            case 0x13:     //停用
                RequestArgumentConvert.SetArgument("_state_", (int)DataStateType.Disable);
                break;

            case 0x11:     //未审核
                lambda.AddRoot(p => p.AuditState <= AuditStateType.Again);
                break;

            case 0x12:     //未结束
                lambda.AddRoot(p => p.AuditState < AuditStateType.End);
                break;
            }
            return(base.GetListData(lambda));
        }
 /// <summary>
 ///     取得列表数据
 /// </summary>
 protected override ApiPageData <TData> GetListData(LambdaItem <TData> lambda)
 {
     if (!RequestArgumentConvert.TryGet("_state_", out int state) || state < 0 || state >= 0x100)
     {
         return(base.GetListData(lambda));
     }
     //BUG:using (ManageModeScope.CreateScope())
     {
         lambda.AddRoot(p => p.DataState == (DataStateType)state);
         return(base.GetListData(lambda));
     }
 }
Пример #4
0
        /// <summary>
        ///     检查值的唯一性
        /// </summary>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="name"></param>
        /// <param name="field"></param>
        protected virtual void CheckUnique<TValue>(string name, Expression<Func<TData, TValue>> field)
        {
            if (!RequestArgumentConvert.TryGet("No", out string no))
            {
                SetFailed(name + "为空");
                return;
            }

            var id = RequestArgumentConvert.GetInt("id", 0);
            var result = id == 0
                ? Business.Access.IsUnique(field, no)
                : Business.Access.IsUnique(field, no, id);
            if (result)
                SetFailed(name + "[" + no + "]不唯一");
            else
                GlobalContext.Current.Status.LastMessage = name + "[" + no + "]唯一";
        }